Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Unified Diff: mojo/android/javatests/src/org/chromium/mojo/system/impl/CoreImplTest.java

Issue 1475983004: Revert making HandleWatcher block until no longer waiting on pipe (r285266). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update comment (undo change in r283888 Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/threading/thread_restrictions.h ('k') | mojo/message_pump/handle_watcher.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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();
« no previous file with comments | « base/threading/thread_restrictions.h ('k') | mojo/message_pump/handle_watcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698