@@ -11,7 +11,6 @@ import 'dart:async';
11
11
import 'dart:convert' ;
12
12
import 'dart:io' ;
13
13
14
- import 'package:dwds/src/config/tool_configuration.dart' ;
15
14
import 'package:dwds/src/services/chrome_proxy_service.dart' ;
16
15
import 'package:dwds/src/utilities/dart_uri.dart' ;
17
16
import 'package:dwds/src/utilities/shared.dart' ;
@@ -22,7 +21,6 @@ import 'package:test_common/logging.dart';
22
21
import 'package:test_common/test_sdk_configuration.dart' ;
23
22
import 'package:vm_service/vm_service.dart' ;
24
23
import 'package:vm_service_interface/vm_service_interface.dart' ;
25
- import 'package:webkit_inspection_protocol/webkit_inspection_protocol.dart' ;
26
24
27
25
import 'fixtures/context.dart' ;
28
26
import 'fixtures/project.dart' ;
@@ -670,38 +668,13 @@ void main() {
670
668
expect (largeString.length, 5 * 250 );
671
669
});
672
670
673
- /// Helper to create a list of 1001 elements, doing a direct JS eval.
674
- Future <RemoteObject > createList () {
675
- final expr = '''
676
- (function () {
677
- const sdk = ${globalToolConfiguration .loadStrategy .loadModuleSnippet }("dart_sdk");
678
- const list = sdk.dart.dsend(sdk.core.List,"filled", [1001, 5]);
679
- list[4] = 100;
680
- return list;
681
- })()''' ;
682
- return service.inspector.jsEvaluate (expr);
683
- }
684
-
685
- /// Helper to create a LinkedHashMap with 1001 entries, doing a direct JS eval.
686
- Future <RemoteObject > createMap () {
687
- final expr = '''
688
- (function () {
689
- const sdk = ${globalToolConfiguration .loadStrategy .loadModuleSnippet }("dart_sdk");
690
- const iterable = sdk.dart.dsend(sdk.core.Iterable, "generate", [1001]);
691
- const list1 = sdk.dart.dsend(iterable, "toList", []);
692
- const reversed = sdk.dart.dload(list1, "reversed");
693
- const list2 = sdk.dart.dsend(reversed, "toList", []);
694
- const map = sdk.dart.dsend(list2, "asMap", []);
695
- const linkedMap = sdk.dart.dsend(sdk.collection.LinkedHashMap, "from", [map]);
696
- return linkedMap;
697
- })()''' ;
698
- return service.inspector.jsEvaluate (expr);
699
- }
700
-
701
671
test ('Lists' , () async {
702
- final list = await createList ();
703
- final inst =
704
- await service.getObject (isolate.id! , list.objectId! ) as Instance ;
672
+ final list = await service.evaluate (
673
+ isolate.id! ,
674
+ bootstrap! .id! ,
675
+ 'topLevelList' ,
676
+ ) as InstanceRef ;
677
+ final inst = await service.getObject (isolate.id! , list.id! ) as Instance ;
705
678
expect (inst.length, 1001 );
706
679
expect (inst.offset, null );
707
680
expect (inst.count, null );
@@ -713,9 +686,12 @@ void main() {
713
686
});
714
687
715
688
test ('Maps' , () async {
716
- final map = await createMap ();
717
- final inst =
718
- await service.getObject (isolate.id! , map.objectId! ) as Instance ;
689
+ final map = await service.evaluate (
690
+ isolate.id! ,
691
+ bootstrap! .id! ,
692
+ 'topLevelMap' ,
693
+ ) as InstanceRef ;
694
+ final inst = await service.getObject (isolate.id! , map.id! ) as Instance ;
719
695
expect (inst.length, 1001 );
720
696
expect (inst.offset, null );
721
697
expect (inst.count, null );
@@ -769,10 +745,14 @@ void main() {
769
745
770
746
group ('getObject called with offset/count parameters' , () {
771
747
test ('Lists with null offset and count are not truncated' , () async {
772
- final list = await createList ();
748
+ final list = await service.evaluate (
749
+ isolate.id! ,
750
+ bootstrap! .id! ,
751
+ 'topLevelList' ,
752
+ ) as InstanceRef ;
773
753
final inst = await service.getObject (
774
754
isolate.id! ,
775
- list.objectId ! ,
755
+ list.id ! ,
776
756
count: null ,
777
757
offset: null ,
778
758
) as Instance ;
@@ -787,10 +767,14 @@ void main() {
787
767
});
788
768
789
769
test ('Lists with null count are not truncated' , () async {
790
- final list = await createList ();
770
+ final list = await service.evaluate (
771
+ isolate.id! ,
772
+ bootstrap! .id! ,
773
+ 'topLevelList' ,
774
+ ) as InstanceRef ;
791
775
final inst = await service.getObject (
792
776
isolate.id! ,
793
- list.objectId ! ,
777
+ list.id ! ,
794
778
count: null ,
795
779
offset: 0 ,
796
780
) as Instance ;
@@ -807,10 +791,14 @@ void main() {
807
791
test (
808
792
'Lists with null count and offset greater than 0 are '
809
793
'truncated from offset to end of list' , () async {
810
- final list = await createList ();
794
+ final list = await service.evaluate (
795
+ isolate.id! ,
796
+ bootstrap! .id! ,
797
+ 'topLevelList' ,
798
+ ) as InstanceRef ;
811
799
final inst = await service.getObject (
812
800
isolate.id! ,
813
- list.objectId ! ,
801
+ list.id ! ,
814
802
count: null ,
815
803
offset: 1000 ,
816
804
) as Instance ;
@@ -823,10 +811,14 @@ void main() {
823
811
});
824
812
825
813
test ('Lists with offset/count are truncated' , () async {
826
- final list = await createList ();
814
+ final list = await service.evaluate (
815
+ isolate.id! ,
816
+ bootstrap! .id! ,
817
+ 'topLevelList' ,
818
+ ) as InstanceRef ;
827
819
final inst = await service.getObject (
828
820
isolate.id! ,
829
- list.objectId ! ,
821
+ list.id ! ,
830
822
count: 7 ,
831
823
offset: 4 ,
832
824
) as Instance ;
@@ -842,10 +834,14 @@ void main() {
842
834
843
835
test ('Lists are truncated to the end if offset/count runs off the end' ,
844
836
() async {
845
- final list = await createList ();
837
+ final list = await service.evaluate (
838
+ isolate.id! ,
839
+ bootstrap! .id! ,
840
+ 'topLevelList' ,
841
+ ) as InstanceRef ;
846
842
final inst = await service.getObject (
847
843
isolate.id! ,
848
- list.objectId ! ,
844
+ list.id ! ,
849
845
count: 5 ,
850
846
offset: 1000 ,
851
847
) as Instance ;
@@ -859,10 +855,14 @@ void main() {
859
855
860
856
test ('Lists are truncated to empty if offset runs off the end' ,
861
857
() async {
862
- final list = await createList ();
858
+ final list = await service.evaluate (
859
+ isolate.id! ,
860
+ bootstrap! .id! ,
861
+ 'topLevelList' ,
862
+ ) as InstanceRef ;
863
863
final inst = await service.getObject (
864
864
isolate.id! ,
865
- list.objectId ! ,
865
+ list.id ! ,
866
866
count: 5 ,
867
867
offset: 1002 ,
868
868
) as Instance ;
@@ -875,10 +875,14 @@ void main() {
875
875
876
876
test ('Lists are truncated to empty with 0 count and null offset' ,
877
877
() async {
878
- final list = await createList ();
878
+ final list = await service.evaluate (
879
+ isolate.id! ,
880
+ bootstrap! .id! ,
881
+ 'topLevelList' ,
882
+ ) as InstanceRef ;
879
883
final inst = await service.getObject (
880
884
isolate.id! ,
881
- list.objectId ! ,
885
+ list.id ! ,
882
886
count: 0 ,
883
887
offset: null ,
884
888
) as Instance ;
@@ -890,10 +894,14 @@ void main() {
890
894
});
891
895
892
896
test ('Maps with null offset/count are not truncated' , () async {
893
- final map = await createMap ();
897
+ final map = await service.evaluate (
898
+ isolate.id! ,
899
+ bootstrap! .id! ,
900
+ 'topLevelMap' ,
901
+ ) as InstanceRef ;
894
902
final inst = await service.getObject (
895
903
isolate.id! ,
896
- map.objectId ! ,
904
+ map.id ! ,
897
905
count: null ,
898
906
offset: null ,
899
907
) as Instance ;
@@ -912,10 +920,14 @@ void main() {
912
920
test (
913
921
'Maps with null count and offset greater than 0 are '
914
922
'truncated from offset to end of map' , () async {
915
- final list = await createMap ();
923
+ final map = await service.evaluate (
924
+ isolate.id! ,
925
+ bootstrap! .id! ,
926
+ 'topLevelMap' ,
927
+ ) as InstanceRef ;
916
928
final inst = await service.getObject (
917
929
isolate.id! ,
918
- list.objectId ! ,
930
+ map.id ! ,
919
931
count: null ,
920
932
offset: 1000 ,
921
933
) as Instance ;
@@ -929,10 +941,14 @@ void main() {
929
941
});
930
942
931
943
test ('Maps with null count are not truncated' , () async {
932
- final map = await createMap ();
944
+ final map = await service.evaluate (
945
+ isolate.id! ,
946
+ bootstrap! .id! ,
947
+ 'topLevelMap' ,
948
+ ) as InstanceRef ;
933
949
final inst = await service.getObject (
934
950
isolate.id! ,
935
- map.objectId ! ,
951
+ map.id ! ,
936
952
count: null ,
937
953
offset: 0 ,
938
954
) as Instance ;
@@ -949,10 +965,14 @@ void main() {
949
965
});
950
966
951
967
test ('Maps with offset/count are truncated' , () async {
952
- final map = await createMap ();
968
+ final map = await service.evaluate (
969
+ isolate.id! ,
970
+ bootstrap! .id! ,
971
+ 'topLevelMap' ,
972
+ ) as InstanceRef ;
953
973
final inst = await service.getObject (
954
974
isolate.id! ,
955
- map.objectId ! ,
975
+ map.id ! ,
956
976
count: 7 ,
957
977
offset: 4 ,
958
978
) as Instance ;
@@ -970,10 +990,14 @@ void main() {
970
990
971
991
test ('Maps are truncated to the end if offset/count runs off the end' ,
972
992
() async {
973
- final map = await createMap ();
993
+ final map = await service.evaluate (
994
+ isolate.id! ,
995
+ bootstrap! .id! ,
996
+ 'topLevelMap' ,
997
+ ) as InstanceRef ;
974
998
final inst = await service.getObject (
975
999
isolate.id! ,
976
- map.objectId ! ,
1000
+ map.id ! ,
977
1001
count: 5 ,
978
1002
offset: 1000 ,
979
1003
) as Instance ;
@@ -988,10 +1012,14 @@ void main() {
988
1012
989
1013
test ('Maps are truncated to empty if offset runs off the end' ,
990
1014
() async {
991
- final list = await createMap ();
1015
+ final map = await service.evaluate (
1016
+ isolate.id! ,
1017
+ bootstrap! .id! ,
1018
+ 'topLevelMap' ,
1019
+ ) as InstanceRef ;
992
1020
final inst = await service.getObject (
993
1021
isolate.id! ,
994
- list.objectId ! ,
1022
+ map.id ! ,
995
1023
count: 5 ,
996
1024
offset: 1002 ,
997
1025
) as Instance ;
@@ -1022,10 +1050,14 @@ void main() {
1022
1050
1023
1051
test ('Maps are truncated to empty if offset runs off the end' ,
1024
1052
() async {
1025
- final list = await createMap ();
1053
+ final map = await service.evaluate (
1054
+ isolate.id! ,
1055
+ bootstrap! .id! ,
1056
+ 'topLevelMap' ,
1057
+ ) as InstanceRef ;
1026
1058
final inst = await service.getObject (
1027
1059
isolate.id! ,
1028
- list.objectId ! ,
1060
+ map.id ! ,
1029
1061
count: 5 ,
1030
1062
offset: 1002 ,
1031
1063
) as Instance ;
@@ -1038,10 +1070,14 @@ void main() {
1038
1070
1039
1071
test ('Maps are truncated to empty with 0 count and null offset' ,
1040
1072
() async {
1041
- final list = await createMap ();
1073
+ final map = await service.evaluate (
1074
+ isolate.id! ,
1075
+ bootstrap! .id! ,
1076
+ 'topLevelMap' ,
1077
+ ) as InstanceRef ;
1042
1078
final inst = await service.getObject (
1043
1079
isolate.id! ,
1044
- list.objectId ! ,
1080
+ map.id ! ,
1045
1081
count: 0 ,
1046
1082
offset: null ,
1047
1083
) as Instance ;
0 commit comments