Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library start_paused_test; | |
| 6 | |
| 7 import "dart:isolate"; | |
| 8 import "package:expect/expect.dart"; | |
| 9 import "package:async_helper/async_helper.dart"; | |
| 10 | |
| 11 void isomain(SendPort p) { | |
| 12 p.send("DONE"); | |
| 13 } | |
| 14 | |
| 15 void notyet(_) { | |
| 16 throw "NOT YET"; | |
| 17 } | |
| 18 | |
| 19 void main() { | |
| 20 test1(); | |
| 21 test2(); | |
| 22 } | |
| 23 | |
| 24 void test1() { | |
| 25 // Test that a paused isolate don't send events. | |
|
floitsch
2014/02/14 14:21:38
doesn't
floitsch
2014/02/14 14:21:38
Add a small description of how you test:
"We spawn
| |
| 26 asyncStart(); | |
|
floitsch
2014/02/14 14:21:38
missing asyncEnd
| |
| 27 RawReceivePort p1 = new RawReceivePort(notyet); | |
| 28 Isolate.spawn(isomain, p1.sendPort, startPaused: true) | |
| 29 .then((isolate) { | |
| 30 RawReceivePort p2; | |
| 31 p2 = new RawReceivePort((x) { | |
| 32 Expect.equals("DONE", x); | |
| 33 p2.close(); | |
| 34 p1.handler = (x) { | |
| 35 Expect.equals("DONE", x); | |
| 36 p1.close(); | |
| 37 }; | |
| 38 isolate.resume(isolate.pauseCapability); | |
| 39 }); | |
| 40 Isolate.spawn(isomain, p2.sendPort); | |
| 41 }); | |
| 42 } | |
| 43 | |
| 44 void test2() { | |
| 45 // Test that a paused isolate don't send events. | |
|
floitsch
2014/02/14 14:21:38
doesn't
| |
| 46 asyncStart(); | |
|
floitsch
2014/02/14 14:21:38
missing asyncEnd
| |
| 47 RawReceivePort p1 = new RawReceivePort(notyet); | |
| 48 Isolate.spawn(isomain, p1.sendPort, startPaused: true) | |
| 49 .then((isolate) { | |
| 50 RawReceivePort p2; | |
| 51 Capability c2 = new Capability(); | |
| 52 // Switch to another pause capability. | |
| 53 isolate.pause(c2); | |
| 54 isolate.resume(isolate.pauseCapability); | |
| 55 p2 = new RawReceivePort((x) { | |
| 56 Expect.equals("DONE", x); | |
| 57 p2.close(); | |
| 58 p1.handler = (x) { | |
| 59 Expect.equals("DONE", x); | |
| 60 p1.close(); | |
| 61 }; | |
| 62 isolate.resume(c2); | |
| 63 }); | |
| 64 Isolate.spawn(isomain, p2.sendPort); | |
| 65 }); | |
| 66 } | |
| OLD | NEW |