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 import 'dart:html'; | 4 import 'dart:html'; |
5 import 'package:unittest/unittest.dart'; | 5 import 'package:unittest/unittest.dart'; |
6 import 'package:observatory/src/elements/curly_block.dart'; | 6 import 'package:observatory/src/elements/curly_block.dart'; |
7 | 7 |
8 main() { | 8 main() { |
9 CurlyBlockElement.tag.ensureRegistration(); | 9 CurlyBlockElement.tag.ensureRegistration(); |
10 | 10 |
11 group('instantiation', () { | 11 group('instantiation', () { |
12 test('default', () { | 12 test('default', () { |
13 final CurlyBlockElement e = new CurlyBlockElement(); | 13 final e = new CurlyBlockElement(); |
14 expect(e, isNotNull, reason: 'element correctly created'); | 14 expect(e, isNotNull, reason: 'element correctly created'); |
15 expect(e.expanded, isFalse); | 15 expect(e.expanded, isFalse); |
16 expect(e.disabled, isFalse); | 16 expect(e.disabled, isFalse); |
17 }); | 17 }); |
18 test('not expanded', () { | 18 test('not expanded', () { |
19 final CurlyBlockElement e = new CurlyBlockElement(expanded: false); | 19 final e = new CurlyBlockElement(expanded: false); |
20 expect(e, isNotNull, reason: 'element correctly created'); | 20 expect(e, isNotNull, reason: 'element correctly created'); |
21 expect(e.expanded, isFalse); | 21 expect(e.expanded, isFalse); |
22 expect(e.disabled, isFalse); | 22 expect(e.disabled, isFalse); |
23 }); | 23 }); |
24 test('not expanded / not disabled', () { | 24 test('not expanded / not disabled', () { |
25 final CurlyBlockElement e = new CurlyBlockElement(expanded: false, | 25 final e = new CurlyBlockElement(expanded: false, |
26 disabled: false); | 26 disabled: false); |
27 expect(e, isNotNull, reason: 'element correctly created'); | 27 expect(e, isNotNull, reason: 'element correctly created'); |
28 expect(e.expanded, isFalse); | 28 expect(e.expanded, isFalse); |
29 expect(e.disabled, isFalse); | 29 expect(e.disabled, isFalse); |
30 }); | 30 }); |
31 test('not expanded / disabled', () { | 31 test('not expanded / disabled', () { |
32 final CurlyBlockElement e = new CurlyBlockElement(expanded: false, | 32 final e = new CurlyBlockElement(expanded: false, |
33 disabled: true); | 33 disabled: true); |
34 expect(e, isNotNull, reason: 'element correctly created'); | 34 expect(e, isNotNull, reason: 'element correctly created'); |
35 expect(e.expanded, isFalse); | 35 expect(e.expanded, isFalse); |
36 expect(e.disabled, isTrue); | 36 expect(e.disabled, isTrue); |
37 }); | 37 }); |
38 test('expanded', () { | 38 test('expanded', () { |
39 final CurlyBlockElement e = new CurlyBlockElement(expanded: true); | 39 final e = new CurlyBlockElement(expanded: true); |
40 expect(e, isNotNull, reason: 'element correctly created'); | 40 expect(e, isNotNull, reason: 'element correctly created'); |
41 expect(e.expanded, isTrue); | 41 expect(e.expanded, isTrue); |
42 expect(e.disabled, isFalse); | 42 expect(e.disabled, isFalse); |
43 }); | 43 }); |
44 test('expanded / not disabled', () { | 44 test('expanded / not disabled', () { |
45 final CurlyBlockElement e = new CurlyBlockElement(expanded: true, | 45 final e = new CurlyBlockElement(expanded: true, disabled: false); |
46 disabled: false); | |
47 expect(e, isNotNull, reason: 'element correctly created'); | 46 expect(e, isNotNull, reason: 'element correctly created'); |
48 expect(e.expanded, isTrue); | 47 expect(e.expanded, isTrue); |
49 expect(e.disabled, isFalse); | 48 expect(e.disabled, isFalse); |
50 }); | 49 }); |
51 test('expanded / disabled', () { | 50 test('expanded / disabled', () { |
52 final CurlyBlockElement e = new CurlyBlockElement(expanded: true, | 51 final e = new CurlyBlockElement(expanded: true, disabled: true); |
53 disabled: true); | |
54 expect(e, isNotNull, reason: 'element correctly created'); | 52 expect(e, isNotNull, reason: 'element correctly created'); |
55 expect(e.expanded, isTrue); | 53 expect(e.expanded, isTrue); |
56 expect(e.disabled, isTrue); | 54 expect(e.disabled, isTrue); |
57 }); | 55 }); |
58 test('not disabled', () { | 56 test('not disabled', () { |
59 final CurlyBlockElement e = new CurlyBlockElement(disabled: false); | 57 final e = new CurlyBlockElement(disabled: false); |
60 expect(e, isNotNull, reason: 'element correctly created'); | 58 expect(e, isNotNull, reason: 'element correctly created'); |
61 expect(e.expanded, isFalse); | 59 expect(e.expanded, isFalse); |
62 expect(e.disabled, isFalse); | 60 expect(e.disabled, isFalse); |
63 }); | 61 }); |
64 test('disabled', () { | 62 test('disabled', () { |
65 final CurlyBlockElement e = new CurlyBlockElement(disabled: true); | 63 final e = new CurlyBlockElement(disabled: true); |
66 expect(e, isNotNull, reason: 'element correctly created'); | 64 expect(e, isNotNull, reason: 'element correctly created'); |
67 expect(e.expanded, isFalse); | 65 expect(e.expanded, isFalse); |
68 expect(e.disabled, isTrue); | 66 expect(e.disabled, isTrue); |
69 }); | 67 }); |
70 }); | 68 }); |
71 test('elements created', () async { | 69 test('elements created', () async { |
72 final CurlyBlockElement e = new CurlyBlockElement(); | 70 final e = new CurlyBlockElement(); |
73 expect(e.shadowRoot, isNotNull, reason: 'shadowRoot is created'); | 71 expect(e.shadowRoot, isNotNull, reason: 'shadowRoot is created'); |
74 document.body.append(e); | 72 document.body.append(e); |
75 await e.onRendered.first; | 73 await e.onRendered.first; |
76 expect(e.shadowRoot.children.length, isNonZero, | 74 expect(e.shadowRoot.children.length, isNonZero, |
77 reason: 'shadowRoot has elements'); | 75 reason: 'shadowRoot has elements'); |
78 e.remove(); | 76 e.remove(); |
79 await e.onRendered.first; | 77 await e.onRendered.first; |
80 expect(e.shadowRoot.children.length, isZero, reason: 'shadowRoot is empty'); | 78 expect(e.shadowRoot.children.length, isZero, reason: 'shadowRoot is empty'); |
81 }); | 79 }); |
82 group('content', () { | 80 group('content', () { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 e.expanded = !e.expanded; | 168 e.expanded = !e.expanded; |
171 await e.onRendered.first; | 169 await e.onRendered.first; |
172 }); | 170 }); |
173 test('does not fire if setting same expanded value', () async { | 171 test('does not fire if setting same expanded value', () async { |
174 e.onToggle.listen(expectAsync((_){}, count: 0)); | 172 e.onToggle.listen(expectAsync((_){}, count: 0)); |
175 e.expanded = e.expanded; | 173 e.expanded = e.expanded; |
176 await e.onRendered.first; | 174 await e.onRendered.first; |
177 }); | 175 }); |
178 }); | 176 }); |
179 } | 177 } |
OLD | NEW |