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/service/debugger_location_second_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 // VMOptions=--error_on_bad_type --error_on_bad_override 4 // VMOptions=--error_on_bad_type --error_on_bad_override
5 5
6 import 'package:observatory/service_io.dart'; 6 import 'package:observatory/service_io.dart';
7 import 'package:observatory/debugger.dart'; 7 import 'package:observatory/debugger.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 import 'service_test_common.dart'; 9 import 'service_test_common.dart';
10 import 'test_helper.dart'; 10 import 'test_helper.dart';
11 import 'dart:async'; 11 import 'dart:async';
12 import 'dart:developer'; 12 import 'dart:developer';
13 13
14 const int LINE_A = 22; 14 const int LINE_A = 22;
15 const int LINE_B = 110; 15 const int LINE_B = 110;
16 const int LINE_C = 12; 16 const int LINE_C = 12;
17 17
18 void testFunction() { 18 void testFunction() {
19 int i = 0; 19 int i = 0;
20 while (i == 0) { 20 while (i == 0) {
21 debugger(); 21 debugger();
22 print('loop'); // Line A. 22 print('loop'); // Line A.
23 print('loop'); 23 print('loop');
24 } 24 }
25 } 25 }
26 26
27 class TestDebugger extends Debugger { 27 class TestDebugger extends Debugger {
28 TestDebugger(this.isolate, this.stack); 28 TestDebugger(this.isolate, this.stack);
29 29
30 VM get vm => isolate.vm; 30 VM get vm => isolate.vm;
31 Isolate isolate; 31 Isolate isolate;
32 ServiceMap stack; 32 ServiceMap stack;
33 int currentFrame = 0; 33 int currentFrame = 0;
34 } 34 }
35 35
36 void debugger_location_dummy_function() {} 36 void debugger_location_dummy_function() {
37 }
37 38
38 class DebuggerLocationTestFoo { 39 class DebuggerLocationTestFoo {
39 DebuggerLocationTestFoo(this.field); 40 DebuggerLocationTestFoo(this.field);
40 DebuggerLocationTestFoo.named(); 41 DebuggerLocationTestFoo.named();
41 42
42 void method() {} 43 void method() {}
43 void madness() {} 44 void madness() {}
44 45
45 int field; 46 int field;
46 } 47 }
47 48
48 class DebuggerLocationTestBar {} 49 class DebuggerLocationTestBar {
50 }
49 51
50 Future<Debugger> initDebugger(Isolate isolate) { 52 Future<Debugger> initDebugger(Isolate isolate) {
51 return isolate.getStack().then((stack) { 53 return isolate.getStack().then((stack) {
52 return new TestDebugger(isolate, stack); 54 return new TestDebugger(isolate, stack);
53 }); 55 });
54 } 56 }
55 57
56 var tests = [ 58 var tests = [
57 hasStoppedAtBreakpoint, 59
60 hasStoppedAtBreakpoint,
58 61
59 // Load the isolate's libraries 62 // Load the isolate's libraries
60 (Isolate isolate) async { 63 (Isolate isolate) async {
61 for (var lib in isolate.libraries) { 64 for (var lib in isolate.libraries) {
62 await lib.load(); 65 await lib.load();
63 } 66 }
64 }, 67 },
65 68
66 // Parse method 69 // Parse method
67 (Isolate isolate) async { 70 (Isolate isolate) async {
68 var debugger = await initDebugger(isolate); 71 var debugger = await initDebugger(isolate);
69 var loc = await DebuggerLocation.parse( 72 var loc =
70 debugger, 'DebuggerLocationTestFoo.method'); 73 await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.method');
71 expect(loc.valid, isTrue); 74 expect(loc.valid, isTrue);
72 expect(loc.toString(), equals('DebuggerLocationTestFoo.method')); 75 expect(loc.toString(), equals('DebuggerLocationTestFoo.method'));
73 }, 76 },
74 77
75 // Parse method 78 // Parse method
76 (Isolate isolate) async { 79 (Isolate isolate) async {
77 var debugger = await initDebugger(isolate); 80 var debugger = await initDebugger(isolate);
78 var loc = await DebuggerLocation.parse( 81 var loc =
79 debugger, 'DebuggerLocationTestFoo.field='); 82 await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.field=');
80 expect(loc.valid, isTrue); 83 expect(loc.valid, isTrue);
81 expect(loc.toString(), equals('DebuggerLocationTestFoo.field=')); 84 expect(loc.toString(), equals('DebuggerLocationTestFoo.field='));
82 }, 85 },
83 86
84 // Parse bad method 87 // Parse bad method
85 (Isolate isolate) async { 88 (Isolate isolate) async {
86 var debugger = await initDebugger(isolate); 89 var debugger = await initDebugger(isolate);
87 var loc = await DebuggerLocation.parse( 90 var loc =
88 debugger, 'DebuggerLocationTestFoo.missing'); 91 await DebuggerLocation.parse(debugger, 'DebuggerLocationTestFoo.missing');
89 expect(loc.valid, isFalse); 92 expect(loc.valid, isFalse);
90 expect( 93 expect(loc.toString(), equals(
91 loc.toString(), 94 'invalid source location '
92 equals('invalid source location ' 95 '(Function \'DebuggerLocationTestFoo.missing\' not found)'));
93 '(Function \'DebuggerLocationTestFoo.missing\' not found)')); 96 },
94 },
95 97
96 // Complete function + script 98 // Complete function + script
97 (Isolate isolate) async { 99 (Isolate isolate) async {
98 var debugger = await initDebugger(isolate); 100 var debugger = await initDebugger(isolate);
99 var completions = await DebuggerLocation.complete(debugger, 'debugger_loc'); 101 var completions = await DebuggerLocation.complete(debugger, 'debugger_loc');
100 expect( 102 expect(completions.toString(), equals(
101 completions.toString(), 103 '[debugger_location_dummy_function,'
102 equals('[debugger_location_dummy_function,' 104 ' debugger_location.dart:,'
103 ' debugger_location.dart:,' 105 ' debugger_location_second_test.dart:]'));
104 ' debugger_location_second_test.dart:]')); 106 },
105 },
106 107
107 // Complete class 108 // Complete class
108 (Isolate isolate) async { 109 (Isolate isolate) async {
109 var debugger = await initDebugger(isolate); 110 var debugger = await initDebugger(isolate);
110 var completions = 111 var completions =
111 await DebuggerLocation.complete(debugger, 'DebuggerLocationTe'); 112 await DebuggerLocation.complete(debugger, 'DebuggerLocationTe');
112 expect( 113 expect(completions.toString(), equals(
113 completions.toString(), 114 '[DebuggerLocationTestBar,'
114 equals('[DebuggerLocationTestBar,' 115 ' DebuggerLocationTestFoo]'));
115 ' DebuggerLocationTestFoo]')); 116 },
116 },
117 117
118 // No completions: unqualified name 118 // No completions: unqualified name
119 (Isolate isolate) async { 119 (Isolate isolate) async {
120 var debugger = await initDebugger(isolate); 120 var debugger = await initDebugger(isolate);
121 var completions = 121 var completions =
122 await DebuggerLocation.complete(debugger, 'debugger_locXYZZY'); 122 await DebuggerLocation.complete(debugger, 'debugger_locXYZZY');
123 expect(completions.toString(), equals('[]')); 123 expect(completions.toString(), equals('[]'));
124 }, 124 },
125 125
126 // Complete method 126 // Complete method
127 (Isolate isolate) async { 127 (Isolate isolate) async {
128 var debugger = await initDebugger(isolate); 128 var debugger = await initDebugger(isolate);
129 var completions = 129 var completions =
130 await DebuggerLocation.complete(debugger, 'DebuggerLocationTestFoo.m'); 130 await DebuggerLocation.complete(debugger, 'DebuggerLocationTestFoo.m');
131 expect( 131 expect(completions.toString(), equals(
132 completions.toString(), 132 '[DebuggerLocationTestFoo.madness,'
133 equals('[DebuggerLocationTestFoo.madness,' 133 ' DebuggerLocationTestFoo.method]'));
134 ' DebuggerLocationTestFoo.method]')); 134 },
135 },
136 135
137 // No completions: qualified name 136 // No completions: qualified name
138 (Isolate isolate) async { 137 (Isolate isolate) async {
139 var debugger = await initDebugger(isolate); 138 var debugger = await initDebugger(isolate);
140 var completions = 139 var completions =
141 await DebuggerLocation.complete(debugger, 'DebuggerLocationTestFoo.q'); 140 await DebuggerLocation.complete(debugger, 'DebuggerLocationTestFoo.q');
142 expect(completions.toString(), equals('[]')); 141 expect(completions.toString(), equals('[]'));
143 }, 142 },
144 143
145 // Complete script 144 // Complete script
146 (Isolate isolate) async { 145 (Isolate isolate) async {
147 var debugger = await initDebugger(isolate); 146 var debugger = await initDebugger(isolate);
148 var completions = await DebuggerLocation.complete( 147 var completions =
149 debugger, 'debugger_location_second_te'); 148 await DebuggerLocation.complete(debugger, 'debugger_location_second_te');
150 expect(completions.toString(), 149 expect(completions.toString(), equals(
151 equals('[debugger_location_second_test.dart:]')); 150 '[debugger_location_second_test.dart:]'));
152 }, 151 },
153 152
154 // Complete script:line 153 // Complete script:line
155 (Isolate isolate) async { 154 (Isolate isolate) async {
156 var debugger = await initDebugger(isolate); 155 var debugger = await initDebugger(isolate);
157 var completions = await DebuggerLocation.complete( 156 var completions =
158 debugger, 'debugger_location_second_test.dart:11'); 157 await DebuggerLocation.complete(debugger,
159 expect( 158 'debugger_location_second_test.dart:11');
160 completions.toString(), 159 expect(completions.toString(), equals(
161 equals('[debugger_location_second_test.dart:${LINE_B + 0} ,' 160 '[debugger_location_second_test.dart:${LINE_B + 0} ,'
162 ' debugger_location_second_test.dart:${LINE_B + 0}:,' 161 ' debugger_location_second_test.dart:${LINE_B + 0}:,'
163 ' debugger_location_second_test.dart:${LINE_B + 1} ,' 162 ' debugger_location_second_test.dart:${LINE_B + 1} ,'
164 ' debugger_location_second_test.dart:${LINE_B + 1}:,' 163 ' debugger_location_second_test.dart:${LINE_B + 1}:,'
165 ' debugger_location_second_test.dart:${LINE_B + 2} ,' 164 ' debugger_location_second_test.dart:${LINE_B + 2} ,'
166 ' debugger_location_second_test.dart:${LINE_B + 2}:,' 165 ' debugger_location_second_test.dart:${LINE_B + 2}:,'
167 ' debugger_location_second_test.dart:${LINE_B + 3} ,' 166 ' debugger_location_second_test.dart:${LINE_B + 3} ,'
168 ' debugger_location_second_test.dart:${LINE_B + 3}:,' 167 ' debugger_location_second_test.dart:${LINE_B + 3}:,'
169 ' debugger_location_second_test.dart:${LINE_B + 4} ,' 168 ' debugger_location_second_test.dart:${LINE_B + 4} ,'
170 ' debugger_location_second_test.dart:${LINE_B + 4}:,' 169 ' debugger_location_second_test.dart:${LINE_B + 4}:,'
171 ' debugger_location_second_test.dart:${LINE_B + 5} ,' 170 ' debugger_location_second_test.dart:${LINE_B + 5} ,'
172 ' debugger_location_second_test.dart:${LINE_B + 5}:,' 171 ' debugger_location_second_test.dart:${LINE_B + 5}:,'
173 ' debugger_location_second_test.dart:${LINE_B + 6} ,' 172 ' debugger_location_second_test.dart:${LINE_B + 6} ,'
174 ' debugger_location_second_test.dart:${LINE_B + 6}:,' 173 ' debugger_location_second_test.dart:${LINE_B + 6}:,'
175 ' debugger_location_second_test.dart:${LINE_B + 9} ,' 174 ' debugger_location_second_test.dart:${LINE_B + 9} ,'
176 ' debugger_location_second_test.dart:${LINE_B + 9}:]')); 175 ' debugger_location_second_test.dart:${LINE_B + 9}:]'));
177 }, 176 },
178 177
179 // Complete script:line:col 178 // Complete script:line:col
180 (Isolate isolate) async { 179 (Isolate isolate) async {
181 var debugger = await initDebugger(isolate); 180 var debugger = await initDebugger(isolate);
182 var completions = await DebuggerLocation.complete( 181 var completions =
183 debugger, 'debugger_location_second_test.dart:$LINE_C:2'); 182 await DebuggerLocation.complete(
184 expect( 183 debugger,
185 completions.toString(), 184 'debugger_location_second_test.dart:$LINE_C:2');
186 equals('[debugger_location_second_test.dart:$LINE_C:2 ,' 185 expect(completions.toString(), equals(
187 ' debugger_location_second_test.dart:$LINE_C:20 ,' 186 '[debugger_location_second_test.dart:$LINE_C:2 ,'
188 ' debugger_location_second_test.dart:$LINE_C:21 ,' 187 ' debugger_location_second_test.dart:$LINE_C:20 ,'
189 ' debugger_location_second_test.dart:$LINE_C:22 ,' 188 ' debugger_location_second_test.dart:$LINE_C:21 ,'
190 ' debugger_location_second_test.dart:$LINE_C:23 ,' 189 ' debugger_location_second_test.dart:$LINE_C:22 ,'
191 ' debugger_location_second_test.dart:$LINE_C:24 ]')); 190 ' debugger_location_second_test.dart:$LINE_C:23 ,'
192 }, 191 ' debugger_location_second_test.dart:$LINE_C:24 ]'));
192 },
193 193
194 // Complete without the script name. 194 // Complete without the script name.
195 (Isolate isolate) async { 195 (Isolate isolate) async {
196 var debugger = await initDebugger(isolate); 196 var debugger = await initDebugger(isolate);
197 var completions = await DebuggerLocation.complete(debugger, '$LINE_C:2'); 197 var completions = await DebuggerLocation.complete(debugger, '$LINE_C:2');
198 expect( 198 expect(completions.toString(), equals(
199 completions.toString(), 199 '[debugger_location_second_test.dart:$LINE_C:2 ,'
200 equals('[debugger_location_second_test.dart:$LINE_C:2 ,' 200 ' debugger_location_second_test.dart:$LINE_C:20 ,'
201 ' debugger_location_second_test.dart:$LINE_C:20 ,' 201 ' debugger_location_second_test.dart:$LINE_C:21 ,'
202 ' debugger_location_second_test.dart:$LINE_C:21 ,' 202 ' debugger_location_second_test.dart:$LINE_C:22 ,'
203 ' debugger_location_second_test.dart:$LINE_C:22 ,' 203 ' debugger_location_second_test.dart:$LINE_C:23 ,'
204 ' debugger_location_second_test.dart:$LINE_C:23 ,' 204 ' debugger_location_second_test.dart:$LINE_C:24 ]'));
205 ' debugger_location_second_test.dart:$LINE_C:24 ]')); 205 },
206 }, 206
207 ]; 207 ];
208 208
209 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); 209 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698