OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 // VMOptions=--compile-all --error_on_bad_type --error_on_bad_override --checked |
5 | 5 |
6 library test_helper; | 6 library test_helper; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:convert'; | 9 import 'dart:convert'; |
10 import 'dart:io'; | 10 import 'dart:io'; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 | 134 |
135 // Cancel the subscription and complete the completer when finished processing | 135 // Cancel the subscription and complete the completer when finished processing |
136 // events. | 136 // events. |
137 typedef void ServiceEventHandler(ServiceEvent event, | 137 typedef void ServiceEventHandler(ServiceEvent event, |
138 StreamSubscription subscription, | 138 StreamSubscription subscription, |
139 Completer completer); | 139 Completer completer); |
140 | 140 |
141 Future processServiceEvents(VM vm, ServiceEventHandler handler) { | 141 Future processServiceEvents(VM vm, |
| 142 String streamId, |
| 143 ServiceEventHandler handler) { |
142 Completer completer = new Completer(); | 144 Completer completer = new Completer(); |
143 var subscription; | 145 var subscription; |
144 subscription = vm.events.stream.listen((ServiceEvent event) { | 146 subscription = vm.getEventStream(streamId).listen((ServiceEvent event) { |
145 handler(event, subscription, completer); | 147 handler(event, subscription, completer); |
146 }); | 148 }); |
147 return completer.future; | 149 return completer.future; |
148 } | 150 } |
149 | 151 |
150 | 152 |
151 Future<Isolate> hasStoppedAtBreakpoint(Isolate isolate) { | 153 Future<Isolate> hasStoppedAtBreakpoint(Isolate isolate) { |
152 if ((isolate.pauseEvent != null) && | 154 if ((isolate.pauseEvent != null) && |
153 (isolate.pauseEvent.eventType == ServiceEvent.kPauseBreakpoint)) { | 155 (isolate.pauseEvent.eventType == ServiceEvent.kPauseBreakpoint)) { |
154 // Already waiting at a breakpoint. | 156 // Already waiting at a breakpoint. |
155 print('Breakpoint reached'); | 157 print('Breakpoint reached'); |
156 return new Future.value(isolate); | 158 return new Future.value(isolate); |
157 } | 159 } |
158 | 160 |
159 // Set up a listener to wait for breakpoint events. | 161 // Set up a listener to wait for breakpoint events. |
160 Completer completer = new Completer(); | 162 Completer completer = new Completer(); |
161 var subscription; | 163 var subscription; |
162 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { | 164 subscription = isolate.vm.debugEvents.listen((ServiceEvent event) { |
163 if (event.eventType == ServiceEvent.kPauseBreakpoint) { | 165 if (event.eventType == ServiceEvent.kPauseBreakpoint) { |
164 print('Breakpoint reached'); | 166 print('Breakpoint reached'); |
165 subscription.cancel(); | 167 subscription.cancel(); |
166 completer.complete(isolate); | 168 completer.complete(isolate); |
167 } | 169 } |
168 }); | 170 }); |
169 | 171 |
170 return completer.future; // Will complete when breakpoint hit. | 172 return completer.future; // Will complete when breakpoint hit. |
171 } | 173 } |
172 | 174 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 }, onError: (e, st) { | 208 }, onError: (e, st) { |
207 process.requestExit(); | 209 process.requestExit(); |
208 if (!_isWebSocketDisconnect(e)) { | 210 if (!_isWebSocketDisconnect(e)) { |
209 print('Unexpected exception in service tests: $e $st'); | 211 print('Unexpected exception in service tests: $e $st'); |
210 throw e; | 212 throw e; |
211 } | 213 } |
212 }); | 214 }); |
213 }); | 215 }); |
214 } | 216 } |
215 } | 217 } |
OLD | NEW |