Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(790)

Side by Side Diff: pkg/polymer/test/event_path_test.dart

Issue 27307004: Converting Polymer's WebComponentsLoaded to an onReady future (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 'dart:async'; 8 import 'package:polymer/polymer.dart';
9 import 'package:unittest/html_config.dart';
9 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
10 import 'package:unittest/html_config.dart';
11 11
12 main() { 12 main() {
13 useHtmlConfiguration(); 13 useHtmlConfiguration();
14
15 setUp(() => Polymer.onReady);
16
14 test('bubbling in the right order', () { 17 test('bubbling in the right order', () {
15 // TODO(sigmund): this should change once we port over the 18 var item1 = query('#item1');
16 // 'WebComponentsReady' event. 19 var menuButton = query('#menuButton');
17 return new Future.delayed(Duration.ZERO).then((_) { 20 // Note: polymer uses automatic node finding (menuButton.$.menu)
18 var item1 = query('#item1'); 21 // also note that their node finding code also reachs into the ids
19 var menuButton = query('#menuButton'); 22 // from the parent shadow (menu.$.selectorContent instead of
20 // Note: polymer uses automatic node finding (menuButton.$.menu) 23 // menu.$.menuShadow.$.selectorContent)
21 // also note that their node finding code also reachs into the ids 24 var menu = menuButton.shadowRoot.query('#menu');
22 // from the parent shadow (menu.$.selectorContent instead of 25 var overlay = menuButton.shadowRoot.query('#overlay');
23 // menu.$.menuShadow.$.selectorContent) 26 var expectedPath = <Node>[
24 var menu = menuButton.shadowRoot.query('#menu'); 27 item1,
25 var overlay = menuButton.shadowRoot.query('#overlay'); 28 menuButton.shadowRoot.query('#menuButtonContent'),
26 var expectedPath = <Node>[ 29 menu.shadowRoot.olderShadowRoot.query('#selectorContent'),
27 item1, 30 menu.shadowRoot.olderShadowRoot.query('#selectorDiv'),
28 menuButton.shadowRoot.query('#menuButtonContent'), 31 menu.shadowRoot.olderShadowRoot,
29 menu.shadowRoot.olderShadowRoot.query('#selectorContent'), 32 menu.shadowRoot.query('#menuShadow'),
30 menu.shadowRoot.olderShadowRoot.query('#selectorDiv'), 33 menu.shadowRoot.query('#menuDiv'),
31 menu.shadowRoot.olderShadowRoot, 34 menu.shadowRoot,
32 menu.shadowRoot.query('#menuShadow'), 35 menu,
33 menu.shadowRoot.query('#menuDiv'), 36 menuButton.shadowRoot.query('#menuButtonDiv'),
34 menu.shadowRoot, 37 // TODO(sigmund): this test is currently broken because currently
35 menu, 38 // registerElement is sensitive to the order in which each custom
36 menuButton.shadowRoot.query('#menuButtonDiv'), 39 // element is registered. When fixed, we should be able to add the
37 // TODO(sigmund): this test is currently broken because currently 40 // following three targets:
38 // registerElement is sensitive to the order in which each custom 41 // overlay.shadowRoot.query('#overlayContent'),
39 // element is registered. When fixed, we should be able to add the 42 // overlay.shadowRoot,
40 // following three targets: 43 // overlay,
41 // overlay.shadowRoot.query('#overlayContent'), 44 menuButton.shadowRoot,
42 // overlay.shadowRoot, 45 menuButton
43 // overlay, 46 ];
44 menuButton.shadowRoot, 47 var x = 0;
45 menuButton 48 for (int i = 0; i < expectedPath.length; i++) {
46 ]; 49 var node = expectedPath[i];
47 var x = 0; 50 expect(node, isNotNull, reason: "Should not be null at $i");
48 for (int i = 0; i < expectedPath.length; i++) { 51 node.on['x'].listen(expectAsync1((e) {
49 var node = expectedPath[i]; 52 expect(e.currentTarget, node);
50 expect(node, isNotNull, reason: "Should not be null at $i"); 53 expect(x++, i);
51 node.on['x'].listen(expectAsync1((e) { 54 }));
52 expect(e.currentTarget, node); 55 }
53 expect(x++, i);
54 }));
55 }
56 56
57 item1.dispatchEvent(new Event('x', canBubble: true)); 57 item1.dispatchEvent(new Event('x', canBubble: true));
58 });
59 }); 58 });
60 } 59 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698