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

Unified 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 side-by-side diff with in-line comments
Download patch
« sdk/lib/isolate/isolate.dart ('K') | « tests/isolate/isolate.status ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/isolate/start_paused_test.dart
diff --git a/tests/isolate/start_paused_test.dart b/tests/isolate/start_paused_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..02209a085b2158bd2a4e39b7d7227ac8ec60b91c
--- /dev/null
+++ b/tests/isolate/start_paused_test.dart
@@ -0,0 +1,66 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library start_paused_test;
+
+import "dart:isolate";
+import "package:expect/expect.dart";
+import "package:async_helper/async_helper.dart";
+
+void isomain(SendPort p) {
+ p.send("DONE");
+}
+
+void notyet(_) {
+ throw "NOT YET";
+}
+
+void main() {
+ test1();
+ test2();
+}
+
+void test1() {
+ // 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
+ asyncStart();
floitsch 2014/02/14 14:21:38 missing asyncEnd
+ RawReceivePort p1 = new RawReceivePort(notyet);
+ Isolate.spawn(isomain, p1.sendPort, startPaused: true)
+ .then((isolate) {
+ RawReceivePort p2;
+ p2 = new RawReceivePort((x) {
+ Expect.equals("DONE", x);
+ p2.close();
+ p1.handler = (x) {
+ Expect.equals("DONE", x);
+ p1.close();
+ };
+ isolate.resume(isolate.pauseCapability);
+ });
+ Isolate.spawn(isomain, p2.sendPort);
+ });
+}
+
+void test2() {
+ // Test that a paused isolate don't send events.
floitsch 2014/02/14 14:21:38 doesn't
+ asyncStart();
floitsch 2014/02/14 14:21:38 missing asyncEnd
+ RawReceivePort p1 = new RawReceivePort(notyet);
+ Isolate.spawn(isomain, p1.sendPort, startPaused: true)
+ .then((isolate) {
+ RawReceivePort p2;
+ Capability c2 = new Capability();
+ // Switch to another pause capability.
+ isolate.pause(c2);
+ isolate.resume(isolate.pauseCapability);
+ p2 = new RawReceivePort((x) {
+ Expect.equals("DONE", x);
+ p2.close();
+ p1.handler = (x) {
+ Expect.equals("DONE", x);
+ p1.close();
+ };
+ isolate.resume(c2);
+ });
+ Isolate.spawn(isomain, p2.sendPort);
+ });
+}
« 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