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

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

Issue 218273002: Upgrading tests with unittest deprecations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 tests.html.events_test; 5 library tests.html.events_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:html'; 8 import 'dart:html';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 import 'package:unittest/html_config.dart'; 10 import 'package:unittest/html_config.dart';
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 }); 89 });
90 90
91 test('DOM event callbacks are associated with the correct zone', () { 91 test('DOM event callbacks are associated with the correct zone', () {
92 var callbacks = []; 92 var callbacks = [];
93 93
94 final element = new Element.tag('test'); 94 final element = new Element.tag('test');
95 element.id = 'eventtarget'; 95 element.id = 'eventtarget';
96 document.body.append(element); 96 document.body.append(element);
97 97
98 // runZoned executes the function synchronously, but we don't want to 98 // runZoned executes the function synchronously, but we don't want to
99 // rely on this. We therefore wrap it into an expectAsync0. 99 // rely on this. We therefore wrap it into an expectAsync.
100 runZoned(expectAsync0(() { 100 runZoned(expectAsync(() {
101 Zone zone = Zone.current; 101 Zone zone = Zone.current;
102 expect(zone, isNot(equals(Zone.ROOT))); 102 expect(zone, isNot(equals(Zone.ROOT)));
103 103
104 var sub; 104 var sub;
105 105
106 void handler(Event e) { 106 void handler(Event e) {
107 expect(Zone.current, equals(zone)); 107 expect(Zone.current, equals(zone));
108 108
109 scheduleMicrotask(expectAsync0(() { 109 scheduleMicrotask(expectAsync(() {
110 expect(Zone.current, equals(zone)); 110 expect(Zone.current, equals(zone));
111 sub.cancel(); 111 sub.cancel();
112 })); 112 }));
113 } 113 }
114 114
115 sub = element.on['test'].listen(expectAsync1(handler)); 115 sub = element.on['test'].listen(expectAsync(handler));
116 })); 116 }));
117 element.dispatchEvent(new Event('test')); 117 element.dispatchEvent(new Event('test'));
118 }); 118 });
119 } 119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698