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

Side by Side Diff: runtime/observatory/tests/observatory_ui/vm_connect/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 'package:unittest/unittest.dart'; 6 import 'package:unittest/unittest.dart';
7 import 'package:observatory/src/elements/nav/notify.dart'; 7 import 'package:observatory/src/elements/nav/notify.dart';
8 import 'package:observatory/src/elements/vm_connect_target.dart'; 8 import 'package:observatory/src/elements/vm_connect_target.dart';
9 import 'package:observatory/src/elements/vm_connect.dart'; 9 import 'package:observatory/src/elements/vm_connect.dart';
10 import '../mocks.dart'; 10 import '../mocks.dart';
11 11
12 void load(_) {} 12 void load(_) {}
13 13
14 main() { 14 main() {
15 VMConnectElement.tag.ensureRegistration(); 15 VMConnectElement.tag.ensureRegistration();
16 16
17 final nTag = NavNotifyElement.tag.name; 17 final nTag = NavNotifyElement.tag.name;
18 final tTag = VMConnectTargetElement.tag.name; 18 final tTag = VMConnectTargetElement.tag.name;
19 19
20 group('instantiation', () { 20 group('instantiation', () {
21 test('default', () { 21 test('default', () {
22 final e = new VMConnectElement( 22 final e = new VMConnectElement(new TargetRepositoryMock(),
23 new TargetRepositoryMock(), load, new NotificationRepositoryMock()); 23 load, new NotificationRepositoryMock());
24 expect(e, isNotNull, reason: 'element correctly created'); 24 expect(e, isNotNull, reason: 'element correctly created');
25 }); 25 });
26 }); 26 });
27 test('is correctly listening', () async { 27 test('is correctly listening', () async {
28 final targets = new TargetRepositoryMock(); 28 final targets = new TargetRepositoryMock();
29 final e = 29 final e = new VMConnectElement(targets, load,
30 new VMConnectElement(targets, load, new NotificationRepositoryMock()); 30 new NotificationRepositoryMock());
31 document.body.append(e); 31 document.body.append(e);
32 await e.onRendered.first; 32 await e.onRendered.first;
33 expect(targets.hasListeners, isTrue, reason: 'is listening'); 33 expect(targets.hasListeners, isTrue, reason: 'is listening');
34 e.remove(); 34 e.remove();
35 await e.onRendered.first; 35 await e.onRendered.first;
36 expect(targets.hasListeners, isFalse, reason: 'is no more listening'); 36 expect(targets.hasListeners, isFalse, reason: 'is no more listening');
37 }); 37 });
38 group('elements', () { 38 group('elements', () {
39 test('created after attachment', () async { 39 test('created after attachment', () async {
40 final targets = new TargetRepositoryMock(list: const [ 40 final targets = new TargetRepositoryMock(list: const [
41 const TargetMock(name: 't-1'), 41 const TargetMock(name: 't-1'), const TargetMock(name: 't-2'),
42 const TargetMock(name: 't-2'), 42 ]);
43 ]); 43 final e = new VMConnectElement(targets, load,
44 final e = 44 new NotificationRepositoryMock());
45 new VMConnectElement(targets, load, new NotificationRepositoryMock());
46 document.body.append(e); 45 document.body.append(e);
47 await e.onRendered.first; 46 await e.onRendered.first;
48 expect(targets.listInvoked, isTrue, reason: 'should invoke list()'); 47 expect(targets.listInvoked, isTrue, reason: 'should invoke list()');
49 expect(e.children.length, isNonZero, reason: 'has elements'); 48 expect(e.children.length, isNonZero, reason: 'has elements');
50 expect(e.querySelectorAll(nTag).length, equals(1)); 49 expect(e.querySelectorAll(nTag).length, equals(1));
51 expect(e.querySelectorAll(tTag).length, equals(2)); 50 expect(e.querySelectorAll(tTag).length, equals(2));
52 e.remove(); 51 e.remove();
53 await e.onRendered.first; 52 await e.onRendered.first;
54 expect(e.children.length, isZero, reason: 'is empty'); 53 expect(e.children.length, isZero, reason: 'is empty');
55 }); 54 });
56 test('react to update event', () async { 55 test('react to update event', () async {
57 final list = <TargetMock>[const TargetMock(name: 't-1')]; 56 final list = <TargetMock>[const TargetMock(name: 't-1')];
58 final targets = new TargetRepositoryMock(list: list); 57 final targets = new TargetRepositoryMock(list: list);
59 final e = 58 final e = new VMConnectElement(targets, load,
60 new VMConnectElement(targets, load, new NotificationRepositoryMock()); 59 new NotificationRepositoryMock());
61 document.body.append(e); 60 document.body.append(e);
62 await e.onRendered.first; 61 await e.onRendered.first;
63 expect(e.querySelectorAll(tTag).length, equals(1)); 62 expect(e.querySelectorAll(tTag).length, equals(1));
64 list.add(const TargetMock(name: 't-2')); 63 list.add(const TargetMock(name: 't-2'));
65 targets.triggerChangeEvent(); 64 targets.triggerChangeEvent();
66 await e.onRendered.first; 65 await e.onRendered.first;
67 expect(e.querySelectorAll(tTag).length, equals(2)); 66 expect(e.querySelectorAll(tTag).length, equals(2));
68 e.remove(); 67 e.remove();
69 await e.onRendered.first; 68 await e.onRendered.first;
70 expect(e.children.length, isZero, reason: 'is empty'); 69 expect(e.children.length, isZero, reason: 'is empty');
71 }); 70 });
72 }); 71 });
73 group('invokes', () { 72 group('invokes', () {
74 test('add on click', () async { 73 test('add on click', () async {
75 final address = 'ws://host:1234/ws'; 74 final address = 'ws://host:1234/ws';
76 final list = <TargetMock>[const TargetMock(name: 't-1')]; 75 final list = <TargetMock>[const TargetMock(name: 't-1')];
77 final targets = new TargetRepositoryMock( 76 final targets = new TargetRepositoryMock(list: list,
78 list: list,
79 add: expectAsync((String val) { 77 add: expectAsync((String val) {
80 expect(val, equals(address)); 78 expect(val, equals(address));
81 }, count: 1, reason: 'should be invoked')); 79 }, count: 1, reason: 'should be invoked'));
82 final e = new VMConnectElement( 80 final e = new VMConnectElement(targets, load,
83 targets, load, new NotificationRepositoryMock(), 81 new NotificationRepositoryMock(), address: address);
84 address: address);
85 document.body.append(e); 82 document.body.append(e);
86 await e.onRendered.first; 83 await e.onRendered.first;
87 (e.querySelector('button.vm_connect') as ButtonElement).click(); 84 (e.querySelector('button.vm_connect') as ButtonElement).click();
88 e.remove(); 85 e.remove();
89 await e.onRendered.first; 86 await e.onRendered.first;
90 }); 87 });
91 test('connect', () async { 88 test('connect', () async {
92 final list = <TargetMock>[const TargetMock(name: 't-1')]; 89 final list = <TargetMock>[const TargetMock(name: 't-1')];
93 final targets = new TargetRepositoryMock( 90 final targets = new TargetRepositoryMock(list: list,
94 list: list,
95 setCurrent: expectAsync((TargetMock t) { 91 setCurrent: expectAsync((TargetMock t) {
96 expect(t, equals(list[0])); 92 expect(t, equals(list[0]));
97 }, count: 1, reason: 'should be invoked')); 93 }, count: 1, reason: 'should be invoked'));
98 final e = 94 final e = new VMConnectElement(targets, load,
99 new VMConnectElement(targets, load, new NotificationRepositoryMock()); 95 new NotificationRepositoryMock());
100 document.body.append(e); 96 document.body.append(e);
101 await e.onRendered.first; 97 await e.onRendered.first;
102 (e.querySelector(tTag) as VMConnectTargetElement).connect(); 98 (e.querySelector(tTag) as VMConnectTargetElement).connect();
103 e.remove(); 99 e.remove();
104 await e.onRendered.first; 100 await e.onRendered.first;
105 }); 101 });
106 test('delete', () async { 102 test('delete', () async {
107 final list = <TargetMock>[const TargetMock(name: 't-1')]; 103 final list = <TargetMock>[const TargetMock(name: 't-1')];
108 final targets = new TargetRepositoryMock( 104 final targets = new TargetRepositoryMock(list: list,
109 list: list,
110 delete: expectAsync((TargetMock t) { 105 delete: expectAsync((TargetMock t) {
111 expect(t, equals(list[0])); 106 expect(t, equals(list[0]));
112 }, count: 1, reason: 'should be invoked')); 107 }, count: 1, reason: 'should be invoked'));
113 final e = 108 final e = new VMConnectElement(targets, load,
114 new VMConnectElement(targets, load, new NotificationRepositoryMock()); 109 new NotificationRepositoryMock());
115 document.body.append(e); 110 document.body.append(e);
116 await e.onRendered.first; 111 await e.onRendered.first;
117 (e.querySelector(tTag) as VMConnectTargetElement).delete(); 112 (e.querySelector(tTag) as VMConnectTargetElement).delete();
118 e.remove(); 113 e.remove();
119 await e.onRendered.first; 114 await e.onRendered.first;
120 }); 115 });
121 }); 116 });
122 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698