| 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 import 'package:unittest/matcher.dart'; | 10 import 'package:unittest/matcher.dart'; |
| 11 | 11 |
| 12 @CustomTag('x-bar') |
| 13 class XBar extends PolymerElement { |
| 14 XBar.created() : super.created(); |
| 15 |
| 16 get testValue => true; |
| 17 } |
| 18 |
| 12 @CustomTag('x-foo') | 19 @CustomTag('x-foo') |
| 13 class XFoo extends PolymerElement { | 20 class XFoo extends PolymerElement { |
| 14 @observable var foo = 'foo!'; | 21 @observable var foo = 'foo!'; |
| 15 final _ready = new Completer(); | 22 final _testDone = new Completer(); |
| 16 Future onTestDone; | 23 Future get onTestDone => _testDone.future; |
| 17 | 24 |
| 18 XFoo.created() : super.created() { | 25 XFoo.created() : super.created(); |
| 19 onTestDone = _ready.future.then(_runTest); | |
| 20 } | |
| 21 | 26 |
| 22 _runTest(_) { | 27 _runTest(_) { |
| 28 expect($['bindId'].text.trim(), 'bar!'); |
| 29 |
| 23 expect(foo, $['foo'].attributes['foo']); | 30 expect(foo, $['foo'].attributes['foo']); |
| 24 expect($['bool'].attributes['foo'], ''); | 31 expect($['bool'].attributes['foo'], ''); |
| 25 expect($['bool'].attributes, isNot(contains('foo?'))); | 32 expect($['bool'].attributes, isNot(contains('foo?'))); |
| 26 expect($['content'].innerHtml, foo); | 33 expect($['content'].innerHtml, foo); |
| 27 | 34 |
| 28 expect(foo, $['bar'].attributes['foo']); | 35 expect(foo, $['bar'].attributes['foo']); |
| 29 expect($['barBool'].attributes['foo'], ''); | 36 expect($['barBool'].attributes['foo'], ''); |
| 30 expect($['barBool'].attributes, isNot(contains('foo?'))); | 37 expect($['barBool'].attributes, isNot(contains('foo?'))); |
| 31 expect($['barContent'].innerHtml, foo); | 38 expect($['barContent'].innerHtml, foo); |
| 39 _testDone.complete(); |
| 32 } | 40 } |
| 33 | 41 |
| 34 ready() => _ready.complete(); | 42 ready() { |
| 43 onMutation($['bindId']).then(_runTest); |
| 44 } |
| 35 } | 45 } |
| 36 | 46 |
| 37 main() { | 47 main() { |
| 38 initPolymer(); | 48 initPolymer(); |
| 39 useHtmlConfiguration(); | 49 useHtmlConfiguration(); |
| 40 | 50 |
| 41 setUp(() => Polymer.onReady); | 51 setUp(() => Polymer.onReady); |
| 42 | 52 |
| 43 test('ready called', () => query('x-foo').onTestDone); | 53 test('ready called', () => query('x-foo').onTestDone); |
| 44 } | 54 } |
| OLD | NEW |