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

Side by Side Diff: runtime/observatory/tests/service/add_breakpoint_rpc_test.dart

Issue 2759973004: Fix observatory tests broken by running dartfmt. Temporarily reverted formatting for evaluate_activ… (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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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:unittest/unittest.dart'; 7 import 'package:unittest/unittest.dart';
8 import 'service_test_common.dart'; 8 import 'service_test_common.dart';
9 import 'test_helper.dart'; 9 import 'test_helper.dart';
10 import 'deferred_library.dart' deferred as deferredLib; 10 import 'deferred_library.dart' deferred as deferredLib;
11 import 'dart:async'; 11 import 'dart:async';
12 12
13 const int LINE_A = 24; 13 const int LINE_A = 24;
14 const int LINE_B = 26; 14 const int LINE_B = 26;
15 15
16 int value = 0; 16 int value = 0;
17 17
18 int incValue(int amount) { 18 int incValue(int amount) {
19 value += amount; 19 value += amount;
20 return amount; 20 return amount;
21 } 21 }
22 22
23 Future testMain() async { 23 Future testMain() async {
24 incValue(incValue(1)); // line A. 24 incValue(incValue(1)); // line A.
25 25
26 incValue(incValue(1)); // line B. 26 incValue(incValue(1)); // line B.
27 27
28 await deferredLib.loadLibrary(); 28 await deferredLib.loadLibrary();
29 deferredLib.deferredTest(); 29 deferredLib.deferredTest();
30 } 30 }
31 31
32 var tests = [ 32 var tests = [
33 hasPausedAtStart, 33 hasPausedAtStart,
34 34
35 // Test future breakpoints. 35 // Test future breakpoints.
36 (Isolate isolate) async { 36 (Isolate isolate) async {
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 completer.complete(null); 88 completer.complete(null);
89 } 89 }
90 }); 90 });
91 await isolate.resume(); 91 await isolate.resume();
92 await completer.future; 92 await completer.future;
93 93
94 // The second breakpoint hits after value has been modified once. 94 // The second breakpoint hits after value has been modified once.
95 expect((await rootLib.evaluate('value')).valueAsString, equals('1')); 95 expect((await rootLib.evaluate('value')).valueAsString, equals('1'));
96 96
97 // Remove the breakpoints. 97 // Remove the breakpoints.
98 expect((await isolate.removeBreakpoint(futureBpt1)).type, 98 expect(
99 equals('Success')); 99 (await isolate.removeBreakpoint(futureBpt1)).type, equals('Success'));
100 expect((await isolate.removeBreakpoint(futureBpt2)).type, 100 expect(
101 equals('Success')); 101 (await isolate.removeBreakpoint(futureBpt2)).type, equals('Success'));
102 }, 102 },
103 103
104 // Test breakpoints in deferred libraries (latent breakpoints). 104 // Test breakpoints in deferred libraries (latent breakpoints).
105 (Isolate isolate) async { 105 (Isolate isolate) async {
106 var rootLib = isolate.rootLibrary; 106 var rootLib = isolate.rootLibrary;
107 var uri = rootLib.scripts[0].uri; 107 var uri = rootLib.scripts[0].uri;
108 var lastSlashPos = uri.lastIndexOf('/'); 108 var lastSlashPos = uri.lastIndexOf('/');
109 var deferredUri =uri.substring(0, lastSlashPos) + '/deferred_library.dart'; 109 var deferredUri = uri.substring(0, lastSlashPos) + '/deferred_library.dart';
110 110
111 // Latent breakpoint. 111 // Latent breakpoint.
112 var latentBpt1 = await isolate.addBreakpointByScriptUri(deferredUri, 15); 112 var latentBpt1 = await isolate.addBreakpointByScriptUri(deferredUri, 15);
113 expect(latentBpt1.number, equals(3)); 113 expect(latentBpt1.number, equals(3));
114 expect(latentBpt1.resolved, isFalse); 114 expect(latentBpt1.resolved, isFalse);
115 expect(await latentBpt1.location.getLine(), equals(15)); 115 expect(await latentBpt1.location.getLine(), equals(15));
116 expect(await latentBpt1.location.getColumn(), equals(null)); 116 expect(await latentBpt1.location.getColumn(), equals(null));
117 117
118 // Latent breakpoint with specific column. 118 // Latent breakpoint with specific column.
119 var latentBpt2 = 119 var latentBpt2 = await isolate.addBreakpointByScriptUri(deferredUri, 15, 3);
120 await isolate.addBreakpointByScriptUri(deferredUri, 15, 3);
121 expect(latentBpt2.number, equals(4)); 120 expect(latentBpt2.number, equals(4));
122 expect(latentBpt2.resolved, isFalse); 121 expect(latentBpt2.resolved, isFalse);
123 expect(await latentBpt2.location.getLine(), equals(15)); 122 expect(await latentBpt2.location.getLine(), equals(15));
124 expect(await latentBpt2.location.getColumn(), equals(3)); 123 expect(await latentBpt2.location.getColumn(), equals(3));
125 124
126 var stream = await isolate.vm.getEventStream(VM.kDebugStream); 125 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
127 Completer completer = new Completer(); 126 Completer completer = new Completer();
128 var subscription; 127 var subscription;
129 var resolvedCount = 0; 128 var resolvedCount = 0;
130 subscription = stream.listen((ServiceEvent event) async { 129 subscription = stream.listen((ServiceEvent event) async {
(...skipping 12 matching lines...) Expand all
143 expect(resolvedCount, equals(2)); 142 expect(resolvedCount, equals(2));
144 expect(latentBpt1.resolved, isTrue); 143 expect(latentBpt1.resolved, isTrue);
145 expect(await latentBpt1.location.getLine(), equals(15)); 144 expect(await latentBpt1.location.getLine(), equals(15));
146 expect(await latentBpt1.location.getColumn(), equals(12)); 145 expect(await latentBpt1.location.getColumn(), equals(12));
147 expect(latentBpt2.resolved, isTrue); 146 expect(latentBpt2.resolved, isTrue);
148 expect(await latentBpt2.location.getLine(), equals(15)); 147 expect(await latentBpt2.location.getLine(), equals(15));
149 expect(await latentBpt2.location.getColumn(), equals(3)); 148 expect(await latentBpt2.location.getColumn(), equals(3));
150 149
151 // The first breakpoint hits before value is modified. 150 // The first breakpoint hits before value is modified.
152 expect((await rootLib.evaluate('deferredLib.value')).valueAsString, 151 expect((await rootLib.evaluate('deferredLib.value')).valueAsString,
153 equals('0')); 152 equals('0'));
154 153
155 stream = await isolate.vm.getEventStream(VM.kDebugStream); 154 stream = await isolate.vm.getEventStream(VM.kDebugStream);
156 completer = new Completer(); 155 completer = new Completer();
157 subscription = stream.listen((ServiceEvent event) async { 156 subscription = stream.listen((ServiceEvent event) async {
158 if (event.kind == ServiceEvent.kPauseBreakpoint) { 157 if (event.kind == ServiceEvent.kPauseBreakpoint) {
159 subscription.cancel(); 158 subscription.cancel();
160 completer.complete(null); 159 completer.complete(null);
161 } 160 }
162 }); 161 });
163 await isolate.resume(); 162 await isolate.resume();
164 await completer.future; 163 await completer.future;
165 164
166 // The second breakpoint hits after value has been modified once. 165 // The second breakpoint hits after value has been modified once.
167 expect((await rootLib.evaluate('deferredLib.value')).valueAsString, 166 expect((await rootLib.evaluate('deferredLib.value')).valueAsString,
168 equals('-1')); 167 equals('-1'));
169 168
170 // Remove the breakpoints. 169 // Remove the breakpoints.
171 expect((await isolate.removeBreakpoint(latentBpt1)).type, 170 expect(
172 equals('Success')); 171 (await isolate.removeBreakpoint(latentBpt1)).type, equals('Success'));
173 expect((await isolate.removeBreakpoint(latentBpt2)).type, 172 expect(
174 equals('Success')); 173 (await isolate.removeBreakpoint(latentBpt2)).type, equals('Success'));
175 }, 174 },
176 175
177
178 // Test resolution of column breakpoints. 176 // Test resolution of column breakpoints.
179 (Isolate isolate) async { 177 (Isolate isolate) async {
180 var script = isolate.rootLibrary.scripts[0]; 178 var script = isolate.rootLibrary.scripts[0];
181 // Try all columns, including some columns that are too big. 179 // Try all columns, including some columns that are too big.
182 for (int col = 1; col <= 50; col++) { 180 for (int col = 1; col <= 50; col++) {
183 var bpt = await isolate.addBreakpoint(script, LINE_A, col); 181 var bpt = await isolate.addBreakpoint(script, LINE_A, col);
184 expect(bpt.resolved, isTrue); 182 expect(bpt.resolved, isTrue);
185 int resolvedLine = await bpt.location.getLine(); 183 int resolvedLine = await bpt.location.getLine();
186 int resolvedCol = await bpt.location.getColumn(); 184 int resolvedCol = await bpt.location.getColumn();
187 print('20:${col} -> ${resolvedLine}:${resolvedCol}'); 185 print('20:${col} -> ${resolvedLine}:${resolvedCol}');
188 if (col <= 10) { 186 if (col <= 10) {
189 expect(resolvedLine, equals(LINE_A)); 187 expect(resolvedLine, equals(LINE_A));
190 expect(resolvedCol, equals(3)); 188 expect(resolvedCol, equals(3));
191 } else if (col <= 19) { 189 } else if (col <= 19) {
192 expect(resolvedLine, equals(LINE_A)); 190 expect(resolvedLine, equals(LINE_A));
193 expect(resolvedCol, equals(12)); 191 expect(resolvedCol, equals(12));
194 } else { 192 } else {
195 expect(resolvedLine, equals(LINE_B)); 193 expect(resolvedLine, equals(LINE_B));
196 expect(resolvedCol, equals(12)); 194 expect(resolvedCol, equals(12));
197 } 195 }
198 expect((await isolate.removeBreakpoint(bpt)).type, equals('Success')); 196 expect((await isolate.removeBreakpoint(bpt)).type, equals('Success'));
199 } 197 }
200 198
201 // Make sure that a zero column is an error. 199 // Make sure that a zero column is an error.
202 var caughtException = false; 200 var caughtException = false;
203 try { 201 try {
204 await isolate.addBreakpoint(script, 20, 0); 202 await isolate.addBreakpoint(script, 20, 0);
205 expect(false, isTrue, reason:'Unreachable'); 203 expect(false, isTrue, reason: 'Unreachable');
206 } on ServerRpcException catch(e) { 204 } on ServerRpcException catch (e) {
207 caughtException = true; 205 caughtException = true;
208 expect(e.code, equals(ServerRpcException.kInvalidParams)); 206 expect(e.code, equals(ServerRpcException.kInvalidParams));
209 expect(e.message, 207 expect(e.message, "addBreakpoint: invalid 'column' parameter: 0");
210 "addBreakpoint: invalid 'column' parameter: 0");
211 } 208 }
212 expect(caughtException, isTrue); 209 expect(caughtException, isTrue);
213 }, 210 },
214 ]; 211 ];
215 212
216 main(args) => runIsolateTests(args, tests, 213 main(args) => runIsolateTests(args, tests,
217 testeeConcurrent: testMain, 214 testeeConcurrent: testMain, pause_on_start: true);
218 pause_on_start: true);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698