mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
Clearer testing of isEnded state of AudioGraphInput.
PiperOrigin-RevId: 604680924
This commit is contained in:
parent
eabba49610
commit
c768e60bf2
1 changed files with 36 additions and 0 deletions
|
|
@ -107,6 +107,42 @@ public class AudioGraphInputTest {
|
|||
assertThat(audioGraphInput.getOutputAudioFormat()).isEqualTo(STEREO_44100);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isEnded_whenInitialized_returnsFalse() throws Exception {
|
||||
AudioGraphInput audioGraphInput =
|
||||
new AudioGraphInput(
|
||||
/* requestedOutputAudioFormat= */ AudioFormat.NOT_SET,
|
||||
/* editedMediaItem= */ FAKE_ITEM,
|
||||
/* inputFormat= */ getPcmFormat(MONO_44100));
|
||||
|
||||
assertThat(audioGraphInput.isEnded()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void isEnded_withEndOfStreamQueued_returnsTrue() throws Exception {
|
||||
AudioGraphInput audioGraphInput =
|
||||
new AudioGraphInput(
|
||||
/* requestedOutputAudioFormat= */ AudioFormat.NOT_SET,
|
||||
/* editedMediaItem= */ FAKE_ITEM,
|
||||
/* inputFormat= */ getPcmFormat(MONO_44100));
|
||||
|
||||
audioGraphInput.onMediaItemChanged(
|
||||
/* editedMediaItem= */ FAKE_ITEM,
|
||||
/* durationUs= */ C.TIME_UNSET,
|
||||
/* decodedFormat= */ getPcmFormat(MONO_44100),
|
||||
/* isLast= */ false);
|
||||
|
||||
checkState(!audioGraphInput.getOutput().hasRemaining());
|
||||
assertThat(audioGraphInput.isEnded()).isFalse();
|
||||
|
||||
// Queue EOS.
|
||||
audioGraphInput.getInputBuffer().setFlags(C.BUFFER_FLAG_END_OF_STREAM);
|
||||
checkState(audioGraphInput.queueInputBuffer());
|
||||
|
||||
assertThat(audioGraphInput.getOutput().hasRemaining()).isFalse();
|
||||
assertThat(audioGraphInput.isEnded()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getOutput_withoutMediaItemChange_returnsEmptyBuffer() throws Exception {
|
||||
AudioGraphInput audioGraphInput =
|
||||
|
|
|
|||
Loading…
Reference in a new issue