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

Unified Diff: client/tests/client/dom/IsolatesTest.dart

Issue 9314008: Migrate all LayoutTests/dart/dom to main repo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Update config file Created 8 years, 11 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 | « client/tests/client/dom/IsolateLightTest.dart ('k') | client/tests/client/dom/KeyNameLocationTest.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/tests/client/dom/IsolatesTest.dart
diff --git a/client/tests/client/dom/IsolatesTest.dart b/client/tests/client/dom/IsolatesTest.dart
new file mode 100644
index 0000000000000000000000000000000000000000..7f062ab0778c59d8c82309db3f7aa98aa40cee77
--- /dev/null
+++ b/client/tests/client/dom/IsolatesTest.dart
@@ -0,0 +1,52 @@
+#library('IsolatesTest');
+#import('../../../testing/unittest/unittest.dart');
+#import('dart:dom');
+#import('dart:json');
+
+class PingPongIsolate extends Isolate {
+ PingPongIsolate() : super.heavy();
+
+ void main() {
+ bool wasThrown = false;
+ try {
+ window.alert('Test');
+ } catch(final e) {
+ wasThrown = true;
+ }
+ // If wasn't thrown, do not listen to messages to make test fail.
+ if (!wasThrown) {
+ return;
+ }
+
+ // Check that JSON library was loaded to isolate.
+ JSON.stringify([1, 2, 3]);
+
+ port.receive((message, replyTo) {
+ replyTo.send(responseFor(message), null);
+ });
+ }
+
+ static String responseFor(message) => 'response for $message';
+}
+
+main() {
+ forLayoutTests();
+ asyncTest('IsolateSpawn', 1, () {
+ new PingPongIsolate().spawn().then((SendPort port) {
+ callbackDone();
+ });
+ });
+ asyncTest('NonDOMIsolates', 1, () {
+ new PingPongIsolate().spawn().then((SendPort port) {
+ final msg1 = 'foo';
+ final msg2 = 'bar';
+ port.call(msg1).receive((response, _) {
+ Expect.equals(PingPongIsolate.responseFor(msg1), response);
+ port.call(msg2).receive((response, _) {
+ Expect.equals(PingPongIsolate.responseFor(msg2), response);
+ callbackDone();
+ });
+ });
+ });
+ });
+}
« no previous file with comments | « client/tests/client/dom/IsolateLightTest.dart ('k') | client/tests/client/dom/KeyNameLocationTest.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698