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

Unified Diff: pkg/polymer/test/bind_properties_test.dart

Issue 420673002: Roll polymer packages to version 0.3.4 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 | « pkg/polymer/test/auto_binding_test.dart ('k') | pkg/polymer/test/bind_properties_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/test/bind_properties_test.dart
diff --git a/pkg/polymer/test/bind_properties_test.dart b/pkg/polymer/test/bind_properties_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5765afb014ada4c392b78dfa964e867fd9396b62
--- /dev/null
+++ b/pkg/polymer/test/bind_properties_test.dart
@@ -0,0 +1,108 @@
+// 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.
+
+import 'dart:async';
+import 'dart:html';
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_config.dart';
+import 'package:polymer/polymer.dart';
+
+export 'package:polymer/init.dart';
+
+class XBaz extends PolymerElement {
+ @published
+ int get val => readValue(#val);
+ set val(v) => writeValue(#val, v);
+
+ XBaz.created() : super.created();
+}
+
+class XBar extends PolymerElement {
+ @published
+ int get val => readValue(#val);
+ set val(v) => writeValue(#val, v);
+
+ XBar.created() : super.created();
+}
+
+class XBat extends PolymerElement {
+ @published
+ int get val => readValue(#val);
+ set val(v) => writeValue(#val, v);
+
+ XBat.created() : super.created();
+}
+
+class XFoo extends PolymerElement {
+ @published
+ int get val => readValue(#val);
+ set val(v) => writeValue(#val, v);
+
+ XFoo.created() : super.created();
+}
+
+@CustomTag('bind-properties-test')
+class XTest extends PolymerElement {
+ XTest.created() : super.created();
+
+ @published var obj;
+
+ ready() {
+ obj = toObservable({'path': {'to': {'value': 3}}});
+ readyCalled();
+ }
+}
+
+var completer = new Completer();
+waitForElementReady(_) => completer.future;
+readyCalled() { completer.complete(null); }
+
+@initMethod
+init() {
+ // TODO(sigmund): investigate why are we still seeing failures due to the
+ // order of registrations, then use @CustomTag instead of this.
+ Polymer.register('x-foo', XFoo);
+ Polymer.register('x-bar', XBar);
+ Polymer.register('x-baz', XBaz);
+ Polymer.register('x-bat', XBat);
+
+ useHtmlConfiguration();
+
+ setUp(() => Polymer.onReady.then(waitForElementReady));
+
+ test('bind properties test', () {
+ var e = document.querySelector('bind-properties-test');
+ var foo = e.shadowRoot.querySelector('#foo');
+ var bar = foo.shadowRoot.querySelector('#bar');
+ var bat = foo.shadowRoot.querySelector('#bat');
+ var baz = bar.shadowRoot.querySelector('#baz');
+
+ expect(foo.val, 3);
+ expect(bar.val, 3);
+ expect(bat.val, 3);
+ expect(baz.val, 3);
+
+ foo.val = 4;
+
+ expect(foo.val, 4);
+ expect(bar.val, 4);
+ expect(bat.val, 4);
+ expect(baz.val, 4);
+
+ baz.val = 5;
+
+ expect(foo.val, 5);
+ expect(bar.val, 5);
+ expect(bat.val, 5);
+ expect(baz.val, 5);
+
+ e.obj['path']['to']['value'] = 6;
+
+ expect(foo.val, 6);
+ expect(bar.val, 6);
+ expect(bat.val, 6);
+ expect(baz.val, 6);
+ });
+}
+
« no previous file with comments | « pkg/polymer/test/auto_binding_test.dart ('k') | pkg/polymer/test/bind_properties_test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698