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 'test_helper.dart'; | 8 import 'test_helper.dart'; |
8 import 'dart:async'; | 9 import 'dart:async'; |
9 | 10 |
10 void testMain() { | 11 void testMain() { |
11 print('Hello'); | 12 print('Hello'); |
12 } | 13 } |
13 | 14 |
14 var tests = [ | 15 var tests = [ |
15 | 16 |
16 (Isolate isolate) async { | 17 (Isolate isolate) async { |
17 Completer completer = new Completer(); | 18 Completer completer = new Completer(); |
18 var stream = await isolate.vm.getEventStream(VM.kDebugStream); | 19 var stream = await isolate.vm.getEventStream(VM.kDebugStream); |
19 var subscription; | 20 var subscription; |
20 subscription = stream.listen((ServiceEvent event) { | 21 subscription = stream.listen((ServiceEvent event) { |
21 if (event.kind == ServiceEvent.kPauseStart) { | 22 if (event.kind == ServiceEvent.kPauseStart) { |
22 print('Received PauseStart'); | 23 print('Received PauseStart'); |
23 subscription.cancel(); | 24 subscription.cancel(); |
24 completer.complete(); | 25 completer.complete(); |
25 } | 26 } |
26 }); | 27 }); |
27 | 28 |
28 if (isolate.pauseEvent != null && | 29 if (isolate.pauseEvent != null && |
29 isolate.pauseEvent.kind == ServiceEvent.kPauseStart) { | 30 isolate.pauseEvent.kind == ServiceEvent.kPauseStart) { |
30 // Wait for the isolate to hit PauseStart. | 31 // Wait for the isolate to hit PauseStart. |
31 subscription.cancel(); | 32 subscription.cancel(); |
32 } else { | 33 } else { |
33 await completer.future; | 34 await completer.future; |
34 } | 35 } |
35 | 36 |
37 // Grab the timestamp. | |
38 var pausetime = isolate.pauseEvent.timestamp; | |
39 expect(pausetime, isNotNull); | |
40 // Reload the isolate. | |
41 await isolate.reload(); | |
42 // Verify that it is the same. | |
43 expect(pausetime.millisecondsSinceEpoch, | |
44 equals(isolate.pauseEvent.timestamp.millisecondsSinceEpoch)); | |
turnidge
2015/08/25 18:25:31
Maybe save the pause time to pauseTime1? See next
Cutch
2015/08/25 21:54:58
Done.
| |
45 | |
36 completer = new Completer(); | 46 completer = new Completer(); |
37 stream = await isolate.vm.getEventStream(VM.kDebugStream); | 47 stream = await isolate.vm.getEventStream(VM.kDebugStream); |
38 subscription = stream.listen((ServiceEvent event) { | 48 subscription = stream.listen((ServiceEvent event) { |
39 if (event.kind == ServiceEvent.kPauseExit) { | 49 if (event.kind == ServiceEvent.kPauseExit) { |
40 print('Received PauseExit'); | 50 print('Received PauseExit'); |
41 subscription.cancel(); | 51 subscription.cancel(); |
42 completer.complete(); | 52 completer.complete(); |
43 } | 53 } |
44 }); | 54 }); |
45 | 55 |
46 print('Resuming...'); | 56 print('Resuming...'); |
47 isolate.resume(); | 57 isolate.resume(); |
48 | 58 |
49 // Wait for the isolate to hit PauseExit. | 59 // Wait for the isolate to hit PauseExit. |
50 await completer.future; | 60 await completer.future; |
61 | |
62 // Grab the timestamp. | |
63 pausetime = isolate.pauseEvent.timestamp; | |
64 expect(pausetime, isNotNull); | |
65 // Reload the isolate. | |
66 await isolate.reload(); | |
67 // Verify that it is the same. | |
68 expect(pausetime.millisecondsSinceEpoch, | |
69 equals(isolate.pauseEvent.timestamp.millisecondsSinceEpoch)); | |
turnidge
2015/08/25 18:25:31
expect(pauseTime2, greaterThan(pauseTime1))
Cutch
2015/08/25 21:54:58
Done.
| |
51 }, | 70 }, |
52 | 71 |
53 ]; | 72 ]; |
54 | 73 |
55 main(args) => runIsolateTests(args, tests, | 74 main(args) => runIsolateTests(args, tests, |
56 testeeConcurrent: testMain, | 75 testeeConcurrent: testMain, |
57 pause_on_start: true, pause_on_exit: true); | 76 pause_on_start: true, pause_on_exit: true); |
OLD | NEW |