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 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:async/async.dart'; | 7 import 'package:async/async.dart'; |
8 import 'package:test/test.dart'; | 8 import 'package:test/test.dart'; |
9 import 'package:vm_service_client/vm_service_client.dart'; | 9 import 'package:vm_service_client/vm_service_client.dart'; |
10 | 10 |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 test("works before the isolate is runnable", () async { | 368 test("works before the isolate is runnable", () async { |
369 client = await runAndConnect(flags: ['--pause-isolates-on-start']); | 369 client = await runAndConnect(flags: ['--pause-isolates-on-start']); |
370 | 370 |
371 // We should be able to set a breakpoint before the relevant library is | 371 // We should be able to set a breakpoint before the relevant library is |
372 // loaded, although it may fail to resolve if the line number is bogus. | 372 // loaded, although it may fail to resolve if the line number is bogus. |
373 var isolate = (await client.getVM()).isolates.first; | 373 var isolate = (await client.getVM()).isolates.first; |
374 var breakpoint = await isolate.addBreakpoint('my/script.dart', 0); | 374 var breakpoint = await isolate.addBreakpoint('my/script.dart', 0); |
375 expect(breakpoint.number, equals(1)); | 375 expect(breakpoint.number, equals(1)); |
376 }); | 376 }); |
377 }); | 377 }); |
378 | |
379 group("invokeExtension", () { | |
380 test("enforces ext. prefix", () async { | |
381 var client = await runAndConnect(); | |
382 var isolate = await (await client.getVM()).isolates.first.loadRunnable(); | |
383 expect(() => isolate.invokeExtension('noprefix'), throwsArgumentError); | |
384 }); | |
385 | |
386 test("forwards to scope", () async { | |
387 var client = await runAndConnect(main: r""" | |
388 registerExtension('ext.ping', (_, __) async { | |
389 return new ServiceExtensionResponse.result('{"type": "pong"}'); | |
390 }); | |
391 """); | |
392 | |
393 var isolate = await (await client.getVM()).isolates.first.loadRunnable(); | |
394 Map response = await isolate.invokeExtension('ext.ping'); | |
395 expect(response, {'type': 'pong'}); | |
nweiz
2016/02/10 21:28:28
Oh jeez, does the protocol automatically JSON-dese
yjbanov
2016/02/10 22:06:07
Yep
| |
396 }); | |
nweiz
2016/02/10 21:28:28
Test passing in arguments as well.
yjbanov
2016/02/10 22:06:07
Done.
| |
397 }); | |
378 } | 398 } |
379 | 399 |
380 /// Starts a client with two unpaused empty isolates. | 400 /// Starts a client with two unpaused empty isolates. |
381 Future<List<VMRunnableIsolate>> _twoIsolates() async { | 401 Future<List<VMRunnableIsolate>> _twoIsolates() async { |
382 client = await runAndConnect(topLevel: r""" | 402 client = await runAndConnect(topLevel: r""" |
383 void otherIsolate(_) {} | 403 void otherIsolate(_) {} |
384 """, main: r""" | 404 """, main: r""" |
385 Isolate.spawn(otherIsolate, null); | 405 Isolate.spawn(otherIsolate, null); |
386 """, flags: ["--pause-isolates-on-start", "--pause-isolates-on-exit"]); | 406 """, flags: ["--pause-isolates-on-start", "--pause-isolates-on-exit"]); |
387 | 407 |
388 var vm = await client.getVM(); | 408 var vm = await client.getVM(); |
389 var main = vm.isolates.first; | 409 var main = vm.isolates.first; |
390 | 410 |
391 var otherFuture = client.onIsolateRunnable.first; | 411 var otherFuture = client.onIsolateRunnable.first; |
392 await main.resume(); | 412 await main.resume(); |
393 var other = await otherFuture; | 413 var other = await otherFuture; |
394 await other.resume(); | 414 await other.resume(); |
395 | 415 |
396 return [main, other]; | 416 return [main, other]; |
397 } | 417 } |
OLD | NEW |