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