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

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

Issue 2725133002: Mojo: Armed Watchers (Closed)
Patch Set: rebase Created 3 years, 9 months 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
Index: mojo/android/javatests/src/org/chromium/mojo/system/impl/WatcherImplTest.java
diff --git a/mojo/android/javatests/src/org/chromium/mojo/system/impl/WatcherImplTest.java b/mojo/android/javatests/src/org/chromium/mojo/system/impl/WatcherImplTest.java
index 6a99fe155f47e0e5b1f52403d04275d183a85405..e14adb1160a9b580ba80d253785480063918689e 100644
--- a/mojo/android/javatests/src/org/chromium/mojo/system/impl/WatcherImplTest.java
+++ b/mojo/android/javatests/src/org/chromium/mojo/system/impl/WatcherImplTest.java
@@ -68,6 +68,17 @@ public class WatcherImplTest extends MojoTestCase {
private static class WatcherResult implements Callback {
private int mResult = Integer.MIN_VALUE;
+ private MessagePipeHandle mReadPipe;
+
+ /**
+ * @param readPipe A MessagePipeHandle to read from when onResult triggers success.
+ */
+ public WatcherResult(MessagePipeHandle readPipe) {
+ mReadPipe = readPipe;
+ }
+ public WatcherResult() {
+ this(null);
+ }
/**
* @see Callback#onResult(int)
@@ -75,6 +86,11 @@ public class WatcherImplTest extends MojoTestCase {
@Override
public void onResult(int result) {
this.mResult = result;
+
+ if (result == MojoResult.OK && mReadPipe != null) {
+ mReadPipe.readMessage(
+ null, 0, MessagePipeHandle.ReadFlags.none().setMayDiscard(true));
+ }
}
/**
@@ -93,7 +109,7 @@ public class WatcherImplTest extends MojoTestCase {
// Checking a correct result.
Pair<MessagePipeHandle, MessagePipeHandle> handles = mCore.createMessagePipe(null);
addHandlePairToClose(handles);
- final WatcherResult watcherResult = new WatcherResult();
+ final WatcherResult watcherResult = new WatcherResult(handles.first);
assertEquals(Integer.MIN_VALUE, watcherResult.getResult());
mWatcher.start(handles.first, Core.HandleSignals.READABLE, watcherResult);

Powered by Google App Engine
This is Rietveld 408576698