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

Side by Side Diff: tests/isolate/start_paused_test.dart

Issue 163523003: Add 'startPaused' option to Isolate.spawn*. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Actually add test. Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
« sdk/lib/isolate/isolate.dart ('K') | « tests/isolate/isolate.status ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« sdk/lib/isolate/isolate.dart ('K') | « tests/isolate/isolate.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698