| 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') | 13 @CustomTag('x-foo') |
| 14 class XFoo extends PolymerElement { | 14 class XFoo extends PolymerElement { |
| 15 XFoo.created() : super.created(); |
| 16 |
| 15 @observable var Foo; | 17 @observable var Foo; |
| 16 @observable var baz; | 18 @observable var baz; |
| 17 } | 19 } |
| 18 | 20 |
| 19 @CustomTag('x-bar') | 21 @CustomTag('x-bar') |
| 20 class XBar extends XFoo { | 22 class XBar extends XFoo { |
| 23 XBar.created() : super.created(); |
| 24 |
| 21 @observable var Bar; | 25 @observable var Bar; |
| 22 } | 26 } |
| 23 | 27 |
| 24 @CustomTag('x-zot') | 28 @CustomTag('x-zot') |
| 25 class XZot extends XBar { | 29 class XZot extends XBar { |
| 30 XZot.created() : super.created(); |
| 31 |
| 26 @published int zot = 3; | 32 @published int zot = 3; |
| 27 } | 33 } |
| 28 | 34 |
| 29 @CustomTag('x-squid') | 35 @CustomTag('x-squid') |
| 30 class XSquid extends XZot { | 36 class XSquid extends XZot { |
| 37 XSquid.created() : super.created(); |
| 38 |
| 31 @published int baz = 13; | 39 @published int baz = 13; |
| 32 @published int zot = 5; | 40 @published int zot = 5; |
| 33 @published int squid = 7; | 41 @published int squid = 7; |
| 34 } | 42 } |
| 35 | 43 |
| 36 main() { | 44 main() { |
| 37 useHtmlConfiguration(); | 45 useHtmlConfiguration(); |
| 38 | 46 |
| 39 test('published properties', () { | 47 test('published properties', () { |
| 40 published(tag) => | 48 published(tag) => |
| 41 query('polymer-element[name=$tag]').xtag.publishedProperties; | 49 query('polymer-element[name=$tag]').xtag.publishedProperties; |
| 42 | 50 |
| 43 print(published('x-foo')); | 51 print(published('x-foo')); |
| 44 print(published('x-bar')); | 52 print(published('x-bar')); |
| 45 print(published('x-zot')); | 53 print(published('x-zot')); |
| 46 print(published('x-squid')); | 54 print(published('x-squid')); |
| 47 | 55 |
| 48 expect(published('x-foo'), ['Foo', 'baz']); | 56 expect(published('x-foo'), ['Foo', 'baz']); |
| 49 expect(published('x-bar'), ['Foo', 'baz', 'Bar']); | 57 expect(published('x-bar'), ['Foo', 'baz', 'Bar']); |
| 50 expect(published('x-zot'), ['Foo', 'baz', 'Bar', 'zot']); | 58 expect(published('x-zot'), ['Foo', 'baz', 'Bar', 'zot']); |
| 51 expect(published('x-squid'), ['Foo', 'baz', 'Bar', 'zot', 'squid']); | 59 expect(published('x-squid'), ['Foo', 'baz', 'Bar', 'zot', 'squid']); |
| 52 }); | 60 }); |
| 53 } | 61 } |
| OLD | NEW |