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 polymer.test.web.event_path_test; | 5 library polymer.test.web.event_path_test; |
6 | 6 |
7 import 'dart:html'; | 7 import 'dart:html'; |
8 import 'package:polymer/polymer.dart'; | 8 import 'package:polymer/polymer.dart'; |
9 import 'package:unittest/html_config.dart'; | 9 import 'package:unittest/html_config.dart'; |
10 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
11 | 11 |
12 class XSelector extends PolymerElement { | 12 class XSelector extends PolymerElement { |
13 XSelector.created() : super.created(); | 13 XSelector.created() : super.created(); |
14 } | 14 } |
15 | 15 |
16 class XOverlay extends PolymerElement { | 16 class XOverlay extends PolymerElement { |
17 XOverlay.created() : super.created(); | 17 XOverlay.created() : super.created(); |
18 } | 18 } |
19 | 19 |
20 class XMenu extends PolymerElement { | 20 class XMenu extends PolymerElement { |
21 XMenu.created() : super.created(); | 21 XMenu.created() : super.created(); |
22 } | 22 } |
23 | 23 |
24 class XMenuButton extends PolymerElement { | 24 class XMenuButton extends PolymerElement { |
25 XMenuButton.created() : super.created(); | 25 XMenuButton.created() : super.created(); |
26 } | 26 } |
27 | 27 |
28 @initMethod | 28 main() => initPolymer().run(() { |
29 main() { | 29 useHtmlConfiguration(); |
| 30 |
30 // TODO(sigmund): use @CustomTag instead of Polymer.regsiter. A bug is making | 31 // TODO(sigmund): use @CustomTag instead of Polymer.regsiter. A bug is making |
31 // this code sensitive to the order in which we register elements (e.g. if | 32 // this code sensitive to the order in which we register elements (e.g. if |
32 // x-menu is registered before x-selector). See dartbug.com/17926. | 33 // x-menu is registered before x-selector). See dartbug.com/17926. |
33 Polymer.register('x-selector', XSelector); | 34 Polymer.register('x-selector', XSelector); |
34 Polymer.register('x-overlay', XOverlay); | 35 Polymer.register('x-overlay', XOverlay); |
35 Polymer.register('x-menu', XMenu); | 36 Polymer.register('x-menu', XMenu); |
36 Polymer.register('x-menu-button', XMenuButton); | 37 Polymer.register('x-menu-button', XMenuButton); |
37 | 38 |
38 useHtmlConfiguration(); | |
39 | |
40 setUp(() => Polymer.onReady); | 39 setUp(() => Polymer.onReady); |
41 | 40 |
42 test('bubbling in the right order', () { | 41 test('bubbling in the right order', () { |
43 var item1 = querySelector('#item1'); | 42 var item1 = querySelector('#item1'); |
44 var menuButton = querySelector('#menuButton'); | 43 var menuButton = querySelector('#menuButton'); |
45 // Note: polymer uses automatic node finding (menuButton.$.menu) | 44 // Note: polymer uses automatic node finding (menuButton.$.menu) |
46 // also note that their node finding code also reachs into the ids | 45 // also note that their node finding code also reachs into the ids |
47 // from the parent shadow (menu.$.selectorContent instead of | 46 // from the parent shadow (menu.$.selectorContent instead of |
48 // menu.$.menuShadow.$.selectorContent) | 47 // menu.$.menuShadow.$.selectorContent) |
49 var menu = menuButton.shadowRoot.querySelector('#menu'); | 48 var menu = menuButton.shadowRoot.querySelector('#menu'); |
(...skipping 24 matching lines...) Expand all Loading... |
74 var node = expectedPath[i]; | 73 var node = expectedPath[i]; |
75 expect(node, isNotNull, reason: "Should not be null at $i"); | 74 expect(node, isNotNull, reason: "Should not be null at $i"); |
76 node.on['x'].listen(expectAsync((e) { | 75 node.on['x'].listen(expectAsync((e) { |
77 expect(e.currentTarget, node); | 76 expect(e.currentTarget, node); |
78 expect(x++, i); | 77 expect(x++, i); |
79 })); | 78 })); |
80 } | 79 } |
81 | 80 |
82 item1.dispatchEvent(new Event('x', canBubble: true)); | 81 item1.dispatchEvent(new Event('x', canBubble: true)); |
83 }); | 82 }); |
84 } | 83 }); |
OLD | NEW |