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