Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: runtime/observatory/tests/service/pause_on_start_and_exit_test.dart

Issue 2759973004: Fix observatory tests broken by running dartfmt. Temporarily reverted formatting for evaluate_activ… (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/models.dart' as M;
7 import 'package:observatory/service_io.dart'; 7 import 'package:observatory/service_io.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 import 'test_helper.dart'; 9 import 'test_helper.dart';
10 import 'dart:async'; 10 import 'dart:async';
11 11
12 void testMain() { 12 void testMain() {
13 print('Hello'); 13 print('Hello');
14 } 14 }
15 15
16 var tests = [ 16 var tests = [
17 (Isolate isolate) async {
18 print('Getting stream...');
19 Completer completer = new Completer();
20 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
21 print('Subscribing...');
22 var subscription;
23 subscription = stream.listen((ServiceEvent event) {
24 if (event.kind == ServiceEvent.kPauseStart) {
25 print('Received $event');
26 subscription.cancel();
27 completer.complete();
28 } else {
29 print('Ignoring event $event');
30 }
31 });
32 print('Subscribed. Pause event is ${isolate.pauseEvent}');
17 33
18 (Isolate isolate) async { 34 if (isolate.pauseEvent != null && isolate.pauseEvent is M.PauseStartEvent) {
19 print('Getting stream...'); 35 // Wait for the isolate to hit PauseStart.
20 Completer completer = new Completer();
21 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
22 print('Subscribing...');
23 var subscription;
24 subscription = stream.listen((ServiceEvent event) {
25 if (event.kind == ServiceEvent.kPauseStart) {
26 print('Received $event');
27 subscription.cancel(); 36 subscription.cancel();
28 completer.complete(); 37 print('Subscription cancelled.');
29 } else { 38 } else {
30 print('Ignoring event $event'); 39 print('Waiting for pause start event.');
40 await completer.future;
31 } 41 }
32 }); 42 print('Done waiting for pause event.');
33 print('Subscribed. Pause event is ${isolate.pauseEvent}');
34 43
35 if (isolate.pauseEvent != null && 44 // Grab the timestamp.
36 isolate.pauseEvent is M.PauseStartEvent) { 45 var pausetime1 = isolate.pauseEvent.timestamp;
37 // Wait for the isolate to hit PauseStart. 46 expect(pausetime1, isNotNull);
38 subscription.cancel(); 47 // Reload the isolate.
39 print('Subscription cancelled.'); 48 await isolate.reload();
40 } else { 49 // Verify that it is the same.
41 print('Waiting for pause start event.'); 50 expect(pausetime1.millisecondsSinceEpoch,
51 equals(isolate.pauseEvent.timestamp.millisecondsSinceEpoch));
52
53 completer = new Completer();
54 stream = await isolate.vm.getEventStream(VM.kDebugStream);
55 subscription = stream.listen((ServiceEvent event) {
56 if (event.kind == ServiceEvent.kPauseExit) {
57 print('Received PauseExit');
58 subscription.cancel();
59 completer.complete();
60 }
61 });
62
63 print('Resuming...');
64 isolate.resume();
65
66 // Wait for the isolate to hit PauseExit.
42 await completer.future; 67 await completer.future;
43 }
44 print('Done waiting for pause event.');
45 68
46 // Grab the timestamp. 69 // Grab the timestamp.
47 var pausetime1 = isolate.pauseEvent.timestamp; 70 var pausetime2 = isolate.pauseEvent.timestamp;
48 expect(pausetime1, isNotNull); 71 expect(pausetime2, isNotNull);
49 // Reload the isolate. 72 // Reload the isolate.
50 await isolate.reload(); 73 await isolate.reload();
51 // Verify that it is the same. 74 // Verify that it is the same.
52 expect(pausetime1.millisecondsSinceEpoch, 75 expect(pausetime2.millisecondsSinceEpoch,
53 equals(isolate.pauseEvent.timestamp.millisecondsSinceEpoch)); 76 equals(isolate.pauseEvent.timestamp.millisecondsSinceEpoch));
54 77 expect(pausetime2.millisecondsSinceEpoch,
55 completer = new Completer(); 78 greaterThan(pausetime1.millisecondsSinceEpoch));
56 stream = await isolate.vm.getEventStream(VM.kDebugStream); 79 },
57 subscription = stream.listen((ServiceEvent event) {
58 if (event.kind == ServiceEvent.kPauseExit) {
59 print('Received PauseExit');
60 subscription.cancel();
61 completer.complete();
62 }
63 });
64
65 print('Resuming...');
66 isolate.resume();
67
68 // Wait for the isolate to hit PauseExit.
69 await completer.future;
70
71 // Grab the timestamp.
72 var pausetime2 = isolate.pauseEvent.timestamp;
73 expect(pausetime2, isNotNull);
74 // Reload the isolate.
75 await isolate.reload();
76 // Verify that it is the same.
77 expect(pausetime2.millisecondsSinceEpoch,
78 equals(isolate.pauseEvent.timestamp.millisecondsSinceEpoch));
79 expect(pausetime2.millisecondsSinceEpoch,
80 greaterThan(pausetime1.millisecondsSinceEpoch));
81 },
82
83 ]; 80 ];
84 81
85 main(args) => runIsolateTests(args, tests, 82 main(args) => runIsolateTests(args, tests,
86 testeeConcurrent: testMain, 83 testeeConcurrent: testMain,
87 pause_on_start: true, 84 pause_on_start: true,
88 pause_on_exit: true, 85 pause_on_exit: true,
89 verbose_vm: true, 86 verbose_vm: true,
90 extraArgs: [ '--trace-service', 87 extraArgs: ['--trace-service', '--trace-service-verbose']);
91 '--trace-service-verbose' ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698