OLD | NEW |
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 expect(element, equals(target)); | 44 expect(element, equals(target)); |
45 invocationCounter++; | 45 invocationCounter++; |
46 } | 46 } |
47 | 47 |
48 Event event = new Event('test'); | 48 Event event = new Event('test'); |
49 | 49 |
50 invocationCounter = 0; | 50 invocationCounter = 0; |
51 element.dispatchEvent(event); | 51 element.dispatchEvent(event); |
52 expect(invocationCounter, isZero); | 52 expect(invocationCounter, isZero); |
53 | 53 |
54 var provider = new EventStreamProvider<CustomEvent>('test'); | 54 var provider = new EventStreamProvider<Event>('test'); |
55 | 55 |
56 var sub = provider.forTarget(element).listen(handler); | 56 var sub = provider.forTarget(element).listen(handler); |
57 invocationCounter = 0; | 57 invocationCounter = 0; |
58 element.dispatchEvent(event); | 58 element.dispatchEvent(event); |
59 expect(invocationCounter, 1); | 59 expect(invocationCounter, 1); |
60 | 60 |
61 sub.cancel(); | 61 sub.cancel(); |
62 invocationCounter = 0; | 62 invocationCounter = 0; |
63 element.dispatchEvent(event); | 63 element.dispatchEvent(event); |
64 expect(invocationCounter, isZero); | 64 expect(invocationCounter, isZero); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(expectAsync(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 } |
OLD | NEW |