mirror of
https://github.com/androidx/media.git
synced 2025-05-13 02:29:52 +08:00
Test SampleQueue.peek
PiperOrigin-RevId: 352781639
This commit is contained in:
parent
4eaa6111c1
commit
2d3e6d4dba
@ -203,6 +203,22 @@ public final class SampleQueueTest {
|
|||||||
assertNoSamplesToRead(null);
|
assertNoSamplesToRead(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void peekConsumesDownstreamFormat() {
|
||||||
|
sampleQueue.format(FORMAT_1);
|
||||||
|
clearFormatHolderAndInputBuffer();
|
||||||
|
int result =
|
||||||
|
sampleQueue.peek(
|
||||||
|
formatHolder, inputBuffer, /* formatRequired= */ false, /* loadingFinished= */ false);
|
||||||
|
assertThat(result).isEqualTo(RESULT_FORMAT_READ);
|
||||||
|
// formatHolder should be populated.
|
||||||
|
assertThat(formatHolder.format).isEqualTo(FORMAT_1);
|
||||||
|
result =
|
||||||
|
sampleQueue.peek(
|
||||||
|
formatHolder, inputBuffer, /* formatRequired= */ false, /* loadingFinished= */ false);
|
||||||
|
assertThat(result).isEqualTo(RESULT_NOTHING_READ);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void equalFormatsDeduplicated() {
|
public void equalFormatsDeduplicated() {
|
||||||
sampleQueue.format(FORMAT_1);
|
sampleQueue.format(FORMAT_1);
|
||||||
@ -1625,10 +1641,32 @@ public final class SampleQueueTest {
|
|||||||
byte[] sampleData,
|
byte[] sampleData,
|
||||||
int offset,
|
int offset,
|
||||||
int length) {
|
int length) {
|
||||||
|
// Check that peeks yields the expected values.
|
||||||
clearFormatHolderAndInputBuffer();
|
clearFormatHolderAndInputBuffer();
|
||||||
int result =
|
int result =
|
||||||
|
sampleQueue.peek(
|
||||||
|
formatHolder, inputBuffer, /* formatRequired= */ false, /* loadingFinished= */ false);
|
||||||
|
assertBufferReadResult(
|
||||||
|
result, timeUs, isKeyFrame, isDecodeOnly, isEncrypted, sampleData, offset, length);
|
||||||
|
|
||||||
|
// Check that read yields the expected values.
|
||||||
|
clearFormatHolderAndInputBuffer();
|
||||||
|
result =
|
||||||
sampleQueue.read(
|
sampleQueue.read(
|
||||||
formatHolder, inputBuffer, /* formatRequired= */ false, /* loadingFinished= */ false);
|
formatHolder, inputBuffer, /* formatRequired= */ false, /* loadingFinished= */ false);
|
||||||
|
assertBufferReadResult(
|
||||||
|
result, timeUs, isKeyFrame, isDecodeOnly, isEncrypted, sampleData, offset, length);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void assertBufferReadResult(
|
||||||
|
int result,
|
||||||
|
long timeUs,
|
||||||
|
boolean isKeyFrame,
|
||||||
|
boolean isDecodeOnly,
|
||||||
|
boolean isEncrypted,
|
||||||
|
byte[] sampleData,
|
||||||
|
int offset,
|
||||||
|
int length) {
|
||||||
assertThat(result).isEqualTo(RESULT_BUFFER_READ);
|
assertThat(result).isEqualTo(RESULT_BUFFER_READ);
|
||||||
// formatHolder should not be populated.
|
// formatHolder should not be populated.
|
||||||
assertThat(formatHolder.format).isNull();
|
assertThat(formatHolder.format).isNull();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user