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

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

Issue 14387011: fix a bug in the Event constructor (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 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 library EventsTest; 1 library EventsTest;
2 import '../../pkg/unittest/lib/unittest.dart'; 2 import '../../pkg/unittest/lib/unittest.dart';
3 import '../../pkg/unittest/lib/html_config.dart'; 3 import '../../pkg/unittest/lib/html_config.dart';
4 import 'dart:html'; 4 import 'dart:html';
5 5
6 main() { 6 main() {
7 useHtmlConfiguration(); 7 useHtmlConfiguration();
8
8 test('TimeStamp', () { 9 test('TimeStamp', () {
9 Event event = new Event('test'); 10 Event event = new Event('test');
10 11
11 int timeStamp = event.timeStamp; 12 int timeStamp = event.timeStamp;
12 expect(timeStamp, greaterThan(0)); 13 expect(timeStamp, greaterThan(0));
13 }); 14 });
15
16 test('Event canBubble and cancelable', () {
17 // Try every combination of canBubble and cancelable
18 for (var i = 0; i < 4; i++) {
19 var bubble = (i & 1) != 0;
20 var cancel = (i & 2) != 0;
21 var e = new Event('input', canBubble: bubble, cancelable: cancel);
22 expect(e.bubbles, bubble, reason: 'canBubble was set to $bubble');
23 expect(e.cancelable, cancel, reason: 'cancelable was set to $cancel');
24 }
25 });
26
14 // The next test is not asynchronous because [on['test'].dispatch(event)] fire s the event 27 // The next test is not asynchronous because [on['test'].dispatch(event)] fire s the event
15 // and event listener synchronously. 28 // and event listener synchronously.
16 test('EventTarget', () { 29 test('EventTarget', () {
17 Element element = new Element.tag('test'); 30 Element element = new Element.tag('test');
18 element.id = 'eventtarget'; 31 element.id = 'eventtarget';
19 window.document.body.nodes.add(element); 32 window.document.body.nodes.add(element);
20 33
21 int invocationCounter = 0; 34 int invocationCounter = 0;
22 void handler(Event e) { 35 void handler(Event e) {
23 expect(e.type, equals('test')); 36 expect(e.type, equals('test'));
(...skipping 23 matching lines...) Expand all
47 provider.forTarget(element).listen(handler); 60 provider.forTarget(element).listen(handler);
48 invocationCounter = 0; 61 invocationCounter = 0;
49 element.dispatchEvent(event); 62 element.dispatchEvent(event);
50 expect(invocationCounter, 1); 63 expect(invocationCounter, 1);
51 64
52 provider.forTarget(element).listen(handler); 65 provider.forTarget(element).listen(handler);
53 invocationCounter = 0; 66 invocationCounter = 0;
54 element.dispatchEvent(event); 67 element.dispatchEvent(event);
55 expect(invocationCounter, 1); 68 expect(invocationCounter, 1);
56 }); 69 });
70
57 test('InitMouseEvent', () { 71 test('InitMouseEvent', () {
58 DivElement div = new Element.tag('div'); 72 DivElement div = new Element.tag('div');
59 MouseEvent event = new MouseEvent('zebra', relatedTarget: div); 73 MouseEvent event = new MouseEvent('zebra', relatedTarget: div);
60 }); 74 });
61 } 75 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/templates/html/impl/impl_Event.darttemplate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698