Commit 9a0203e9 by samrobinson Committed by kim-vde

Change experimental method naming for blockUntilDelivered.

PiperOrigin-RevId: 325786522
parent eb946345
...@@ -323,13 +323,13 @@ public final class PlayerMessage { ...@@ -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 { ...@@ -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 { ...@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment