Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(710)

Side by Side Diff: runtime/observatory/tests/observatory_ui/nav/refresh/element_test.dart

Issue 2211603002: Centralized event streams (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merged with master Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 'dart:async'; 5 import 'dart:async';
6 import 'package:unittest/unittest.dart'; 6 import 'package:unittest/unittest.dart';
7 import 'package:observatory/src/elements/nav/refresh.dart'; 7 import 'package:observatory/src/elements/nav/refresh.dart';
8 8
9 main() { 9 main() {
10 NavRefreshElement.tag.ensureRegistration(); 10 NavRefreshElement.tag.ensureRegistration();
11
11 group('instantiation', () { 12 group('instantiation', () {
12 test('no parameters', () { 13 test('no parameters', () {
13 final NavRefreshElement e = new NavRefreshElement(); 14 final e = new NavRefreshElement();
14 expect(e, isNotNull, reason: 'element correctly created'); 15 expect(e, isNotNull, reason: 'element correctly created');
15 expect(e.label, isNotNull, reason: 'label is set to default'); 16 expect(e.label, isNotNull, reason: 'label is set to default');
16 expect(e.disabled, isFalse, reason: 'element correctly created'); 17 expect(e.disabled, isFalse, reason: 'element correctly created');
17 }); 18 });
18 test('label', () { 19 test('label', () {
19 final label = 'custom-label'; 20 final label = 'custom-label';
20 final NavRefreshElement e = new NavRefreshElement(label: label); 21 final e = new NavRefreshElement(label: label);
21 expect(e, isNotNull, reason: 'element correctly created'); 22 expect(e, isNotNull, reason: 'element correctly created');
22 expect(e.label, isNotNull, reason: 'label is set'); 23 expect(e.label, isNotNull, reason: 'label is set');
23 expect(e.label, equals(label), reason: 'label is set to value'); 24 expect(e.label, equals(label), reason: 'label is set to value');
24 }); 25 });
25 test('not disabled', () { 26 test('not disabled', () {
26 final NavRefreshElement e = new NavRefreshElement(disabled: false); 27 final e = new NavRefreshElement(disabled: false);
27 expect(e, isNotNull, reason: 'element correctly created'); 28 expect(e, isNotNull, reason: 'element correctly created');
28 expect(e.disabled, isFalse, reason: 'element correctly created'); 29 expect(e.disabled, isFalse, reason: 'element correctly created');
29 }); 30 });
30 test('disabled', () { 31 test('disabled', () {
31 final NavRefreshElement e = new NavRefreshElement(disabled: true); 32 final e = new NavRefreshElement(disabled: true);
32 expect(e, isNotNull, reason: 'element correctly created'); 33 expect(e, isNotNull, reason: 'element correctly created');
33 expect(e.disabled, isTrue, reason: 'element correctly created'); 34 expect(e.disabled, isTrue, reason: 'element correctly created');
34 }); 35 });
35 }); 36 });
36 group('elements', () { 37 group('elements', () {
37 test('created after attachment', () async { 38 test('created after attachment', () async {
38 final NavRefreshElement e = new NavRefreshElement(); 39 final e = new NavRefreshElement();
39 document.body.append(e); 40 document.body.append(e);
40 await e.onRendered.first; 41 await e.onRendered.first;
41 expect(e.children.length, isNonZero, reason: 'has elements'); 42 expect(e.children.length, isNonZero, reason: 'has elements');
42 e.remove(); 43 e.remove();
43 await e.onRendered.first; 44 await e.onRendered.first;
44 expect(e.children.length, isZero, reason: 'is empty'); 45 expect(e.children.length, isZero, reason: 'is empty');
45 }); 46 });
46 test('contain custom label', () async { 47 test('contain custom label', () async {
47 final label = 'custom-label'; 48 final label = 'custom-label';
48 final NavRefreshElement e = new NavRefreshElement(label: label); 49 final e = new NavRefreshElement(label: label);
49 document.body.append(e); 50 document.body.append(e);
50 await e.onRendered.first; 51 await e.onRendered.first;
51 expect(e.innerHtml.contains(label), isTrue); 52 expect(e.innerHtml.contains(label), isTrue);
52 e.remove(); 53 e.remove();
53 await e.onRendered.first; 54 await e.onRendered.first;
54 }); 55 });
55 test('react to label change', () async { 56 test('react to label change', () async {
56 final label1 = 'custom-label-1'; 57 final label1 = 'custom-label-1';
57 final label2 = 'custom-label-2'; 58 final label2 = 'custom-label-2';
58 final NavRefreshElement e = new NavRefreshElement(label: label1); 59 final e = new NavRefreshElement(label: label1);
59 document.body.append(e); 60 document.body.append(e);
60 await e.onRendered.first; 61 await e.onRendered.first;
61 expect(e.innerHtml.contains(label1), isTrue); 62 expect(e.innerHtml.contains(label1), isTrue);
62 expect(e.innerHtml.contains(label2), isFalse); 63 expect(e.innerHtml.contains(label2), isFalse);
63 e.label = label2; 64 e.label = label2;
64 await e.onRendered.first; 65 await e.onRendered.first;
65 expect(e.innerHtml.contains(label2), isTrue); 66 expect(e.innerHtml.contains(label2), isTrue);
66 expect(e.innerHtml.contains(label1), isFalse); 67 expect(e.innerHtml.contains(label1), isFalse);
67 e.remove(); 68 e.remove();
68 await e.onRendered.first; 69 await e.onRendered.first;
69 }); 70 });
70 test('react to disabled change', () async { 71 test('react to disabled change', () async {
71 final NavRefreshElement e = new NavRefreshElement(disabled: false); 72 final e = new NavRefreshElement(disabled: false);
72 document.body.append(e); 73 document.body.append(e);
73 await e.onRendered.first; 74 await e.onRendered.first;
74 expect(e.disabled, isFalse); 75 expect(e.disabled, isFalse);
75 e.disabled = true; 76 e.disabled = true;
76 await e.onRendered.first; 77 await e.onRendered.first;
77 expect(e.disabled, isTrue); 78 expect(e.disabled, isTrue);
78 e.remove(); 79 e.remove();
79 await e.onRendered.first; 80 await e.onRendered.first;
80 }); 81 });
81 }); 82 });
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 sub = e.onRefresh.listen(expectAsync((_) {}, count: 0)); 114 sub = e.onRefresh.listen(expectAsync((_) {}, count: 0));
114 e.refresh(); 115 e.refresh();
115 }); 116 });
116 test('does not fires on click if disabled', () async { 117 test('does not fires on click if disabled', () async {
117 e.disabled = true; 118 e.disabled = true;
118 sub = e.onRefresh.listen(expectAsync((_) {}, count: 0)); 119 sub = e.onRefresh.listen(expectAsync((_) {}, count: 0));
119 e.querySelector('button').click(); 120 e.querySelector('button').click();
120 }); 121 });
121 }); 122 });
122 } 123 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698