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 test('TimeStamp', () { | 8 test('TimeStamp', () { |
9 Event event = new Event('test'); | 9 Event event = new Event('test'); |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 void handler(Event e) { | 22 void handler(Event e) { |
23 expect(e.type, equals('test')); | 23 expect(e.type, equals('test')); |
24 Element target = e.target; | 24 Element target = e.target; |
25 expect(element, equals(target)); | 25 expect(element, equals(target)); |
26 invocationCounter++; | 26 invocationCounter++; |
27 } | 27 } |
28 | 28 |
29 Event event = new Event('test'); | 29 Event event = new Event('test'); |
30 | 30 |
31 invocationCounter = 0; | 31 invocationCounter = 0; |
32 element.on['test'].dispatch(event); | 32 element.dispatchEvent(event); |
33 expect(invocationCounter, isZero); | 33 expect(invocationCounter, isZero); |
34 | 34 |
35 element.on['test'].add(handler, false); | 35 var provider = new EventStreamProvider<CustomEvent>('test'); |
| 36 |
| 37 var sub = provider.forTarget(element).listen(handler); |
36 invocationCounter = 0; | 38 invocationCounter = 0; |
37 element.on['test'].dispatch(event); | 39 element.dispatchEvent(event); |
38 expect(invocationCounter, 1); | 40 expect(invocationCounter, 1); |
39 | 41 |
40 element.on['test'].remove(handler, false); | 42 sub.cancel(); |
41 invocationCounter = 0; | 43 invocationCounter = 0; |
42 element.on['test'].dispatch(event); | 44 element.dispatchEvent(event); |
43 expect(invocationCounter, isZero); | 45 expect(invocationCounter, isZero); |
44 | 46 |
45 element.on['test'].add(handler, false); | 47 provider.forTarget(element).listen(handler); |
46 invocationCounter = 0; | 48 invocationCounter = 0; |
47 element.on['test'].dispatch(event); | 49 element.dispatchEvent(event); |
48 expect(invocationCounter, 1); | 50 expect(invocationCounter, 1); |
49 | 51 |
50 element.on['test'].add(handler, false); | 52 provider.forTarget(element).listen(handler); |
51 invocationCounter = 0; | 53 invocationCounter = 0; |
52 element.on['test'].dispatch(event); | 54 element.dispatchEvent(event); |
53 expect(invocationCounter, 1); | 55 expect(invocationCounter, 1); |
54 }); | 56 }); |
55 test('InitMouseEvent', () { | 57 test('InitMouseEvent', () { |
56 DivElement div = new Element.tag('div'); | 58 DivElement div = new Element.tag('div'); |
57 MouseEvent event = new MouseEvent('zebra', relatedTarget: div); | 59 MouseEvent event = new MouseEvent('zebra', relatedTarget: div); |
58 }); | 60 }); |
59 } | 61 } |
OLD | NEW |