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

Unified Diff: packages/polymer/test/property_observe_test.dart

Issue 1400473008: Roll Observatory packages and add a roll script (Closed) Base URL: git@github.com:dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « packages/polymer/test/property_change_test.html ('k') | packages/polymer/test/property_observe_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: packages/polymer/test/property_observe_test.dart
diff --git a/packages/polymer/test/property_observe_test.dart b/packages/polymer/test/property_observe_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2f4d696fcc00314479a75c20ca38b5eefe0383c0
--- /dev/null
+++ b/packages/polymer/test/property_observe_test.dart
@@ -0,0 +1,89 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library polymer.test.property_change_test;
+
+import 'dart:async';
+import 'dart:html';
+import 'package:polymer/polymer.dart';
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_config.dart';
+
+var _changes = 0;
+final _done = new Completer();
+
+checkDone() {
+ if (6 == ++_changes) {
+ _done.complete();
+ }
+}
+
+@CustomTag('x-test')
+class XTest extends PolymerElement {
+ @observable String bar = '';
+ @observable String pie;
+ @observable Map a;
+
+ XTest.created() : super.created();
+
+ ready() {
+ bar = 'bar';
+ pie = 'pie';
+ a = {'b': {'c': 'exists'}};
+ }
+
+ barChanged() {
+ // Dart note: unlike polymer-js we support multiple observers, due to how
+ // our @ObserveProperty metadata translated.
+ // _done.completeError('barChanged should not be called.');
+ expect('bar', 'bar', reason: 'barChanged called');
+ checkDone();
+ }
+
+ @ObserveProperty('bar pie')
+ validate() {
+ window.console.log('validate');
+ expect('bar', 'bar', reason: 'custom change observer called');
+ expect('pie', 'pie', reason: 'custom change observer called');
+ checkDone();
+ }
+
+ // Dart note: test that we can observe "pie" twice.
+ @ObserveProperty('pie')
+ validateYummyPie() {
+ window.console.log('validateYummyPie');
+ expect('pie', 'pie', reason: 'validateYummyPie called');
+ checkDone();
+ }
+
+ @ObserveProperty('a.b.c')
+ validateSubPath(oldValue, newValue) {
+ window.console.log('validateSubPath $oldValue $newValue');
+ expect(newValue, 'exists', reason: 'subpath change observer called');
+ checkDone();
+ }
+}
+
+@CustomTag('x-test2')
+class XTest2 extends XTest {
+ @observable String noogle;
+
+ XTest2.created() : super.created();
+
+ @ObserveProperty('noogle')
+ validate() => super.validate();
+
+ ready() {
+ super.ready();
+ noogle = 'noogle';
+ }
+}
+
+main() => initPolymer().then((zone) => zone.run(() {
+ useHtmlConfiguration();
+
+ setUp(() => Polymer.onReady);
+
+ test('changes detected', () => _done.future);
+}));
« no previous file with comments | « packages/polymer/test/property_change_test.html ('k') | packages/polymer/test/property_observe_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698