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

Side by Side Diff: runtime/observatory/tests/service/debugging_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/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++; 14 counter++;
15 counter++; // Line 15. We set our breakpoint here. 15 counter++; // Line 15. We set our breakpoint here.
16 counter++; 16 counter++;
17 if (counter % 300 == 0) { 17 if (counter % 300 == 0) {
18 print('counter = $counter'); 18 print('counter = $counter');
19 } 19 }
20 } 20 }
21 21
22 void startTimer() { 22 void startTimer() {
23 new Timer.periodic(const Duration(milliseconds:10), periodicTask); 23 new Timer.periodic(const Duration(milliseconds: 10), periodicTask);
24 } 24 }
25 25
26 var tests = [ 26 var tests = [
27
28 // Pause 27 // Pause
29 (Isolate isolate) async { 28 (Isolate isolate) async {
30 Completer completer = new Completer(); 29 Completer completer = new Completer();
31 var stream = await isolate.vm.getEventStream(VM.kDebugStream); 30 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
32 var subscription; 31 var subscription;
33 subscription = stream.listen((ServiceEvent event) { 32 subscription = stream.listen((ServiceEvent event) {
34 if (event.kind == ServiceEvent.kPauseInterrupted) { 33 if (event.kind == ServiceEvent.kPauseInterrupted) {
35 subscription.cancel(); 34 subscription.cancel();
36 completer.complete(); 35 completer.complete();
37 } 36 }
38 }); 37 });
39 isolate.pause(); 38 isolate.pause();
40 await completer.future; 39 await completer.future;
41 }, 40 },
42 41
43 // Resume 42 // Resume
44 (Isolate isolate) async { 43 (Isolate isolate) async {
45 Completer completer = new Completer(); 44 Completer completer = new Completer();
46 var stream = await isolate.vm.getEventStream(VM.kDebugStream); 45 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
47 var subscription; 46 var subscription;
48 subscription = stream.listen((ServiceEvent event) { 47 subscription = stream.listen((ServiceEvent event) {
49 if (event.kind == ServiceEvent.kResume) { 48 if (event.kind == ServiceEvent.kResume) {
50 subscription.cancel(); 49 subscription.cancel();
51 completer.complete(); 50 completer.complete();
52 } 51 }
53 }); 52 });
54 isolate.resume(); 53 isolate.resume();
55 await completer.future; 54 await completer.future;
56 }, 55 },
57 56
58 // Add breakpoint 57 // Add breakpoint
59 (Isolate isolate) async { 58 (Isolate isolate) async {
60 await isolate.rootLibrary.load(); 59 await isolate.rootLibrary.load();
61 60
62 // Set up a listener to wait for breakpoint events. 61 // Set up a listener to wait for breakpoint events.
63 Completer completer = new Completer(); 62 Completer completer = new Completer();
64 var stream = await isolate.vm.getEventStream(VM.kDebugStream); 63 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
65 var subscription; 64 var subscription;
66 subscription = stream.listen((ServiceEvent event) { 65 subscription = stream.listen((ServiceEvent event) {
67 if (event.kind == ServiceEvent.kPauseBreakpoint) { 66 if (event.kind == ServiceEvent.kPauseBreakpoint) {
68 print('Breakpoint reached'); 67 print('Breakpoint reached');
69 subscription.cancel(); 68 subscription.cancel();
70 completer.complete(); 69 completer.complete();
71 } 70 }
72 }); 71 });
73 72
74 var script = isolate.rootLibrary.scripts[0]; 73 var script = isolate.rootLibrary.scripts[0];
75 await script.load(); 74 await script.load();
76 75
77 // Add the breakpoint. 76 // Add the breakpoint.
78 var result = await isolate.addBreakpoint(script, 15); 77 var result = await isolate.addBreakpoint(script, 15);
79 expect(result is Breakpoint, isTrue); 78 expect(result is Breakpoint, isTrue);
80 Breakpoint bpt = result; 79 Breakpoint bpt = result;
81 expect(bpt.type, equals('Breakpoint')); 80 expect(bpt.type, equals('Breakpoint'));
82 expect(bpt.location.script.id, equals(script.id)); 81 expect(bpt.location.script.id, equals(script.id));
83 expect(bpt.location.script.tokenToLine(bpt.location.tokenPos), equals(15)); 82 expect(bpt.location.script.tokenToLine(bpt.location.tokenPos), equals(15));
84 expect(isolate.breakpoints.length, equals(1)); 83 expect(isolate.breakpoints.length, equals(1));
85 84
86 await completer.future; // Wait for breakpoint events. 85 await completer.future; // Wait for breakpoint events.
87 }, 86 },
88 87
89 // We are at the breakpoint on line 15. 88 // We are at the breakpoint on line 15.
90 (Isolate isolate) async { 89 (Isolate isolate) async {
91 ServiceMap stack = await isolate.getStack(); 90 ServiceMap stack = await isolate.getStack();
92 expect(stack.type, equals('Stack')); 91 expect(stack.type, equals('Stack'));
93 expect(stack['frames'].length, greaterThanOrEqualTo(1)); 92 expect(stack['frames'].length, greaterThanOrEqualTo(1));
94 93
95 Script script = stack['frames'][0].location.script; 94 Script script = stack['frames'][0].location.script;
96 expect(script.name,endsWith('debugging_test.dart')); 95 expect(script.name, endsWith('debugging_test.dart'));
97 expect(script.tokenToLine(stack['frames'][0].location.tokenPos), equals(15)); 96 expect(
98 }, 97 script.tokenToLine(stack['frames'][0].location.tokenPos), equals(15));
98 },
99 99
100 // Stepping 100 // Stepping
101 (Isolate isolate) async { 101 (Isolate isolate) async {
102 // Set up a listener to wait for breakpoint events. 102 // Set up a listener to wait for breakpoint events.
103 Completer completer = new Completer(); 103 Completer completer = new Completer();
104 var stream = await isolate.vm.getEventStream(VM.kDebugStream); 104 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
105 var subscription; 105 var subscription;
106 subscription = stream.listen((ServiceEvent event) { 106 subscription = stream.listen((ServiceEvent event) {
107 if (event.kind == ServiceEvent.kPauseBreakpoint) { 107 if (event.kind == ServiceEvent.kPauseBreakpoint) {
108 print('Breakpoint reached'); 108 print('Breakpoint reached');
109 subscription.cancel(); 109 subscription.cancel();
110 completer.complete(); 110 completer.complete();
111 } 111 }
112 }); 112 });
113 113
114 await isolate.stepOver(); 114 await isolate.stepOver();
115 await completer.future; // Wait for breakpoint events. 115 await completer.future; // Wait for breakpoint events.
116 }, 116 },
117 117
118 // We are now at line 16. 118 // We are now at line 16.
119 (Isolate isolate) async { 119 (Isolate isolate) async {
120 ServiceMap stack = await isolate.getStack(); 120 ServiceMap stack = await isolate.getStack();
121 expect(stack.type, equals('Stack')); 121 expect(stack.type, equals('Stack'));
122 expect(stack['frames'].length, greaterThanOrEqualTo(1)); 122 expect(stack['frames'].length, greaterThanOrEqualTo(1));
123 123
124 Script script = stack['frames'][0].location.script; 124 Script script = stack['frames'][0].location.script;
125 expect(script.name,endsWith('debugging_test.dart')); 125 expect(script.name, endsWith('debugging_test.dart'));
126 expect(script.tokenToLine(stack['frames'][0].location.tokenPos), equals(16)); 126 expect(
127 }, 127 script.tokenToLine(stack['frames'][0].location.tokenPos), equals(16));
128 },
128 129
129 // Remove breakpoint 130 // Remove breakpoint
130 (Isolate isolate) async { 131 (Isolate isolate) async {
131 // Set up a listener to wait for breakpoint events. 132 // Set up a listener to wait for breakpoint events.
132 Completer completer = new Completer(); 133 Completer completer = new Completer();
133 var stream = await isolate.vm.getEventStream(VM.kDebugStream); 134 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
134 var subscription; 135 var subscription;
135 subscription = stream.listen((ServiceEvent event) { 136 subscription = stream.listen((ServiceEvent event) {
136 if (event.kind == ServiceEvent.kBreakpointRemoved) { 137 if (event.kind == ServiceEvent.kBreakpointRemoved) {
137 print('Breakpoint removed'); 138 print('Breakpoint removed');
138 expect(isolate.breakpoints.length, equals(0)); 139 expect(isolate.breakpoints.length, equals(0));
139 subscription.cancel(); 140 subscription.cancel();
140 completer.complete(); 141 completer.complete();
141 } 142 }
142 }); 143 });
143 144
144 expect(isolate.breakpoints.length, equals(1)); 145 expect(isolate.breakpoints.length, equals(1));
145 var bpt = isolate.breakpoints.values.first; 146 var bpt = isolate.breakpoints.values.first;
146 await isolate.removeBreakpoint(bpt); 147 await isolate.removeBreakpoint(bpt);
147 await completer.future; 148 await completer.future;
148 }, 149 },
149 150
150 // Resume 151 // Resume
151 (Isolate isolate) async { 152 (Isolate isolate) async {
152 Completer completer = new Completer(); 153 Completer completer = new Completer();
153 var stream = await isolate.vm.getEventStream(VM.kDebugStream); 154 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
154 var subscription; 155 var subscription;
155 subscription = stream.listen((ServiceEvent event) { 156 subscription = stream.listen((ServiceEvent event) {
156 if (event.kind == ServiceEvent.kResume) { 157 if (event.kind == ServiceEvent.kResume) {
157 subscription.cancel(); 158 subscription.cancel();
158 completer.complete(); 159 completer.complete();
159 } 160 }
160 }); 161 });
161 isolate.resume(); 162 isolate.resume();
162 await completer.future; 163 await completer.future;
163 }, 164 },
164 165
165 // Add breakpoint at function entry 166 // Add breakpoint at function entry
166 (Isolate isolate) async { 167 (Isolate isolate) async {
167 // Set up a listener to wait for breakpoint events. 168 // Set up a listener to wait for breakpoint events.
168 Completer completer = new Completer(); 169 Completer completer = new Completer();
169 var stream = await isolate.vm.getEventStream(VM.kDebugStream); 170 var stream = await isolate.vm.getEventStream(VM.kDebugStream);
170 var subscription; 171 var subscription;
171 subscription = stream.listen((ServiceEvent event) { 172 subscription = stream.listen((ServiceEvent event) {
172 if (event.kind == ServiceEvent.kPauseBreakpoint) { 173 if (event.kind == ServiceEvent.kPauseBreakpoint) {
173 print('Breakpoint reached'); 174 print('Breakpoint reached');
174 subscription.cancel(); 175 subscription.cancel();
175 completer.complete(); 176 completer.complete();
176 } 177 }
177 }); 178 });
178 179
179 // Find a specific function. 180 // Find a specific function.
180 ServiceFunction function = isolate.rootLibrary.functions.firstWhere( 181 ServiceFunction function = isolate.rootLibrary.functions
181 (f) => f.name == 'periodicTask'); 182 .firstWhere((f) => f.name == 'periodicTask');
182 expect(function, isNotNull); 183 expect(function, isNotNull);
183 184
184 // Add the breakpoint at function entry 185 // Add the breakpoint at function entry
185 var result = await isolate.addBreakpointAtEntry(function); 186 var result = await isolate.addBreakpointAtEntry(function);
186 expect(result is Breakpoint, isTrue); 187 expect(result is Breakpoint, isTrue);
187 Breakpoint bpt = result; 188 Breakpoint bpt = result;
188 expect(bpt.type, equals('Breakpoint')); 189 expect(bpt.type, equals('Breakpoint'));
189 expect(bpt.location.script.name, equals('debugging_test.dart')); 190 expect(bpt.location.script.name, equals('debugging_test.dart'));
190 expect(bpt.location.script.tokenToLine(bpt.location.tokenPos), equals(13)); 191 expect(bpt.location.script.tokenToLine(bpt.location.tokenPos), equals(13));
191 expect(isolate.breakpoints.length, equals(1)); 192 expect(isolate.breakpoints.length, equals(1));
192 193
193 await completer.future; // Wait for breakpoint events. 194 await completer.future; // Wait for breakpoint events.
194 }, 195 },
195 196
196 // We are now at line 13. 197 // We are now at line 13.
197 (Isolate isolate) async { 198 (Isolate isolate) async {
198 ServiceMap stack = await isolate.getStack(); 199 ServiceMap stack = await isolate.getStack();
199 expect(stack.type, equals('Stack')); 200 expect(stack.type, equals('Stack'));
200 expect(stack['frames'].length, greaterThanOrEqualTo(1)); 201 expect(stack['frames'].length, greaterThanOrEqualTo(1));
201 202
202 Script script = stack['frames'][0].location.script; 203 Script script = stack['frames'][0].location.script;
203 expect(script.name,endsWith('debugging_test.dart')); 204 expect(script.name, endsWith('debugging_test.dart'));
204 expect(script.tokenToLine(stack['frames'][0].location.tokenPos), equals(13)); 205 expect(
205 }, 206 script.tokenToLine(stack['frames'][0].location.tokenPos), equals(13));
206 207 },
207 ]; 208 ];
208 209
209 main(args) => runIsolateTests(args, tests, testeeBefore: startTimer); 210 main(args) => runIsolateTests(args, tests, testeeBefore: startTimer);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698