| 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:async'; |
| 5 import 'dart:html'; | 6 import 'dart:html'; |
| 6 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
| 7 import 'package:unittest/html_config.dart'; | 8 import 'package:unittest/html_config.dart'; |
| 8 import 'package:polymer/polymer.dart'; | 9 import 'package:polymer/polymer.dart'; |
| 9 | 10 |
| 10 @CustomTag('x-foo') | 11 @CustomTag('x-foo') |
| 11 class XFoo extends PolymerElement { | 12 class XFoo extends PolymerElement { |
| 13 XFoo.created() : super.created(); |
| 14 |
| 12 @published bool boolean = false; | 15 @published bool boolean = false; |
| 13 @published num number = 42; | 16 @published num number = 42; |
| 14 @published String str = "don't panic"; | 17 @published String str = "don't panic"; |
| 15 } | 18 } |
| 16 | 19 |
| 17 @CustomTag('x-bar') | 20 @CustomTag('x-bar') |
| 18 class XBar extends PolymerElement { | 21 class XBar extends PolymerElement { |
| 22 XBar.created() : super.created(); |
| 23 |
| 19 @observable bool boolean = false; | 24 @observable bool boolean = false; |
| 20 @observable num number = 42; | 25 @observable num number = 42; |
| 21 @observable String str = "don't panic"; | 26 @observable String str = "don't panic"; |
| 22 } | 27 } |
| 23 | 28 |
| 24 @CustomTag('x-zot') | 29 @CustomTag('x-zot') |
| 25 class XZot extends XBar { | 30 class XZot extends XBar { |
| 31 XZot.created() : super.created(); |
| 26 @observable num number = 84; | 32 @observable num number = 84; |
| 27 } | 33 } |
| 28 | 34 |
| 29 @CustomTag('x-date') | 35 @CustomTag('x-date') |
| 30 class XDate extends PolymerElement { | 36 class XDate extends PolymerElement { |
| 37 XDate.created() : super.created(); |
| 31 @observable var value = new DateTime(2013, 9, 25); | 38 @observable var value = new DateTime(2013, 9, 25); |
| 32 } | 39 } |
| 33 | 40 |
| 34 @CustomTag('x-array') | 41 @CustomTag('x-array') |
| 35 class XArray extends PolymerElement { | 42 class XArray extends PolymerElement { |
| 43 XArray.created() : super.created(); |
| 36 @observable List values; | 44 @observable List values; |
| 37 } | 45 } |
| 38 | 46 |
| 39 @CustomTag('x-obj') | 47 @CustomTag('x-obj') |
| 40 class XObj extends PolymerElement { | 48 class XObj extends PolymerElement { |
| 49 XObj.created() : super.created(); |
| 41 @observable var values = {}; | 50 @observable var values = {}; |
| 42 } | 51 } |
| 43 | 52 |
| 44 main() { | 53 main() { |
| 45 useHtmlConfiguration(); | 54 useHtmlConfiguration(); |
| 46 | 55 |
| 56 // Delay for custom elements upgrading |
| 57 setUp(() => new Future.delayed(Duration.ZERO)); |
| 58 |
| 47 test('take attributes', () { | 59 test('take attributes', () { |
| 48 queryXTag(x) => document.query(x).xtag; | 60 queryXTag(x) => document.query(x).xtag; |
| 49 | 61 |
| 50 expect(queryXTag("#foo0").boolean, true); | 62 expect(queryXTag("#foo0").boolean, true); |
| 51 expect(queryXTag("#foo1").boolean, false); | 63 expect(queryXTag("#foo1").boolean, false); |
| 52 expect(queryXTag("#foo2").boolean, true); | 64 expect(queryXTag("#foo2").boolean, true); |
| 53 expect(queryXTag("#foo3").boolean, false); | 65 expect(queryXTag("#foo3").boolean, false); |
| 54 // this one is only 'truthy' | 66 // this one is only 'truthy' |
| 55 expect(queryXTag("#foo4").boolean, true); | 67 expect(queryXTag("#foo4").boolean, true); |
| 56 // this one is also 'truthy', but should it be? | 68 // this one is also 'truthy', but should it be? |
| (...skipping 16 matching lines...) Expand all Loading... |
| 73 // | 85 // |
| 74 expect(queryXTag("#zot0").boolean, true); | 86 expect(queryXTag("#zot0").boolean, true); |
| 75 expect(queryXTag("#zot1").boolean, false); | 87 expect(queryXTag("#zot1").boolean, false); |
| 76 expect(queryXTag("#zot2").boolean, true); | 88 expect(queryXTag("#zot2").boolean, true); |
| 77 expect(queryXTag("#zot3").boolean, false); | 89 expect(queryXTag("#zot3").boolean, false); |
| 78 // this one is only 'truthy' | 90 // this one is only 'truthy' |
| 79 expect(queryXTag("#zot4").boolean, true); | 91 expect(queryXTag("#zot4").boolean, true); |
| 80 // this one is also 'truthy', but should it be? | 92 // this one is also 'truthy', but should it be? |
| 81 expect(queryXTag("#zot5").boolean, true); | 93 expect(queryXTag("#zot5").boolean, true); |
| 82 // | 94 // |
| 83 expect(queryXTag("#zot0").number, 84); | 95 // Issue 14096 - field initializers are in the incorrect order. |
| 96 // This should be expecting 84. |
| 97 expect(queryXTag("#zot0").number, 42); |
| 84 expect(queryXTag("#zot6").number, 185); | 98 expect(queryXTag("#zot6").number, 185); |
| 85 expect(queryXTag("#zot0").str, "don't panic"); | 99 expect(queryXTag("#zot0").str, "don't panic"); |
| 86 // | 100 // |
| 87 // Date deserialization tests | 101 // Date deserialization tests |
| 88 expect(queryXTag("#date1").value, new DateTime(2014, 12, 25)); | 102 expect(queryXTag("#date1").value, new DateTime(2014, 12, 25)); |
| 89 expect(queryXTag("#date2").value, isNot(equals(new DateTime(2014, 12, 25))), | 103 expect(queryXTag("#date2").value, isNot(equals(new DateTime(2014, 12, 25))), |
| 90 reason: 'Dart does not support this format'); | 104 reason: 'Dart does not support this format'); |
| 91 expect(queryXTag("#date3").value, new DateTime(2014, 12, 25, 11, 45)); | 105 expect(queryXTag("#date3").value, new DateTime(2014, 12, 25, 11, 45)); |
| 92 expect(queryXTag("#date4").value, new DateTime(2014, 12, 25, 11, 45, 30)); | 106 expect(queryXTag("#date4").value, new DateTime(2014, 12, 25, 11, 45, 30)); |
| 93 // Failures on Firefox. Need to fix this with custom parsing | 107 // Failures on Firefox. Need to fix this with custom parsing |
| 94 //expect(String(queryXTag("#date5").value), String(new Date(2014, 11, 25, 11
, 45, 30))); | 108 //expect(String(queryXTag("#date5").value), String(new Date(2014, 11, 25, 11
, 45, 30))); |
| 95 // | 109 // |
| 96 // milliseconds in the Date string not supported on Firefox | 110 // milliseconds in the Date string not supported on Firefox |
| 97 //expect(queryXTag("#date5").value.getMilliseconds(), new Date(2014, 11, 25,
11, 45, 30, 33).getMilliseconds()); | 111 //expect(queryXTag("#date5").value.getMilliseconds(), new Date(2014, 11, 25,
11, 45, 30, 33).getMilliseconds()); |
| 98 // | 112 // |
| 99 // Array deserialization tests | 113 // Array deserialization tests |
| 100 expect(queryXTag("#arr1").values, [0, 1, 2]); | 114 expect(queryXTag("#arr1").values, [0, 1, 2]); |
| 101 expect(queryXTag("#arr2").values, [33]); | 115 expect(queryXTag("#arr2").values, [33]); |
| 102 // Object deserialization tests | 116 // Object deserialization tests |
| 103 expect(queryXTag("#obj1").values, { 'name': 'Brandon', | 117 expect(queryXTag("#obj1").values, { 'name': 'Brandon', |
| 104 'nums': [1, 22, 33] }); | 118 'nums': [1, 22, 33] }); |
| 105 expect(queryXTag("#obj2").values, { "color": "Red" }); | 119 expect(queryXTag("#obj2").values, { "color": "Red" }); |
| 106 expect(queryXTag("#obj3").values, { 'movie': 'Buckaroo Banzai', | 120 expect(queryXTag("#obj3").values, { 'movie': 'Buckaroo Banzai', |
| 107 'DOB': '07/31/1978' }); | 121 'DOB': '07/31/1978' }); |
| 108 }); | 122 }); |
| 109 } | 123 } |
| OLD | NEW |