| OLD | NEW |
| 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/models.dart' as M; |
| 6 import 'package:observatory/service_io.dart'; | 7 import 'package:observatory/service_io.dart'; |
| 7 import 'package:unittest/unittest.dart'; | 8 import 'package:unittest/unittest.dart'; |
| 8 import 'test_helper.dart'; | 9 import 'test_helper.dart'; |
| 9 import 'dart:async'; | 10 import 'dart:async'; |
| 10 | 11 |
| 11 void testMain() { | 12 void testMain() { |
| 12 print('Hello'); | 13 print('Hello'); |
| 13 } | 14 } |
| 14 | 15 |
| 15 var tests = [ | 16 var tests = [ |
| 16 | 17 |
| 17 (Isolate isolate) async { | 18 (Isolate isolate) async { |
| 18 print('Getting stream...'); | 19 print('Getting stream...'); |
| 19 Completer completer = new Completer(); | 20 Completer completer = new Completer(); |
| 20 var stream = await isolate.vm.getEventStream(VM.kDebugStream); | 21 var stream = await isolate.vm.getEventStream(VM.kDebugStream); |
| 21 print('Subscribing...'); | 22 print('Subscribing...'); |
| 22 var subscription; | 23 var subscription; |
| 23 subscription = stream.listen((ServiceEvent event) { | 24 subscription = stream.listen((ServiceEvent event) { |
| 24 if (event.kind == ServiceEvent.kPauseStart) { | 25 if (event.kind == ServiceEvent.kPauseStart) { |
| 25 print('Received $event'); | 26 print('Received $event'); |
| 26 subscription.cancel(); | 27 subscription.cancel(); |
| 27 completer.complete(); | 28 completer.complete(); |
| 28 } else { | 29 } else { |
| 29 print('Ignoring event $event'); | 30 print('Ignoring event $event'); |
| 30 } | 31 } |
| 31 }); | 32 }); |
| 32 print('Subscribed. Pause event is ${isolate.pauseEvent}'); | 33 print('Subscribed. Pause event is ${isolate.pauseEvent}'); |
| 33 | 34 |
| 34 if (isolate.pauseEvent != null && | 35 if (isolate.pauseEvent != null && |
| 35 isolate.pauseEvent.kind == ServiceEvent.kPauseStart) { | 36 isolate.pauseEvent is M.PauseStartEvent) { |
| 36 // Wait for the isolate to hit PauseStart. | 37 // Wait for the isolate to hit PauseStart. |
| 37 subscription.cancel(); | 38 subscription.cancel(); |
| 38 print('Subscription cancelled.'); | 39 print('Subscription cancelled.'); |
| 39 } else { | 40 } else { |
| 40 print('Waiting for pause start event.'); | 41 print('Waiting for pause start event.'); |
| 41 await completer.future; | 42 await completer.future; |
| 42 } | 43 } |
| 43 print('Done waiting for pause event.'); | 44 print('Done waiting for pause event.'); |
| 44 | 45 |
| 45 // Grab the timestamp. | 46 // Grab the timestamp. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 }, | 84 }, |
| 84 | 85 |
| 85 ]; | 86 ]; |
| 86 | 87 |
| 87 main(args) => runIsolateTests(args, tests, | 88 main(args) => runIsolateTests(args, tests, |
| 88 testeeConcurrent: testMain, | 89 testeeConcurrent: testMain, |
| 89 pause_on_start: true, | 90 pause_on_start: true, |
| 90 pause_on_exit: true, | 91 pause_on_exit: true, |
| 91 trace_service: true, | 92 trace_service: true, |
| 92 verbose_vm: true); | 93 verbose_vm: true); |
| OLD | NEW |