| 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 class XFoo extends PolymerElement { | 13 class XFoo extends PolymerElement { |
| 14 XFoo.created() : super.created(); | 14 XFoo.created() : super.created(); |
| 15 | 15 |
| 16 @published var Foo; | 16 @published var Foo; |
| 17 } | 17 } |
| 18 | 18 |
| 19 class XBar extends XFoo { | 19 class XBar extends XFoo { |
| 20 XBar.created() : super.created(); | 20 XBar.created() : super.created(); |
| 21 | 21 |
| 22 @published var Bar; | 22 @published var Bar; |
| 23 } | 23 } |
| 24 | 24 |
| 25 @CustomTag('x-zot') | 25 @CustomTag('x-zot') |
| 26 class XZot extends XBar { | 26 class XZot extends XBar { |
| 27 XZot.created() : super.created(); | 27 XZot.created() : super.created(); |
| 28 | 28 |
| 29 var m; |
| 29 @published int zot = 3; | 30 @published int zot = 3; |
| 30 } | 31 } |
| 31 | 32 |
| 32 // TODO(sigmund): uncomment this part of the test too (see dartbug.com/14559) | 33 // TODO(sigmund): uncomment this part of the test too (see dartbug.com/14559) |
| 33 // class XWho extends XZot { | 34 // class XWho extends XZot { |
| 34 // XWho.created() : super.created(); | 35 // XWho.created() : super.created(); |
| 35 // | 36 // |
| 36 // @published var zap; | 37 // @published var zap; |
| 37 // } | 38 // } |
| 38 | 39 |
| 39 @CustomTag('x-squid') | 40 @CustomTag('x-squid') |
| 40 class XSquid extends XZot { | 41 class XSquid extends XZot { |
| 41 XSquid.created() : super.created(); | 42 XSquid.created() : super.created(); |
| 42 | 43 |
| 43 @published int baz = 13; | 44 @published int baz = 13; |
| 44 @published int zot = 5; | 45 @published int zot = 5; |
| 45 @published int squid = 7; | 46 @published int squid = 7; |
| 46 } | 47 } |
| 47 | 48 |
| 48 main() { | 49 main() { |
| 49 initPolymer(); | 50 initPolymer(); |
| 50 useHtmlConfiguration(); | 51 useHtmlConfiguration(); |
| 51 | 52 |
| 52 setUp(() => Polymer.onReady); | 53 setUp(() => Polymer.onReady); |
| 53 | 54 |
| 54 test('published properties', () { | 55 test('published properties', () { |
| 55 published(tag) => | 56 published(tag) => |
| 56 query('polymer-element[name=$tag]').publishedProperties; | 57 query('polymer-element[name=$tag]').publishedProperties; |
| 57 | 58 |
| 58 expect(published('x-zot'), [#Foo, #Bar, #zot]); | 59 expect(published('x-zot'), [#Foo, #Bar, #zot, #m]); |
| 59 expect(published('x-squid'), [#Foo, #Bar, #zot, #baz, #squid]); | 60 expect(published('x-squid'), [#Foo, #Bar, #zot, #m, #baz, #squid]); |
| 61 expect(published('x-noscript'), [#Foo, #Bar, #zot, #m]); |
| 60 // TODO(sigmund): uncomment, see above | 62 // TODO(sigmund): uncomment, see above |
| 61 // expect(published('x-squid'), [#Foo, #Bar, #zot, #zap, #baz, #squid]); | 63 // expect(published('x-squid'), [#Foo, #Bar, #zot, #zap, #baz, #squid]); |
| 62 }); | 64 }); |
| 63 } | 65 } |
| OLD | NEW |