Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: pkg/polymer/test/property_observe_test.dart

Issue 132403010: big update to observe, template_binding, polymer (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 var _changes = 0;
15 final _done = new Completer();
16
17 checkDone() {
18 if (4 == ++_changes) {
19 _done.complete();
20 }
21 }
22
23 @CustomTag('x-test')
24 class XTest extends PolymerElement {
25 @observable String bar = '';
26 @observable String pie;
27 @observable Map a;
28
29 XTest.created() : super.created();
30
31 ready() {
32 bar = 'bar';
33 pie = 'pie';
34 a = {'b': {'c': 'exists'}};
35 }
36
37 barChanged() {
38 _done.completeError('barChanged should not be called.');
Siggi Cherem (dart-lang) 2014/02/03 22:52:48 seems a bit strange that this is not called. Is th
Jennifer Messerly 2014/02/04 00:33:06 it isn't in Polymer.js. It is now supported in Dar
39 }
40
41 @ObserveProperty('bar pie')
42 validate() {
43 window.console.log('validate');
44 expect('bar', 'bar', reason: 'custom change observer called');
45 expect('pie', 'pie', reason: 'custom change observer called');
46 checkDone();
47 }
48
49 @ObserveProperty('a.b.c')
50 validateSubPath(oldValue, newValue) {
51 window.console.log('validateSubPath $oldValue $newValue');
52 expect(newValue, 'exists', reason: 'subpath change observer called');
53 checkDone();
54 }
55 }
56
57 @CustomTag('x-test2')
58 class XTest2 extends XTest {
59 @observable String noogle;
60
61 XTest2.created() : super.created();
62
63 @ObserveProperty('noogle')
64 validate() => super.validate();
65
66 ready() {
67 super.ready();
68 noogle = 'noogle';
69 }
70 }
71
72 main() => initPolymer().run(() {
73 useHtmlConfiguration();
74
75 setUp(() => Polymer.onReady);
76
77 test('changes detected', () => _done.future);
78 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698