Chromium Code Reviews| Index: tests/html/streams_test.dart |
| diff --git a/tests/html/streams_test.dart b/tests/html/streams_test.dart |
| index 8d76320ad039a6e40061894a0e8376a76cafd1da..a0f3a7183777be706d9b4f6293b3c83e6d5b1291 100644 |
| --- a/tests/html/streams_test.dart |
| +++ b/tests/html/streams_test.dart |
| @@ -6,20 +6,18 @@ import 'dart:html'; |
| class StreamHelper { |
| var _a; |
| - var _b; |
| StreamHelper() { |
| _a = new TextInputElement(); |
| document.body.append(_a); |
| - _b = new TextInputElement(); |
| - document.body.append(_b); |
| } |
| + Element get element => _a; |
| Stream<Event> get stream => _a.onFocus; |
| // Causes an event on a to be fired. |
| void pulse() { |
| - _b.focus(); |
| - _a.focus(); |
| + var event = new Event('focus'); |
| + _a.$dom_dispatchEvent(event); |
|
Jennifer Messerly
2013/01/14 21:56:51
is there a way to do this without $dom_?
blois
2013/01/14 22:00:05
Currently it's on the old events API, but I need t
|
| } |
| } |
| @@ -27,15 +25,14 @@ main() { |
| useHtmlConfiguration(); |
| test('simple', () { |
| - var a = new TextInputElement(); |
| - document.body.append(a); |
| + var helper = new StreamHelper(); |
| var callCount = 0; |
| - a.onFocus.listen((Event e) { |
| + helper.stream.listen((Event e) { |
| ++callCount; |
| }); |
| - a.focus(); |
| + helper.pulse(); |
| expect(callCount, 1); |
| }); |
| @@ -44,8 +41,8 @@ main() { |
| var parent = new DivElement(); |
| document.body.append(parent); |
| - var child = new TextInputElement(); |
| - parent.append(child); |
| + var helper = new StreamHelper(); |
| + parent.append(helper.element); |
| var childCallCount = 0; |
| var parentCallCount = 0; |
| @@ -54,12 +51,13 @@ main() { |
| expect(childCallCount, 0); |
| }); |
| - Element.focusEvent.forTarget(child, useCapture: true).listen((Event e) { |
| - ++childCallCount; |
| - expect(parentCallCount, 1); |
| - }); |
| + Element.focusEvent.forTarget(helper.element, useCapture: true).listen( |
| + (Event e) { |
| + ++childCallCount; |
| + expect(parentCallCount, 1); |
| + }); |
| - child.focus(); |
| + helper.pulse(); |
| expect(childCallCount, 1); |
| expect(parentCallCount, 1); |
| }); |