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=--error_on_bad_type --error_on_bad_override | 4 // VMOptions=--error_on_bad_type --error_on_bad_override |
5 | 5 |
6 library get_object_rpc_test; | 6 library get_object_rpc_test; |
7 | 7 |
8 import 'dart:typed_data'; | 8 import 'dart:typed_data'; |
9 import 'dart:convert' show BASE64; | 9 import 'dart:convert' show BASE64; |
10 import 'package:observatory/service_io.dart'; | 10 import 'package:observatory/service_io.dart'; |
11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
12 import 'test_helper.dart'; | 12 import 'test_helper.dart'; |
13 | 13 |
14 class _DummyClass { | 14 class _DummyClass { |
15 static var dummyVar = 11; | 15 static var dummyVar = 11; |
16 void dummyFunction() { | 16 void dummyFunction() {} |
17 } | |
18 } | 17 } |
19 | 18 |
20 class _DummySubClass extends _DummyClass { | 19 class _DummySubClass extends _DummyClass {} |
21 } | |
22 | 20 |
23 void warmup() { | 21 void warmup() { |
24 // Silence analyzer. | 22 // Silence analyzer. |
25 new _DummySubClass(); | 23 new _DummySubClass(); |
26 new _DummyClass().dummyFunction(); | 24 new _DummyClass().dummyFunction(); |
27 } | 25 } |
28 | 26 |
29 eval(Isolate isolate, String expression) async { | 27 eval(Isolate isolate, String expression) async { |
30 Map params = { | 28 Map params = { |
31 'targetId': isolate.rootLibrary.id, | 29 'targetId': isolate.rootLibrary.id, |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 Uint8List bytes = BASE64.decode(result['bytes']); | 449 Uint8List bytes = BASE64.decode(result['bytes']); |
452 expect(bytes.buffer.asUint8List().toString(), equals('[3, 2, 1]')); | 450 expect(bytes.buffer.asUint8List().toString(), equals('[3, 2, 1]')); |
453 }, | 451 }, |
454 | 452 |
455 // Uint8List prefix. | 453 // Uint8List prefix. |
456 (Isolate isolate) async { | 454 (Isolate isolate) async { |
457 // Call eval to get a Dart list. | 455 // Call eval to get a Dart list. |
458 var evalResult = await eval(isolate, 'uint8List'); | 456 var evalResult = await eval(isolate, 'uint8List'); |
459 var params = { | 457 var params = { |
460 'objectId': evalResult['id'], | 458 'objectId': evalResult['id'], |
461 'count' : 2, | 459 'count': 2, |
462 }; | 460 }; |
463 var result = await isolate.invokeRpcNoUpgrade('getObject', params); | 461 var result = await isolate.invokeRpcNoUpgrade('getObject', params); |
464 expect(result['type'], equals('Instance')); | 462 expect(result['type'], equals('Instance')); |
465 expect(result['kind'], equals('Uint8List')); | 463 expect(result['kind'], equals('Uint8List')); |
466 expect(result['_vmType'], equals('TypedData')); | 464 expect(result['_vmType'], equals('TypedData')); |
467 expect(result['id'], startsWith('objects/')); | 465 expect(result['id'], startsWith('objects/')); |
468 expect(result['valueAsString'], isNull); | 466 expect(result['valueAsString'], isNull); |
469 expect(result['class']['type'], equals('@Class')); | 467 expect(result['class']['type'], equals('@Class')); |
470 expect(result['class']['name'], equals('_Uint8List')); | 468 expect(result['class']['name'], equals('_Uint8List')); |
471 expect(result['size'], isPositive); | 469 expect(result['size'], isPositive); |
472 expect(result['fields'], isEmpty); | 470 expect(result['fields'], isEmpty); |
473 expect(result['length'], equals(3)); | 471 expect(result['length'], equals(3)); |
474 expect(result['offset'], isNull); | 472 expect(result['offset'], isNull); |
475 expect(result['count'], equals(2)); | 473 expect(result['count'], equals(2)); |
476 expect(result['bytes'], equals('AwI=')); | 474 expect(result['bytes'], equals('AwI=')); |
477 Uint8List bytes = BASE64.decode(result['bytes']); | 475 Uint8List bytes = BASE64.decode(result['bytes']); |
478 expect(bytes.buffer.asUint8List().toString(), equals('[3, 2]')); | 476 expect(bytes.buffer.asUint8List().toString(), equals('[3, 2]')); |
479 }, | 477 }, |
480 | 478 |
481 // Uint8List suffix. | 479 // Uint8List suffix. |
482 (Isolate isolate) async { | 480 (Isolate isolate) async { |
483 // Call eval to get a Dart list. | 481 // Call eval to get a Dart list. |
484 var evalResult = await eval(isolate, 'uint8List'); | 482 var evalResult = await eval(isolate, 'uint8List'); |
485 var params = { | 483 var params = { |
486 'objectId': evalResult['id'], | 484 'objectId': evalResult['id'], |
487 'offset' : 2, | 485 'offset': 2, |
488 'count' : 2, | 486 'count': 2, |
489 }; | 487 }; |
490 var result = await isolate.invokeRpcNoUpgrade('getObject', params); | 488 var result = await isolate.invokeRpcNoUpgrade('getObject', params); |
491 expect(result['type'], equals('Instance')); | 489 expect(result['type'], equals('Instance')); |
492 expect(result['kind'], equals('Uint8List')); | 490 expect(result['kind'], equals('Uint8List')); |
493 expect(result['_vmType'], equals('TypedData')); | 491 expect(result['_vmType'], equals('TypedData')); |
494 expect(result['id'], startsWith('objects/')); | 492 expect(result['id'], startsWith('objects/')); |
495 expect(result['valueAsString'], isNull); | 493 expect(result['valueAsString'], isNull); |
496 expect(result['class']['type'], equals('@Class')); | 494 expect(result['class']['type'], equals('@Class')); |
497 expect(result['class']['name'], equals('_Uint8List')); | 495 expect(result['class']['name'], equals('_Uint8List')); |
498 expect(result['size'], isPositive); | 496 expect(result['size'], isPositive); |
499 expect(result['fields'], isEmpty); | 497 expect(result['fields'], isEmpty); |
500 expect(result['length'], equals(3)); | 498 expect(result['length'], equals(3)); |
501 expect(result['offset'], equals(2)); | 499 expect(result['offset'], equals(2)); |
502 expect(result['count'], equals(1)); | 500 expect(result['count'], equals(1)); |
503 expect(result['bytes'], equals('AQ==')); | 501 expect(result['bytes'], equals('AQ==')); |
504 Uint8List bytes = BASE64.decode(result['bytes']); | 502 Uint8List bytes = BASE64.decode(result['bytes']); |
505 expect(bytes.buffer.asUint8List().toString(), equals('[1]')); | 503 expect(bytes.buffer.asUint8List().toString(), equals('[1]')); |
506 }, | 504 }, |
507 | 505 |
508 // Uint8List with wacky offset. | 506 // Uint8List with wacky offset. |
509 (Isolate isolate) async { | 507 (Isolate isolate) async { |
510 // Call eval to get a Dart list. | 508 // Call eval to get a Dart list. |
511 var evalResult = await eval(isolate, 'uint8List'); | 509 var evalResult = await eval(isolate, 'uint8List'); |
512 var params = { | 510 var params = { |
513 'objectId': evalResult['id'], | 511 'objectId': evalResult['id'], |
514 'offset' : 100, | 512 'offset': 100, |
515 'count' : 2, | 513 'count': 2, |
516 }; | 514 }; |
517 var result = await isolate.invokeRpcNoUpgrade('getObject', params); | 515 var result = await isolate.invokeRpcNoUpgrade('getObject', params); |
518 expect(result['type'], equals('Instance')); | 516 expect(result['type'], equals('Instance')); |
519 expect(result['kind'], equals('Uint8List')); | 517 expect(result['kind'], equals('Uint8List')); |
520 expect(result['_vmType'], equals('TypedData')); | 518 expect(result['_vmType'], equals('TypedData')); |
521 expect(result['id'], startsWith('objects/')); | 519 expect(result['id'], startsWith('objects/')); |
522 expect(result['valueAsString'], isNull); | 520 expect(result['valueAsString'], isNull); |
523 expect(result['class']['type'], equals('@Class')); | 521 expect(result['class']['type'], equals('@Class')); |
524 expect(result['class']['name'], equals('_Uint8List')); | 522 expect(result['class']['name'], equals('_Uint8List')); |
525 expect(result['size'], isPositive); | 523 expect(result['size'], isPositive); |
(...skipping 28 matching lines...) Expand all Loading... |
554 Uint8List bytes = BASE64.decode(result['bytes']); | 552 Uint8List bytes = BASE64.decode(result['bytes']); |
555 expect(bytes.buffer.asUint64List().toString(), equals('[3, 2, 1]')); | 553 expect(bytes.buffer.asUint64List().toString(), equals('[3, 2, 1]')); |
556 }, | 554 }, |
557 | 555 |
558 // Uint64List prefix. | 556 // Uint64List prefix. |
559 (Isolate isolate) async { | 557 (Isolate isolate) async { |
560 // Call eval to get a Dart list. | 558 // Call eval to get a Dart list. |
561 var evalResult = await eval(isolate, 'uint64List'); | 559 var evalResult = await eval(isolate, 'uint64List'); |
562 var params = { | 560 var params = { |
563 'objectId': evalResult['id'], | 561 'objectId': evalResult['id'], |
564 'count' : 2, | 562 'count': 2, |
565 }; | 563 }; |
566 var result = await isolate.invokeRpcNoUpgrade('getObject', params); | 564 var result = await isolate.invokeRpcNoUpgrade('getObject', params); |
567 expect(result['type'], equals('Instance')); | 565 expect(result['type'], equals('Instance')); |
568 expect(result['kind'], equals('Uint64List')); | 566 expect(result['kind'], equals('Uint64List')); |
569 expect(result['_vmType'], equals('TypedData')); | 567 expect(result['_vmType'], equals('TypedData')); |
570 expect(result['id'], startsWith('objects/')); | 568 expect(result['id'], startsWith('objects/')); |
571 expect(result['valueAsString'], isNull); | 569 expect(result['valueAsString'], isNull); |
572 expect(result['class']['type'], equals('@Class')); | 570 expect(result['class']['type'], equals('@Class')); |
573 expect(result['class']['name'], equals('_Uint64List')); | 571 expect(result['class']['name'], equals('_Uint64List')); |
574 expect(result['size'], isPositive); | 572 expect(result['size'], isPositive); |
575 expect(result['fields'], isEmpty); | 573 expect(result['fields'], isEmpty); |
576 expect(result['length'], equals(3)); | 574 expect(result['length'], equals(3)); |
577 expect(result['offset'], isNull); | 575 expect(result['offset'], isNull); |
578 expect(result['count'], equals(2)); | 576 expect(result['count'], equals(2)); |
579 expect(result['bytes'], equals('AwAAAAAAAAACAAAAAAAAAA==')); | 577 expect(result['bytes'], equals('AwAAAAAAAAACAAAAAAAAAA==')); |
580 Uint8List bytes = BASE64.decode(result['bytes']); | 578 Uint8List bytes = BASE64.decode(result['bytes']); |
581 expect(bytes.buffer.asUint64List().toString(), equals('[3, 2]')); | 579 expect(bytes.buffer.asUint64List().toString(), equals('[3, 2]')); |
582 }, | 580 }, |
583 | 581 |
584 // Uint64List suffix. | 582 // Uint64List suffix. |
585 (Isolate isolate) async { | 583 (Isolate isolate) async { |
586 // Call eval to get a Dart list. | 584 // Call eval to get a Dart list. |
587 var evalResult = await eval(isolate, 'uint64List'); | 585 var evalResult = await eval(isolate, 'uint64List'); |
588 var params = { | 586 var params = { |
589 'objectId': evalResult['id'], | 587 'objectId': evalResult['id'], |
590 'offset' : 2, | 588 'offset': 2, |
591 'count' : 2, | 589 'count': 2, |
592 }; | 590 }; |
593 var result = await isolate.invokeRpcNoUpgrade('getObject', params); | 591 var result = await isolate.invokeRpcNoUpgrade('getObject', params); |
594 expect(result['type'], equals('Instance')); | 592 expect(result['type'], equals('Instance')); |
595 expect(result['kind'], equals('Uint64List')); | 593 expect(result['kind'], equals('Uint64List')); |
596 expect(result['_vmType'], equals('TypedData')); | 594 expect(result['_vmType'], equals('TypedData')); |
597 expect(result['id'], startsWith('objects/')); | 595 expect(result['id'], startsWith('objects/')); |
598 expect(result['valueAsString'], isNull); | 596 expect(result['valueAsString'], isNull); |
599 expect(result['class']['type'], equals('@Class')); | 597 expect(result['class']['type'], equals('@Class')); |
600 expect(result['class']['name'], equals('_Uint64List')); | 598 expect(result['class']['name'], equals('_Uint64List')); |
601 expect(result['size'], isPositive); | 599 expect(result['size'], isPositive); |
602 expect(result['fields'], isEmpty); | 600 expect(result['fields'], isEmpty); |
603 expect(result['length'], equals(3)); | 601 expect(result['length'], equals(3)); |
604 expect(result['offset'], equals(2)); | 602 expect(result['offset'], equals(2)); |
605 expect(result['count'], equals(1)); | 603 expect(result['count'], equals(1)); |
606 expect(result['bytes'], equals('AQAAAAAAAAA=')); | 604 expect(result['bytes'], equals('AQAAAAAAAAA=')); |
607 Uint8List bytes = BASE64.decode(result['bytes']); | 605 Uint8List bytes = BASE64.decode(result['bytes']); |
608 expect(bytes.buffer.asUint64List().toString(), equals('[1]')); | 606 expect(bytes.buffer.asUint64List().toString(), equals('[1]')); |
609 }, | 607 }, |
610 | 608 |
611 // Uint64List with wacky offset. | 609 // Uint64List with wacky offset. |
612 (Isolate isolate) async { | 610 (Isolate isolate) async { |
613 // Call eval to get a Dart list. | 611 // Call eval to get a Dart list. |
614 var evalResult = await eval(isolate, 'uint64List'); | 612 var evalResult = await eval(isolate, 'uint64List'); |
615 var params = { | 613 var params = { |
616 'objectId': evalResult['id'], | 614 'objectId': evalResult['id'], |
617 'offset' : 100, | 615 'offset': 100, |
618 'count' : 2, | 616 'count': 2, |
619 }; | 617 }; |
620 var result = await isolate.invokeRpcNoUpgrade('getObject', params); | 618 var result = await isolate.invokeRpcNoUpgrade('getObject', params); |
621 expect(result['type'], equals('Instance')); | 619 expect(result['type'], equals('Instance')); |
622 expect(result['kind'], equals('Uint64List')); | 620 expect(result['kind'], equals('Uint64List')); |
623 expect(result['_vmType'], equals('TypedData')); | 621 expect(result['_vmType'], equals('TypedData')); |
624 expect(result['id'], startsWith('objects/')); | 622 expect(result['id'], startsWith('objects/')); |
625 expect(result['valueAsString'], isNull); | 623 expect(result['valueAsString'], isNull); |
626 expect(result['class']['type'], equals('@Class')); | 624 expect(result['class']['type'], equals('@Class')); |
627 expect(result['class']['name'], equals('_Uint64List')); | 625 expect(result['class']['name'], equals('_Uint64List')); |
628 expect(result['size'], isPositive); | 626 expect(result['size'], isPositive); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 }, | 669 }, |
672 | 670 |
673 // invalid library. | 671 // invalid library. |
674 (Isolate isolate) async { | 672 (Isolate isolate) async { |
675 var params = { | 673 var params = { |
676 'objectId': 'libraries/9999999', | 674 'objectId': 'libraries/9999999', |
677 }; | 675 }; |
678 bool caughtException; | 676 bool caughtException; |
679 try { | 677 try { |
680 await isolate.invokeRpcNoUpgrade('getObject', params); | 678 await isolate.invokeRpcNoUpgrade('getObject', params); |
681 expect(false, isTrue, reason:'Unreachable'); | 679 expect(false, isTrue, reason: 'Unreachable'); |
682 } on ServerRpcException catch(e) { | 680 } on ServerRpcException catch (e) { |
683 caughtException = true; | 681 caughtException = true; |
684 expect(e.code, equals(ServerRpcException.kInvalidParams)); | 682 expect(e.code, equals(ServerRpcException.kInvalidParams)); |
685 expect(e.message, | 683 expect(e.message, |
686 "getObject: invalid 'objectId' parameter: libraries/9999999"); | 684 "getObject: invalid 'objectId' parameter: libraries/9999999"); |
687 } | 685 } |
688 expect(caughtException, isTrue); | 686 expect(caughtException, isTrue); |
689 }, | 687 }, |
690 | 688 |
691 // script. | 689 // script. |
692 (Isolate isolate) async { | 690 (Isolate isolate) async { |
693 // Get the library first. | 691 // Get the library first. |
694 var params = { | 692 var params = { |
695 'objectId': isolate.rootLibrary.id, | 693 'objectId': isolate.rootLibrary.id, |
696 }; | 694 }; |
(...skipping 17 matching lines...) Expand all Loading... |
714 }, | 712 }, |
715 | 713 |
716 // invalid script. | 714 // invalid script. |
717 (Isolate isolate) async { | 715 (Isolate isolate) async { |
718 var params = { | 716 var params = { |
719 'objectId': 'scripts/9999999', | 717 'objectId': 'scripts/9999999', |
720 }; | 718 }; |
721 bool caughtException; | 719 bool caughtException; |
722 try { | 720 try { |
723 await isolate.invokeRpcNoUpgrade('getObject', params); | 721 await isolate.invokeRpcNoUpgrade('getObject', params); |
724 expect(false, isTrue, reason:'Unreachable'); | 722 expect(false, isTrue, reason: 'Unreachable'); |
725 } on ServerRpcException catch(e) { | 723 } on ServerRpcException catch (e) { |
726 caughtException = true; | 724 caughtException = true; |
727 expect(e.code, equals(ServerRpcException.kInvalidParams)); | 725 expect(e.code, equals(ServerRpcException.kInvalidParams)); |
728 expect(e.message, | 726 expect(e.message, |
729 "getObject: invalid 'objectId' parameter: scripts/9999999"); | 727 "getObject: invalid 'objectId' parameter: scripts/9999999"); |
730 } | 728 } |
731 expect(caughtException, isTrue); | 729 expect(caughtException, isTrue); |
732 }, | 730 }, |
733 | 731 |
734 // class | 732 // class |
735 (Isolate isolate) async { | 733 (Isolate isolate) async { |
736 // Call eval to get a class id. | 734 // Call eval to get a class id. |
737 var evalResult = await eval(isolate, 'new _DummyClass()'); | 735 var evalResult = await eval(isolate, 'new _DummyClass()'); |
738 var params = { | 736 var params = { |
739 'objectId': evalResult['class']['id'], | 737 'objectId': evalResult['class']['id'], |
(...skipping 21 matching lines...) Expand all Loading... |
761 }, | 759 }, |
762 | 760 |
763 // invalid class. | 761 // invalid class. |
764 (Isolate isolate) async { | 762 (Isolate isolate) async { |
765 var params = { | 763 var params = { |
766 'objectId': 'classes/9999999', | 764 'objectId': 'classes/9999999', |
767 }; | 765 }; |
768 bool caughtException; | 766 bool caughtException; |
769 try { | 767 try { |
770 await isolate.invokeRpcNoUpgrade('getObject', params); | 768 await isolate.invokeRpcNoUpgrade('getObject', params); |
771 expect(false, isTrue, reason:'Unreachable'); | 769 expect(false, isTrue, reason: 'Unreachable'); |
772 } on ServerRpcException catch(e) { | 770 } on ServerRpcException catch (e) { |
773 caughtException = true; | 771 caughtException = true; |
774 expect(e.code, equals(ServerRpcException.kInvalidParams)); | 772 expect(e.code, equals(ServerRpcException.kInvalidParams)); |
775 expect(e.message, | 773 expect(e.message, |
776 "getObject: invalid 'objectId' parameter: classes/9999999"); | 774 "getObject: invalid 'objectId' parameter: classes/9999999"); |
777 } | 775 } |
778 expect(caughtException, isTrue); | 776 expect(caughtException, isTrue); |
779 }, | 777 }, |
780 | 778 |
781 // type. | 779 // type. |
782 (Isolate isolate) async { | 780 (Isolate isolate) async { |
783 // Call eval to get a class id. | 781 // Call eval to get a class id. |
784 var evalResult = await eval(isolate, 'new _DummyClass()'); | 782 var evalResult = await eval(isolate, 'new _DummyClass()'); |
785 var id = "${evalResult['class']['id']}/types/0"; | 783 var id = "${evalResult['class']['id']}/types/0"; |
786 var params = { | 784 var params = { |
(...skipping 14 matching lines...) Expand all Loading... |
801 // invalid type. | 799 // invalid type. |
802 (Isolate isolate) async { | 800 (Isolate isolate) async { |
803 var evalResult = await eval(isolate, 'new _DummyClass()'); | 801 var evalResult = await eval(isolate, 'new _DummyClass()'); |
804 var id = "${evalResult['class']['id']}/types/9999999"; | 802 var id = "${evalResult['class']['id']}/types/9999999"; |
805 var params = { | 803 var params = { |
806 'objectId': id, | 804 'objectId': id, |
807 }; | 805 }; |
808 bool caughtException; | 806 bool caughtException; |
809 try { | 807 try { |
810 await isolate.invokeRpcNoUpgrade('getObject', params); | 808 await isolate.invokeRpcNoUpgrade('getObject', params); |
811 expect(false, isTrue, reason:'Unreachable'); | 809 expect(false, isTrue, reason: 'Unreachable'); |
812 } on ServerRpcException catch(e) { | 810 } on ServerRpcException catch (e) { |
813 caughtException = true; | 811 caughtException = true; |
814 expect(e.code, equals(ServerRpcException.kInvalidParams)); | 812 expect(e.code, equals(ServerRpcException.kInvalidParams)); |
815 expect(e.message, | 813 expect( |
816 startsWith("getObject: invalid 'objectId' parameter: ")); | 814 e.message, startsWith("getObject: invalid 'objectId' parameter: ")); |
817 } | 815 } |
818 expect(caughtException, isTrue); | 816 expect(caughtException, isTrue); |
819 }, | 817 }, |
820 | 818 |
821 // function. | 819 // function. |
822 (Isolate isolate) async { | 820 (Isolate isolate) async { |
823 // Call eval to get a class id. | 821 // Call eval to get a class id. |
824 var evalResult = await eval(isolate, 'new _DummyClass()'); | 822 var evalResult = await eval(isolate, 'new _DummyClass()'); |
825 var id = "${evalResult['class']['id']}/functions/dummyFunction"; | 823 var id = "${evalResult['class']['id']}/functions/dummyFunction"; |
826 var params = { | 824 var params = { |
(...skipping 19 matching lines...) Expand all Loading... |
846 (Isolate isolate) async { | 844 (Isolate isolate) async { |
847 // Call eval to get a class id. | 845 // Call eval to get a class id. |
848 var evalResult = await eval(isolate, 'new _DummyClass()'); | 846 var evalResult = await eval(isolate, 'new _DummyClass()'); |
849 var id = "${evalResult['class']['id']}/functions/invalid"; | 847 var id = "${evalResult['class']['id']}/functions/invalid"; |
850 var params = { | 848 var params = { |
851 'objectId': id, | 849 'objectId': id, |
852 }; | 850 }; |
853 bool caughtException; | 851 bool caughtException; |
854 try { | 852 try { |
855 await isolate.invokeRpcNoUpgrade('getObject', params); | 853 await isolate.invokeRpcNoUpgrade('getObject', params); |
856 expect(false, isTrue, reason:'Unreachable'); | 854 expect(false, isTrue, reason: 'Unreachable'); |
857 } on ServerRpcException catch(e) { | 855 } on ServerRpcException catch (e) { |
858 caughtException = true; | 856 caughtException = true; |
859 expect(e.code, equals(ServerRpcException.kInvalidParams)); | 857 expect(e.code, equals(ServerRpcException.kInvalidParams)); |
860 expect(e.message, | 858 expect( |
861 startsWith("getObject: invalid 'objectId' parameter: ")); | 859 e.message, startsWith("getObject: invalid 'objectId' parameter: ")); |
862 } | 860 } |
863 expect(caughtException, isTrue); | 861 expect(caughtException, isTrue); |
864 }, | 862 }, |
865 | 863 |
866 // field | 864 // field |
867 (Isolate isolate) async { | 865 (Isolate isolate) async { |
868 // Call eval to get a class id. | 866 // Call eval to get a class id. |
869 var evalResult = await eval(isolate, 'new _DummyClass()'); | 867 var evalResult = await eval(isolate, 'new _DummyClass()'); |
870 var id = "${evalResult['class']['id']}/fields/dummyVar"; | 868 var id = "${evalResult['class']['id']}/fields/dummyVar"; |
871 var params = { | 869 var params = { |
(...skipping 17 matching lines...) Expand all Loading... |
889 (Isolate isolate) async { | 887 (Isolate isolate) async { |
890 // Call eval to get a class id. | 888 // Call eval to get a class id. |
891 var evalResult = await eval(isolate, 'new _DummyClass()'); | 889 var evalResult = await eval(isolate, 'new _DummyClass()'); |
892 var id = "${evalResult['class']['id']}/fields/mythicalField"; | 890 var id = "${evalResult['class']['id']}/fields/mythicalField"; |
893 var params = { | 891 var params = { |
894 'objectId': id, | 892 'objectId': id, |
895 }; | 893 }; |
896 bool caughtException; | 894 bool caughtException; |
897 try { | 895 try { |
898 await isolate.invokeRpcNoUpgrade('getObject', params); | 896 await isolate.invokeRpcNoUpgrade('getObject', params); |
899 expect(false, isTrue, reason:'Unreachable'); | 897 expect(false, isTrue, reason: 'Unreachable'); |
900 } on ServerRpcException catch(e) { | 898 } on ServerRpcException catch (e) { |
901 caughtException = true; | 899 caughtException = true; |
902 expect(e.code, equals(ServerRpcException.kInvalidParams)); | 900 expect(e.code, equals(ServerRpcException.kInvalidParams)); |
903 expect(e.message, | 901 expect( |
904 startsWith("getObject: invalid 'objectId' parameter: ")); | 902 e.message, startsWith("getObject: invalid 'objectId' parameter: ")); |
905 } | 903 } |
906 expect(caughtException, isTrue); | 904 expect(caughtException, isTrue); |
907 }, | 905 }, |
908 | 906 |
909 // code. | 907 // code. |
910 (Isolate isolate) async { | 908 (Isolate isolate) async { |
911 // Call eval to get a class id. | 909 // Call eval to get a class id. |
912 var evalResult = await eval(isolate, 'new _DummyClass()'); | 910 var evalResult = await eval(isolate, 'new _DummyClass()'); |
913 var funcId = "${evalResult['class']['id']}/functions/dummyFunction"; | 911 var funcId = "${evalResult['class']['id']}/functions/dummyFunction"; |
914 var params = { | 912 var params = { |
915 'objectId': funcId, | 913 'objectId': funcId, |
916 }; | 914 }; |
917 var funcResult = await isolate.invokeRpcNoUpgrade('getObject', params); | 915 var funcResult = await isolate.invokeRpcNoUpgrade('getObject', params); |
918 params = { | 916 params = { |
919 'objectId': funcResult['code']['id'], | 917 'objectId': funcResult['code']['id'], |
920 }; | 918 }; |
921 var result = await isolate.invokeRpcNoUpgrade('getObject', params); | 919 var result = await isolate.invokeRpcNoUpgrade('getObject', params); |
922 expect(result['type'], equals('Code')); | 920 expect(result['type'], equals('Code')); |
923 expect(result['name'], equals('_DummyClass.dummyFunction')); | 921 expect(result['name'], equals('_DummyClass.dummyFunction')); |
924 expect(result['_vmName'], equals('dummyFunction')); | 922 expect(result['_vmName'], equals('dummyFunction')); |
925 expect(result['kind'], equals('Dart')); | 923 expect(result['kind'], equals('Dart')); |
926 expect(result['_optimized'], new isInstanceOf<bool>()); | 924 expect(result['_optimized'], new isInstanceOf<bool>()); |
927 expect(result['function']['type'], equals('@Function')); | 925 expect(result['function']['type'], equals('@Function')); |
928 expect(result['_startAddress'], new isInstanceOf<String>()); | 926 expect(result['_startAddress'], new isInstanceOf<String>()); |
929 expect(result['_endAddress'], new isInstanceOf<String>()); | 927 expect(result['_endAddress'], new isInstanceOf<String>()); |
930 expect(result['_objectPool'], isNotNull); | 928 expect(result['_objectPool'], isNotNull); |
931 expect(result['_disassembly'], isNotNull); | 929 expect(result['_disassembly'], isNotNull); |
932 expect(result['_descriptors'], isNotNull); | 930 expect(result['_descriptors'], isNotNull); |
933 expect(result['_inlinedFunctions'], anyOf([isNull, new isInstanceOf<List>()]
)); | 931 expect( |
934 expect(result['_inlinedIntervals'], anyOf([isNull, new isInstanceOf<List>()]
)); | 932 result['_inlinedFunctions'], anyOf([isNull, new isInstanceOf<List>()])); |
| 933 expect( |
| 934 result['_inlinedIntervals'], anyOf([isNull, new isInstanceOf<List>()])); |
935 }, | 935 }, |
936 | 936 |
937 // invalid code. | 937 // invalid code. |
938 (Isolate isolate) async { | 938 (Isolate isolate) async { |
939 var params = { | 939 var params = { |
940 'objectId': 'code/0', | 940 'objectId': 'code/0', |
941 }; | 941 }; |
942 bool caughtException; | 942 bool caughtException; |
943 try { | 943 try { |
944 await isolate.invokeRpcNoUpgrade('getObject', params); | 944 await isolate.invokeRpcNoUpgrade('getObject', params); |
945 expect(false, isTrue, reason:'Unreachable'); | 945 expect(false, isTrue, reason: 'Unreachable'); |
946 } on ServerRpcException catch(e) { | 946 } on ServerRpcException catch (e) { |
947 caughtException = true; | 947 caughtException = true; |
948 expect(e.code, equals(ServerRpcException.kInvalidParams)); | 948 expect(e.code, equals(ServerRpcException.kInvalidParams)); |
949 expect(e.message, | 949 expect(e.message, "getObject: invalid 'objectId' parameter: code/0"); |
950 "getObject: invalid 'objectId' parameter: code/0"); | |
951 } | 950 } |
952 expect(caughtException, isTrue); | 951 expect(caughtException, isTrue); |
953 }, | 952 }, |
954 ]; | 953 ]; |
955 | 954 |
956 main(args) async => runIsolateTests(args, tests, testeeBefore:warmup); | 955 main(args) async => runIsolateTests(args, tests, testeeBefore: warmup); |
OLD | NEW |