OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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:observatory/src/elements/curly_block.dart'; | 7 import 'package:observatory/src/elements/curly_block.dart'; |
8 | 8 |
9 main() { | 9 main() { |
10 CurlyBlockElement.tag.ensureRegistration(); | 10 CurlyBlockElement.tag.ensureRegistration(); |
11 | 11 |
12 group('instantiation', () { | 12 group('instantiation', () { |
13 test('default', () { | 13 test('default', () { |
14 final e = new CurlyBlockElement(); | 14 final e = new CurlyBlockElement(); |
15 expect(e, isNotNull, reason: 'element correctly created'); | 15 expect(e, isNotNull, reason: 'element correctly created'); |
16 expect(e.expanded, isFalse); | 16 expect(e.expanded, isFalse); |
17 expect(e.disabled, isFalse); | 17 expect(e.disabled, isFalse); |
18 }); | 18 }); |
19 test('not expanded', () { | 19 test('not expanded', () { |
20 final e = new CurlyBlockElement(expanded: false); | 20 final e = new CurlyBlockElement(expanded: false); |
21 expect(e, isNotNull, reason: 'element correctly created'); | 21 expect(e, isNotNull, reason: 'element correctly created'); |
22 expect(e.expanded, isFalse); | 22 expect(e.expanded, isFalse); |
23 expect(e.disabled, isFalse); | 23 expect(e.disabled, isFalse); |
24 }); | 24 }); |
25 test('not expanded / not disabled', () { | 25 test('not expanded / not disabled', () { |
26 final e = new CurlyBlockElement(expanded: false, disabled: false); | 26 final e = new CurlyBlockElement(expanded: false, |
| 27 disabled: false); |
27 expect(e, isNotNull, reason: 'element correctly created'); | 28 expect(e, isNotNull, reason: 'element correctly created'); |
28 expect(e.expanded, isFalse); | 29 expect(e.expanded, isFalse); |
29 expect(e.disabled, isFalse); | 30 expect(e.disabled, isFalse); |
30 }); | 31 }); |
31 test('not expanded / disabled', () { | 32 test('not expanded / disabled', () { |
32 final e = new CurlyBlockElement(expanded: false, disabled: true); | 33 final e = new CurlyBlockElement(expanded: false, |
| 34 disabled: true); |
33 expect(e, isNotNull, reason: 'element correctly created'); | 35 expect(e, isNotNull, reason: 'element correctly created'); |
34 expect(e.expanded, isFalse); | 36 expect(e.expanded, isFalse); |
35 expect(e.disabled, isTrue); | 37 expect(e.disabled, isTrue); |
36 }); | 38 }); |
37 test('expanded', () { | 39 test('expanded', () { |
38 final e = new CurlyBlockElement(expanded: true); | 40 final e = new CurlyBlockElement(expanded: true); |
39 expect(e, isNotNull, reason: 'element correctly created'); | 41 expect(e, isNotNull, reason: 'element correctly created'); |
40 expect(e.expanded, isTrue); | 42 expect(e.expanded, isTrue); |
41 expect(e.disabled, isFalse); | 43 expect(e.disabled, isFalse); |
42 }); | 44 }); |
(...skipping 20 matching lines...) Expand all Loading... |
63 expect(e, isNotNull, reason: 'element correctly created'); | 65 expect(e, isNotNull, reason: 'element correctly created'); |
64 expect(e.expanded, isFalse); | 66 expect(e.expanded, isFalse); |
65 expect(e.disabled, isTrue); | 67 expect(e.disabled, isTrue); |
66 }); | 68 }); |
67 }); | 69 }); |
68 test('elements created', () async { | 70 test('elements created', () async { |
69 final e = new CurlyBlockElement(); | 71 final e = new CurlyBlockElement(); |
70 expect(e.children.length, isZero, reason: 'is empty'); | 72 expect(e.children.length, isZero, reason: 'is empty'); |
71 document.body.append(e); | 73 document.body.append(e); |
72 await e.onRendered.first; | 74 await e.onRendered.first; |
73 expect(e.children.length, isNonZero, reason: 'has elements'); | 75 expect(e.children.length, isNonZero, |
| 76 reason: 'has elements'); |
74 e.remove(); | 77 e.remove(); |
75 await e.onRendered.first; | 78 await e.onRendered.first; |
76 expect(e.children.length, isZero, reason: 'is empty'); | 79 expect(e.children.length, isZero, reason: 'is empty'); |
77 }); | 80 }); |
78 group('content', () { | 81 group('content', () { |
79 CurlyBlockElement e; | 82 CurlyBlockElement e; |
80 setUp(() async { | 83 setUp(() async { |
81 e = new CurlyBlockElement(); | 84 e = new CurlyBlockElement(); |
82 e.content = [document.createElement('content')]; | 85 e.content = [document.createElement('content')]; |
83 document.body.append(e); | 86 document.body.append(e); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 setUp(() async { | 148 setUp(() async { |
146 e = new CurlyBlockElement(); | 149 e = new CurlyBlockElement(); |
147 document.body.append(e); | 150 document.body.append(e); |
148 await e.onRendered.first; | 151 await e.onRendered.first; |
149 }); | 152 }); |
150 tearDown(() async { | 153 tearDown(() async { |
151 e.remove(); | 154 e.remove(); |
152 await e.onRendered.first; | 155 await e.onRendered.first; |
153 }); | 156 }); |
154 test('fires on toggle', () async { | 157 test('fires on toggle', () async { |
155 e.onToggle.listen(expectAsync((CurlyBlockToggleEvent event) { | 158 e.onToggle.listen(expectAsync((CurlyBlockToggleEvent event){ |
156 expect(event, isNotNull); | 159 expect(event, isNotNull); |
157 expect(event.control, equals(e)); | 160 expect(event.control, equals(e)); |
158 }, count: 1)); | 161 }, count: 1)); |
159 e.toggle(); | 162 e.toggle(); |
160 await e.onRendered.first; | 163 await e.onRendered.first; |
161 }); | 164 }); |
162 test('fires on manual toggle', () async { | 165 test('fires on manual toggle', () async { |
163 e.onToggle.listen(expectAsync((CurlyBlockToggleEvent event) { | 166 e.onToggle.listen(expectAsync((CurlyBlockToggleEvent event){ |
164 expect(event, isNotNull); | 167 expect(event, isNotNull); |
165 expect(event.control, equals(e)); | 168 expect(event.control, equals(e)); |
166 }, count: 1)); | 169 }, count: 1)); |
167 e.expanded = !e.expanded; | 170 e.expanded = !e.expanded; |
168 await e.onRendered.first; | 171 await e.onRendered.first; |
169 }); | 172 }); |
170 test('does not fire if setting same expanded value', () async { | 173 test('does not fire if setting same expanded value', () async { |
171 e.onToggle.listen(expectAsync((_) {}, count: 0)); | 174 e.onToggle.listen(expectAsync((_){}, count: 0)); |
172 e.expanded = e.expanded; | 175 e.expanded = e.expanded; |
173 await e.onRendered.first; | 176 await e.onRendered.first; |
174 }); | 177 }); |
175 }); | 178 }); |
176 } | 179 } |
OLD | NEW |