| 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 --checked |
| 4 | 5 |
| 5 import 'package:observatory/service_io.dart'; | 6 import 'package:observatory/service_io.dart'; |
| 6 import 'package:unittest/unittest.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 helper(i) { | 11 void helper(i) { |
| 11 print(i); | 12 print(i); |
| 12 } | 13 } |
| 13 | 14 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 Completer completer = new Completer(); | 95 Completer completer = new Completer(); |
| 95 List events = []; | 96 List events = []; |
| 96 var subscription; | 97 var subscription; |
| 97 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { | 98 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { |
| 98 if (event.eventType == ServiceEvent.kPauseBreakpoint) { | 99 if (event.eventType == ServiceEvent.kPauseBreakpoint) { |
| 99 print('Breakpoint reached'); | 100 print('Breakpoint reached'); |
| 100 subscription.cancel(); | 101 subscription.cancel(); |
| 101 completer.complete(); | 102 completer.complete(); |
| 102 } | 103 } |
| 103 }); | 104 }); |
| 104 | 105 |
| 105 return isolate.stepInto().then((isolate) { | 106 return isolate.stepInto().then((isolate) { |
| 106 return completer.future; // Wait for breakpoint events. | 107 return completer.future; // Wait for breakpoint events. |
| 107 }); | 108 }); |
| 108 }, | 109 }, |
| 109 | 110 |
| 110 // Get the stack trace again. We are in 'helper'. | 111 // Get the stack trace again. We are in 'helper'. |
| 111 (Isolate isolate) { | 112 (Isolate isolate) { |
| 112 return isolate.getStack().then((ServiceMap stack) { | 113 return isolate.getStack().then((ServiceMap stack) { |
| 113 expect(stack.type, equals('Stack')); | 114 expect(stack.type, equals('Stack')); |
| 114 expect(stack['frames'].length, greaterThanOrEqualTo(2)); | 115 expect(stack['frames'].length, greaterThanOrEqualTo(2)); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 Completer completer = new Completer(); | 159 Completer completer = new Completer(); |
| 159 List events = []; | 160 List events = []; |
| 160 var subscription; | 161 var subscription; |
| 161 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { | 162 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { |
| 162 if (event.eventType == ServiceEvent.kPauseBreakpoint) { | 163 if (event.eventType == ServiceEvent.kPauseBreakpoint) { |
| 163 print('Breakpoint reached'); | 164 print('Breakpoint reached'); |
| 164 subscription.cancel(); | 165 subscription.cancel(); |
| 165 completer.complete(); | 166 completer.complete(); |
| 166 } | 167 } |
| 167 }); | 168 }); |
| 168 | 169 |
| 169 // Find a specific function. | 170 // Find a specific function. |
| 170 ServiceFunction function = isolate.rootLib.functions.firstWhere( | 171 ServiceFunction function = isolate.rootLib.functions.firstWhere( |
| 171 (f) => f.name == 'helper'); | 172 (f) => f.name == 'helper'); |
| 172 expect(function, isNotNull); | 173 expect(function, isNotNull); |
| 173 | 174 |
| 174 // Add the breakpoint at function entry | 175 // Add the breakpoint at function entry |
| 175 return isolate.addBreakpointAtEntry(function).then((result) { | 176 return isolate.addBreakpointAtEntry(function).then((result) { |
| 176 expect(result is Breakpoint, isTrue); | 177 expect(result is Breakpoint, isTrue); |
| 177 Breakpoint bpt = result; | 178 Breakpoint bpt = result; |
| 178 expect(bpt.type, equals('Breakpoint')); | 179 expect(bpt.type, equals('Breakpoint')); |
| 179 expect(bpt.script.name, equals('debugging_test.dart')); | 180 expect(bpt.script.name, equals('debugging_test.dart')); |
| 180 expect(bpt.tokenPos, equals(28)); | 181 expect(bpt.tokenPos, equals(28)); |
| 181 expect(isolate.breakpoints.length, equals(1)); | 182 expect(isolate.breakpoints.length, equals(1)); |
| 182 return completer.future; // Wait for breakpoint events. | 183 return completer.future; // Wait for breakpoint events. |
| 183 }); | 184 }); |
| 184 }, | 185 }, |
| 185 | 186 |
| 186 ]; | 187 ]; |
| 187 | 188 |
| 188 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); | 189 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); |
| OLD | NEW |