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

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

Issue 2411153002: Make reloadSources service RPC public (Closed)
Patch Set: turnidge review Created 4 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
« no previous file with comments | « runtime/observatory/tests/service/reload_sources_test.dart ('k') | runtime/vm/debugger.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 library service_test_common; 5 library service_test_common;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'package:observatory/models.dart' as M; 8 import 'package:observatory/models.dart' as M;
9 import 'package:observatory/service_common.dart'; 9 import 'package:observatory/service_common.dart';
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 bool isEventOfKind(M.Event event, String kind) { 137 bool isEventOfKind(M.Event event, String kind) {
138 switch (kind) { 138 switch (kind) {
139 case ServiceEvent.kPauseBreakpoint: 139 case ServiceEvent.kPauseBreakpoint:
140 return event is M.PauseBreakpointEvent; 140 return event is M.PauseBreakpointEvent;
141 case ServiceEvent.kPauseException: 141 case ServiceEvent.kPauseException:
142 return event is M.PauseExceptionEvent; 142 return event is M.PauseExceptionEvent;
143 case ServiceEvent.kPauseExit: 143 case ServiceEvent.kPauseExit:
144 return event is M.PauseExitEvent; 144 return event is M.PauseExitEvent;
145 case ServiceEvent.kPauseStart: 145 case ServiceEvent.kPauseStart:
146 return event is M.PauseStartEvent; 146 return event is M.PauseStartEvent;
147 case ServiceEvent.kPausePostRequest:
148 return event is M.PausePostRequestEvent;
147 default: 149 default:
148 return false; 150 return false;
149 } 151 }
150 } 152 }
151 153
152 Future<Isolate> hasPausedFor(Isolate isolate, String kind) { 154 Future<Isolate> hasPausedFor(Isolate isolate, String kind) {
153 // Set up a listener to wait for breakpoint events. 155 // Set up a listener to wait for breakpoint events.
154 Completer completer = new Completer(); 156 Completer completer = new Completer();
155 isolate.vm.getEventStream(VM.kDebugStream).then((stream) { 157 isolate.vm.getEventStream(VM.kDebugStream).then((stream) {
156 var subscription; 158 var subscription;
(...skipping 24 matching lines...) Expand all
181 }); 183 });
182 }); 184 });
183 185
184 return completer.future; // Will complete when breakpoint hit. 186 return completer.future; // Will complete when breakpoint hit.
185 } 187 }
186 188
187 Future<Isolate> hasStoppedAtBreakpoint(Isolate isolate) { 189 Future<Isolate> hasStoppedAtBreakpoint(Isolate isolate) {
188 return hasPausedFor(isolate, ServiceEvent.kPauseBreakpoint); 190 return hasPausedFor(isolate, ServiceEvent.kPauseBreakpoint);
189 } 191 }
190 192
193 Future<Isolate> hasStoppedPostRequest(Isolate isolate) {
194 return hasPausedFor(isolate, ServiceEvent.kPausePostRequest);
195 }
196
191 Future<Isolate> hasStoppedWithUnhandledException(Isolate isolate) { 197 Future<Isolate> hasStoppedWithUnhandledException(Isolate isolate) {
192 return hasPausedFor(isolate, ServiceEvent.kPauseException); 198 return hasPausedFor(isolate, ServiceEvent.kPauseException);
193 } 199 }
194 200
195 Future<Isolate> hasStoppedAtExit(Isolate isolate) { 201 Future<Isolate> hasStoppedAtExit(Isolate isolate) {
196 return hasPausedFor(isolate, ServiceEvent.kPauseExit); 202 return hasPausedFor(isolate, ServiceEvent.kPauseExit);
197 } 203 }
198 204
199 Future<Isolate> hasPausedAtStart(Isolate isolate) { 205 Future<Isolate> hasPausedAtStart(Isolate isolate) {
200 return hasPausedFor(isolate, ServiceEvent.kPauseStart); 206 return hasPausedFor(isolate, ServiceEvent.kPauseStart);
201 } 207 }
202 208
209 IsolateTest reloadSources([bool pause = false]) {
210 return (Isolate isolate) async {
211 Map<String, dynamic> params = <String, dynamic>{ };
212 if (pause == true) {
213 params['pause'] = pause;
214 }
215 return isolate.invokeRpc('reloadSources', params);
216 };
217 }
218
203 // Currying is your friend. 219 // Currying is your friend.
204 IsolateTest setBreakpointAtLine(int line) { 220 IsolateTest setBreakpointAtLine(int line) {
205 return (Isolate isolate) async { 221 return (Isolate isolate) async {
206 print("Setting breakpoint for line $line"); 222 print("Setting breakpoint for line $line");
207 Library lib = await isolate.rootLibrary.load(); 223 Library lib = await isolate.rootLibrary.load();
208 Script script = lib.scripts.single; 224 Script script = lib.scripts.single;
209 225
210 Breakpoint bpt = await isolate.addBreakpoint(script, line); 226 Breakpoint bpt = await isolate.addBreakpoint(script, line);
211 print("Breakpoint is $bpt"); 227 print("Breakpoint is $bpt");
212 expect(bpt, isNotNull); 228 expect(bpt, isNotNull);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 await isolate.stepInto(); 342 await isolate.stepInto();
327 return hasStoppedAtBreakpoint(isolate); 343 return hasStoppedAtBreakpoint(isolate);
328 } 344 }
329 345
330 Future<Isolate> stepOut(Isolate isolate) async { 346 Future<Isolate> stepOut(Isolate isolate) async {
331 await isolate.stepOut(); 347 await isolate.stepOut();
332 return hasStoppedAtBreakpoint(isolate); 348 return hasStoppedAtBreakpoint(isolate);
333 } 349 }
334 350
335 351
352 Future isolateIsRunning(Isolate isolate) async {
353 await isolate.reload();
354 expect(isolate.running, true);
355 }
356
336 Future<Class> getClassFromRootLib(Isolate isolate, String className) async { 357 Future<Class> getClassFromRootLib(Isolate isolate, String className) async {
337 Library rootLib = await isolate.rootLibrary.load(); 358 Library rootLib = await isolate.rootLibrary.load();
338 for (var i = 0; i < rootLib.classes.length; i++) { 359 for (var i = 0; i < rootLib.classes.length; i++) {
339 Class cls = rootLib.classes[i]; 360 Class cls = rootLib.classes[i];
340 if (cls.name == className) { 361 if (cls.name == className) {
341 return cls; 362 return cls;
342 } 363 }
343 } 364 }
344 return null; 365 return null;
345 } 366 }
346 367
347 368
348 Future<Instance> rootLibraryFieldValue(Isolate isolate, 369 Future<Instance> rootLibraryFieldValue(Isolate isolate,
349 String fieldName) async { 370 String fieldName) async {
350 Library rootLib = await isolate.rootLibrary.load(); 371 Library rootLib = await isolate.rootLibrary.load();
351 Field field = rootLib.variables.singleWhere((v) => v.name == fieldName); 372 Field field = rootLib.variables.singleWhere((v) => v.name == fieldName);
352 await field.load(); 373 await field.load();
353 Instance value = field.staticValue; 374 Instance value = field.staticValue;
354 await value.load(); 375 await value.load();
355 return value; 376 return value;
356 } 377 }
OLDNEW
« no previous file with comments | « runtime/observatory/tests/service/reload_sources_test.dart ('k') | runtime/vm/debugger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698