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

Unified Diff: tests/isolate/ondone_test.dart

Issue 1074223002: Update Isolate API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix typo Created 5 years, 8 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
« no previous file with comments | « tests/isolate/kill_test.dart ('k') | tests/isolate/ping_pause_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/ondone_test.dart
diff --git a/tests/isolate/ondone_test.dart b/tests/isolate/ondone_test.dart
index af990ad31e8e3d05cd950bcbe23519efadfed95e..ec0007cab06d4026e2b204f47f455e577654a8f6 100644
--- a/tests/isolate/ondone_test.dart
+++ b/tests/isolate/ondone_test.dart
@@ -23,6 +23,7 @@ void isomain(SendPort replyPort) {
void main() {
testExit();
testCancelExit();
+ testOverrideResponse();
}
void testExit() {
@@ -31,14 +32,15 @@ void testExit() {
var completer = new Completer(); // Completed by first reply from isolate.
RawReceivePort reply = new RawReceivePort(completer.complete);
RawReceivePort onExitPort;
- onExitPort = new RawReceivePort((_) {
+ onExitPort = new RawReceivePort((v) {
+ if (v != "RESPONSE") throw "WRONG RESPONSE: $v";
reply.close();
onExitPort.close();
if (!mayComplete) throw "COMPLETED EARLY";
asyncEnd();
});
Isolate.spawn(isomain, reply.sendPort).then((Isolate isolate) {
- isolate.addOnExitListener(onExitPort.sendPort);
+ isolate.addOnExitListener(onExitPort.sendPort, response: "RESPONSE");
return completer.future;
}).then((echoPort) {
int counter = 4;
@@ -92,3 +94,33 @@ void testCancelExit() {
});
});
}
+
+void testOverrideResponse() {
+ bool mayComplete = false;
+ asyncStart();
+ var completer = new Completer(); // Completed by first reply from isolate.
+ RawReceivePort reply = new RawReceivePort(completer.complete);
+ RawReceivePort onExitPort;
+ onExitPort = new RawReceivePort((v) {
+ if (v != "RESPONSE2") throw "WRONG RESPONSE: $v";
+ reply.close();
+ onExitPort.close();
+ if (!mayComplete) throw "COMPLETED EARLY";
+ asyncEnd();
+ });
+ Isolate.spawn(isomain, reply.sendPort).then((Isolate isolate) {
+ isolate.addOnExitListener(onExitPort.sendPort, response: "RESPONSE");
+ isolate.addOnExitListener(onExitPort.sendPort, response: "RESPONSE2");
+ return completer.future;
+ }).then((echoPort) {
+ int counter = 4;
+ reply.handler = (v) {
+ if (v != counter) throw "WRONG REPLY";
+ if (v == 0) throw "REPLY INSTEAD OF SHUTDOWN";
+ counter--;
+ mayComplete = (counter == 0);
+ echoPort.send(counter);
+ };
+ echoPort.send(counter);
+ });
+}
« no previous file with comments | « tests/isolate/kill_test.dart ('k') | tests/isolate/ping_pause_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698