OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library polymer.test.property_change_test; |
| 6 |
| 7 import 'dart:async'; |
| 8 import 'package:polymer/polymer.dart'; |
| 9 import 'package:unittest/unittest.dart'; |
| 10 import 'package:unittest/html_config.dart'; |
| 11 |
| 12 // Dart note: this is a tad different from the JS code. We don't support putting |
| 13 // expandos on Dart objects and then observing them. On the other hand, we want |
| 14 // to make sure that superclass observers are correctly detected. |
| 15 |
| 16 final _zonk = new Completer(); |
| 17 final _bar = new Completer(); |
| 18 |
| 19 @reflectable |
| 20 class XBase extends PolymerElement { |
| 21 @observable String zonk = ''; |
| 22 |
| 23 XBase.created() : super.created(); |
| 24 |
| 25 zonkChanged() { |
| 26 expect(zonk, 'zonk', reason: 'change calls *Changed on superclass'); |
| 27 _zonk.complete(); |
| 28 } |
| 29 } |
| 30 |
| 31 @CustomTag('x-test') |
| 32 class XTest extends XBase { |
| 33 @observable String bar = ''; |
| 34 |
| 35 XTest.created() : super.created(); |
| 36 |
| 37 ready() { |
| 38 bar = 'bar'; |
| 39 new Future(() { |
| 40 zonk = 'zonk'; |
| 41 }); |
| 42 } |
| 43 |
| 44 barChanged() { |
| 45 expect(bar, 'bar', reason: 'change in ready calls *Changed'); |
| 46 _bar.complete(); |
| 47 } |
| 48 } |
| 49 |
| 50 main() => initPolymer().then((zone) => zone.run(() { |
| 51 useHtmlConfiguration(); |
| 52 |
| 53 setUp(() => Polymer.onReady); |
| 54 |
| 55 test('bar change detected', () => _bar.future); |
| 56 test('zonk change detected', () => _zonk.future); |
| 57 })); |
OLD | NEW |