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

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

Issue 1393523002: Support tab completion of line:col in the debugger. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fix warnings and other issues Created 5 years, 2 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 'test_helper.dart'; 8 import 'test_helper.dart';
9 import 'deferred_library.dart' deferred as deferredLib; 9 import 'deferred_library.dart' deferred as deferredLib;
10 import 'dart:async'; 10 import 'dart:async';
11 import 'dart:developer' as developer;
12 11
13 int value = 0; 12 int value = 0;
14 13
15 int incValue(int amount) { 14 int incValue(int amount) {
16 value += amount; 15 value += amount;
17 return amount; 16 return amount;
18 } 17 }
19 18
20 Future testMain() async { 19 Future testMain() async {
21 incValue(incValue(1)); // line 21 20 incValue(incValue(1)); // line 20
22 21
23 incValue(incValue(1)); // line 23 22 incValue(incValue(1)); // line 22
24 23
25 await deferredLib.loadLibrary(); 24 await deferredLib.loadLibrary();
26 deferredLib.deferredTest(); 25 deferredLib.deferredTest();
27 } 26 }
28 27
29 var tests = [ 28 var tests = [
30 hasPausedAtStart, 29 hasPausedAtStart,
31 30
32 // Test future breakpoints. 31 // Test future breakpoints.
33 (Isolate isolate) async { 32 (Isolate isolate) async {
34 var rootLib = isolate.rootLibrary; 33 var rootLib = isolate.rootLibrary;
35 await rootLib.load(); 34 await rootLib.load();
36 var script = rootLib.scripts[0]; 35 var script = rootLib.scripts[0];
37 36
38 // Future breakpoint. 37 // Future breakpoint.
39 var futureBpt1 = await isolate.addBreakpoint(script, 21); 38 var futureBpt1 = await isolate.addBreakpoint(script, 20);
40 expect(futureBpt1.number, equals(1)); 39 expect(futureBpt1.number, equals(1));
41 expect(futureBpt1.resolved, isFalse); 40 expect(futureBpt1.resolved, isFalse);
42 expect(await futureBpt1.location.getLine(), equals(21)); 41 expect(await futureBpt1.location.getLine(), equals(20));
43 expect(await futureBpt1.location.getColumn(), equals(null)); 42 expect(await futureBpt1.location.getColumn(), equals(null));
44 43
45 // Future breakpoint with specific column. 44 // Future breakpoint with specific column.
46 var futureBpt2 = await isolate.addBreakpoint(script, 21, 3); 45 var futureBpt2 = await isolate.addBreakpoint(script, 20, 3);
47 expect(futureBpt2.number, equals(2)); 46 expect(futureBpt2.number, equals(2));
48 expect(futureBpt2.resolved, isFalse); 47 expect(futureBpt2.resolved, isFalse);
49 expect(await futureBpt2.location.getLine(), equals(21)); 48 expect(await futureBpt2.location.getLine(), equals(20));
50 expect(await futureBpt2.location.getColumn(), equals(3)); 49 expect(await futureBpt2.location.getColumn(), equals(3));
51 50
52 var stream = await isolate.vm.getEventStream(VM.kDebugStream); 51 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
53 Completer completer = new Completer(); 52 Completer completer = new Completer();
54 var subscription; 53 var subscription;
55 var resolvedCount = 0; 54 var resolvedCount = 0;
56 subscription = stream.listen((ServiceEvent event) async { 55 subscription = stream.listen((ServiceEvent event) async {
57 if (event.kind == ServiceEvent.kBreakpointResolved) { 56 if (event.kind == ServiceEvent.kBreakpointResolved) {
58 resolvedCount++; 57 resolvedCount++;
59 } 58 }
60 if (event.kind == ServiceEvent.kPauseBreakpoint) { 59 if (event.kind == ServiceEvent.kPauseBreakpoint) {
61 subscription.cancel(); 60 subscription.cancel();
62 completer.complete(null); 61 completer.complete(null);
63 } 62 }
64 }); 63 });
65 await isolate.resume(); 64 await isolate.resume();
66 await completer.future; 65 await completer.future;
67 66
68 // After resolution the breakpoints have assigned line & column. 67 // After resolution the breakpoints have assigned line & column.
69 expect(resolvedCount, equals(2)); 68 expect(resolvedCount, equals(2));
70 expect(futureBpt1.resolved, isTrue); 69 expect(futureBpt1.resolved, isTrue);
71 expect(await futureBpt1.location.getLine(), equals(21)); 70 expect(await futureBpt1.location.getLine(), equals(20));
72 expect(await futureBpt1.location.getColumn(), equals(12)); 71 expect(await futureBpt1.location.getColumn(), equals(12));
73 expect(futureBpt2.resolved, isTrue); 72 expect(futureBpt2.resolved, isTrue);
74 expect(await futureBpt2.location.getLine(), equals(21)); 73 expect(await futureBpt2.location.getLine(), equals(20));
75 expect(await futureBpt2.location.getColumn(), equals(3)); 74 expect(await futureBpt2.location.getColumn(), equals(3));
76 75
77 // The first breakpoint hits before value is modified. 76 // The first breakpoint hits before value is modified.
78 expect((await rootLib.evaluate('value')).valueAsString, equals('0')); 77 expect((await rootLib.evaluate('value')).valueAsString, equals('0'));
79 78
80 stream = await isolate.vm.getEventStream(VM.kDebugStream); 79 stream = await isolate.vm.getEventStream(VM.kDebugStream);
81 completer = new Completer(); 80 completer = new Completer();
82 subscription = stream.listen((ServiceEvent event) async { 81 subscription = stream.listen((ServiceEvent event) async {
83 if (event.kind == ServiceEvent.kPauseBreakpoint) { 82 if (event.kind == ServiceEvent.kPauseBreakpoint) {
84 subscription.cancel(); 83 subscription.cancel();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 expect((await isolate.removeBreakpoint(latentBpt2)).type, 169 expect((await isolate.removeBreakpoint(latentBpt2)).type,
171 equals('Success')); 170 equals('Success'));
172 }, 171 },
173 172
174 173
175 // Test resolution of column breakpoints. 174 // Test resolution of column breakpoints.
176 (Isolate isolate) async { 175 (Isolate isolate) async {
177 var script = isolate.rootLibrary.scripts[0]; 176 var script = isolate.rootLibrary.scripts[0];
178 // Try all columns, including some columns that are too big. 177 // Try all columns, including some columns that are too big.
179 for (int col = 1; col <= 50; col++) { 178 for (int col = 1; col <= 50; col++) {
180 var bpt = await isolate.addBreakpoint(script, 21, col); 179 var bpt = await isolate.addBreakpoint(script, 20, col);
181 expect(bpt.resolved, isTrue); 180 expect(bpt.resolved, isTrue);
182 int resolvedLine = await bpt.location.getLine(); 181 int resolvedLine = await bpt.location.getLine();
183 int resolvedCol = await bpt.location.getColumn(); 182 int resolvedCol = await bpt.location.getColumn();
184 print('21:${col} -> ${resolvedLine}:${resolvedCol}'); 183 print('20:${col} -> ${resolvedLine}:${resolvedCol}');
185 if (col <= 10) { 184 if (col <= 10) {
186 expect(resolvedLine, equals(21)); 185 expect(resolvedLine, equals(20));
187 expect(resolvedCol, equals(3)); 186 expect(resolvedCol, equals(3));
188 } else if (col <= 19) { 187 } else if (col <= 19) {
189 expect(resolvedLine, equals(21)); 188 expect(resolvedLine, equals(20));
190 expect(resolvedCol, equals(12)); 189 expect(resolvedCol, equals(12));
191 } else { 190 } else {
192 expect(resolvedLine, equals(23)); 191 expect(resolvedLine, equals(22));
193 expect(resolvedCol, equals(12)); 192 expect(resolvedCol, equals(12));
194 } 193 }
195 expect((await isolate.removeBreakpoint(bpt)).type, equals('Success')); 194 expect((await isolate.removeBreakpoint(bpt)).type, equals('Success'));
196 } 195 }
197 196
198 // Make sure that a zero column is an error. 197 // Make sure that a zero column is an error.
199 var caughtException = false; 198 var caughtException = false;
200 try { 199 try {
201 await isolate.addBreakpoint(script, 21, 0); 200 await isolate.addBreakpoint(script, 20, 0);
202 expect(false, isTrue, reason:'Unreachable'); 201 expect(false, isTrue, reason:'Unreachable');
203 } on ServerRpcException catch(e) { 202 } on ServerRpcException catch(e) {
204 caughtException = true; 203 caughtException = true;
205 expect(e.code, equals(ServerRpcException.kInvalidParams)); 204 expect(e.code, equals(ServerRpcException.kInvalidParams));
206 expect(e.message, 205 expect(e.message,
207 "addBreakpoint: invalid 'column' parameter: 0"); 206 "addBreakpoint: invalid 'column' parameter: 0");
208 } 207 }
209 expect(caughtException, isTrue); 208 expect(caughtException, isTrue);
210 }, 209 },
211 ]; 210 ];
212 211
213 main(args) => runIsolateTests(args, tests, 212 main(args) => runIsolateTests(args, tests,
214 testeeConcurrent: testMain, 213 testeeConcurrent: testMain,
215 pause_on_start: true); 214 pause_on_start: true);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698