| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:html'; | 6 import 'dart:html'; |
| 7 import 'package:polymer/polymer.dart'; | 7 import 'package:polymer/polymer.dart'; |
| 8 import 'package:polymer/platform.dart' as Platform; | |
| 9 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 10 import 'package:unittest/html_config.dart'; | 9 import 'package:unittest/html_config.dart'; |
| 11 | 10 |
| 12 @CustomTag('x-test') | 11 @CustomTag('x-test') |
| 13 class XTest extends PolymerElement { | 12 class XTest extends PolymerElement { |
| 14 @observable List list; | 13 @observable List list; |
| 15 | 14 |
| 16 final _enteredView = new Completer(); | 15 final _enteredView = new Completer(); |
| 17 Future onTestDone; | 16 Future onTestDone; |
| 18 | 17 |
| 19 XTest.created() : super.created() { | 18 XTest.created() : super.created() { |
| 20 onTestDone = _enteredView.future.then(_runTest); | 19 onTestDone = _enteredView.future.then(_runTest); |
| 21 } | 20 } |
| 22 | 21 |
| 23 enteredView() { | 22 enteredView() { |
| 24 super.enteredView(); | 23 super.enteredView(); |
| 25 _enteredView.complete(); | 24 _enteredView.complete(); |
| 26 } | 25 } |
| 27 | 26 |
| 28 _runTest(_) { | 27 _runTest(_) { |
| 29 list = [ | 28 list = [ |
| 30 {'name': 'foo'}, | 29 {'name': 'foo'}, |
| 31 {'name': 'bar'} | 30 {'name': 'bar'} |
| 32 ]; | 31 ]; |
| 33 | 32 return new Future(() { |
| 34 Platform.flush(); | |
| 35 Platform.endOfMicrotask(expectAsync0(() { | |
| 36 // tickle SD polyfill | 33 // tickle SD polyfill |
| 37 offsetHeight; | 34 offsetHeight; |
| 38 var children = this.$['echo'].children; | 35 var children = this.$['echo'].children; |
| 39 expect(children[0].localName, 'template', reason: | 36 expect(children[0].localName, 'template', reason: |
| 40 'shadowDOM dynamic distribution via template'); | 37 'shadowDOM dynamic distribution via template'); |
| 41 expect(children[1].text, 'foo', reason: | 38 expect(children[1].text, 'foo', reason: |
| 42 'shadowDOM dynamic distribution via template'); | 39 'shadowDOM dynamic distribution via template'); |
| 43 expect(children[2].text, 'bar', reason: | 40 expect(children[2].text, 'bar', reason: |
| 44 'shadowDOM dynamic distribution via template'); | 41 'shadowDOM dynamic distribution via template'); |
| 45 | 42 |
| 46 // TODO(jmesserly): restore this if we get the JS interop capability. | 43 // TODO(jmesserly): restore this if we get the JS interop capability. |
| 47 /* | 44 /* |
| 48 if (window.ShadowDOMPolyfill) { | 45 if (window.ShadowDOMPolyfill) { |
| 49 var actualChildren = this.$.echo.impl.children; | 46 var actualChildren = this.$.echo.impl.children; |
| 50 chai.assert.equal(actualChildren.length, 4, | 47 chai.assert.equal(actualChildren.length, 4, |
| 51 'shadowDOMPolyfill distributes expected number of actual children.'); | 48 'shadowDOMPolyfill distributes expected number of actual children.'); |
| 52 } | 49 } |
| 53 */ | 50 */ |
| 54 })); | 51 }); |
| 55 } | 52 } |
| 56 } | 53 } |
| 57 | 54 |
| 58 main() { | 55 main() { |
| 59 initPolymer(); | 56 initPolymer(); |
| 60 useHtmlConfiguration(); | 57 useHtmlConfiguration(); |
| 61 | 58 |
| 62 setUp(() => Polymer.onReady); | 59 setUp(() => Polymer.onReady); |
| 63 | 60 |
| 64 test('inserted called', () => query('x-test').onTestDone); | 61 test('inserted called', () => query('x-test').onTestDone); |
| 65 } | 62 } |
| OLD | NEW |