OLD | NEW |
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 |
9 test('TimeStamp', () { | 9 test('TimeStamp', () { |
10 Event event = new Event('test'); | 10 Event event = new Event('test'); |
(...skipping 11 matching lines...) Expand all Loading... |
22 expect(e.bubbles, bubble, reason: 'canBubble was set to $bubble'); | 22 expect(e.bubbles, bubble, reason: 'canBubble was set to $bubble'); |
23 expect(e.cancelable, cancel, reason: 'cancelable was set to $cancel'); | 23 expect(e.cancelable, cancel, reason: 'cancelable was set to $cancel'); |
24 } | 24 } |
25 }); | 25 }); |
26 | 26 |
27 // 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 |
28 // and event listener synchronously. | 28 // and event listener synchronously. |
29 test('EventTarget', () { | 29 test('EventTarget', () { |
30 Element element = new Element.tag('test'); | 30 Element element = new Element.tag('test'); |
31 element.id = 'eventtarget'; | 31 element.id = 'eventtarget'; |
32 window.document.body.nodes.add(element); | 32 window.document.body.append(element); |
33 | 33 |
34 int invocationCounter = 0; | 34 int invocationCounter = 0; |
35 void handler(Event e) { | 35 void handler(Event e) { |
36 expect(e.type, equals('test')); | 36 expect(e.type, equals('test')); |
37 Element target = e.target; | 37 Element target = e.target; |
38 expect(element, equals(target)); | 38 expect(element, equals(target)); |
39 invocationCounter++; | 39 invocationCounter++; |
40 } | 40 } |
41 | 41 |
42 Event event = new Event('test'); | 42 Event event = new Event('test'); |
(...skipping 23 matching lines...) Expand all Loading... |
66 invocationCounter = 0; | 66 invocationCounter = 0; |
67 element.dispatchEvent(event); | 67 element.dispatchEvent(event); |
68 expect(invocationCounter, 1); | 68 expect(invocationCounter, 1); |
69 }); | 69 }); |
70 | 70 |
71 test('InitMouseEvent', () { | 71 test('InitMouseEvent', () { |
72 DivElement div = new Element.tag('div'); | 72 DivElement div = new Element.tag('div'); |
73 MouseEvent event = new MouseEvent('zebra', relatedTarget: div); | 73 MouseEvent event = new MouseEvent('zebra', relatedTarget: div); |
74 }); | 74 }); |
75 } | 75 } |
OLD | NEW |