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

Side by Side Diff: runtime/observatory/tests/service/steal_breakpoint_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 --steal-breakpoints 4 // VMOptions=--error_on_bad_type --error_on_bad_override --steal-breakpoints
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 int counter = 0; 11 int counter = 0;
12 12
13 void periodicTask(_) { 13 void periodicTask(_) {
14 counter++; // Line 14. We set our breakpoint here. 14 counter++; // Line 14. We set our breakpoint here.
15 if (counter % 1000 == 0) { 15 if (counter % 1000 == 0) {
16 print('counter = $counter'); 16 print('counter = $counter');
17 } 17 }
18 } 18 }
19 19
20 void startTimer() { 20 void startTimer() {
21 new Timer.periodic(const Duration(milliseconds:10), periodicTask); 21 new Timer.periodic(const Duration(milliseconds: 10), periodicTask);
22 } 22 }
23 23
24 var tests = [ 24 var tests = [
25 // Add a breakpoint and wait for it to be reached.
26 (Isolate isolate) async {
27 await isolate.rootLibrary.load();
25 28
26 // Add a breakpoint and wait for it to be reached. 29 // Set up a listener to wait for breakpoint events.
27 (Isolate isolate) async { 30 Completer completer = new Completer();
28 await isolate.rootLibrary.load(); 31 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
32 var subscription;
33 subscription = stream.listen((ServiceEvent event) {
34 if (event.kind == ServiceEvent.kPauseBreakpoint) {
35 print('Isolate paused at breakpoint');
36 subscription.cancel();
37 completer.complete();
38 }
39 });
29 40
30 // Set up a listener to wait for breakpoint events. 41 // Add the breakpoint.
31 Completer completer = new Completer(); 42 var script = isolate.rootLibrary.scripts[0];
32 var stream = await isolate.vm.getEventStream(VM.kDebugStream); 43 var result = await isolate.addBreakpoint(script, 14);
33 var subscription; 44 expect(result is Breakpoint, isTrue);
34 subscription = stream.listen((ServiceEvent event) {
35 if (event.kind == ServiceEvent.kPauseBreakpoint) {
36 print('Isolate paused at breakpoint');
37 subscription.cancel();
38 completer.complete();
39 }
40 });
41 45
42 // Add the breakpoint. 46 await completer.future; // Wait for breakpoint event to fire.
43 var script = isolate.rootLibrary.scripts[0]; 47 },
44 var result = await isolate.addBreakpoint(script, 14);
45 expect(result is Breakpoint, isTrue);
46
47 await completer.future; // Wait for breakpoint event to fire.
48 },
49 48
50 // We are at the breakpoint on line 14. 49 // We are at the breakpoint on line 14.
51 (Isolate isolate) async { 50 (Isolate isolate) async {
52 ServiceMap stack = await isolate.getStack(); 51 ServiceMap stack = await isolate.getStack();
53 expect(stack.type, equals('Stack')); 52 expect(stack.type, equals('Stack'));
54 expect(stack['frames'].length, greaterThanOrEqualTo(1)); 53 expect(stack['frames'].length, greaterThanOrEqualTo(1));
55 54
56 Script script = stack['frames'][0].location.script; 55 Script script = stack['frames'][0].location.script;
57 await script.load(); 56 await script.load();
58 expect(script.name,endsWith('steal_breakpoint_test.dart')); 57 expect(script.name, endsWith('steal_breakpoint_test.dart'));
59 expect(script.tokenToLine(stack['frames'][0].location.tokenPos), equals(14)); 58 expect(
60 }, 59 script.tokenToLine(stack['frames'][0].location.tokenPos), equals(14));
60 },
61 61
62 // Resume 62 // Resume
63 (Isolate isolate) async { 63 (Isolate isolate) async {
64 Completer completer = new Completer(); 64 Completer completer = new Completer();
65 var stream = await isolate.vm.getEventStream(VM.kDebugStream); 65 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
66 var subscription; 66 var subscription;
67 subscription = stream.listen((ServiceEvent event) { 67 subscription = stream.listen((ServiceEvent event) {
68 if (event.kind == ServiceEvent.kResume) { 68 if (event.kind == ServiceEvent.kResume) {
69 print('Isolate resumed'); 69 print('Isolate resumed');
70 subscription.cancel(); 70 subscription.cancel();
71 completer.complete(); 71 completer.complete();
72 } 72 }
73 }); 73 });
74 isolate.resume(); 74 isolate.resume();
75 await completer.future; 75 await completer.future;
76 }, 76 },
77
78 ]; 77 ];
79 78
80 main(args) => runIsolateTests(args, tests, testeeBefore: startTimer); 79 main(args) => runIsolateTests(args, tests, testeeBefore: startTimer);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698