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

Side by Side Diff: pkg/dev_compiler/test/codegen/lib/html/event_test.dart

Issue 2413073002: Start cleaning up the HTML tests. (Closed)
Patch Set: Unfork expect.dart. Created 4 years, 2 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 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 EventTest;
6 import "package:expect/expect.dart";
7 import 'package:unittest/unittest.dart';
8 import 'package:unittest/html_config.dart';
9 import 'dart:html'; 5 import 'dart:html';
10 6
11 // TODO(nweiz): Make this private to testEvents when Frog supports closures with 7 import 'package:minitest/minitest.dart';
12 // optional arguments. 8
13 eventTest(String name, Event eventFn(), void validate(Event), 9 eventTest(String name, Event eventFn(), void validate(Event),
14 [String type = 'foo']) { 10 [String type = 'foo']) {
15 test(name, () { 11 test(name, () {
16 final el = new Element.tag('div'); 12 final el = new Element.tag('div');
17 var fired = false; 13 var fired = false;
18 el.on[type].listen((ev) { 14 el.on[type].listen((ev) {
19 fired = true; 15 fired = true;
20 validate(ev); 16 validate(ev);
21 }); 17 });
22 el.dispatchEvent(eventFn()); 18 el.dispatchEvent(eventFn());
23 expect(fired, isTrue, reason: 'Expected event to be dispatched.'); 19 expect(fired, isTrue, reason: 'Expected event to be dispatched.');
24 }); 20 });
25 } 21 }
26 22
27 main() { 23 main() {
28 useHtmlConfiguration();
29
30 // Issue 1005. 24 // Issue 1005.
31 // eventTest('AnimationEvent', () => new AnimationEvent('foo', 'color', 0.5), 25 // eventTest('AnimationEvent', () => new AnimationEvent('foo', 'color', 0.5),
32 // (ev) { 26 // (ev) {
33 // expect(ev.animationName, 'color'); 27 // expect(ev.animationName, 'color');
34 // expect(ev.elapsedTime, 0.5); 28 // expect(ev.elapsedTime, 0.5);
35 // }); 29 // });
36 30
37 // Issue 1005. 31 // Issue 1005.
38 // eventTest('BeforeLoadEvent', 32 // eventTest('BeforeLoadEvent',
39 // () => new BeforeLoadEvent('foo', 'http://example.url'), 33 // () => new BeforeLoadEvent('foo', 'http://example.url'),
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 () => new HashChangeEvent('foo', oldUrl: 'http://old.url', 88 () => new HashChangeEvent('foo', oldUrl: 'http://old.url',
95 newUrl: 'http://new.url'), (ev) { 89 newUrl: 'http://new.url'), (ev) {
96 expect(ev.oldUrl, equals('http://old.url')); 90 expect(ev.oldUrl, equals('http://old.url'));
97 expect(ev.newUrl, equals('http://new.url')); 91 expect(ev.newUrl, equals('http://new.url'));
98 }); 92 });
99 93
100 // KeyboardEvent has its own test file, and has cross-browser issues. 94 // KeyboardEvent has its own test file, and has cross-browser issues.
101 95
102 eventTest('MouseEvent', 96 eventTest('MouseEvent',
103 () => new MouseEvent('foo', view: window, detail: 1, screenX: 2, 97 () => new MouseEvent('foo', view: window, detail: 1, screenX: 2,
104 screenY: 3, clientX: 4, clientY: 5, button: 6, 98 screenY: 3, clientX: 4, clientY: 5, button: 6,
105 ctrlKey: true, altKey: true, shiftKey: true, 99 ctrlKey: true, altKey: true, shiftKey: true,
106 metaKey: true, relatedTarget: document.body), 100 metaKey: true, relatedTarget: document.body),
107 (ev) { 101 (ev) {
108 expect(ev.detail, 1); 102 expect(ev.detail, 1);
109 expect(ev.screen.x, 2); 103 expect(ev.screen.x, 2);
110 expect(ev.screen.y, 3); 104 expect(ev.screen.y, 3);
111 expect(ev.client.x, 4); 105 expect(ev.client.x, 4);
112 expect(ev.client.y, 5); 106 expect(ev.client.y, 5);
113 expect(ev.offset.x, 4); // Same as clientX. 107 expect(ev.offset.x, 4); // Same as clientX.
114 expect(ev.offset.y, 5); // Same as clientY. 108 expect(ev.offset.y, 5); // Same as clientY.
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 expect(ev.screen.x, 3); 184 expect(ev.screen.x, 3);
191 expect(ev.screen.y, 4); 185 expect(ev.screen.y, 4);
192 expect(ev.client.x, 5); 186 expect(ev.client.x, 5);
193 expect(ev.client.y, 6); 187 expect(ev.client.y, 6);
194 expect(ev.ctrlKey, isTrue); 188 expect(ev.ctrlKey, isTrue);
195 expect(ev.altKey, isTrue); 189 expect(ev.altKey, isTrue);
196 expect(ev.shiftKey, isTrue); 190 expect(ev.shiftKey, isTrue);
197 expect(ev.metaKey, isTrue); 191 expect(ev.metaKey, isTrue);
198 }, 'mousewheel'); 192 }, 'mousewheel');
199 } 193 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698