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

Unified Diff: tests/isolate/raw_port_test.dart

Issue 70263002: Add RawReceivePort to dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 7 years, 1 month 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/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/raw_port_test.dart
diff --git a/tests/isolate/raw_port_test.dart b/tests/isolate/raw_port_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8e334ca83e4496899f65d1a266e6ba6b917daec8
--- /dev/null
+++ b/tests/isolate/raw_port_test.dart
@@ -0,0 +1,57 @@
+// Copyright (c) 2012, 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.
+
+// Test RawReceivePort.
+
+library raw_port_test;
+import 'dart:isolate';
+import 'dart:async';
+import '../../pkg/unittest/lib/unittest.dart';
+
+
+void remote(SendPort port) { port.send("reply"); }
+void remote2(SendPort port) {
+ port.send("reply 1");
+ port.send("reply 2");
+}
+
+main() {
+ test("raw receive", () {
+ RawReceivePort port = new RawReceivePort();
+ Isolate.spawn(remote, port.sendPort);
+ port.handler = expectAsync1((v) {
+ expect(v, "reply");
+ port.close();
+ });
+ });
+ test("raw receive twice - change handler", () {
+ RawReceivePort port = new RawReceivePort();
+ Isolate.spawn(remote2, port.sendPort);
+ port.handler = expectAsync1((v) {
+ expect(v, "reply 1");
+ port.handler = expectAsync1((v) {
+ expect(v, "reply 2");
+ port.close();
+ });
+ });
+ });
+ test("from-raw-port", () {
+ RawReceivePort rawPort = new RawReceivePort();
+ Isolate.spawn(remote, rawPort.sendPort);
+ rawPort.handler = expectAsync1((v) {
+ expect(v, "reply");
+ ReceivePort port = new ReceivePort.fromRawReceivePort(rawPort);
+ Isolate.spawn(remote, rawPort.sendPort);
+ Isolate.spawn(remote, port.sendPort);
+ int ctr = 2;
+ port.listen(expectAsync1((v) {
+ expect(v, "reply");
+ ctr--;
+ if (ctr == 0) port.close();
+ }, count: 2),
+ onDone: expectAsync0((){}));
+ });
+ });
+
+}
« no previous file with comments | « tests/isolate/isolate.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698