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

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

Issue 2767533002: Revert "Fix observatory tests broken by running dartfmt." (Closed)
Patch Set: Created 3 years, 9 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 4
5 import 'dart:html'; 5 import 'dart:html';
6 import 'dart:async'; 6 import 'dart:async';
7 import 'package:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'package:observatory/models.dart' as M; 8 import 'package:observatory/models.dart' as M;
9 import 'package:observatory/src/elements/allocation_profile.dart'; 9 import 'package:observatory/src/elements/allocation_profile.dart';
10 import 'package:observatory/src/elements/class_ref.dart'; 10 import 'package:observatory/src/elements/class_ref.dart';
(...skipping 13 matching lines...) Expand all
24 final events = new EventRepositoryMock(); 24 final events = new EventRepositoryMock();
25 final notif = new NotificationRepositoryMock(); 25 final notif = new NotificationRepositoryMock();
26 test('instantiation', () { 26 test('instantiation', () {
27 final repo = new AllocationProfileRepositoryMock(); 27 final repo = new AllocationProfileRepositoryMock();
28 final e = new AllocationProfileElement(vm, isolate, events, notif, repo); 28 final e = new AllocationProfileElement(vm, isolate, events, notif, repo);
29 expect(e, isNotNull, reason: 'element correctly created'); 29 expect(e, isNotNull, reason: 'element correctly created');
30 }); 30 });
31 test('elements created', () async { 31 test('elements created', () async {
32 final completer = new Completer<AllocationProfileMock>(); 32 final completer = new Completer<AllocationProfileMock>();
33 final repo = new AllocationProfileRepositoryMock( 33 final repo = new AllocationProfileRepositoryMock(
34 getter: expectAsync((M.IsolateRef i, bool gc, bool reset) { 34 getter: expectAsync((M.IsolateRef i, bool gc, bool reset) {
35 expect(i, equals(isolate)); 35 expect(i, equals(isolate));
36 expect(gc, isFalse); 36 expect(gc, isFalse);
37 expect(reset, isFalse); 37 expect(reset, isFalse);
38 return completer.future; 38 return completer.future;
39 }, count: 1)); 39 }, count: 1));
40 final e = new AllocationProfileElement(vm, isolate, events, notif, repo); 40 final e = new AllocationProfileElement(vm, isolate, events, notif, repo);
41 document.body.append(e); 41 document.body.append(e);
42 await e.onRendered.first; 42 await e.onRendered.first;
43 expect(e.children.length, isNonZero, reason: 'has elements'); 43 expect(e.children.length, isNonZero, reason: 'has elements');
44 expect(e.querySelectorAll(vTag).length, isZero); 44 expect(e.querySelectorAll(vTag).length, isZero);
45 completer.complete(const AllocationProfileMock()); 45 completer.complete(const AllocationProfileMock());
46 await e.onRendered.first; 46 await e.onRendered.first;
47 expect(e.querySelectorAll(vTag).length, equals(1)); 47 expect(e.querySelectorAll(vTag).length, equals(1));
48 e.remove(); 48 e.remove();
49 await e.onRendered.first; 49 await e.onRendered.first;
50 expect(e.children.length, isZero, reason: 'is empty'); 50 expect(e.children.length, isZero, reason: 'is empty');
51 }); 51 });
52 group('reacts', () { 52 group('reacts', () {
53 test('to refresh', () async { 53 test('to refresh', () async {
54 final completer = new Completer<AllocationProfileMock>(); 54 final completer = new Completer<AllocationProfileMock>();
55 int step = 0; 55 int step = 0;
56 final repo = new AllocationProfileRepositoryMock( 56 final repo = new AllocationProfileRepositoryMock(
57 getter: expectAsync((M.IsolateRef i, bool gc, bool reset) { 57 getter: expectAsync((M.IsolateRef i, bool gc, bool reset) {
58 expect(i, equals(isolate)); 58 expect(i, equals(isolate));
59 switch (step) { 59 switch (step) {
60 case 0: 60 case 0:
61 expect(gc, isFalse); 61 expect(gc, isFalse);
62 expect(reset, isFalse); 62 expect(reset, isFalse);
63 break; 63 break;
64 case 1: 64 case 1:
65 expect(gc, isFalse); 65 expect(gc, isFalse);
66 expect(reset, isTrue); 66 expect(reset, isTrue);
67 break; 67 break;
68 case 2: 68 case 2:
69 expect(gc, isTrue); 69 expect(gc, isTrue);
70 expect(reset, isFalse); 70 expect(reset, isFalse);
71 break; 71 break;
72 case 3: 72 case 3:
73 expect(gc, isFalse); 73 expect(gc, isFalse);
74 expect(reset, isFalse); 74 expect(reset, isFalse);
75 break; 75 break;
76 } 76 }
77 step++; 77 step++;
78 return completer.future; 78 return completer.future;
79 }, count: 4)); 79 }, count: 4));
80 final e = new AllocationProfileElement(vm, isolate, events, notif, repo); 80 final e = new AllocationProfileElement(vm, isolate, events, notif, repo);
81 document.body.append(e); 81 document.body.append(e);
82 await e.onRendered.first; 82 await e.onRendered.first;
83 completer.complete(const AllocationProfileMock()); 83 completer.complete(const AllocationProfileMock());
84 await e.onRendered.first; 84 await e.onRendered.first;
85 e 85 e.querySelectorAll(rTag).sublist(1, 4)
86 .querySelectorAll(rTag)
87 .sublist(1, 4)
88 .forEach((NavRefreshElement e) => e.refresh()); 86 .forEach((NavRefreshElement e) => e.refresh());
89 e.remove(); 87 e.remove();
90 await e.onRendered.first; 88 await e.onRendered.first;
91 expect(e.children.length, isZero, reason: 'is empty'); 89 expect(e.children.length, isZero, reason: 'is empty');
92 }); 90 });
93 test('to gc', () async { 91 test('to gc', () async {
94 final events = new EventRepositoryMock(); 92 final events = new EventRepositoryMock();
95 final completer = new Completer<AllocationProfileMock>(); 93 final completer = new Completer<AllocationProfileMock>();
96 int count = 0; 94 int count = 0;
97 final repo = new AllocationProfileRepositoryMock( 95 final repo = new AllocationProfileRepositoryMock(
98 getter: expectAsync((M.IsolateRef i, bool gc, bool reset) { 96 getter: expectAsync((M.IsolateRef i, bool gc, bool reset) {
99 expect(i, equals(isolate)); 97 expect(i, equals(isolate));
100 expect(gc, isFalse); 98 expect(gc, isFalse);
101 expect(reset, isFalse); 99 expect(reset, isFalse);
102 count++; 100 count++;
103 return completer.future; 101 return completer.future;
104 }, count: 2)); 102 }, count: 2));
105 final e = new AllocationProfileElement(vm, isolate, events, notif, repo); 103 final e = new AllocationProfileElement(vm, isolate, events, notif, repo);
106 document.body.append(e); 104 document.body.append(e);
107 await e.onRendered.first; 105 await e.onRendered.first;
108 completer.complete(const AllocationProfileMock()); 106 completer.complete(const AllocationProfileMock());
109 await e.onRendered.first; 107 await e.onRendered.first;
110 e.querySelector('input[type=\'checkbox\']').click(); 108 e.querySelector('input[type=\'checkbox\']').click();
111 expect(events.onGCEventHasListener, isTrue); 109 expect(events.onGCEventHasListener, isTrue);
112 events.add(new GCEventMock(isolate: isolate)); 110 events.add(new GCEventMock(isolate: isolate));
113 await e.onRendered.first; 111 await e.onRendered.first;
114 expect(count, equals(2)); 112 expect(count, equals(2));
115 // shouldn't trigger 113 // shouldn't trigger
116 events.add(new GCEventMock(isolate: new IsolateRefMock(id: 'another'))); 114 events.add(new GCEventMock(isolate: new IsolateRefMock(id: 'another')));
117 await (() async {}()); 115 await (() async {} ());
118 e.querySelector('input[type=\'checkbox\']').click(); 116 e.querySelector('input[type=\'checkbox\']').click();
119 // shouldn't trigger 117 // shouldn't trigger
120 events.add(new GCEventMock(isolate: isolate)); 118 events.add(new GCEventMock(isolate: isolate));
121 await (() async {}()); 119 await (() async {} ());
122 e.remove(); 120 e.remove();
123 await e.onRendered.first; 121 await e.onRendered.first;
124 expect(e.children.length, isZero, reason: 'is empty'); 122 expect(e.children.length, isZero, reason: 'is empty');
125 }); 123 });
126 test('to sort change', () async { 124 test('to sort change', () async {
127 const clazz1 = const ClassRefMock(name: 'class1'); 125 const clazz1 = const ClassRefMock(name: 'class1');
128 const clazz2 = const ClassRefMock(name: 'class2'); 126 const clazz2 = const ClassRefMock(name: 'class2');
129 const clazz3 = const ClassRefMock(name: 'class3'); 127 const clazz3 = const ClassRefMock(name: 'class3');
130 const profile = const AllocationProfileMock(members: const [ 128 const profile = const AllocationProfileMock(members: const [
131 const ClassHeapStatsMock( 129 const ClassHeapStatsMock(clazz: clazz2, newSpace: const AllocationsMock(
132 clazz: clazz2, 130 accumulated: const AllocationCountMock(bytes: 10)
133 newSpace: const AllocationsMock( 131 )),
134 accumulated: const AllocationCountMock(bytes: 10))),
135 const ClassHeapStatsMock(clazz: clazz3), 132 const ClassHeapStatsMock(clazz: clazz3),
136 const ClassHeapStatsMock( 133 const ClassHeapStatsMock(clazz: clazz1, newSpace: const AllocationsMock(
137 clazz: clazz1, 134 accumulated: const AllocationCountMock(bytes: 5)
138 newSpace: const AllocationsMock( 135 ))
139 accumulated: const AllocationCountMock(bytes: 5)))
140 ]); 136 ]);
141 final completer = new Completer<AllocationProfileMock>(); 137 final completer = new Completer<AllocationProfileMock>();
142 final repo = new AllocationProfileRepositoryMock( 138 final repo = new AllocationProfileRepositoryMock(
143 getter: expectAsync((M.IsolateRef i, bool gc, bool reset) { 139 getter: expectAsync((M.IsolateRef i, bool gc, bool reset) {
144 expect(i, equals(isolate)); 140 expect(i, equals(isolate));
145 expect(gc, isFalse); 141 expect(gc, isFalse);
146 expect(reset, isFalse); 142 expect(reset, isFalse);
147 return completer.future; 143 return completer.future;
148 }, count: 1)); 144 }, count: 1));
149 final e = new AllocationProfileElement(vm, isolate, events, notif, repo); 145 final e = new AllocationProfileElement(vm, isolate, events, notif, repo);
150 document.body.append(e); 146 document.body.append(e);
151 await e.onRendered.first; 147 await e.onRendered.first;
152 completer.complete(profile); 148 completer.complete(profile);
153 await e.onRendered.first; 149 await e.onRendered.first;
154 expect((e.querySelector(cTag) as ClassRefElement).cls, equals(clazz1)); 150 expect((e.querySelector(cTag) as ClassRefElement).cls, equals(clazz1));
155 e.querySelector('button.bytes').click(); 151 e.querySelector('button.bytes').click();
156 await e.onRendered.first; 152 await e.onRendered.first;
157 expect((e.querySelector(cTag) as ClassRefElement).cls, equals(clazz2)); 153 expect((e.querySelector(cTag) as ClassRefElement).cls, equals(clazz2));
158 e.querySelector('button.bytes').click(); 154 e.querySelector('button.bytes').click();
159 await e.onRendered.first; 155 await e.onRendered.first;
160 expect((e.querySelector(cTag) as ClassRefElement).cls, equals(clazz3)); 156 expect((e.querySelector(cTag) as ClassRefElement).cls, equals(clazz3));
161 e.remove(); 157 e.remove();
162 await e.onRendered.first; 158 await e.onRendered.first;
163 expect(e.children.length, isZero, reason: 'is empty'); 159 expect(e.children.length, isZero, reason: 'is empty');
164 }); 160 });
165 }); 161 });
166 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698