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 import 'dart:async'; | |
6 import 'dart:html'; | |
7 import 'package:unittest/unittest.dart'; | |
8 import 'package:unittest/html_config.dart'; | |
9 import 'package:polymer/polymer.dart'; | |
10 | |
11 export 'package:polymer/init.dart'; | |
12 | |
13 class XBaz extends PolymerElement { | |
14 @published | |
15 int get val => readValue(#val); | |
16 set val(v) => writeValue(#val, v); | |
17 | |
18 XBaz.created() : super.created(); | |
19 } | |
20 | |
21 class XBar extends PolymerElement { | |
22 @published | |
23 int get val => readValue(#val); | |
24 set val(v) => writeValue(#val, v); | |
25 | |
26 XBar.created() : super.created(); | |
27 } | |
28 | |
29 class XBat extends PolymerElement { | |
30 @published | |
31 int get val => readValue(#val); | |
32 set val(v) => writeValue(#val, v); | |
33 | |
34 XBat.created() : super.created(); | |
35 } | |
36 | |
37 class XFoo extends PolymerElement { | |
38 @published | |
39 int get val => readValue(#val); | |
40 set val(v) => writeValue(#val, v); | |
41 | |
42 XFoo.created() : super.created(); | |
43 } | |
44 | |
45 @CustomTag('bind-properties-test') | |
46 class XTest extends PolymerElement { | |
47 XTest.created() : super.created(); | |
48 | |
49 @published var obj; | |
50 | |
51 ready() { | |
52 obj = toObservable({'path': {'to': {'value': 3}}}); | |
53 readyCalled(); | |
54 } | |
55 } | |
56 | |
57 var completer = new Completer(); | |
58 waitForElementReady(_) => completer.future; | |
59 readyCalled() { | |
60 completer.complete(null); | |
61 } | |
62 | |
63 @initMethod | |
64 init() { | |
65 // TODO(sigmund): investigate why are we still seeing failures due to the | |
66 // order of registrations, then use @CustomTag instead of this. | |
67 Polymer.register('x-foo', XFoo); | |
68 Polymer.register('x-bar', XBar); | |
69 Polymer.register('x-baz', XBaz); | |
70 Polymer.register('x-bat', XBat); | |
71 | |
72 useHtmlConfiguration(); | |
73 | |
74 setUp(() => Polymer.onReady.then(waitForElementReady)); | |
75 | |
76 test('bind properties test', () { | |
77 var e = document.querySelector('bind-properties-test'); | |
78 var foo = e.shadowRoot.querySelector('#foo'); | |
79 var bar = foo.shadowRoot.querySelector('#bar'); | |
80 var bat = foo.shadowRoot.querySelector('#bat'); | |
81 var baz = bar.shadowRoot.querySelector('#baz'); | |
82 | |
83 expect(foo.val, 3); | |
84 expect(bar.val, 3); | |
85 expect(bat.val, 3); | |
86 expect(baz.val, 3); | |
87 | |
88 foo.val = 4; | |
89 | |
90 expect(foo.val, 4); | |
91 expect(bar.val, 4); | |
92 expect(bat.val, 4); | |
93 expect(baz.val, 4); | |
94 | |
95 baz.val = 5; | |
96 | |
97 expect(foo.val, 5); | |
98 expect(bar.val, 5); | |
99 expect(bat.val, 5); | |
100 expect(baz.val, 5); | |
101 | |
102 e.obj['path']['to']['value'] = 6; | |
103 | |
104 expect(foo.val, 6); | |
105 expect(bar.val, 6); | |
106 expect(bat.val, 6); | |
107 expect(baz.val, 6); | |
108 }); | |
109 } | |
OLD | NEW |