| 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 class XBase extends PolymerElement { |
| 22 @observable String zonk = ''; |
| 23 |
| 24 XBase.created() : super.created(); |
| 25 |
| 26 zonkChanged() { |
| 27 expect(zonk, 'zonk', reason: 'change calls *Changed on superclass'); |
| 28 _zonk.complete(); |
| 29 } |
| 30 } |
| 31 |
| 32 @CustomTag('x-test') |
| 33 class XTest extends XBase { |
| 34 @observable String bar = ''; |
| 35 |
| 36 XTest.created() : super.created(); |
| 37 |
| 38 ready() { |
| 39 bar = 'bar'; |
| 40 new Future(() { zonk = 'zonk'; }); |
| 41 } |
| 42 |
| 43 barChanged() { |
| 44 expect(bar, 'bar', reason: 'change in ready calls *Changed'); |
| 45 _bar.complete(); |
| 46 } |
| 47 } |
| 48 |
| 49 main() { |
| 50 initPolymer(); |
| 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 |