22// for details. All rights reserved. Use of this source code is governed by a
33// BSD-style license that can be found in the LICENSE file.
44
5- // @ dart = 2.9
5+ import ' dart:async' ;
66
77import 'package:dwds/src/connections/debug_connection.dart' ;
88import 'package:dwds/src/debugging/debugger.dart' ;
@@ -20,8 +20,8 @@ final context = TestContext(
2020WipConnection get tabConnection => context.tabConnection;
2121
2222void main () {
23- AppInspector inspector;
24- Debugger debugger;
23+ late AppInspector inspector;
24+ late Debugger debugger;
2525
2626 setUpAll (() async {
2727 await context.setUp ();
@@ -54,9 +54,9 @@ void main() {
5454 final remoteObject = await libraryPublicFinal ();
5555 final nullVariable = await inspector.loadField (remoteObject, 'notFinal' );
5656 final ref = await inspector.instanceRefFor (nullVariable);
57- expect (ref.valueAsString, 'null' );
57+ expect (ref! .valueAsString, 'null' );
5858 expect (ref.kind, InstanceKind .kNull);
59- final classRef = ref.classRef;
59+ final classRef = ref.classRef! ;
6060 expect (classRef.name, 'Null' );
6161 expect (classRef.id, 'classes|dart:core|Null' );
6262 });
@@ -65,9 +65,9 @@ void main() {
6565 final remoteObject = await libraryPublicFinal ();
6666 final count = await inspector.loadField (remoteObject, 'count' );
6767 final ref = await inspector.instanceRefFor (count);
68- expect (ref.valueAsString, '0' );
68+ expect (ref! .valueAsString, '0' );
6969 expect (ref.kind, InstanceKind .kDouble);
70- final classRef = ref.classRef;
70+ final classRef = ref.classRef! ;
7171 expect (classRef.name, 'Double' );
7272 expect (classRef.id, 'classes|dart:core|Double' );
7373 });
@@ -76,8 +76,8 @@ void main() {
7676 final remoteObject = await libraryPublicFinal ();
7777 final count = await inspector.loadField (remoteObject, 'myselfField' );
7878 final ref = await inspector.instanceRefFor (count);
79- expect (ref.kind, InstanceKind .kPlainInstance);
80- final classRef = ref.classRef;
79+ expect (ref! .kind, InstanceKind .kPlainInstance);
80+ final classRef = ref.classRef! ;
8181 expect (classRef.name, 'MyTestClass<dynamic>' );
8282 expect (
8383 classRef.id,
@@ -87,11 +87,11 @@ void main() {
8787
8888 test ('for closure' , () async {
8989 final remoteObject = await libraryPublicFinal ();
90- final properties = await debugger.getProperties (remoteObject.objectId);
90+ final properties = await debugger.getProperties (remoteObject.objectId! );
9191 final closure =
9292 properties.firstWhere ((property) => property.name == 'closure' );
93- final instanceRef = await inspector.instanceRefFor (closure.value);
94- final functionName = instanceRef.closureFunction.name;
93+ final instanceRef = await inspector.instanceRefFor (closure.value! );
94+ final functionName = instanceRef! .closureFunction! .name;
9595 // Older SDKs do not contain function names
9696 if (functionName != 'Closure' ) {
9797 expect (functionName, 'someFunction' );
@@ -102,40 +102,40 @@ void main() {
102102 test ('for a list' , () async {
103103 final remoteObject = await libraryPublic ();
104104 final ref = await inspector.instanceRefFor (remoteObject);
105- expect (ref.length, greaterThan (0 ));
105+ expect (ref! .length, greaterThan (0 ));
106106 expect (ref.kind, InstanceKind .kList);
107- expect (ref.classRef.name, 'List<String>' );
107+ expect (ref.classRef! .name, 'List<String>' );
108108 });
109109
110110 test ('for map' , () async {
111111 final remoteObject =
112112 await inspector.jsEvaluate (libraryVariableExpression ('map' ));
113113 final ref = await inspector.instanceRefFor (remoteObject);
114- expect (ref.length, 2 );
114+ expect (ref! .length, 2 );
115115 expect (ref.kind, InstanceKind .kMap);
116- expect (ref.classRef.name, 'LinkedMap<Object, Object>' );
116+ expect (ref.classRef! .name, 'LinkedMap<Object, Object>' );
117117 });
118118
119119 test ('for an IdentityMap' , () async {
120120 final remoteObject =
121121 await inspector.jsEvaluate (libraryVariableExpression ('identityMap' ));
122122 final ref = await inspector.instanceRefFor (remoteObject);
123- expect (ref.length, 2 );
123+ expect (ref! .length, 2 );
124124 expect (ref.kind, InstanceKind .kMap);
125- expect (ref.classRef.name, 'IdentityMap<String, int>' );
125+ expect (ref.classRef! .name, 'IdentityMap<String, int>' );
126126 });
127127 });
128128
129129 group ('instance' , () {
130130 test ('for class object' , () async {
131131 final remoteObject = await libraryPublicFinal ();
132132 final instance = await inspector.instanceFor (remoteObject);
133- expect (instance.kind, InstanceKind .kPlainInstance);
134- final classRef = instance.classRef;
133+ expect (instance! .kind, InstanceKind .kPlainInstance);
134+ final classRef = instance.classRef! ;
135135 expect (classRef, isNotNull);
136136 expect (classRef.name, 'MyTestClass<dynamic>' );
137137 final fieldNames =
138- instance.fields.map ((boundField) => boundField.decl.name).toList ();
138+ instance.fields! .map ((boundField) => boundField.decl! .name).toList ();
139139 expect (fieldNames, [
140140 '_privateField' ,
141141 'abstractField' ,
@@ -146,54 +146,54 @@ void main() {
146146 'notFinal' ,
147147 'tornOff' ,
148148 ]);
149- for (var field in instance.fields) {
150- expect (field.decl.declaredType, isNotNull);
149+ for (var field in instance.fields! ) {
150+ expect (field.decl! .declaredType, isNotNull);
151151 }
152152 });
153153
154154 test ('for closure' , () async {
155155 final remoteObject = await libraryPublicFinal ();
156- final properties = await debugger.getProperties (remoteObject.objectId);
156+ final properties = await debugger.getProperties (remoteObject.objectId! );
157157 final closure =
158158 properties.firstWhere ((property) => property.name == 'closure' );
159- final instance = await inspector.instanceFor (closure.value);
160- expect (instance.kind, InstanceKind .kClosure);
161- expect (instance.classRef.name, 'Closure' );
159+ final instance = await inspector.instanceFor (closure.value! );
160+ expect (instance! .kind, InstanceKind .kClosure);
161+ expect (instance.classRef! .name, 'Closure' );
162162 });
163163
164164 test ('for a nested class' , () async {
165165 final libraryRemoteObject = await libraryPublicFinal ();
166166 final fieldRemoteObject =
167167 await inspector.loadField (libraryRemoteObject, 'myselfField' );
168168 final instance = await inspector.instanceFor (fieldRemoteObject);
169- expect (instance.kind, InstanceKind .kPlainInstance);
170- final classRef = instance.classRef;
169+ expect (instance! .kind, InstanceKind .kPlainInstance);
170+ final classRef = instance.classRef! ;
171171 expect (classRef, isNotNull);
172172 expect (classRef.name, 'MyTestClass<dynamic>' );
173173 });
174174
175175 test ('for a list' , () async {
176176 final remote = await libraryPublic ();
177177 final instance = await inspector.instanceFor (remote);
178- expect (instance.kind, InstanceKind .kList);
179- final classRef = instance.classRef;
178+ expect (instance! .kind, InstanceKind .kList);
179+ final classRef = instance.classRef! ;
180180 expect (classRef, isNotNull);
181181 expect (classRef.name, 'List<String>' );
182- final first = instance.elements[0 ];
182+ final first = instance.elements! [0 ];
183183 expect (first.valueAsString, 'library' );
184184 });
185185
186186 test ('for a map' , () async {
187187 final remote =
188188 await inspector.jsEvaluate (libraryVariableExpression ('map' ));
189189 final instance = await inspector.instanceFor (remote);
190- expect (instance.kind, InstanceKind .kMap);
191- final classRef = instance.classRef;
190+ expect (instance! .kind, InstanceKind .kMap);
191+ final classRef = instance.classRef! ;
192192 expect (classRef.name, 'LinkedMap<Object, Object>' );
193- final first = instance.associations[0 ].value as InstanceRef ;
193+ final first = instance.associations! [0 ].value as InstanceRef ;
194194 expect (first.kind, InstanceKind .kList);
195195 expect (first.length, 3 );
196- final second = instance.associations[1 ].value as InstanceRef ;
196+ final second = instance.associations! [1 ].value as InstanceRef ;
197197 expect (second.kind, InstanceKind .kString);
198198 expect (second.valueAsString, 'something' );
199199 });
@@ -202,10 +202,10 @@ void main() {
202202 final remote =
203203 await inspector.jsEvaluate (libraryVariableExpression ('identityMap' ));
204204 final instance = await inspector.instanceFor (remote);
205- expect (instance.kind, InstanceKind .kMap);
206- final classRef = instance.classRef;
205+ expect (instance! .kind, InstanceKind .kMap);
206+ final classRef = instance.classRef! ;
207207 expect (classRef.name, 'IdentityMap<String, int>' );
208- final first = instance.associations[0 ].value;
208+ final first = instance.associations! [0 ].value;
209209 expect (first.valueAsString, '1' );
210210 });
211211
@@ -214,12 +214,12 @@ void main() {
214214 final remote =
215215 await inspector.jsEvaluate (libraryVariableExpression ('notAList' ));
216216 final instance = await inspector.instanceFor (remote);
217- expect (instance.kind, InstanceKind .kPlainInstance);
218- final classRef = instance.classRef;
217+ expect (instance! .kind, InstanceKind .kPlainInstance);
218+ final classRef = instance.classRef! ;
219219 expect (classRef.name, 'NotReallyAList' );
220220 expect (instance.elements, isNull);
221- final field = instance.fields.first;
222- expect (field.decl.name, '_internal' );
221+ final field = instance.fields! .first;
222+ expect (field.decl! .name, '_internal' );
223223 });
224224 });
225225}
0 commit comments