| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 4 for details. All rights reserved. Use of this source code is governed by a | 4 for details. All rights reserved. Use of this source code is governed by a |
| 5 BSD-style license that can be found in the LICENSE file. | 5 BSD-style license that can be found in the LICENSE file. |
| 6 --> | 6 --> |
| 7 <html> | 7 <html> |
| 8 <head> | 8 <head> |
| 9 <title>event path</title> | 9 <title>event path</title> |
| 10 <script src="packages/polymer/testing/testing.js"></script> | 10 <script src="packages/polymer/boot.js"></script> |
| 11 <script src="packages/unittest/test_controller.js"></script> | 11 <script src="packages/unittest/test_controller.js"></script> |
| 12 <!-- | 12 <!-- |
| 13 Test ported from: | 13 Test ported from: |
| 14 https://github.com/Polymer/polymer/blob/7936ff8/test/js/events.js | 14 https://github.com/Polymer/polymer/blob/7936ff8/test/js/events.js |
| 15 | 15 |
| 16 TODO(sigmund): when we have support for mutation observers, render all of | 16 TODO(sigmund): when we have support for mutation observers, render all of |
| 17 the test in Dart (like events.js does in JS) | 17 the test in Dart (like events.js does in JS) |
| 18 --> | 18 --> |
| 19 </head> | 19 </head> |
| 20 <body> | 20 <body> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 50 void clickHandler(event, detail, target) { | 50 void clickHandler(event, detail, target) { |
| 51 clicks.add('local click under $localName (id $id) on ${target.id}'); | 51 clicks.add('local click under $localName (id $id) on ${target.id}'); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 </script> | 54 </script> |
| 55 </polymer-element> | 55 </polymer-element> |
| 56 | 56 |
| 57 <test-a id="a"></test-a> | 57 <test-a id="a"></test-a> |
| 58 <test-b id="b"></test-b> | 58 <test-b id="b"></test-b> |
| 59 | 59 |
| 60 <script type="application/dart"> | 60 <script type="application/dart" src="events_test.dart"></script> |
| 61 import 'dart:html'; | |
| 62 import 'dart:async'; | |
| 63 import 'package:unittest/unittest.dart'; | |
| 64 import 'package:unittest/html_config.dart'; | |
| 65 | |
| 66 main() { | |
| 67 useHtmlConfiguration(); | |
| 68 | |
| 69 test('host event', () { | |
| 70 // Note: this test is currently the only event in | |
| 71 // polymer/test/js/events.js at commit #7936ff8 | |
| 72 Timer.run(expectAsync0(() { | |
| 73 var testA = query('#a'); | |
| 74 expect(testA.xtag.clicks, isEmpty); | |
| 75 testA.click(); | |
| 76 expect(testA.xtag.clicks, ['host click on: test-a (id a)']); | |
| 77 })); | |
| 78 }); | |
| 79 | |
| 80 test('local event', () { | |
| 81 Timer.run(expectAsync0(() { | |
| 82 var testB = query('#b'); | |
| 83 expect(testB.xtag.clicks, isEmpty); | |
| 84 testB.click(); | |
| 85 expect(testB.xtag.clicks, []); | |
| 86 var b1 = testB.shadowRoot.query('#b-1'); | |
| 87 b1.click(); | |
| 88 expect(testB.xtag.clicks, []); | |
| 89 var b2 = testB.shadowRoot.query('#b-2'); | |
| 90 b2.click(); | |
| 91 expect(testB.xtag.clicks, ['local click under test-b (id b) on b-2']); | |
| 92 })); | |
| 93 }); | |
| 94 } | |
| 95 </script> | |
| 96 </body> | 61 </body> |
| 97 </html> | 62 </html> |
| OLD | NEW |