| OLD | NEW | 
|   1 // Copyright (c) 2017, the Dart project authors.  Please see the AUTHORS file |   1 // Copyright (c) 2017, 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 import 'dart:async'; |   5 import 'dart:async'; | 
|   6 import 'test_helper.dart'; |   6 import 'test_helper.dart'; | 
|   7 import 'service_test_common.dart'; |   7 import 'service_test_common.dart'; | 
|   8 import 'package:observatory/service_io.dart'; |   8 import 'package:observatory/service_io.dart'; | 
|   9 import 'package:unittest/unittest.dart'; |   9 import 'package:unittest/unittest.dart'; | 
|  10  |  10  | 
|  11 const int LINE_A = 28, LINE_B = 33; |  11 const int LINE_A = 28, LINE_B = 33; | 
|  12  |  12  | 
|  13 class VMServiceClient { |  13 class VMServiceClient { | 
|  14   VMServiceClient(this.x); |  14   VMServiceClient(this.x); | 
|  15   close() => new Future.microtask(() => print("close")); |  15   close() => new Future.microtask(() => print("close")); | 
|  16   var x; |  16   var x; | 
|  17 } |  17 } | 
|  18  |  18  | 
|  19 collect() async { |  19 collect() async { | 
|  20   var uri = "abc"; |  20   var uri = "abc"; | 
|  21   var vmService; |  21   var vmService; | 
|  22   await new Future.microtask(() async { |  22   await new Future.microtask(() async { | 
|  23     try { |  23     try { | 
|  24       vmService = new VMServiceClient(uri); |  24       vmService = new VMServiceClient(uri); | 
|  25       await new Future.microtask(() => throw new TimeoutException("here")); |  25       await new Future.microtask(() => throw new TimeoutException("here")); | 
|  26     } on dynamic { |  26     } on dynamic { | 
|  27       vmService.close(); |  27       vmService.close(); | 
|  28       rethrow; // LINE_A |  28       rethrow;  // LINE_A | 
|  29     } |  29     } | 
|  30   }); |  30   }); | 
|  31 } |  31 } | 
|  32  |  32  | 
|  33 test_code() async { |  33 test_code() async {  // LINE_B | 
|  34   // LINE_B |  | 
|  35   try { |  34   try { | 
|  36     await collect(); |  35     await collect(); | 
|  37   } on TimeoutException { |  36   } on TimeoutException { | 
|  38     print("ok"); |  37     print("ok"); | 
|  39   } |  38   } | 
|  40 } |  39 } | 
|  41  |  40  | 
|  42 Future<Isolate> stepThroughProgram(Isolate isolate) async { |  41 Future<Isolate> stepThroughProgram(Isolate isolate) async { | 
|  43   Completer completer = new Completer(); |  42   Completer completer = new Completer(); | 
|  44   int pauseEventsSeen = 0; |  43   int pauseEventsSeen = 0; | 
|  45  |  44  | 
|  46   await subscribeToStream(isolate.vm, VM.kDebugStream, |  45   await subscribeToStream(isolate.vm, VM.kDebugStream, | 
|  47       (ServiceEvent event) async { |  46       (ServiceEvent event) async { | 
|  48     if (event.kind == ServiceEvent.kPauseBreakpoint) { |  47     if (event.kind == ServiceEvent.kPauseBreakpoint) { | 
|  49       // We are paused: Step further. |  48       // We are paused: Step further. | 
|  50       pauseEventsSeen++; |  49       pauseEventsSeen++; | 
|  51       isolate.stepInto(); |  50       isolate.stepInto(); | 
|  52     } else if (event.kind == ServiceEvent.kPauseExit) { |  51     } else if (event.kind == ServiceEvent.kPauseExit) { | 
|  53       // We are at the exit: The test is done. |  52       // We are at the exit: The test is done. | 
|  54       expect(pauseEventsSeen > 20, true, |  53       expect(pauseEventsSeen > 20, true, | 
|  55           reason: "Saw only $pauseEventsSeen pause events."); |  54           reason: "Saw only $pauseEventsSeen pause events."); | 
|  56       await cancelStreamSubscription(VM.kDebugStream); |  55       await cancelStreamSubscription(VM.kDebugStream); | 
|  57       completer.complete(); |  56       completer.complete(); | 
|  58     } |  57     } | 
|  59   }); |  58   }); | 
|  60   isolate.resume(); |  59   isolate.resume(); | 
|  61   return completer.future; |  60   return completer.future; | 
|  62 } |  61 } | 
|  63  |  62  | 
|  64 var tests = [ |  63 var tests = [hasPausedAtStart, | 
|  65   hasPausedAtStart, |  64              markDartColonLibrariesDebuggable, | 
|  66   markDartColonLibrariesDebuggable, |  65              setBreakpointAtLine(LINE_B), | 
|  67   setBreakpointAtLine(LINE_B), |  66              resumeIsolate, | 
|  68   resumeIsolate, |  67              hasStoppedAtBreakpoint, | 
|  69   hasStoppedAtBreakpoint, |  68              setBreakpointAtLine(LINE_A), | 
|  70   setBreakpointAtLine(LINE_A), |  69              resumeIsolate, | 
|  71   resumeIsolate, |  70              hasStoppedAtBreakpoint, | 
|  72   hasStoppedAtBreakpoint, |  71              stepOut, | 
|  73   stepOut, |  72              stoppedAtLine(LINE_B), | 
|  74   stoppedAtLine(LINE_B), |  73              resumeIsolate]; | 
|  75   resumeIsolate |  | 
|  76 ]; |  | 
|  77  |  74  | 
|  78 main(args) => runIsolateTestsSynchronous(args, tests, |  75 main(args) => runIsolateTestsSynchronous(args, tests, | 
|  79     testeeConcurrent: test_code, pause_on_start: true, pause_on_exit: false); |  76     testeeConcurrent: test_code, pause_on_start: true, pause_on_exit: false); | 
| OLD | NEW |