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

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

Issue 2751423005: Run dartfmt on all files under runtime. (Closed)
Patch Set: Run dartfmt on all files under runtime. 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 'package:unittest/unittest.dart'; 6 import 'package:unittest/unittest.dart';
7 import 'package:observatory/src/elements/class_tree.dart'; 7 import 'package:observatory/src/elements/class_tree.dart';
8 import 'package:observatory/src/elements/nav/notify.dart'; 8 import 'package:observatory/src/elements/nav/notify.dart';
9 import '../mocks.dart'; 9 import '../mocks.dart';
10 10
11 main() { 11 main() {
12 ClassTreeElement.tag.ensureRegistration(); 12 ClassTreeElement.tag.ensureRegistration();
13 13
14 final nTag = NavNotifyElement.tag.name; 14 final nTag = NavNotifyElement.tag.name;
15 const vm = const VMMock(); 15 const vm = const VMMock();
16 const isolate = const IsolateRefMock(); 16 const isolate = const IsolateRefMock();
17 final events = new EventRepositoryMock(); 17 final events = new EventRepositoryMock();
18 final notifications = new NotificationRepositoryMock(); 18 final notifications = new NotificationRepositoryMock();
19 19
20 group('instantiation', () { 20 group('instantiation', () {
21 test('default', () { 21 test('default', () {
22 final e = new ClassTreeElement(vm, isolate, events, notifications, 22 final e = new ClassTreeElement(
23 new ClassRepositoryMock()); 23 vm, isolate, events, notifications, new ClassRepositoryMock());
24 expect(e, isNotNull, reason: 'element correctly created'); 24 expect(e, isNotNull, reason: 'element correctly created');
25 }); 25 });
26 }); 26 });
27 group('elements', () { 27 group('elements', () {
28 test('created after attachment', () async { 28 test('created after attachment', () async {
29 const child2_id = 'c2-id'; 29 const child2_id = 'c2-id';
30 const child1_1_id = 'c1_1-id'; 30 const child1_1_id = 'c1_1-id';
31 const child1_id = 'c1-id'; 31 const child1_id = 'c1-id';
32 const child2 = const ClassMock(id: child2_id); 32 const child2 = const ClassMock(id: child2_id);
33 const child1_1 = const ClassMock(id: child1_1_id); 33 const child1_1 = const ClassMock(id: child1_1_id);
34 const child1 = const ClassMock(id: child1_id, 34 const child1 =
35 subclasses: const [child1_1]); 35 const ClassMock(id: child1_id, subclasses: const [child1_1]);
36 const object = const ClassMock(id: 'o-id', 36 const object =
37 subclasses: const [child1, child2]); 37 const ClassMock(id: 'o-id', subclasses: const [child1, child2]);
38 const ids = const [child1_id, child1_1_id, child2_id]; 38 const ids = const [child1_id, child1_1_id, child2_id];
39 bool rendered = false; 39 bool rendered = false;
40 final e = new ClassTreeElement(vm, isolate, events, notifications, 40 final e = new ClassTreeElement(
41 vm,
42 isolate,
43 events,
44 notifications,
41 new ClassRepositoryMock( 45 new ClassRepositoryMock(
42 object: expectAsync((i) async { 46 object: expectAsync((i) async {
43 expect(i, equals(isolate)); 47 expect(i, equals(isolate));
44 expect(rendered, isFalse); 48 expect(rendered, isFalse);
45 return object; 49 return object;
46 }, count: 1), 50 }, count: 1),
47 getter: expectAsync((i, id) async { 51 getter: expectAsync((i, id) async {
48 expect(i, equals(isolate)); 52 expect(i, equals(isolate));
49 expect(ids.contains(id), isTrue); 53 expect(ids.contains(id), isTrue);
50 switch (id) { 54 switch (id) {
51 case child1_id: return child1; 55 case child1_id:
52 case child1_1_id: return child1_1; 56 return child1;
53 case child2_id: return child2; 57 case child1_1_id:
54 default: return null; 58 return child1_1;
59 case child2_id:
60 return child2;
61 default:
62 return null;
55 } 63 }
56 }, count: 3))); 64 }, count: 3)));
57 document.body.append(e); 65 document.body.append(e);
58 await e.onRendered.first; 66 await e.onRendered.first;
59 rendered = true; 67 rendered = true;
60 expect(e.children.length, isNonZero, reason: 'has elements'); 68 expect(e.children.length, isNonZero, reason: 'has elements');
61 expect(e.querySelectorAll(nTag).length, equals(1)); 69 expect(e.querySelectorAll(nTag).length, equals(1));
62 e.remove(); 70 e.remove();
63 await e.onRendered.first; 71 await e.onRendered.first;
64 expect(e.children.length, isZero, reason: 'is empty'); 72 expect(e.children.length, isZero, reason: 'is empty');
65 }); 73 });
66 }); 74 });
67 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698