mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Change experimental method naming for blockUntilDelivered.
PiperOrigin-RevId: 325786522
This commit is contained in:
parent
eb9463454b
commit
9a0203e954
2 changed files with 11 additions and 11 deletions
|
|
@ -323,13 +323,13 @@ public final class PlayerMessage {
|
||||||
* @throws InterruptedException If the current thread is interrupted while waiting for the message
|
* @throws InterruptedException If the current thread is interrupted while waiting for the message
|
||||||
* to be delivered.
|
* to be delivered.
|
||||||
*/
|
*/
|
||||||
public synchronized boolean experimental_blockUntilDelivered(long timeoutMs)
|
public synchronized boolean experimentalBlockUntilDelivered(long timeoutMs)
|
||||||
throws InterruptedException, TimeoutException {
|
throws InterruptedException, TimeoutException {
|
||||||
return experimental_blockUntilDelivered(timeoutMs, Clock.DEFAULT);
|
return experimentalBlockUntilDelivered(timeoutMs, Clock.DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting()
|
@VisibleForTesting()
|
||||||
/* package */ synchronized boolean experimental_blockUntilDelivered(long timeoutMs, Clock clock)
|
/* package */ synchronized boolean experimentalBlockUntilDelivered(long timeoutMs, Clock clock)
|
||||||
throws InterruptedException, TimeoutException {
|
throws InterruptedException, TimeoutException {
|
||||||
Assertions.checkState(isSent);
|
Assertions.checkState(isSent);
|
||||||
Assertions.checkState(handler.getLooper().getThread() != Thread.currentThread());
|
Assertions.checkState(handler.getLooper().getThread() != Thread.currentThread());
|
||||||
|
|
|
||||||
|
|
@ -66,30 +66,30 @@ public class PlayerMessageTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void experimental_blockUntilDelivered_timesOut() throws Exception {
|
public void experimentalBlockUntilDelivered_timesOut() throws Exception {
|
||||||
when(clock.elapsedRealtime()).thenReturn(0L).thenReturn(TIMEOUT_MS * 2);
|
when(clock.elapsedRealtime()).thenReturn(0L).thenReturn(TIMEOUT_MS * 2);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
message.send().experimental_blockUntilDelivered(TIMEOUT_MS, clock);
|
message.send().experimentalBlockUntilDelivered(TIMEOUT_MS, clock);
|
||||||
fail();
|
fail();
|
||||||
} catch (TimeoutException expected) {
|
} catch (TimeoutException expected) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure experimental_blockUntilDelivered() entered the blocking loop
|
// Ensure experimentalBlockUntilDelivered() entered the blocking loop
|
||||||
verify(clock, Mockito.times(2)).elapsedRealtime();
|
verify(clock, Mockito.times(2)).elapsedRealtime();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void experimental_blockUntilDelivered_onAlreadyProcessed_succeeds() throws Exception {
|
public void experimentalBlockUntilDelivered_onAlreadyProcessed_succeeds() throws Exception {
|
||||||
when(clock.elapsedRealtime()).thenReturn(0L);
|
when(clock.elapsedRealtime()).thenReturn(0L);
|
||||||
|
|
||||||
message.send().markAsProcessed(/* isDelivered= */ true);
|
message.send().markAsProcessed(/* isDelivered= */ true);
|
||||||
|
|
||||||
assertThat(message.experimental_blockUntilDelivered(TIMEOUT_MS, clock)).isTrue();
|
assertThat(message.experimentalBlockUntilDelivered(TIMEOUT_MS, clock)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void experimental_blockUntilDelivered_markAsProcessedWhileBlocked_succeeds()
|
public void experimentalBlockUntilDelivered_markAsProcessedWhileBlocked_succeeds()
|
||||||
throws Exception {
|
throws Exception {
|
||||||
message.send();
|
message.send();
|
||||||
|
|
||||||
|
|
@ -114,8 +114,8 @@ public class PlayerMessageTest {
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
assertThat(message.experimental_blockUntilDelivered(TIMEOUT_MS, clock)).isTrue();
|
assertThat(message.experimentalBlockUntilDelivered(TIMEOUT_MS, clock)).isTrue();
|
||||||
// Ensure experimental_blockUntilDelivered() entered the blocking loop.
|
// Ensure experimentalBlockUntilDelivered() entered the blocking loop.
|
||||||
verify(clock, Mockito.atLeast(2)).elapsedRealtime();
|
verify(clock, Mockito.atLeast(2)).elapsedRealtime();
|
||||||
future.get(1, SECONDS);
|
future.get(1, SECONDS);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue