| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 test_helper; | 5 library test_helper; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:convert'; | 8 import 'dart:convert'; |
| 9 import 'dart:io'; | 9 import 'dart:io'; |
| 10 import 'package:observatory/service_io.dart'; | 10 import 'package:observatory/service_io.dart'; |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 expect(bpt is Breakpoint, isTrue); | 242 expect(bpt is Breakpoint, isTrue); |
| 243 }; | 243 }; |
| 244 } | 244 } |
| 245 | 245 |
| 246 IsolateTest stoppedAtLine(int line) { | 246 IsolateTest stoppedAtLine(int line) { |
| 247 return (Isolate isolate) async { | 247 return (Isolate isolate) async { |
| 248 print("Checking we are at line $line"); | 248 print("Checking we are at line $line"); |
| 249 | 249 |
| 250 ServiceMap stack = await isolate.getStack(); | 250 ServiceMap stack = await isolate.getStack(); |
| 251 expect(stack.type, equals('Stack')); | 251 expect(stack.type, equals('Stack')); |
| 252 expect(stack['frames'].length, greaterThanOrEqualTo(1)); | |
| 253 | 252 |
| 254 Frame top = stack['frames'][0]; | 253 List<Frame> frames = stack['frames']; |
| 255 print("We are at $top"); | 254 expect(frames.length, greaterThanOrEqualTo(1)); |
| 255 |
| 256 Frame top = frames[0]; |
| 256 Script script = await top.location.script.load(); | 257 Script script = await top.location.script.load(); |
| 257 expect(script.tokenToLine(top.location.tokenPos), equals(line)); | 258 if (script.tokenToLine(top.location.tokenPos) != line) { |
| 259 var sb = new StringBuffer(); |
| 260 sb.write("Expected to be at line $line, but got stack trace:\n"); |
| 261 for (Frame f in stack['frames']) { |
| 262 sb.write(" $f\n"); |
| 263 } |
| 264 throw sb.toString(); |
| 265 } |
| 258 }; | 266 }; |
| 259 } | 267 } |
| 260 | 268 |
| 261 | 269 |
| 262 Future<Isolate> resumeIsolate(Isolate isolate) { | 270 Future<Isolate> resumeIsolate(Isolate isolate) { |
| 263 Completer completer = new Completer(); | 271 Completer completer = new Completer(); |
| 264 isolate.vm.getEventStream(VM.kDebugStream).then((stream) { | 272 isolate.vm.getEventStream(VM.kDebugStream).then((stream) { |
| 265 var subscription; | 273 var subscription; |
| 266 subscription = stream.listen((ServiceEvent event) { | 274 subscription = stream.listen((ServiceEvent event) { |
| 267 if (event.kind == ServiceEvent.kResume) { | 275 if (event.kind == ServiceEvent.kResume) { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 }, onError: (e, st) { | 369 }, onError: (e, st) { |
| 362 process.requestExit(); | 370 process.requestExit(); |
| 363 if (!_isWebSocketDisconnect(e)) { | 371 if (!_isWebSocketDisconnect(e)) { |
| 364 print('Unexpected exception in service tests: $e $st'); | 372 print('Unexpected exception in service tests: $e $st'); |
| 365 throw e; | 373 throw e; |
| 366 } | 374 } |
| 367 }); | 375 }); |
| 368 }); | 376 }); |
| 369 } | 377 } |
| 370 } | 378 } |
| OLD | NEW |