| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 @TestOn('browser') | 4 @TestOn('browser') |
| 5 library polymer.test.src.common.behavior_composition_test; | 5 library polymer.test.src.common.behavior_composition_test; |
| 6 | 6 |
| 7 import 'dart:html'; | 7 import 'dart:html'; |
| 8 import 'dart:js'; | 8 import 'dart:js'; |
| 9 import 'package:polymer/polymer.dart'; | 9 import 'package:polymer/polymer.dart'; |
| 10 import 'package:polymer/src/common/polymer_descriptor.dart'; | 10 import 'package:polymer/src/common/polymer_descriptor.dart'; |
| 11 import 'package:test/test.dart'; | 11 import 'package:test/test.dart'; |
| 12 import 'package:web_components/web_components.dart'; | 12 import 'package:web_components/web_components.dart'; |
| 13 import '../../common.dart'; | 13 import '../../common.dart'; |
| 14 | 14 |
| 15 main() async { | 15 main() async { |
| 16 await initPolymer(); | 16 await initPolymer(); |
| 17 | 17 |
| 18 group('behavior composition', () { | 18 group('behavior composition', () { |
| 19 test('Correct usage of mixins works', () { | 19 test('Correct usage of mixins works', () { |
| 20 var descriptor = | 20 var descriptor = |
| 21 createPolymerDescriptor(Good, const PolymerRegister('good-element')); | 21 createPolymerDescriptor(Good, const PolymerRegister('good-element')); |
| 22 // Should only get [BehaviorFour] in the top level behaviors object. | 22 // Should only get [BehaviorFour] in the top level behaviors object, in |
| 23 expect(descriptor['behaviors'].length, 1); | 23 // addition to Polymer.Dart.Behavior. |
| 24 expect(descriptor['behaviors'].length, 2); |
| 24 | 25 |
| 25 var behaviorFour = behavior.getBehavior(BehaviorFour); | 26 var behaviorFour = behavior.getBehavior(BehaviorFour); |
| 26 expect(descriptor['behaviors'][0], behaviorFour); | 27 expect(descriptor['behaviors'][1], behaviorFour); |
| 27 expect(behaviorFour, new isInstanceOf<JsArray>()); | 28 expect(behaviorFour, new isInstanceOf<JsArray>()); |
| 28 expect(behaviorFour.length, 2); | 29 expect(behaviorFour.length, 2); |
| 29 | 30 |
| 30 var behaviorThree = behavior.getBehavior(BehaviorThree); | 31 var behaviorThree = behavior.getBehavior(BehaviorThree); |
| 31 expect(behaviorFour[0], behaviorThree); | 32 expect(behaviorFour[0], behaviorThree); |
| 32 expect(behaviorFour[1], new isInstanceOf<JsObject>()); | 33 expect(behaviorFour[1], new isInstanceOf<JsObject>()); |
| 33 expect(behaviorThree, new isInstanceOf<JsArray>()); | 34 expect(behaviorThree, new isInstanceOf<JsArray>()); |
| 34 expect(behaviorThree.length, 3); | 35 expect(behaviorThree.length, 3); |
| 35 | 36 |
| 36 var behaviorTwo = behavior.getBehavior(BehaviorTwo); | 37 var behaviorTwo = behavior.getBehavior(BehaviorTwo); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 78 } |
| 78 | 79 |
| 79 class Incomplete extends PolymerElement with BehaviorOne, BehaviorThree { | 80 class Incomplete extends PolymerElement with BehaviorOne, BehaviorThree { |
| 80 Incomplete.created() : super.created(); | 81 Incomplete.created() : super.created(); |
| 81 } | 82 } |
| 82 | 83 |
| 83 class Invalid extends PolymerElement | 84 class Invalid extends PolymerElement |
| 84 with BehaviorTwo, BehaviorOne, BehaviorThree { | 85 with BehaviorTwo, BehaviorOne, BehaviorThree { |
| 85 Invalid.created() : super.created(); | 86 Invalid.created() : super.created(); |
| 86 } | 87 } |
| OLD | NEW |