| 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:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 9 import 'package:unittest/html_config.dart'; | 9 import 'package:unittest/html_config.dart'; |
| 10 | 10 |
| 11 @CustomTag('x-test') | 11 @CustomTag('x-test') |
| 12 class XTest extends PolymerElement { | 12 class XTest extends PolymerElement { |
| 13 @observable List list; | 13 @observable List list; |
| 14 | 14 |
| 15 final _enteredView = new Completer(); | 15 final _attached = new Completer(); |
| 16 Future onTestDone; | 16 Future onTestDone; |
| 17 | 17 |
| 18 XTest.created() : super.created() { | 18 XTest.created() : super.created() { |
| 19 onTestDone = _enteredView.future.then(_runTest); | 19 onTestDone = _attached.future.then(_runTest); |
| 20 } | 20 } |
| 21 | 21 |
| 22 enteredView() { | 22 attached() { |
| 23 super.enteredView(); | 23 super.attached(); |
| 24 _enteredView.complete(); | 24 _attached.complete(); |
| 25 } | 25 } |
| 26 | 26 |
| 27 _runTest(_) { | 27 _runTest(_) { |
| 28 list = [ | 28 list = [ |
| 29 {'name': 'foo'}, | 29 {'name': 'foo'}, |
| 30 {'name': 'bar'} | 30 {'name': 'bar'} |
| 31 ]; | 31 ]; |
| 32 return new Future(() { | 32 return new Future(() { |
| 33 // tickle SD polyfill | 33 // tickle SD polyfill |
| 34 offsetHeight; | 34 offsetHeight; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 main() => initPolymer().run(() { | 55 main() => initPolymer().run(() { |
| 56 useHtmlConfiguration(); | 56 useHtmlConfiguration(); |
| 57 | 57 |
| 58 setUp(() => Polymer.onReady); | 58 setUp(() => Polymer.onReady); |
| 59 | 59 |
| 60 test('inserted called', () => (querySelector('x-test') as XTest).onTestDone); | 60 test('inserted called', () => (querySelector('x-test') as XTest).onTestDone); |
| 61 }); | 61 }); |
| OLD | NEW |