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 // This is ported from event-path-declarative-test.dart in polymer/test/html/. | 5 // This is ported from event-path-declarative-test.dart in polymer/test/html/. |
6 // While the original test was intended to test event.path support, we changed | 6 // While the original test was intended to test event.path support, we changed |
7 // the test structure just to check that the event was handled in the expected | 7 // the test structure just to check that the event was handled in the expected |
8 // order. | 8 // order. |
9 library polymer.test.event_path_declarative_test; | 9 library polymer.test.event_path_declarative_test; |
10 | 10 |
11 import 'dart:async'; | 11 import 'dart:async'; |
12 import 'dart:html'; | 12 import 'dart:html'; |
13 | 13 |
14 import 'package:unittest/unittest.dart'; | 14 import 'package:unittest/unittest.dart'; |
15 import 'package:unittest/html_config.dart'; | 15 import 'package:unittest/html_config.dart'; |
16 import 'package:polymer/polymer.dart'; | 16 import 'package:polymer/polymer.dart'; |
17 | 17 |
18 var _observedEvents = []; | 18 var _observedEvents = []; |
19 var _testFired; | 19 var _testFired; |
20 | 20 |
| 21 main() => initPolymer(); |
| 22 |
21 @reflectable | 23 @reflectable |
22 class XZug extends PolymerElement { | 24 class XZug extends PolymerElement { |
23 | 25 |
24 XZug.created() : super.created(); | 26 XZug.created() : super.created(); |
25 | 27 |
26 ready() { | 28 ready() { |
27 shadowRoot.on['test-event'].listen((e) { | 29 shadowRoot.on['test-event'].listen((e) { |
28 _testFired.complete(null); | 30 _testFired.complete(null); |
29 }); | 31 }); |
30 } | 32 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 72 |
71 divTestEventHandler(e, detail, sender) { | 73 divTestEventHandler(e, detail, sender) { |
72 _observedEvents.add(sender); | 74 _observedEvents.add(sender); |
73 } | 75 } |
74 | 76 |
75 testEventHandler(e, detail, sender) { | 77 testEventHandler(e, detail, sender) { |
76 _observedEvents.add(sender); | 78 _observedEvents.add(sender); |
77 } | 79 } |
78 } | 80 } |
79 | 81 |
80 @initMethod main() { | 82 @initMethod init() { |
81 useHtmlConfiguration(); | 83 useHtmlConfiguration(); |
82 // TODO(sigmund): switch back to use @CustomTag. We seem to be running into a | 84 // TODO(sigmund): switch back to use @CustomTag. We seem to be running into a |
83 // problem where using @CustomTag doesn't guarantee that we register the tags | 85 // problem where using @CustomTag doesn't guarantee that we register the tags |
84 // in the following order (the query from mirrors is non deterministic). | 86 // in the following order (the query from mirrors is non deterministic). |
85 // We shouldn't care about registration order though. See dartbug.com/14459 | 87 // We shouldn't care about registration order though. See dartbug.com/14459 |
86 Polymer.register('x-zug', XZug); | 88 Polymer.register('x-zug', XZug); |
87 Polymer.register('x-foo', XFoo); | 89 Polymer.register('x-foo', XFoo); |
88 Polymer.register('x-bar', XBar); | 90 Polymer.register('x-bar', XBar); |
89 | 91 |
90 _testFired = new Completer(); | 92 _testFired = new Completer(); |
(...skipping 16 matching lines...) Expand all Loading... |
107 var expectedPath = [ xBarContent, xBarDiv, xFooContent, | 109 var expectedPath = [ xBarContent, xBarDiv, xFooContent, |
108 xZugContent, xZugDiv, xZug, xFooDiv, xFoo, xBar]; | 110 xZugContent, xZugDiv, xZug, xFooDiv, xFoo, xBar]; |
109 debugName(e) => '${e.localName}#${e.id}'; | 111 debugName(e) => '${e.localName}#${e.id}'; |
110 expect(_observedEvents, expectedPath, reason: | 112 expect(_observedEvents, expectedPath, reason: |
111 '<br>\nexpected: ${expectedPath.map(debugName).join(',')}' | 113 '<br>\nexpected: ${expectedPath.map(debugName).join(',')}' |
112 '<br>\nactual: ${_observedEvents.map(debugName).join(',')}' | 114 '<br>\nactual: ${_observedEvents.map(debugName).join(',')}' |
113 ); | 115 ); |
114 }); | 116 }); |
115 }); | 117 }); |
116 } | 118 } |
OLD | NEW |