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