| 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 | 9 |
| 10 genRepeater(value) { | 10 genRepeater(value) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 r3_named(y: 'Not a closure', x: 'Not a closure'); | 47 r3_named(y: 'Not a closure', x: 'Not a closure'); |
| 48 } | 48 } |
| 49 | 49 |
| 50 | 50 |
| 51 var tests = [ | 51 var tests = [ |
| 52 (Isolate isolate) async { | 52 (Isolate isolate) async { |
| 53 var rootLib = await isolate.rootLibrary.load(); | 53 var rootLib = await isolate.rootLibrary.load(); |
| 54 | 54 |
| 55 var breaksHit = 0; | 55 var breaksHit = 0; |
| 56 | 56 |
| 57 var subscription; | 57 var subscriptionFuture; |
| 58 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { | 58 subscriptionFuture = isolate.vm.getDebugEventStream().then((stream) { |
| 59 if (event.kind == ServiceEvent.kPauseBreakpoint) { | 59 return stream.listen((ServiceEvent event) { |
| 60 print("Hit breakpoint ${event.breakpoint}"); | 60 if (event.kind == ServiceEvent.kPauseBreakpoint) { |
| 61 breaksHit++; | 61 print("Hit breakpoint ${event.breakpoint}"); |
| 62 isolate.resume(); | 62 breaksHit++; |
| 63 } | 63 isolate.resume(); |
| 64 } |
| 65 }); |
| 64 }); | 66 }); |
| 65 | 67 |
| 66 valueOfField(String name) async { | 68 valueOfField(String name) async { |
| 67 var field = rootLib.variables.singleWhere((v) => v.name == name); | 69 var field = rootLib.variables.singleWhere((v) => v.name == name); |
| 68 await field.load(); | 70 await field.load(); |
| 69 return field.staticValue; | 71 return field.staticValue; |
| 70 | 72 |
| 71 } | 73 } |
| 72 var r1Ref = await valueOfField('r1'); | 74 var r1Ref = await valueOfField('r1'); |
| 73 | 75 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 84 | 86 |
| 85 await isolate.removeBreakpoint(bpt1); | 87 await isolate.removeBreakpoint(bpt1); |
| 86 print("Removed breakpoint $bpt1"); | 88 print("Removed breakpoint $bpt1"); |
| 87 print("testeeDo()"); | 89 print("testeeDo()"); |
| 88 await r1Ref.reload(); | 90 await r1Ref.reload(); |
| 89 expect(r1Ref.activationBreakpoint, equals(null)); | 91 expect(r1Ref.activationBreakpoint, equals(null)); |
| 90 res = await rootLib.evaluate("testeeDo()"); | 92 res = await rootLib.evaluate("testeeDo()"); |
| 91 expect(res is Instance, isTrue); // Not error. | 93 expect(res is Instance, isTrue); // Not error. |
| 92 expect(breaksHit, equals(1)); | 94 expect(breaksHit, equals(1)); |
| 93 | 95 |
| 94 await subscription.cancel(); | 96 await (await subscriptionFuture).cancel(); |
| 95 }, | 97 }, |
| 96 | 98 |
| 97 (Isolate isolate) async { | 99 (Isolate isolate) async { |
| 98 var rootLib = await isolate.rootLibrary.load(); | 100 var rootLib = await isolate.rootLibrary.load(); |
| 99 | 101 |
| 100 var breaksHit = 0; | 102 var breaksHit = 0; |
| 101 | 103 |
| 102 var subscription; | 104 var subscriptionFuture; |
| 103 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { | 105 subscriptionFuture = isolate.vm.getDebugEventStream().then((stream) { |
| 104 if (event.kind == ServiceEvent.kPauseBreakpoint) { | 106 return stream.listen((ServiceEvent event) { |
| 105 print("Hit breakpoint ${event.breakpoint}"); | 107 if (event.kind == ServiceEvent.kPauseBreakpoint) { |
| 106 breaksHit++; | 108 print("Hit breakpoint ${event.breakpoint}"); |
| 107 isolate.resume(); | 109 breaksHit++; |
| 108 } | 110 isolate.resume(); |
| 111 } |
| 112 }); |
| 109 }); | 113 }); |
| 110 | 114 |
| 111 valueOfField(String name) async { | 115 valueOfField(String name) async { |
| 112 var field = rootLib.variables.singleWhere((v) => v.name == name); | 116 var field = rootLib.variables.singleWhere((v) => v.name == name); |
| 113 await field.load(); | 117 await field.load(); |
| 114 return field.staticValue; | 118 return field.staticValue; |
| 115 } | 119 } |
| 116 var r1Ref = await valueOfField('r1_named'); | 120 var r1Ref = await valueOfField('r1_named'); |
| 117 | 121 |
| 118 var bpt1 = await isolate.addBreakOnActivation(r1Ref); | 122 var bpt1 = await isolate.addBreakOnActivation(r1Ref); |
| 119 print("Added breakpoint $bpt1"); | 123 print("Added breakpoint $bpt1"); |
| 120 expect(bpt1 is Breakpoint, isTrue); | 124 expect(bpt1 is Breakpoint, isTrue); |
| 121 expect(breaksHit, equals(0)); | 125 expect(breaksHit, equals(0)); |
| 122 await r1Ref.reload(); | 126 await r1Ref.reload(); |
| 123 expect(r1Ref.activationBreakpoint, equals(bpt1)); | 127 expect(r1Ref.activationBreakpoint, equals(bpt1)); |
| 124 print("testeeDoNamed()"); | 128 print("testeeDoNamed()"); |
| 125 var res = await rootLib.evaluate("testeeDoNamed()"); | 129 var res = await rootLib.evaluate("testeeDoNamed()"); |
| 126 expect(res is Instance, isTrue); // Not error. | 130 expect(res is Instance, isTrue); // Not error. |
| 127 expect(breaksHit, equals(1)); | 131 expect(breaksHit, equals(1)); |
| 128 | 132 |
| 129 await isolate.removeBreakpoint(bpt1); | 133 await isolate.removeBreakpoint(bpt1); |
| 130 print("Removed breakpoint $bpt1"); | 134 print("Removed breakpoint $bpt1"); |
| 131 await r1Ref.reload(); | 135 await r1Ref.reload(); |
| 132 expect(r1Ref.activationBreakpoint, equals(null)); | 136 expect(r1Ref.activationBreakpoint, equals(null)); |
| 133 print("testeeDoNamed()"); | 137 print("testeeDoNamed()"); |
| 134 res = await rootLib.evaluate("testeeDoNamed()"); | 138 res = await rootLib.evaluate("testeeDoNamed()"); |
| 135 expect(res is Instance, isTrue); // Not error. | 139 expect(res is Instance, isTrue); // Not error. |
| 136 expect(breaksHit, equals(1)); | 140 expect(breaksHit, equals(1)); |
| 137 | 141 |
| 138 await subscription.cancel(); | 142 await (await subscriptionFuture).cancel(); |
| 139 }, | 143 }, |
| 140 | 144 |
| 141 (Isolate isolate) async { | 145 (Isolate isolate) async { |
| 142 var rootLib = await isolate.rootLibrary.load(); | 146 var rootLib = await isolate.rootLibrary.load(); |
| 143 | 147 |
| 144 var breaksHit = 0; | 148 var breaksHit = 0; |
| 145 | 149 |
| 146 var subscription; | 150 var subscriptionFuture; |
| 147 subscription = isolate.vm.events.stream.listen((ServiceEvent event) { | 151 subscriptionFuture = isolate.vm.getDebugEventStream().then((stream) { |
| 148 if (event.kind == ServiceEvent.kPauseBreakpoint) { | 152 return stream.listen((ServiceEvent event) { |
| 149 print("Hit breakpoint ${event.breakpoint}"); | 153 if (event.kind == ServiceEvent.kPauseBreakpoint) { |
| 150 breaksHit++; | 154 print("Hit breakpoint ${event.breakpoint}"); |
| 151 isolate.resume(); | 155 breaksHit++; |
| 152 } | 156 isolate.resume(); |
| 157 } |
| 158 }); |
| 153 }); | 159 }); |
| 154 | 160 |
| 155 valueOfField(String name) async { | 161 valueOfField(String name) async { |
| 156 var field = rootLib.variables.singleWhere((v) => v.name == name); | 162 var field = rootLib.variables.singleWhere((v) => v.name == name); |
| 157 await field.load(); | 163 await field.load(); |
| 158 return field.staticValue; | 164 return field.staticValue; |
| 159 } | 165 } |
| 160 var r1Ref = await valueOfField('r1'); | 166 var r1Ref = await valueOfField('r1'); |
| 161 var r2Ref = await valueOfField('r2'); | 167 var r2Ref = await valueOfField('r2'); |
| 162 | 168 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 193 | 199 |
| 194 await isolate.removeBreakpoint(bpt2); | 200 await isolate.removeBreakpoint(bpt2); |
| 195 print("Removed breakpoint $bpt2"); | 201 print("Removed breakpoint $bpt2"); |
| 196 await r2Ref.reload(); | 202 await r2Ref.reload(); |
| 197 expect(r2Ref.activationBreakpoint, equals(null)); | 203 expect(r2Ref.activationBreakpoint, equals(null)); |
| 198 print("testeeDo()"); | 204 print("testeeDo()"); |
| 199 res = await rootLib.evaluate("testeeDo()"); | 205 res = await rootLib.evaluate("testeeDo()"); |
| 200 expect(res is Instance, isTrue); // Not error. | 206 expect(res is Instance, isTrue); // Not error. |
| 201 expect(breaksHit, equals(4)); | 207 expect(breaksHit, equals(4)); |
| 202 | 208 |
| 203 await subscription.cancel(); | 209 await (await subscriptionFuture).cancel(); |
| 204 }, | 210 }, |
| 205 | 211 |
| 206 ]; | 212 ]; |
| 207 | 213 |
| 208 main(args) => runIsolateTests(args, tests, testeeBefore: testeeSetup); | 214 main(args) => runIsolateTests(args, tests, testeeBefore: testeeSetup); |
| OLD | NEW |