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/service_io.dart'; | 6 import 'package:observatory/service_io.dart'; |
7 import 'package:unittest/unittest.dart'; | 7 import 'package:unittest/unittest.dart'; |
8 import 'test_helper.dart'; | 8 import 'test_helper.dart'; |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 | 10 |
11 void testMain() { | 11 void testMain() { |
12 print('Hello'); | 12 print('Hello'); |
13 } | 13 } |
14 | 14 |
15 var tests = [ | 15 var tests = [ |
16 | 16 |
17 (Isolate isolate) async { | 17 (Isolate isolate) async { |
| 18 print('Getting stream...'); |
18 Completer completer = new Completer(); | 19 Completer completer = new Completer(); |
19 var stream = await isolate.vm.getEventStream(VM.kDebugStream); | 20 var stream = await isolate.vm.getEventStream(VM.kDebugStream); |
| 21 print('Subscribing...'); |
20 var subscription; | 22 var subscription; |
21 subscription = stream.listen((ServiceEvent event) { | 23 subscription = stream.listen((ServiceEvent event) { |
22 if (event.kind == ServiceEvent.kPauseStart) { | 24 if (event.kind == ServiceEvent.kPauseStart) { |
23 print('Received PauseStart'); | 25 print('Received $event'); |
24 subscription.cancel(); | 26 subscription.cancel(); |
25 completer.complete(); | 27 completer.complete(); |
| 28 } else { |
| 29 print('Ignoring event $event'); |
26 } | 30 } |
27 }); | 31 }); |
| 32 print('Subscribed. Pause event is ${isolate.pauseEvent}'); |
28 | 33 |
29 if (isolate.pauseEvent != null && | 34 if (isolate.pauseEvent != null && |
30 isolate.pauseEvent.kind == ServiceEvent.kPauseStart) { | 35 isolate.pauseEvent.kind == ServiceEvent.kPauseStart) { |
31 // Wait for the isolate to hit PauseStart. | 36 // Wait for the isolate to hit PauseStart. |
32 subscription.cancel(); | 37 subscription.cancel(); |
33 print('subscription cancelled.'); | 38 print('Subscription cancelled.'); |
34 } else { | 39 } else { |
35 print('waiting for pause start event.'); | 40 print('Waiting for pause start event.'); |
36 await completer.future; | 41 await completer.future; |
37 } | 42 } |
| 43 print('Done waiting for pause event.'); |
38 | 44 |
39 // Grab the timestamp. | 45 // Grab the timestamp. |
40 var pausetime1 = isolate.pauseEvent.timestamp; | 46 var pausetime1 = isolate.pauseEvent.timestamp; |
41 expect(pausetime1, isNotNull); | 47 expect(pausetime1, isNotNull); |
42 // Reload the isolate. | 48 // Reload the isolate. |
43 await isolate.reload(); | 49 await isolate.reload(); |
44 // Verify that it is the same. | 50 // Verify that it is the same. |
45 expect(pausetime1.millisecondsSinceEpoch, | 51 expect(pausetime1.millisecondsSinceEpoch, |
46 equals(isolate.pauseEvent.timestamp.millisecondsSinceEpoch)); | 52 equals(isolate.pauseEvent.timestamp.millisecondsSinceEpoch)); |
47 | 53 |
(...skipping 26 matching lines...) Expand all Loading... |
74 | 80 |
75 expect(pausetime2.millisecondsSinceEpoch, | 81 expect(pausetime2.millisecondsSinceEpoch, |
76 greaterThan(pausetime1.millisecondsSinceEpoch)); | 82 greaterThan(pausetime1.millisecondsSinceEpoch)); |
77 }, | 83 }, |
78 | 84 |
79 ]; | 85 ]; |
80 | 86 |
81 main(args) => runIsolateTests(args, tests, | 87 main(args) => runIsolateTests(args, tests, |
82 testeeConcurrent: testMain, | 88 testeeConcurrent: testMain, |
83 pause_on_start: true, pause_on_exit: true); | 89 pause_on_start: true, pause_on_exit: true); |
OLD | NEW |