Index: mojo/android/javatests/src/org/chromium/mojo/system/impl/CoreImplTest.java |
diff --git a/mojo/android/javatests/src/org/chromium/mojo/system/impl/CoreImplTest.java b/mojo/android/javatests/src/org/chromium/mojo/system/impl/CoreImplTest.java |
index c9cd084d4cb4b789fb30db3d4395224499c49dc2..9b85895bfd2f3f5c77f8f4c051d7345b465b2e97 100644 |
--- a/mojo/android/javatests/src/org/chromium/mojo/system/impl/CoreImplTest.java |
+++ b/mojo/android/javatests/src/org/chromium/mojo/system/impl/CoreImplTest.java |
@@ -690,8 +690,8 @@ public class CoreImplTest extends MojoTestCase { |
assertEquals(Integer.MIN_VALUE, asyncWaiterResult.getResult()); |
assertEquals(null, asyncWaiterResult.getException()); |
- Cancellable cancellable = core.getDefaultAsyncWaiter().asyncWait(handles.first, |
- Core.HandleSignals.READABLE, Core.DEADLINE_INFINITE, asyncWaiterResult); |
+ core.getDefaultAsyncWaiter().asyncWait(handles.first, Core.HandleSignals.READABLE, |
+ Core.DEADLINE_INFINITE, asyncWaiterResult); |
assertEquals(Integer.MIN_VALUE, asyncWaiterResult.getResult()); |
assertEquals(null, asyncWaiterResult.getException()); |
@@ -699,7 +699,7 @@ public class CoreImplTest extends MojoTestCase { |
assertEquals(Integer.MIN_VALUE, asyncWaiterResult.getResult()); |
assertEquals(null, asyncWaiterResult.getException()); |
- cancellable.cancel(); |
+ handles.first.close(); |
runLoopUntilIdle(); |
// TODO(qsr) Re-enable when MojoWaitMany handles it correctly. |
// assertNull(asyncWaiterResult.getException()); |
@@ -710,6 +710,56 @@ public class CoreImplTest extends MojoTestCase { |
* Testing core {@link AsyncWaiter} implementation. |
*/ |
@SmallTest |
+ public void testAsyncWaiterWaitingOnInvalidHandle() { |
+ Core core = CoreImpl.getInstance(); |
+ |
+ // Closing the peer handle. |
+ Pair<MessagePipeHandle, MessagePipeHandle> handles = core.createMessagePipe(null); |
+ addHandlePairToClose(handles); |
+ |
+ final AsyncWaiterResult asyncWaiterResult = new AsyncWaiterResult(); |
+ assertEquals(Integer.MIN_VALUE, asyncWaiterResult.getResult()); |
+ assertEquals(null, asyncWaiterResult.getException()); |
+ |
+ handles.first.close(); |
+ core.getDefaultAsyncWaiter().asyncWait(handles.first, Core.HandleSignals.READABLE, |
+ Core.DEADLINE_INFINITE, asyncWaiterResult); |
+ assertEquals(Integer.MIN_VALUE, asyncWaiterResult.getResult()); |
+ assertEquals(null, asyncWaiterResult.getException()); |
+ |
+ runLoopUntilIdle(); |
+ assertNotNull(asyncWaiterResult.getException()); |
+ assertEquals(MojoResult.INVALID_ARGUMENT, |
+ asyncWaiterResult.getException().getMojoResult()); |
+ assertEquals(Integer.MIN_VALUE, asyncWaiterResult.getResult()); |
+ } |
+ |
+ /** |
+ * Testing core {@link AsyncWaiter} implementation. |
+ */ |
+ @SmallTest |
+ public void testAsyncWaiterWaitingOnDefaultInvalidHandle() { |
+ Core core = CoreImpl.getInstance(); |
+ |
+ final AsyncWaiterResult asyncWaiterResult = new AsyncWaiterResult(); |
+ assertEquals(Integer.MIN_VALUE, asyncWaiterResult.getResult()); |
+ assertEquals(null, asyncWaiterResult.getException()); |
+ |
+ core.getDefaultAsyncWaiter().asyncWait(InvalidHandle.INSTANCE, Core.HandleSignals.READABLE, |
+ Core.DEADLINE_INFINITE, asyncWaiterResult); |
+ assertEquals(Integer.MIN_VALUE, asyncWaiterResult.getResult()); |
+ assertEquals(null, asyncWaiterResult.getException()); |
+ |
+ runLoopUntilIdle(); |
+ assertNotNull(asyncWaiterResult.getException()); |
+ assertEquals(MojoResult.INVALID_ARGUMENT, asyncWaiterResult.getException().getMojoResult()); |
+ assertEquals(Integer.MIN_VALUE, asyncWaiterResult.getResult()); |
+ } |
+ |
+ /** |
+ * Testing core {@link AsyncWaiter} implementation. |
+ */ |
+ @SmallTest |
public void testAsyncWaiterWaitingWithTimeout() { |
Core core = CoreImpl.getInstance(); |