Index: mojo/dart/test/handle_watcher_test.dart |
diff --git a/mojo/dart/test/handle_watcher_test.dart b/mojo/dart/test/handle_watcher_test.dart |
index dd0ac3748cf0d93fffbf4323b435940508eeeca4..f151a11d09e041067cea6d1c2e0e530289f7e014 100644 |
--- a/mojo/dart/test/handle_watcher_test.dart |
+++ b/mojo/dart/test/handle_watcher_test.dart |
@@ -20,13 +20,13 @@ void simpleTest() { |
var completer = new Completer(); |
int numEvents = 0; |
- handle.enableWriteEvents(); |
handle.listen((_) { |
numEvents++; |
handle.close(); |
}, onDone: () { |
completer.complete(numEvents); |
}); |
+ handle.enableWriteEvents(); |
siva
2014/12/29 23:20:44
Why does this have to be moved down?
zra
2014/12/30 16:29:33
It doesn't have to be. enableWriteEvents() can go
|
completer.future.then((int numEvents) { |
Expect.equals(1, numEvents); |
@@ -41,11 +41,10 @@ Future simpleAsyncAwaitTest() async { |
var endpoint = pipe.endpoints[0]; |
Expect.isTrue(endpoint.handle.isValid); |
- var handle = new MojoHandle(endpoint.handle); |
+ var handle = new MojoHandle(endpoint.handle, MojoHandleSignals.READWRITE); |
int numEvents = 0; |
- handle.enableWriteEvents(); |
- await for (var signal in handle) { |
+ await for (List<int> event in handle) { |
numEvents++; |
handle.close(); |
} |
@@ -87,18 +86,19 @@ Future pingPongIsolate(MojoMessagePipeEndpoint endpoint) async { |
int pings = 0; |
int pongs = 0; |
var handle = new MojoHandle(endpoint.handle); |
- await for (var signal in handle) { |
- if (MojoHandleSignals.isReadWrite(signal)) { |
+ await for (List<int> event in handle) { |
+ var mojoSignals = new MojoHandleSignals(event[1]); |
+ if (mojoSignals.isReadWrite) { |
// We are either sending or receiving. |
- throw new Exception("Unexpected signal"); |
- } else if (MojoHandleSignals.isReadable(signal)) { |
+ throw new Exception("Unexpected event"); |
+ } else if (mojoSignals.isReadable) { |
expectStringFromEndpoint("Ping", endpoint); |
pings++; |
handle.enableWriteEvents(); |
- } else if (MojoHandleSignals.isWritable(signal)) { |
+ } else if (mojoSignals.isWritable) { |
endpoint.write(byteDataOfString("Pong")); |
pongs++; |
- handle.disableWriteEvents(); |
+ handle.enableReadEvents(); |
} |
} |
handle.close(); |
@@ -111,28 +111,28 @@ Future pingPongTest() async { |
var pipe = new MojoMessagePipe(); |
var isolate = await Isolate.spawn(pingPongIsolate, pipe.endpoints[0]); |
var endpoint = pipe.endpoints[1]; |
- var handle = new MojoHandle(endpoint.handle); |
+ var handle = new MojoHandle(endpoint.handle, MojoHandleSignals.READWRITE); |
int pings = 0; |
int pongs = 0; |
- handle.enableWriteEvents(); // This side will send first. |
- await for (var signal in handle) { |
- if (MojoHandleSignals.isReadWrite(signal)) { |
+ await for (List<int> event in handle) { |
+ var mojoSignals = new MojoHandleSignals(event[1]); |
+ if (mojoSignals.isReadWrite) { |
// We are either sending or receiving. |
- throw new Exception("Unexpected signal"); |
- } else if (MojoHandleSignals.isReadable(signal)) { |
+ throw new Exception("Unexpected event"); |
+ } else if (mojoSignals.isReadable) { |
expectStringFromEndpoint("Pong", endpoint); |
pongs++; |
if (pongs == 10) { |
handle.close(); |
} |
handle.enableWriteEvents(); // Now it is our turn to send. |
- } else if (MojoHandleSignals.isWritable(signal)) { |
+ } else if (mojoSignals.isWritable) { |
if (pings < 10) { |
endpoint.write(byteDataOfString("Ping")); |
pings++; |
} |
- handle.disableWriteEvents(); // Don't send while waiting for reply. |
+ handle.enableReadEvents(); // Don't send while waiting for reply. |
} |
} |
Expect.equals(10, pings); |