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

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

Issue 794473002: Delete polymer from the Dart repo (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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
« no previous file with comments | « pkg/polymer/test/property_change_test.html ('k') | pkg/polymer/test/property_observe_test.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
13 var _changes = 0;
14 final _done = new Completer();
15
16 checkDone() {
17 if (6 == ++_changes) {
18 _done.complete();
19 }
20 }
21
22 @CustomTag('x-test')
23 class XTest extends PolymerElement {
24 @observable String bar = '';
25 @observable String pie;
26 @observable Map a;
27
28 XTest.created() : super.created();
29
30 ready() {
31 bar = 'bar';
32 pie = 'pie';
33 a = {'b': {'c': 'exists'}};
34 }
35
36 barChanged() {
37 // Dart note: unlike polymer-js we support multiple observers, due to how
38 // our @ObserveProperty metadata translated.
39 // _done.completeError('barChanged should not be called.');
40 expect('bar', 'bar', reason: 'barChanged called');
41 checkDone();
42 }
43
44 @ObserveProperty('bar pie')
45 validate() {
46 window.console.log('validate');
47 expect('bar', 'bar', reason: 'custom change observer called');
48 expect('pie', 'pie', reason: 'custom change observer called');
49 checkDone();
50 }
51
52 // Dart note: test that we can observe "pie" twice.
53 @ObserveProperty('pie')
54 validateYummyPie() {
55 window.console.log('validateYummyPie');
56 expect('pie', 'pie', reason: 'validateYummyPie called');
57 checkDone();
58 }
59
60
61 @ObserveProperty('a.b.c')
62 validateSubPath(oldValue, newValue) {
63 window.console.log('validateSubPath $oldValue $newValue');
64 expect(newValue, 'exists', reason: 'subpath change observer called');
65 checkDone();
66 }
67 }
68
69 @CustomTag('x-test2')
70 class XTest2 extends XTest {
71 @observable String noogle;
72
73 XTest2.created() : super.created();
74
75 @ObserveProperty('noogle')
76 validate() => super.validate();
77
78 ready() {
79 super.ready();
80 noogle = 'noogle';
81 }
82 }
83
84 main() => initPolymer().run(() {
85 useHtmlConfiguration();
86
87 setUp(() => Polymer.onReady);
88
89 test('changes detected', () => _done.future);
90 });
OLDNEW
« no previous file with comments | « pkg/polymer/test/property_change_test.html ('k') | pkg/polymer/test/property_observe_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698