| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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=--error_on_bad_type --error_on_bad_override | 4 // VMOptions=--error_on_bad_type --error_on_bad_override |
| 5 | 5 |
| 6 import 'dart:async'; | 6 import 'dart:async'; |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 import 'package:observatory/models.dart' as M; |
| 8 import 'package:observatory/service_io.dart'; | 9 import 'package:observatory/service_io.dart'; |
| 9 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 10 import 'service_test_common.dart'; | 11 import 'service_test_common.dart'; |
| 11 import 'test_helper.dart'; | 12 import 'test_helper.dart'; |
| 12 | 13 |
| 13 var tests = [ | 14 var tests = [ |
| 14 (VM vm) async { | 15 (VM vm) async { |
| 15 // Create a new fs. | 16 // Create a new fs. |
| 16 var fsName = 'scratch'; | 17 var fsName = 'scratch'; |
| 17 var result = await vm.invokeRpcNoUpgrade('_createDevFS', { | 18 var result = await vm.invokeRpcNoUpgrade('_createDevFS', { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 expect(result['type'], equals('Success')); | 136 expect(result['type'], equals('Success')); |
| 136 var spawnedIsolate = await completer.future; | 137 var spawnedIsolate = await completer.future; |
| 137 | 138 |
| 138 // Wait for the spawned isolate to hit a breakpoint. | 139 // Wait for the spawned isolate to hit a breakpoint. |
| 139 await spawnedIsolate.load(); | 140 await spawnedIsolate.load(); |
| 140 await hasStoppedAtBreakpoint(spawnedIsolate); | 141 await hasStoppedAtBreakpoint(spawnedIsolate); |
| 141 | 142 |
| 142 // Make sure that we are running code from the spawned isolate. | 143 // Make sure that we are running code from the spawned isolate. |
| 143 result = await spawnedIsolate.rootLibrary.evaluate('proofOfLife()'); | 144 result = await spawnedIsolate.rootLibrary.evaluate('proofOfLife()'); |
| 144 expect(result.type, equals('Instance')); | 145 expect(result.type, equals('Instance')); |
| 145 expect(result.kind, equals('String')); | 146 expect(result.kind, equals(M.InstanceKind.string)); |
| 146 expect(result.valueAsString, equals('I live!')); | 147 expect(result.valueAsString, equals('I live!')); |
| 147 | 148 |
| 148 // Spawn the script with arguments. | 149 // Spawn the script with arguments. |
| 149 completer = new Completer(); | 150 completer = new Completer(); |
| 150 sub = await vm.listenEventStream( | 151 sub = await vm.listenEventStream( |
| 151 VM.kIsolateStream, | 152 VM.kIsolateStream, |
| 152 (ServiceEvent event) { | 153 (ServiceEvent event) { |
| 153 if (event.kind == ServiceEvent.kIsolateSpawn) { | 154 if (event.kind == ServiceEvent.kIsolateSpawn) { |
| 154 expect(event.spawnToken, equals('mySpawnToken1')); | 155 expect(event.spawnToken, equals('mySpawnToken1')); |
| 155 expect(event.isolate, isNotNull); | 156 expect(event.isolate, isNotNull); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 166 expect(result['type'], equals('Success')); | 167 expect(result['type'], equals('Success')); |
| 167 spawnedIsolate = await completer.future; | 168 spawnedIsolate = await completer.future; |
| 168 | 169 |
| 169 // Wait for the spawned isolate to hit a breakpoint. | 170 // Wait for the spawned isolate to hit a breakpoint. |
| 170 await spawnedIsolate.load(); | 171 await spawnedIsolate.load(); |
| 171 await hasStoppedAtBreakpoint(spawnedIsolate); | 172 await hasStoppedAtBreakpoint(spawnedIsolate); |
| 172 | 173 |
| 173 // Make sure that we are running code from the spawned isolate. | 174 // Make sure that we are running code from the spawned isolate. |
| 174 result = await spawnedIsolate.rootLibrary.evaluate('proofOfLife()'); | 175 result = await spawnedIsolate.rootLibrary.evaluate('proofOfLife()'); |
| 175 expect(result.type, equals('Instance')); | 176 expect(result.type, equals('Instance')); |
| 176 expect(result.kind, equals('String')); | 177 expect(result.kind, equals(M.InstanceKind.string)); |
| 177 expect(result.valueAsString, equals('I live, [one, two, three]!')); | 178 expect(result.valueAsString, equals('I live, [one, two, three]!')); |
| 178 | 179 |
| 179 // Spawn the script with arguments and message | 180 // Spawn the script with arguments and message |
| 180 completer = new Completer(); | 181 completer = new Completer(); |
| 181 sub = await vm.listenEventStream( | 182 sub = await vm.listenEventStream( |
| 182 VM.kIsolateStream, | 183 VM.kIsolateStream, |
| 183 (ServiceEvent event) { | 184 (ServiceEvent event) { |
| 184 if (event.kind == ServiceEvent.kIsolateSpawn) { | 185 if (event.kind == ServiceEvent.kIsolateSpawn) { |
| 185 expect(event.spawnToken, equals('mySpawnToken2')); | 186 expect(event.spawnToken, equals('mySpawnToken2')); |
| 186 expect(event.isolate, isNotNull); | 187 expect(event.isolate, isNotNull); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 198 expect(result['type'], equals('Success')); | 199 expect(result['type'], equals('Success')); |
| 199 spawnedIsolate = await completer.future; | 200 spawnedIsolate = await completer.future; |
| 200 | 201 |
| 201 // Wait for the spawned isolate to hit a breakpoint. | 202 // Wait for the spawned isolate to hit a breakpoint. |
| 202 await spawnedIsolate.load(); | 203 await spawnedIsolate.load(); |
| 203 await hasStoppedAtBreakpoint(spawnedIsolate); | 204 await hasStoppedAtBreakpoint(spawnedIsolate); |
| 204 | 205 |
| 205 // Make sure that we are running code from the spawned isolate. | 206 // Make sure that we are running code from the spawned isolate. |
| 206 result = await spawnedIsolate.rootLibrary.evaluate('proofOfLife()'); | 207 result = await spawnedIsolate.rootLibrary.evaluate('proofOfLife()'); |
| 207 expect(result.type, equals('Instance')); | 208 expect(result.type, equals('Instance')); |
| 208 expect(result.kind, equals('String')); | 209 expect(result.kind, equals(M.InstanceKind.string)); |
| 209 expect(result.valueAsString, equals('I live, [A, B, C], test!')); | 210 expect(result.valueAsString, equals('I live, [A, B, C], test!')); |
| 210 | 211 |
| 211 // Delete the fs. | 212 // Delete the fs. |
| 212 result = await vm.invokeRpcNoUpgrade('_deleteDevFS', { | 213 result = await vm.invokeRpcNoUpgrade('_deleteDevFS', { |
| 213 'fsName': fsName, | 214 'fsName': fsName, |
| 214 }); | 215 }); |
| 215 expect(result['type'], equals('Success')); | 216 expect(result['type'], equals('Success')); |
| 216 }, | 217 }, |
| 217 ]; | 218 ]; |
| 218 | 219 |
| 219 main(args) async => runVMTests(args, tests); | 220 main(args) async => runVMTests(args, tests); |
| OLD | NEW |