| 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() { | 29 main() { |
| 29 // TODO(sigmund): use @CustomTag instead of Polymer.regsiter. A bug is making | 30 // TODO(sigmund): use @CustomTag instead of Polymer.regsiter. A bug is making |
| 30 // this code sensitive to the order in which we register elements (e.g. if | 31 // this code sensitive to the order in which we register elements (e.g. if |
| 31 // x-menu is registered before x-selector). See dartbug.com/17926. | 32 // x-menu is registered before x-selector). See dartbug.com/17926. |
| 32 Polymer.register('x-selector', XSelector); | 33 Polymer.register('x-selector', XSelector); |
| 33 Polymer.register('x-overlay', XOverlay); | 34 Polymer.register('x-overlay', XOverlay); |
| 34 Polymer.register('x-menu', XMenu); | 35 Polymer.register('x-menu', XMenu); |
| 35 Polymer.register('x-menu-button', XMenuButton); | 36 Polymer.register('x-menu-button', XMenuButton); |
| 36 | 37 |
| 37 initPolymer(); | |
| 38 useHtmlConfiguration(); | 38 useHtmlConfiguration(); |
| 39 | 39 |
| 40 setUp(() => Polymer.onReady); | 40 setUp(() => Polymer.onReady); |
| 41 | 41 |
| 42 test('bubbling in the right order', () { | 42 test('bubbling in the right order', () { |
| 43 var item1 = querySelector('#item1'); | 43 var item1 = querySelector('#item1'); |
| 44 var menuButton = querySelector('#menuButton'); | 44 var menuButton = querySelector('#menuButton'); |
| 45 // Note: polymer uses automatic node finding (menuButton.$.menu) | 45 // Note: polymer uses automatic node finding (menuButton.$.menu) |
| 46 // also note that their node finding code also reachs into the ids | 46 // also note that their node finding code also reachs into the ids |
| 47 // from the parent shadow (menu.$.selectorContent instead of | 47 // from the parent shadow (menu.$.selectorContent instead of |
| (...skipping 27 matching lines...) Expand all Loading... |
| 75 expect(node, isNotNull, reason: "Should not be null at $i"); | 75 expect(node, isNotNull, reason: "Should not be null at $i"); |
| 76 node.on['x'].listen(expectAsync((e) { | 76 node.on['x'].listen(expectAsync((e) { |
| 77 expect(e.currentTarget, node); | 77 expect(e.currentTarget, node); |
| 78 expect(x++, i); | 78 expect(x++, i); |
| 79 })); | 79 })); |
| 80 } | 80 } |
| 81 | 81 |
| 82 item1.dispatchEvent(new Event('x', canBubble: true)); | 82 item1.dispatchEvent(new Event('x', canBubble: true)); |
| 83 }); | 83 }); |
| 84 } | 84 } |
| OLD | NEW |