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

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

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

Powered by Google App Engine
This is Rietveld 408576698