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=--compile-all --error_on_bad_type --error_on_bad_override | 4 // VMOptions=--compile-all --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 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 subscription.cancel(); | 48 subscription.cancel(); |
49 completer.complete(); | 49 completer.complete(); |
50 } | 50 } |
51 }); | 51 }); |
52 isolate.resume(); | 52 isolate.resume(); |
53 await completer.future; | 53 await completer.future; |
54 }, | 54 }, |
55 | 55 |
56 // Add breakpoint | 56 // Add breakpoint |
57 (Isolate isolate) async { | 57 (Isolate isolate) async { |
58 await isolate.rootLib.load(); | 58 await isolate.rootLibrary.load(); |
59 | 59 |
60 // Set up a listener to wait for breakpoint events. | 60 // Set up a listener to wait for breakpoint events. |
61 Completer completer = new Completer(); | 61 Completer completer = new Completer(); |
62 var subscription; | 62 var subscription; |
63 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { | 63 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { |
64 if (event.eventType == ServiceEvent.kPauseBreakpoint) { | 64 if (event.eventType == ServiceEvent.kPauseBreakpoint) { |
65 print('Breakpoint reached'); | 65 print('Breakpoint reached'); |
66 subscription.cancel(); | 66 subscription.cancel(); |
67 completer.complete(); | 67 completer.complete(); |
68 } | 68 } |
69 }); | 69 }); |
70 | 70 |
71 var script = isolate.rootLib.scripts[0]; | 71 var script = isolate.rootLibrary.scripts[0]; |
72 await script.load(); | 72 await script.load(); |
73 | 73 |
74 // Add the breakpoint. | 74 // Add the breakpoint. |
75 var result = await isolate.addBreakpoint(script, 15); | 75 var result = await isolate.addBreakpoint(script, 15); |
76 expect(result is Breakpoint, isTrue); | 76 expect(result is Breakpoint, isTrue); |
77 Breakpoint bpt = result; | 77 Breakpoint bpt = result; |
78 expect(bpt.type, equals('Breakpoint')); | 78 expect(bpt.type, equals('Breakpoint')); |
79 expect(bpt.script.id, equals(script.id)); | 79 expect(bpt.script.id, equals(script.id)); |
80 expect(bpt.script.tokenToLine(bpt.tokenPos), equals(15)); | 80 expect(bpt.script.tokenToLine(bpt.tokenPos), equals(15)); |
81 expect(isolate.breakpoints.length, equals(1)); | 81 expect(isolate.breakpoints.length, equals(1)); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 var subscription; | 163 var subscription; |
164 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { | 164 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { |
165 if (event.eventType == ServiceEvent.kPauseBreakpoint) { | 165 if (event.eventType == ServiceEvent.kPauseBreakpoint) { |
166 print('Breakpoint reached'); | 166 print('Breakpoint reached'); |
167 subscription.cancel(); | 167 subscription.cancel(); |
168 completer.complete(); | 168 completer.complete(); |
169 } | 169 } |
170 }); | 170 }); |
171 | 171 |
172 // Find a specific function. | 172 // Find a specific function. |
173 ServiceFunction function = isolate.rootLib.functions.firstWhere( | 173 ServiceFunction function = isolate.rootLibrary.functions.firstWhere( |
174 (f) => f.name == 'periodicTask'); | 174 (f) => f.name == 'periodicTask'); |
175 expect(function, isNotNull); | 175 expect(function, isNotNull); |
176 | 176 |
177 // Add the breakpoint at function entry | 177 // Add the breakpoint at function entry |
178 var result = await isolate.addBreakpointAtEntry(function); | 178 var result = await isolate.addBreakpointAtEntry(function); |
179 expect(result is Breakpoint, isTrue); | 179 expect(result is Breakpoint, isTrue); |
180 Breakpoint bpt = result; | 180 Breakpoint bpt = result; |
181 expect(bpt.type, equals('Breakpoint')); | 181 expect(bpt.type, equals('Breakpoint')); |
182 expect(bpt.script.name, equals('debugging_test.dart')); | 182 expect(bpt.script.name, equals('debugging_test.dart')); |
183 expect(bpt.script.tokenToLine(bpt.tokenPos), equals(14)); | 183 expect(bpt.script.tokenToLine(bpt.tokenPos), equals(14)); |
184 expect(isolate.breakpoints.length, equals(1)); | 184 expect(isolate.breakpoints.length, equals(1)); |
185 | 185 |
186 await completer.future; // Wait for breakpoint events. | 186 await completer.future; // Wait for breakpoint events. |
187 }, | 187 }, |
188 | 188 |
189 // We are now at line 14. | 189 // We are now at line 14. |
190 (Isolate isolate) async { | 190 (Isolate isolate) async { |
191 ServiceMap stack = await isolate.getStack(); | 191 ServiceMap stack = await isolate.getStack(); |
192 expect(stack.type, equals('Stack')); | 192 expect(stack.type, equals('Stack')); |
193 expect(stack['frames'].length, greaterThanOrEqualTo(1)); | 193 expect(stack['frames'].length, greaterThanOrEqualTo(1)); |
194 | 194 |
195 Script script = stack['frames'][0]['script']; | 195 Script script = stack['frames'][0]['script']; |
196 expect(script.name,endsWith('debugging_test.dart')); | 196 expect(script.name,endsWith('debugging_test.dart')); |
197 expect(script.tokenToLine(stack['frames'][0]['tokenPos']), equals(14)); | 197 expect(script.tokenToLine(stack['frames'][0]['tokenPos']), equals(14)); |
198 }, | 198 }, |
199 | 199 |
200 ]; | 200 ]; |
201 | 201 |
202 main(args) => runIsolateTests(args, tests, testeeBefore: startTimer); | 202 main(args) => runIsolateTests(args, tests, testeeBefore: startTimer); |
OLD | NEW |