| 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 | 4 |
| 5 import 'package:observatory/service_io.dart'; | 5 import 'package:observatory/service_io.dart'; |
| 6 import 'package:unittest/unittest.dart'; | 6 import 'package:unittest/unittest.dart'; |
| 7 import 'test_helper.dart'; | 7 import 'test_helper.dart'; |
| 8 import 'dart:async'; | 8 import 'dart:async'; |
| 9 | 9 |
| 10 void helper(i) { | 10 void helper(i) { |
| 11 print(i); | 11 print(i); |
| 12 } | 12 } |
| 13 | 13 |
| 14 void testFunction() { | 14 void testFunction() { |
| 15 int i = 0; | 15 int i = 0; |
| 16 while (true) { | 16 while (true) { |
| 17 if (++i % 100000000 == 0) { | 17 if (++i % 100000000 == 0) { |
| 18 helper(i); // line 18 | 18 helper(i); // line 18 |
| 19 } | 19 } |
| 20 } | 20 } |
| 21 } | 21 } |
| 22 | 22 |
| 23 var tests = [ | 23 var tests = [ |
| 24 | 24 |
| 25 // Pause | 25 // Pause |
| 26 (Isolate isolate) { | 26 (Isolate isolate) { |
| 27 Completer completer = new Completer(); | 27 Completer completer = new Completer(); |
| 28 isolate.vm.events.stream.listen((ServiceEvent event) { | 28 var subscription; |
| 29 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { |
| 29 if (event.eventType == ServiceEvent.kPauseInterrupted) { | 30 if (event.eventType == ServiceEvent.kPauseInterrupted) { |
| 31 subscription.cancel(); |
| 30 completer.complete(); | 32 completer.complete(); |
| 31 } | 33 } |
| 32 }); | 34 }); |
| 33 isolate.pause(); | 35 isolate.pause(); |
| 34 return completer.future; | 36 return completer.future; |
| 35 }, | 37 }, |
| 36 | 38 |
| 37 // Resume | 39 // Resume |
| 38 (Isolate isolate) { | 40 (Isolate isolate) { |
| 39 return isolate.resume().then((_) { | 41 Completer completer = new Completer(); |
| 40 expect(isolate.pauseEvent.eventType, equals(ServiceEvent.kResume)); | 42 var subscription; |
| 41 expect(isolate.running, isTrue); | 43 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { |
| 42 expect(isolate.paused, isFalse); | 44 if (event.eventType == ServiceEvent.kResume) { |
| 45 subscription.cancel(); |
| 46 completer.complete(); |
| 47 } |
| 43 }); | 48 }); |
| 49 isolate.resume(); |
| 50 return completer.future; |
| 44 }, | 51 }, |
| 45 | 52 |
| 46 // Add breakpoint | 53 // Add breakpoint |
| 47 (Isolate isolate) { | 54 (Isolate isolate) { |
| 48 return isolate.rootLib.load().then((_) { | 55 return isolate.rootLib.load().then((_) { |
| 49 // Set up a listener to wait for breakpoint events. | 56 // Set up a listener to wait for breakpoint events. |
| 50 Completer completer = new Completer(); | 57 Completer completer = new Completer(); |
| 51 List events = []; | 58 List events = []; |
| 52 var subscription; | 59 var subscription; |
| 53 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { | 60 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 133 |
| 127 expect(isolate.breakpoints.length, equals(1)); | 134 expect(isolate.breakpoints.length, equals(1)); |
| 128 var bpt = isolate.breakpoints.values.first; | 135 var bpt = isolate.breakpoints.values.first; |
| 129 return isolate.removeBreakpoint(bpt).then((_) { | 136 return isolate.removeBreakpoint(bpt).then((_) { |
| 130 return completer.future; | 137 return completer.future; |
| 131 }); | 138 }); |
| 132 }, | 139 }, |
| 133 | 140 |
| 134 // Resume | 141 // Resume |
| 135 (Isolate isolate) { | 142 (Isolate isolate) { |
| 136 return isolate.resume().then((_) { | 143 Completer completer = new Completer(); |
| 137 expect(isolate.pauseEvent.eventType, equals(ServiceEvent.kResume)); | 144 var subscription; |
| 138 expect(isolate.running, isTrue); | 145 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { |
| 139 expect(isolate.paused, isFalse); | 146 if (event.eventType == ServiceEvent.kResume) { |
| 147 subscription.cancel(); |
| 148 completer.complete(); |
| 149 } |
| 140 }); | 150 }); |
| 151 isolate.resume(); |
| 152 return completer.future; |
| 141 }, | 153 }, |
| 142 | 154 |
| 143 // Add breakpoint at function entry | 155 // Add breakpoint at function entry |
| 144 (Isolate isolate) { | 156 (Isolate isolate) { |
| 145 // Set up a listener to wait for breakpoint events. | 157 // Set up a listener to wait for breakpoint events. |
| 146 Completer completer = new Completer(); | 158 Completer completer = new Completer(); |
| 147 List events = []; | 159 List events = []; |
| 148 var subscription; | 160 var subscription; |
| 149 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { | 161 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { |
| 150 if (event.eventType == ServiceEvent.kPauseBreakpoint) { | 162 if (event.eventType == ServiceEvent.kPauseBreakpoint) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 167 expect(bpt.script.name, equals('debugging_test.dart')); | 179 expect(bpt.script.name, equals('debugging_test.dart')); |
| 168 expect(bpt.tokenPos, equals(29)); | 180 expect(bpt.tokenPos, equals(29)); |
| 169 expect(isolate.breakpoints.length, equals(1)); | 181 expect(isolate.breakpoints.length, equals(1)); |
| 170 return completer.future; // Wait for breakpoint events. | 182 return completer.future; // Wait for breakpoint events. |
| 171 }); | 183 }); |
| 172 }, | 184 }, |
| 173 | 185 |
| 174 ]; | 186 ]; |
| 175 | 187 |
| 176 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); | 188 main(args) => runIsolateTests(args, tests, testeeConcurrent: testFunction); |
| OLD | NEW |