From ad5ca0812d532645a60407881244df6ecad0e957 Mon Sep 17 00:00:00 2001 From: tonihei Date: Thu, 27 Jul 2017 08:15:15 -0700 Subject: [PATCH] Add unit test for FakeDataSource. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=163341994 --- .../com/google/android/exoplayer2/testutil/FakeDataSet.java | 4 ++-- .../google/android/exoplayer2/testutil/FakeDataSource.java | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSet.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSet.java index 2580205361..fd85b02d78 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSet.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSet.java @@ -162,8 +162,8 @@ public class FakeDataSet { } /** - * Appends data of the specified length. No actual data is available and this data should not - * be read. + * Appends a data segment of the specified length. No actual data is available and the + * {@link FakeDataSource} will perform no copy operations when this data is read. */ public FakeData appendReadData(int length) { Assertions.checkState(length > 0); diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSource.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSource.java index 6180a8aa77..aacd265e45 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSource.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/FakeDataSource.java @@ -166,6 +166,7 @@ public class FakeDataSource implements DataSource { // Do not allow crossing of the segment boundary. readLength = Math.min(readLength, current.length - current.bytesRead); // Perform the read and return. + Assertions.checkArgument(buffer.length - offset >= readLength); if (current.data != null) { System.arraycopy(current.data, current.bytesRead, buffer, offset, readLength); }