2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
- // @dart = 2.9
6
-
7
5
@TestOn ('vm' )
8
6
import 'package:dwds/dwds.dart' ;
9
7
import 'package:dwds/src/connections/debug_connection.dart' ;
@@ -23,8 +21,8 @@ final context = TestContext(
23
21
WipConnection get tabConnection => context.tabConnection;
24
22
25
23
void main () {
26
- AppInspector inspector;
27
- Debugger debugger;
24
+ late AppInspector inspector;
25
+ late Debugger debugger;
28
26
29
27
setUpAll (() async {
30
28
await context.setUp ();
@@ -60,7 +58,7 @@ void main() {
60
58
() => inspector.jsEvaluate ('<' ),
61
59
throwsA (isA <ChromeDebugException >()
62
60
.having ((e) => e.text, 'text' , 'Uncaught' )
63
- .having ((e) => e.exception.description, 'description' ,
61
+ .having ((e) => e.exception? .description, 'description' ,
64
62
contains ('SyntaxError' ))
65
63
.having ((e) => e.stackTrace, 'stackTrace' , isNull)
66
64
.having ((e) => e.evalContents, 'evalContents' , '<' )));
@@ -78,9 +76,9 @@ void main() {
78
76
''' ),
79
77
throwsA (isA <ChromeDebugException >()
80
78
.having ((e) => e.text, 'text' , 'Uncaught' )
81
- .having ((e) => e.exception.description, 'description' ,
79
+ .having ((e) => e.exception? .description, 'description' ,
82
80
contains ('ReferenceError' ))
83
- .having ((e) => e.stackTrace.printFrames ()[0 ], 'stackTrace' ,
81
+ .having ((e) => e.stackTrace? .printFrames ()[0 ], 'stackTrace' ,
84
82
contains ('foo()' ))
85
83
.having ((e) => e.evalContents, 'evalContents' , contains ('foo' ))));
86
84
});
@@ -89,17 +87,17 @@ void main() {
89
87
test ('send toString' , () async {
90
88
final remoteObject = await libraryPublicFinal ();
91
89
final toString =
92
- await inspector.invoke (remoteObject.objectId, 'toString' , []);
90
+ await inspector.invoke (remoteObject.objectId! , 'toString' , []);
93
91
expect (toString.value, 'A test class with message world' );
94
92
});
95
93
96
94
group ('getObject' , () {
97
95
test ('for class with generic' , () async {
98
96
final remoteObject = await libraryPublicFinal ();
99
97
final instance =
100
- await inspector.getObject (remoteObject.objectId) as Instance ;
101
- final classRef = instance.classRef;
102
- final clazz = await inspector.getObject (classRef.id) as Class ;
98
+ await inspector.getObject (remoteObject.objectId! ) as Instance ;
99
+ final classRef = instance.classRef! ;
100
+ final clazz = await inspector.getObject (classRef.id! ) as Class ;
103
101
expect (clazz.name, 'MyTestClass<dynamic>' );
104
102
});
105
103
});
@@ -120,7 +118,7 @@ void main() {
120
118
121
119
test ('properties' , () async {
122
120
final remoteObject = await libraryPublicFinal ();
123
- final properties = await debugger.getProperties (remoteObject.objectId);
121
+ final properties = await debugger.getProperties (remoteObject.objectId! );
124
122
final names =
125
123
properties.map ((p) => p.name).where ((x) => x != '__proto__' ).toList ();
126
124
final expected = [
@@ -141,16 +139,18 @@ void main() {
141
139
// We test these here because the test fixture has more complicated members
142
140
// to exercise.
143
141
144
- LibraryRef bootstrapLibrary;
145
- RemoteObject instance;
142
+ LibraryRef ? bootstrapLibrary;
143
+ late RemoteObject instance;
144
+ late String objectId;
146
145
147
146
setUp (() async {
148
147
bootstrapLibrary = inspector.isolate.rootLib;
149
148
instance = await libraryPublicFinal ();
149
+ objectId = instance.objectId! ;
150
150
});
151
151
152
152
test ('invoke top-level private' , () async {
153
- final remote = await inspector.invoke (bootstrapLibrary.id,
153
+ final remote = await inspector.invoke (bootstrapLibrary! .id! ,
154
154
'_libraryPrivateFunction' , [dartIdFor (2 ), dartIdFor (3 )]);
155
155
expect (
156
156
remote,
@@ -159,17 +159,16 @@ void main() {
159
159
});
160
160
161
161
test ('invoke instance private' , () async {
162
- final remote = await inspector. invoke (
163
- instance. objectId, 'privateMethod' , [dartIdFor ('some string' )]);
162
+ final remote = await inspector
163
+ . invoke ( objectId, 'privateMethod' , [dartIdFor ('some string' )]);
164
164
expect (
165
165
remote,
166
166
const TypeMatcher <RemoteObject >().having ((instance) => instance.value,
167
167
'result' , 'some string : a private field' ));
168
168
});
169
169
170
170
test ('invoke instance method with object parameter' , () async {
171
- final remote = await inspector
172
- .invoke (instance.objectId, 'equals' , [instance.objectId]);
171
+ final remote = await inspector.invoke (objectId, 'equals' , [objectId]);
173
172
expect (
174
173
remote,
175
174
const TypeMatcher <RemoteObject >()
@@ -179,15 +178,15 @@ void main() {
179
178
test ('invoke instance method with object parameter 2' , () async {
180
179
final libraryPrivateList = await libraryPrivate ();
181
180
final remote = await inspector
182
- .invoke (instance. objectId, 'equals' , [libraryPrivateList.objectId]);
181
+ .invoke (objectId, 'equals' , [libraryPrivateList.objectId]);
183
182
expect (
184
183
remote,
185
184
const TypeMatcher <RemoteObject >()
186
185
.having ((instance) => instance.value, 'result' , false ));
187
186
});
188
187
189
188
test ('invoke closure stored in an instance field' , () async {
190
- final remote = await inspector.invoke (instance. objectId, 'closure' , []);
189
+ final remote = await inspector.invoke (objectId, 'closure' , []);
191
190
expect (
192
191
remote,
193
192
const TypeMatcher <RemoteObject >()
@@ -196,7 +195,7 @@ void main() {
196
195
197
196
test ('invoke a torn-off method' , () async {
198
197
final toString = await inspector.loadField (instance, 'tornOff' );
199
- final result = await inspector.invoke (toString.objectId, 'call' , []);
198
+ final result = await inspector.invoke (toString.objectId! , 'call' , []);
200
199
expect (
201
200
result,
202
201
const TypeMatcher <RemoteObject >().having ((instance) => instance.value,
0 commit comments