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

Unified Diff: tests/html/isolates_test.dart

Issue 10837070: Remove old isolate API and update all code in the repository to use (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. Created 8 years, 5 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 | « tests/co19/test_config.dart ('k') | tests/html/js_interop_4_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/isolates_test.dart
diff --git a/tests/html/isolates_test.dart b/tests/html/isolates_test.dart
index fa6070b3f177027a3e82d5ec7f55ca4443527d25..6b2e6941646ac113480a791c58caaea999c6b383 100644
--- a/tests/html/isolates_test.dart
+++ b/tests/html/isolates_test.dart
@@ -5,53 +5,45 @@
#import('dart:json');
#import('dart:isolate', prefix:'isolate');
-class PingPongIsolate extends isolate.Isolate {
- PingPongIsolate() : super.heavy();
+String responseFor(message) => 'response for $message';
- 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);
- });
+void isolateEntry() {
+ 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]);
- static String responseFor(message) => 'response for $message';
+ isolate.port.receive((message, replyTo) {
+ replyTo.send(responseFor(message), null);
+ });
}
main() {
useHtmlConfiguration();
test('IsolateSpawn', () {
- new PingPongIsolate().spawn().then(expectAsync1((isolate.SendPort port) {
- }));
+ isolate.spawnFunction(isolateEntry);
});
test('NonDOMIsolates', () {
var callback = expectAsync0((){});
- new PingPongIsolate().spawn().then((isolate.SendPort port) {
+ var port = isolate.spawnFunction(isolateEntry);
+ final msg1 = 'foo';
+ final msg2 = 'bar';
+ port.call(msg1).then((response) {
guardAsync(() {
- final msg1 = 'foo';
- final msg2 = 'bar';
- port.call(msg1).then((response) {
+ Expect.equals(responseFor(msg1), response);
+ port.call(msg2).then((response) {
guardAsync(() {
- Expect.equals(PingPongIsolate.responseFor(msg1), response);
- port.call(msg2).then((response) {
- guardAsync(() {
- Expect.equals(PingPongIsolate.responseFor(msg2), response);
- callback();
- });
- });
+ Expect.equals(responseFor(msg2), response);
+ callback();
});
});
});
« no previous file with comments | « tests/co19/test_config.dart ('k') | tests/html/js_interop_4_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698