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

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

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 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
OLDNEW
1 library NativeGCTest; 1 library NativeGCTest;
2
2 import 'package:unittest/unittest.dart'; 3 import 'package:unittest/unittest.dart';
3 import 'package:unittest/html_config.dart'; 4 import 'package:unittest/html_config.dart';
4 import 'dart:html'; 5 import 'dart:html';
5 6
6 var testEvent = new EventStreamProvider<Event>('test'); 7 var testEvent = new EventStreamProvider<Event>('test');
7 8
8 main() { 9 main() {
9 useHtmlConfiguration(); 10 useHtmlConfiguration();
10 11
11 test('EventListener', () { 12 test('EventListener', () {
12 final int N = 1000000; 13 final int N = 1000000;
13 final int M = 1000; 14 final int M = 1000;
14 15
15 var div; 16 var div;
16 for (int i = 0; i < M; ++i) { 17 for (int i = 0; i < M; ++i) {
17 // This memory should be freed when the listener below is 18 // This memory should be freed when the listener below is
18 // collected. 19 // collected.
19 List l = new List(N); 20 List l = new List(N);
20 21
21 // Record the iteration number. 22 // Record the iteration number.
22 l[N - 1] = i; 23 l[N - 1] = i;
23 24
24 div = new Element.tag('div'); 25 div = new Element.tag('div');
25 testEvent.forTarget(div).listen((_) { 26 testEvent.forTarget(div).listen((_) {
26 // Only the final iteration's listener should be invoked. 27 // Only the final iteration's listener should be invoked.
27 // Note: the reference to l keeps the entire list alive. 28 // Note: the reference to l keeps the entire list alive.
28 expect(l[N - 1], M - 1); 29 expect(l[N - 1], M - 1);
29 }); 30 });
30 } 31 }
31 32
32 final event = new Event('test'); 33 final event = new Event('test');
33 div.dispatchEvent(event); 34 div.dispatchEvent(event);
34 }); 35 });
35 36
36 test('WindowEventListener', () { 37 test('WindowEventListener', () {
37 String message = 'WindowEventListenerTestPingMessage'; 38 String message = 'WindowEventListenerTestPingMessage';
38 39
39 Element testDiv = new DivElement(); 40 Element testDiv = new DivElement();
40 testDiv.id = '#TestDiv'; 41 testDiv.id = '#TestDiv';
41 document.body.append(testDiv); 42 document.body.append(testDiv);
42 window.onMessage.listen((e) { 43 window.onMessage.listen((e) {
43 if (e.data == message) testDiv.click(); 44 if (e.data == message) testDiv.click();
44 }); 45 });
45 46
46 for (int i = 0; i < 100; ++i) { 47 for (int i = 0; i < 100; ++i) {
47 triggerMajorGC(); 48 triggerMajorGC();
48 } 49 }
49 50
50 testDiv.onClick.listen(expectAsync((e) {})); 51 testDiv.onClick.listen(expectAsync((e) {}));
51 window.postMessage(message, '*'); 52 window.postMessage(message, '*');
52 }); 53 });
53 } 54 }
54 55
55 void triggerMajorGC() { 56 void triggerMajorGC() {
56 List list = new List(1000000); 57 List list = new List(1000000);
57 Element div = new DivElement(); 58 Element div = new DivElement();
58 div.onClick.listen((e) => print(list[0])); 59 div.onClick.listen((e) => print(list[0]));
59 } 60 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698