| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 import 'dart:html'; | 5 import 'dart:html'; |
| 6 import 'package:unittest/unittest.dart'; | 6 import 'package:unittest/unittest.dart'; |
| 7 import 'package:unittest/html_config.dart'; | 7 import 'package:unittest/html_config.dart'; |
| 8 import 'package:polymer/polymer.dart'; | 8 import 'package:polymer/polymer.dart'; |
| 9 | 9 |
| 10 // Dart note: unlike JS, you can't publish something that doesn't | 10 // Dart note: unlike JS, you can't publish something that doesn't |
| 11 // have a corresponding field because we can't dynamically add properties. | 11 // have a corresponding field because we can't dynamically add properties. |
| 12 // So we define XFoo and XBar types here. | 12 // So we define XFoo and XBar types here. |
| 13 @CustomTag('x-foo') | |
| 14 class XFoo extends PolymerElement { | 13 class XFoo extends PolymerElement { |
| 15 XFoo.created() : super.created(); | 14 XFoo.created() : super.created(); |
| 16 | 15 |
| 17 @observable var Foo; | 16 @published var Foo; |
| 18 @observable var baz; | |
| 19 } | 17 } |
| 20 | 18 |
| 21 @CustomTag('x-bar') | |
| 22 class XBar extends XFoo { | 19 class XBar extends XFoo { |
| 23 XBar.created() : super.created(); | 20 XBar.created() : super.created(); |
| 24 | 21 |
| 25 @observable var Bar; | 22 @published var Bar; |
| 26 } | 23 } |
| 27 | 24 |
| 28 @CustomTag('x-zot') | 25 @CustomTag('x-zot') |
| 29 class XZot extends XBar { | 26 class XZot extends XBar { |
| 30 XZot.created() : super.created(); | 27 XZot.created() : super.created(); |
| 31 | 28 |
| 32 @published int zot = 3; | 29 @published int zot = 3; |
| 33 } | 30 } |
| 34 | 31 |
| 32 class XWho extends XZot { |
| 33 XWho.created() : super.created(); |
| 34 |
| 35 @published var zap; |
| 36 } |
| 37 |
| 35 @CustomTag('x-squid') | 38 @CustomTag('x-squid') |
| 36 class XSquid extends XZot { | 39 class XSquid extends XWho { |
| 37 XSquid.created() : super.created(); | 40 XSquid.created() : super.created(); |
| 38 | 41 |
| 39 @published int baz = 13; | 42 @published int baz = 13; |
| 40 @published int zot = 5; | 43 @published int zot = 5; |
| 41 @published int squid = 7; | 44 @published int squid = 7; |
| 42 } | 45 } |
| 43 | 46 |
| 44 main() { | 47 main() { |
| 45 initPolymer(); | 48 initPolymer(); |
| 46 useHtmlConfiguration(); | 49 useHtmlConfiguration(); |
| 47 | 50 |
| 48 setUp(() => Polymer.onReady); | 51 setUp(() => Polymer.onReady); |
| 49 | 52 |
| 50 test('published properties', () { | 53 test('published properties', () { |
| 51 published(tag) => | 54 published(tag) => |
| 52 query('polymer-element[name=$tag]').publishedProperties; | 55 query('polymer-element[name=$tag]').publishedProperties; |
| 53 | 56 |
| 54 expect(published('x-foo'), [#Foo, #baz]); | 57 expect(published('x-zot'), [#Foo, #Bar, #zot]); |
| 55 expect(published('x-bar'), [#Foo, #baz, #Bar]); | 58 expect(published('x-squid'), [#Foo, #Bar, #zot, #zap, #baz, #squid]); |
| 56 expect(published('x-zot'), [#Foo, #baz, #Bar, #zot]); | |
| 57 expect(published('x-squid'), [#Foo, #baz, #Bar, #zot, #squid]); | |
| 58 }); | 59 }); |
| 59 } | 60 } |
| OLD | NEW |