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:html'; | |
6 import 'package:unittest/unittest.dart'; | |
7 import 'package:unittest/html_config.dart'; | |
8 import 'package:polymer/polymer.dart'; | |
9 import 'package:logging/logging.dart'; | |
10 | |
11 // Dart note: unlike JS, you can't publish something that doesn't | |
12 // have a corresponding field because we can't dynamically add properties. | |
13 // So we define XFoo and XBar types here. | |
14 class XFoo extends PolymerElement { | |
15 XFoo.created() : super.created(); | |
16 | |
17 @published var Foo; | |
18 } | |
19 | |
20 class XBar extends XFoo { | |
21 XBar.created() : super.created(); | |
22 | |
23 @published var Bar; | |
24 } | |
25 | |
26 @CustomTag('x-zot') | |
27 class XZot extends XBar { | |
28 XZot.created() : super.created(); | |
29 | |
30 // Note: this is published because it appears in the `attributes` attribute. | |
31 var m; | |
32 | |
33 @published int zot = 3; | |
34 } | |
35 | |
36 // Regresion test for dartbug.comk/14559. The bug is still open, but we don't | |
37 // hit it now that we use smoke. The bug was assinging @CustomTag('x-zot') to | |
38 // this class incorrectly and as a result `zap` was listed in `x-zot`. | |
39 class XWho extends XZot { | |
40 XWho.created() : super.created(); | |
41 | |
42 @published var zap; | |
43 } | |
44 | |
45 @CustomTag('x-squid') | |
46 class XSquid extends XZot { | |
47 XSquid.created() : super.created(); | |
48 | |
49 @published int baz = 13; | |
50 @published int zot = 5; | |
51 @published int squid = 7; | |
52 } | |
53 | |
54 main() { | |
55 useHtmlConfiguration(); | |
56 | |
57 initPolymer().then((zone) { | |
58 zone.run(() { | |
59 Logger.root.level = Level.ALL; | |
60 Logger.root.onRecord.listen((r) => print('${r.loggerName} ${r.message}')); | |
61 | |
62 Polymer.register('x-noscript', XZot); | |
63 | |
64 setUp(() => Polymer.onReady); | |
65 | |
66 test('published properties', () { | |
67 published(tag) => (new Element.tag( | |
68 tag) as PolymerElement).element.publishedProperties; | |
69 | |
70 expect(published('x-zot'), ['Foo', 'Bar', 'zot', 'm']); | |
71 expect( | |
72 published('x-squid'), ['Foo', 'Bar', 'zot', 'm', 'baz', 'squid']); | |
73 expect(published('x-noscript'), ['Foo', 'Bar', 'zot', 'm']); | |
74 expect( | |
75 published('x-squid'), ['Foo', 'Bar', 'zot', 'm', 'baz', 'squid']); | |
76 }); | |
77 }); | |
78 }); | |
79 } | |
OLD | NEW |