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

Side by Side Diff: tests/html/js_interop_4_test.dart

Issue 10702110: Added Dartium support for JS to Dart PortSync calls (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed tabbing 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/html/js_interop_3_test.dart ('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
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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 3 // BSD-style license that can be found in the LICENSE file
4 4
5 #library('JsInterop4Test'); 5 #library('JsInterop4Test');
6 #import('../../lib/unittest/unittest.dart'); 6 #import('../../lib/unittest/unittest.dart');
7 #import('../../lib/unittest/html_config.dart'); 7 #import('../../lib/unittest/html_config.dart');
8 #import('dart:html'); 8 #import('dart:html');
9 #import('dart:isolate'); 9 #import('dart:isolate');
10 10
11 const testData = const [1, '2', 'true']; 11 final testData = const [1, '2', 'true'];
12 12
13 // TODO(vsm): Convert all DOM isolate tests to the new syntax.
13 class TestIsolate extends Isolate { 14 class TestIsolate extends Isolate {
14 TestIsolate() : super(); 15 TestIsolate() : super();
15 16
16 void main() { 17 void main() {
17 var fun1 = window.lookupPort('fun1'); 18 var fun1 = window.lookupPort('fun1');
18 var result = fun1.callSync(testData); 19 var result = fun1.callSync(testData);
19 20
20 var fun2 = window.lookupPort('fun2'); 21 var fun2 = window.lookupPort('fun2');
21 fun2.callSync(result); 22 fun2.callSync(result);
22 } 23 }
23 } 24 }
24 25
25 main() { 26 main() {
26 useHtmlConfiguration(); 27 useHtmlConfiguration();
27 28
28 // Test that our interop scheme also works from Dart to Dart. 29 // Test that our interop scheme also works from Dart to Dart.
29 test('dart-to-dart-same-isolate', () { 30 test('dart-to-dart-same-isolate', () {
30 var fun = expectAsync1((message) { 31 var fun = expectAsync1((message) {
31 Expect.listEquals(testData, message); 32 Expect.listEquals(testData, message);
32 return message.length; 33 return message.length;
33 }); 34 });
34 35
35 var port1 = new ReceivePortSync(); 36 var port1 = new ReceivePortSync();
36 port1.receive(fun); 37 port1.receive(fun);
37 window.registerPort('fun', port1.toSendPort()); 38 window.registerPort('fun', port1.toSendPort());
38 39
39 var port2 = window.lookupPort('fun'); 40 var port2 = window.lookupPort('fun');
40 var result = port2.callSync(testData); 41 var result = port2.callSync(testData);
41 Expect.equals(3, result); 42 Expect.equals(3, result);
42 }); 43 });
43 44
44 // Test across isolate boundary. 45 // Test across isolate boundary.
45 test('dart-to-dart-cross-isolate', () { 46 test('dart-to-dart-cross-isolate', () {
46 var done = expectAsync0(() {});
47
48 var fun1 = (message) { 47 var fun1 = (message) {
49 Expect.listEquals(testData, message); 48 Expect.listEquals(testData, message);
50 return message.length; 49 return message.length;
51 }; 50 };
52 51
53 var port1 = new ReceivePortSync(); 52 var port1 = new ReceivePortSync();
54 port1.receive(fun1); 53 port1.receive(fun1);
55 window.registerPort('fun1', port1.toSendPort()); 54 window.registerPort('fun1', port1.toSendPort());
56 55
56 // TODO(vsm): Investigate why this needs to be called asynchronously.
57 var done = expectAsync0(() {});
57 var fun2 = (message) { 58 var fun2 = (message) {
58 Expect.equals(3, message); 59 Expect.equals(3, message);
59
60 // TODO(vsm): Investigate why this needs to be called asynchronously.
61 window.setTimeout(done, 0); 60 window.setTimeout(done, 0);
62 }; 61 };
63 62
64 var port2 = new ReceivePortSync(); 63 var port2 = new ReceivePortSync();
65 port2.receive(fun2); 64 port2.receive(fun2);
66 window.registerPort('fun2', port2.toSendPort()); 65 window.registerPort('fun2', port2.toSendPort());
67 66
68 new TestIsolate().spawn().then((p) {}); 67 new TestIsolate().spawn();
69 }); 68 });
70 } 69 }
OLDNEW
« no previous file with comments | « tests/html/js_interop_3_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698