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

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

Issue 2173373002: Revert "Use Timer and not AnimationFrame during Observatory UI tests" (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Revert "Use Timer and not AnimationFrame during Observatory UI tests" 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/helpers/rendering_queue.dart';
8 import 'package:observatory/src/elements/nav/refresh.dart'; 7 import 'package:observatory/src/elements/nav/refresh.dart';
9 8
10 main() { 9 main() {
11 NavRefreshElement.tag.ensureRegistration(); 10 NavRefreshElement.tag.ensureRegistration();
12
13 final TimedRenderingBarrier barrier = new TimedRenderingBarrier();
14 final RenderingQueue queue = new RenderingQueue.fromBarrier(barrier);
15 group('instantiation', () { 11 group('instantiation', () {
16 test('no parameters', () { 12 test('no parameters', () {
17 final NavRefreshElement e = new NavRefreshElement(); 13 final NavRefreshElement e = new NavRefreshElement();
18 expect(e, isNotNull, reason: 'element correctly created'); 14 expect(e, isNotNull, reason: 'element correctly created');
19 expect(e.label, isNotNull, reason: 'label is set to default'); 15 expect(e.label, isNotNull, reason: 'label is set to default');
20 expect(e.disabled, isFalse, reason: 'element correctly created'); 16 expect(e.disabled, isFalse, reason: 'element correctly created');
21 }); 17 });
22 test('label', () { 18 test('label', () {
23 final label = 'custom-label'; 19 final label = 'custom-label';
24 final NavRefreshElement e = new NavRefreshElement(label: label); 20 final NavRefreshElement e = new NavRefreshElement(label: label);
25 expect(e, isNotNull, reason: 'element correctly created'); 21 expect(e, isNotNull, reason: 'element correctly created');
26 expect(e.label, isNotNull, reason: 'label is set'); 22 expect(e.label, isNotNull, reason: 'label is set');
27 expect(e.label, equals(label), reason: 'label is set to value'); 23 expect(e.label, equals(label), reason: 'label is set to value');
28 }); 24 });
29 test('not disabled', () { 25 test('not disabled', () {
30 final NavRefreshElement e = new NavRefreshElement(disabled: false); 26 final NavRefreshElement e = new NavRefreshElement(disabled: false);
31 expect(e, isNotNull, reason: 'element correctly created'); 27 expect(e, isNotNull, reason: 'element correctly created');
32 expect(e.disabled, isFalse, reason: 'element correctly created'); 28 expect(e.disabled, isFalse, reason: 'element correctly created');
33 }); 29 });
34 test('disabled', () { 30 test('disabled', () {
35 final NavRefreshElement e = new NavRefreshElement(disabled: true); 31 final NavRefreshElement e = new NavRefreshElement(disabled: true);
36 expect(e, isNotNull, reason: 'element correctly created'); 32 expect(e, isNotNull, reason: 'element correctly created');
37 expect(e.disabled, isTrue, reason: 'element correctly created'); 33 expect(e.disabled, isTrue, reason: 'element correctly created');
38 }); 34 });
39 }); 35 });
40 group('elements', () { 36 group('elements', () {
41 test('created after attachment', () async { 37 test('created after attachment', () async {
42 final NavRefreshElement e = new NavRefreshElement(queue: queue); 38 final NavRefreshElement e = new NavRefreshElement();
43 document.body.append(e); 39 document.body.append(e);
44 await e.onRendered.first; 40 await e.onRendered.first;
45 expect(e.children.length, isNonZero, reason: 'has elements'); 41 expect(e.children.length, isNonZero, reason: 'has elements');
46 e.remove(); 42 e.remove();
47 await e.onRendered.first; 43 await e.onRendered.first;
48 expect(e.children.length, isZero, reason: 'is empty'); 44 expect(e.children.length, isZero, reason: 'is empty');
49 }); 45 });
50 test('contain custom label', () async { 46 test('contain custom label', () async {
51 final label = 'custom-label'; 47 final label = 'custom-label';
52 final NavRefreshElement e = new NavRefreshElement(label: label, 48 final NavRefreshElement e = new NavRefreshElement(label: label);
53 queue: queue);
54 document.body.append(e); 49 document.body.append(e);
55 await e.onRendered.first; 50 await e.onRendered.first;
56 expect(e.innerHtml.contains(label), isTrue); 51 expect(e.innerHtml.contains(label), isTrue);
57 e.remove(); 52 e.remove();
58 await e.onRendered.first; 53 await e.onRendered.first;
59 }); 54 });
60 test('react to label change', () async { 55 test('react to label change', () async {
61 final label1 = 'custom-label-1'; 56 final label1 = 'custom-label-1';
62 final label2 = 'custom-label-2'; 57 final label2 = 'custom-label-2';
63 final NavRefreshElement e = new NavRefreshElement(label: label1, 58 final NavRefreshElement e = new NavRefreshElement(label: label1);
64 queue: queue);
65 document.body.append(e); 59 document.body.append(e);
66 await e.onRendered.first; 60 await e.onRendered.first;
67 expect(e.innerHtml.contains(label1), isTrue); 61 expect(e.innerHtml.contains(label1), isTrue);
68 expect(e.innerHtml.contains(label2), isFalse); 62 expect(e.innerHtml.contains(label2), isFalse);
69 e.label = label2; 63 e.label = label2;
70 await e.onRendered.first; 64 await e.onRendered.first;
71 expect(e.innerHtml.contains(label2), isTrue); 65 expect(e.innerHtml.contains(label2), isTrue);
72 expect(e.innerHtml.contains(label1), isFalse); 66 expect(e.innerHtml.contains(label1), isFalse);
73 e.remove(); 67 e.remove();
74 await e.onRendered.first; 68 await e.onRendered.first;
75 }); 69 });
76 test('react to disabled change', () async { 70 test('react to disabled change', () async {
77 final NavRefreshElement e = new NavRefreshElement(disabled: false, 71 final NavRefreshElement e = new NavRefreshElement(disabled: false);
78 queue: queue);
79 document.body.append(e); 72 document.body.append(e);
80 await e.onRendered.first; 73 await e.onRendered.first;
81 expect(e.disabled, isFalse); 74 expect(e.disabled, isFalse);
82 e.disabled = true; 75 e.disabled = true;
83 await e.onRendered.first; 76 await e.onRendered.first;
84 expect(e.disabled, isTrue); 77 expect(e.disabled, isTrue);
85 e.remove(); 78 e.remove();
86 await e.onRendered.first; 79 await e.onRendered.first;
87 }); 80 });
88 }); 81 });
89 group('event', () { 82 group('event', () {
90 NavRefreshElement e; 83 NavRefreshElement e;
91 StreamSubscription sub; 84 StreamSubscription sub;
92 setUp(() async { 85 setUp(() async {
93 e = new NavRefreshElement(queue: queue); 86 e = new NavRefreshElement();
94 document.body.append(e); 87 document.body.append(e);
95 await e.onRendered.first; 88 await e.onRendered.first;
96 }); 89 });
97 tearDown(() async { 90 tearDown(() async {
98 sub.cancel(); 91 sub.cancel();
99 e.remove(); 92 e.remove();
100 await e.onRendered.first; 93 await e.onRendered.first;
101 }); 94 });
102 test('fires', () async { 95 test('fires', () async {
103 sub = e.onRefresh.listen(expectAsync((event) { 96 sub = e.onRefresh.listen(expectAsync((event) {
(...skipping 16 matching lines...) Expand all
120 sub = e.onRefresh.listen(expectAsync((_) {}, count: 0)); 113 sub = e.onRefresh.listen(expectAsync((_) {}, count: 0));
121 e.refresh(); 114 e.refresh();
122 }); 115 });
123 test('does not fires on click if disabled', () async { 116 test('does not fires on click if disabled', () async {
124 e.disabled = true; 117 e.disabled = true;
125 sub = e.onRefresh.listen(expectAsync((_) {}, count: 0)); 118 sub = e.onRefresh.listen(expectAsync((_) {}, count: 0));
126 e.querySelector('button').click(); 119 e.querySelector('button').click();
127 }); 120 });
128 }); 121 });
129 } 122 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698