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

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

Issue 12220003: Adding event delegation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/src/EventStreamProvider.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 library streams_test; 1 library streams_test;
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:async'; 4 import 'dart:async';
5 import 'dart:html'; 5 import 'dart:html';
6 6
7 class StreamHelper { 7 class StreamHelper {
8 var _a; 8 var _a;
9 StreamHelper() { 9 StreamHelper() {
10 _a = new TextInputElement(); 10 _a = new TextInputElement();
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 ++callCountOne; 163 ++callCountOne;
164 }); 164 });
165 helper.pulse(); 165 helper.pulse();
166 expect(callCountOne, 1); 166 expect(callCountOne, 1);
167 167
168 subscription.onData(null); 168 subscription.onData(null);
169 helper.pulse(); 169 helper.pulse();
170 expect(callCountOne, 1); 170 expect(callCountOne, 1);
171 }); 171 });
172 172
173 test('forTargets', () {
174 var a = new StreamHelper();
175 var b = new StreamHelper();
176
177 var aTriggered = false;
178 var bTriggered = false;
179 Element.focusEvent.forTargets([a.element, b.element]).listen((e) {
180 if (e.target == a.element) {
181 aTriggered = true;
182 } else if (e.target == b.element) {
183 bTriggered = true;
184 } else {
185 expect(false, true, reason: 'Event for unrecognized element');
186 }
187 });
188
189 a.pulse();
190 expect(aTriggered, true);
191 expect(bTriggered, false);
192
193 b.pulse();
194 expect(aTriggered, true);
195 expect(bTriggered, true);
196 });
197
173 var stream = new StreamHelper().stream; 198 var stream = new StreamHelper().stream;
174 // Streams have had some type-checking issues, these tests just validate that 199 // Streams have had some type-checking issues, these tests just validate that
175 // those are OK. 200 // those are OK.
176 test('first', () { 201 test('first', () {
177 stream.first.then((_) {}); 202 stream.first.then((_) {});
178 }); 203 });
179 204
180 test('asBroadcastStream', () { 205 test('asBroadcastStream', () {
181 stream.asBroadcastStream().listen((_) {}); 206 stream.asBroadcastStream().listen((_) {});
182 }); 207 });
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 }); 295 });
271 296
272 test('singleMatching', () { 297 test('singleMatching', () {
273 stream.singleMatching((_) => true).then((_) {}); 298 stream.singleMatching((_) => true).then((_) {});
274 }); 299 });
275 300
276 test('elementAt', () { 301 test('elementAt', () {
277 stream.elementAt(0).then((_) {}); 302 stream.elementAt(0).then((_) {});
278 }); 303 });
279 } 304 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tools/dom/src/EventStreamProvider.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698