From c902c5745c3a69afd98cc856b79aea7251de19ea Mon Sep 17 00:00:00 2001 From: "sky@chromium.org" Date: Thu, 24 Jul 2014 14:57:28 +0000 Subject: Makes HandleWatcher block until no longer waiting on pipe BUG=394886 TEST=covered as best as can from tests R=darin@chromium.org, jam@chromium.org Review URL: https://codereview.chromium.org/409943003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@285266 0039d316-1c4b-4281-b951-d872f2087c98 --- .../chromium/mojo/system/impl/CoreImplTest.java | 56 ++-------------------- 1 file changed, 3 insertions(+), 53 deletions(-) (limited to 'mojo/android/javatests') 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 abe7fa3..97bab76 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 @@ -648,8 +648,8 @@ public class CoreImplTest extends MojoTestCase { assertEquals(Integer.MIN_VALUE, asyncWaiterResult.getResult()); assertEquals(null, asyncWaiterResult.getException()); - core.getDefaultAsyncWaiter().asyncWait(handles.first, Core.HandleSignals.READABLE, - Core.DEADLINE_INFINITE, asyncWaiterResult); + Cancellable cancellable = core.getDefaultAsyncWaiter().asyncWait(handles.first, + Core.HandleSignals.READABLE, Core.DEADLINE_INFINITE, asyncWaiterResult); assertEquals(Integer.MIN_VALUE, asyncWaiterResult.getResult()); assertEquals(null, asyncWaiterResult.getException()); @@ -657,7 +657,7 @@ public class CoreImplTest extends MojoTestCase { assertEquals(Integer.MIN_VALUE, asyncWaiterResult.getResult()); assertEquals(null, asyncWaiterResult.getException()); - handles.first.close(); + cancellable.cancel(); nativeRunLoop(RUN_LOOP_TIMEOUT_MS); // TODO(qsr) Re-enable when MojoWaitMany handles it correctly. // assertNull(asyncWaiterResult.getException()); @@ -668,56 +668,6 @@ public class CoreImplTest extends MojoTestCase { * Testing core {@link AsyncWaiter} implementation. */ @SmallTest - public void testAsyncWaiterWaitingOnInvalidHandle() { - Core core = CoreImpl.getInstance(); - - // Closing the peer handle. - Pair 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()); - - nativeRunLoop(RUN_LOOP_TIMEOUT_MS); - 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()); - - nativeRunLoop(RUN_LOOP_TIMEOUT_MS); - 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(); -- cgit v1.1