@@ -82,7 +82,7 @@ void main() {
82
82
restoreVmServiceConnectionFunction ();
83
83
});
84
84
85
- test ('end-to-end with three vm connections and flutter view query' , () async {
85
+ test ('end-to-end with one vm connection and flutter view query' , () async {
86
86
int port = 0 ;
87
87
Future <PortForwarder > fakePortForwardingFunction (
88
88
String address,
@@ -102,54 +102,72 @@ void main() {
102
102
fuchsiaPortForwardingFunction = fakePortForwardingFunction;
103
103
final FakeSshCommandRunner fakeRunner = FakeSshCommandRunner ();
104
104
// Adds some extra junk to make sure the strings will be cleaned up.
105
- fakeRunner.findResponse = < String > ['/hub/blah/blah/blah/vmservice-port\n ' ];
106
- fakeRunner.lsResponse = < String > ['123\n\n\n ' , '456 ' , '789' ];
105
+ fakeRunner.iqueryResponse = < String > [
106
+ '[' ,
107
+ ' {' ,
108
+ ' "data_source": "Inspect",' ,
109
+ ' "metadata": {' ,
110
+ ' "filename": "fuchsia.inspect.Tree",' ,
111
+ ' "component_url": "fuchsia-pkg://fuchsia.com/flutter_runner#meta/flutter_runner.cm",' ,
112
+ ' "timestamp": 12345678901234' ,
113
+ ' },' ,
114
+ ' "moniker": "core/session-manager/session/flutter_runner",' ,
115
+ ' "payload": {' ,
116
+ ' "root": {' ,
117
+ ' "vm_service_port": "12345",' ,
118
+ ' "16859221": {' ,
119
+ ' "empty_tree": "this semantic tree is empty"' ,
120
+ ' },' ,
121
+ ' "build_info": {' ,
122
+ ' "dart_sdk_git_revision": "77e83fcc14fa94049f363d554579f48fbd6bb7a1",' ,
123
+ ' "dart_sdk_semantic_version": "2.19.0-317.0.dev",' ,
124
+ ' "flutter_engine_git_revision": "563b8e830c697a543bf0a8a9f4ae3edfad86ea86",' ,
125
+ ' "fuchsia_sdk_version": "10.20221018.0.1"' ,
126
+ ' },' ,
127
+ ' "vm": {' ,
128
+ ' "dst_status": 1,' ,
129
+ ' "get_profile_status": 0,' ,
130
+ ' "num_get_profile_calls": 1,' ,
131
+ ' "num_intl_provider_errors": 0,' ,
132
+ ' "num_on_change_calls": 0,' ,
133
+ ' "timezone_content_status": 0,' ,
134
+ ' "tz_data_close_status": -1,' ,
135
+ ' "tz_data_status": -1' ,
136
+ ' }' ,
137
+ ' }' ,
138
+ ' },' ,
139
+ ' "version": 1' ,
140
+ ' }' ,
141
+ ' ]'
142
+ ];
107
143
fakeRunner.address = 'fe80::8eae:4cff:fef4:9247' ;
108
144
fakeRunner.interface = 'eno1' ;
109
145
110
146
final FuchsiaRemoteConnection connection =
111
147
await FuchsiaRemoteConnection .connectWithSshCommandRunner (fakeRunner);
112
148
113
- // [fakePortForwardingFunction] will have returned three different
114
- // forwarded ports, incrementing the port each time by one. (Just a sanity
115
- // check that the forwarding port was called).
116
- expect (forwardedPorts.length, 3 );
117
- expect (forwardedPorts[0 ].remotePort, 123 );
118
- expect (forwardedPorts[1 ].remotePort, 456 );
119
- expect (forwardedPorts[2 ].remotePort, 789 );
120
- expect (forwardedPorts[0 ].port, 0 );
121
- expect (forwardedPorts[1 ].port, 1 );
122
- expect (forwardedPorts[2 ].port, 2 );
149
+ expect (forwardedPorts.length, 1 );
150
+ expect (forwardedPorts[0 ].remotePort, 12345 );
123
151
124
152
// VMs should be accessed via localhost ports given by
125
153
// [fakePortForwardingFunction].
126
154
expect (uriConnections[0 ],
127
- Uri (scheme: 'ws' , host: '[::1]' , port: 0 , path: '/ws' ));
128
- expect (uriConnections[1 ],
129
- Uri (scheme: 'ws' , host: '[::1]' , port: 1 , path: '/ws' ));
130
- expect (uriConnections[2 ],
131
- Uri (scheme: 'ws' , host: '[::1]' , port: 2 , path: '/ws' ));
155
+ Uri (scheme: 'ws' , host: '[::1]' , port: 0 , path: '/ws' ));
132
156
133
157
final List <FlutterView > views = await connection.getFlutterViews ();
134
158
expect (views, isNot (null ));
135
- expect (views.length, 3 );
159
+ expect (views.length, 1 );
136
160
// Since name can be null, check for the ID on all of them.
137
161
expect (views[0 ].id, 'flutterView0' );
138
- expect (views[1 ].id, 'flutterView1' );
139
- expect (views[2 ].id, 'flutterView2' );
140
162
141
163
expect (views[0 ].name, equals (null ));
142
- expect (views[1 ].name, 'file://flutterBinary1' );
143
- expect (views[2 ].name, 'file://flutterBinary2' );
144
164
145
165
// Ensure the ports are all closed after stop was called.
146
166
await connection.stop ();
147
167
expect (forwardedPorts[0 ].stopped, true );
148
- expect (forwardedPorts[1 ].stopped, true );
149
- expect (forwardedPorts[2 ].stopped, true );
150
168
});
151
169
152
- test ('end-to-end with three vms and remote open port' , () async {
170
+ test ('end-to-end with one vm and remote open port' , () async {
153
171
int port = 0 ;
154
172
Future <PortForwarder > fakePortForwardingFunction (
155
173
String address,
@@ -170,53 +188,71 @@ void main() {
170
188
fuchsiaPortForwardingFunction = fakePortForwardingFunction;
171
189
final FakeSshCommandRunner fakeRunner = FakeSshCommandRunner ();
172
190
// Adds some extra junk to make sure the strings will be cleaned up.
173
- fakeRunner.findResponse = < String > ['/hub/blah/blah/blah/vmservice-port\n ' ];
174
- fakeRunner.lsResponse = < String > ['123\n\n\n ' , '456 ' , '789' ];
191
+ fakeRunner.iqueryResponse = < String > [
192
+ '[' ,
193
+ ' {' ,
194
+ ' "data_source": "Inspect",' ,
195
+ ' "metadata": {' ,
196
+ ' "filename": "fuchsia.inspect.Tree",' ,
197
+ ' "component_url": "fuchsia-pkg://fuchsia.com/flutter_runner#meta/flutter_runner.cm",' ,
198
+ ' "timestamp": 12345678901234' ,
199
+ ' },' ,
200
+ ' "moniker": "core/session-manager/session/flutter_runner",' ,
201
+ ' "payload": {' ,
202
+ ' "root": {' ,
203
+ ' "vm_service_port": "12345",' ,
204
+ ' "16859221": {' ,
205
+ ' "empty_tree": "this semantic tree is empty"' ,
206
+ ' },' ,
207
+ ' "build_info": {' ,
208
+ ' "dart_sdk_git_revision": "77e83fcc14fa94049f363d554579f48fbd6bb7a1",' ,
209
+ ' "dart_sdk_semantic_version": "2.19.0-317.0.dev",' ,
210
+ ' "flutter_engine_git_revision": "563b8e830c697a543bf0a8a9f4ae3edfad86ea86",' ,
211
+ ' "fuchsia_sdk_version": "10.20221018.0.1"' ,
212
+ ' },' ,
213
+ ' "vm": {' ,
214
+ ' "dst_status": 1,' ,
215
+ ' "get_profile_status": 0,' ,
216
+ ' "num_get_profile_calls": 1,' ,
217
+ ' "num_intl_provider_errors": 0,' ,
218
+ ' "num_on_change_calls": 0,' ,
219
+ ' "timezone_content_status": 0,' ,
220
+ ' "tz_data_close_status": -1,' ,
221
+ ' "tz_data_status": -1' ,
222
+ ' }' ,
223
+ ' }' ,
224
+ ' },' ,
225
+ ' "version": 1' ,
226
+ ' }' ,
227
+ ' ]'
228
+ ];
175
229
fakeRunner.address = 'fe80::8eae:4cff:fef4:9247' ;
176
230
fakeRunner.interface = 'eno1' ;
177
231
final FuchsiaRemoteConnection connection =
178
232
await FuchsiaRemoteConnection .connectWithSshCommandRunner (fakeRunner);
179
233
180
- // [fakePortForwardingFunction] will have returned three different
181
- // forwarded ports, incrementing the port each time by one. (Just a sanity
182
- // check that the forwarding port was called).
183
- expect (forwardedPorts.length, 3 );
184
- expect (forwardedPorts[0 ].remotePort, 123 );
185
- expect (forwardedPorts[1 ].remotePort, 456 );
186
- expect (forwardedPorts[2 ].remotePort, 789 );
187
- expect (forwardedPorts[0 ].port, 0 );
188
- expect (forwardedPorts[1 ].port, 1 );
189
- expect (forwardedPorts[2 ].port, 2 );
234
+ expect (forwardedPorts.length, 1 );
235
+ expect (forwardedPorts[0 ].remotePort, 12345 );
190
236
191
237
// VMs should be accessed via the alternate address given by
192
238
// [fakePortForwardingFunction].
193
239
expect (uriConnections[0 ],
194
- Uri (scheme: 'ws' , host: '[fe80::1:2%25eno2]' , port: 0 , path: '/ws' ));
195
- expect (uriConnections[1 ],
196
- Uri (scheme: 'ws' , host: '[fe80::1:2%25eno2]' , port: 1 , path: '/ws' ));
197
- expect (uriConnections[2 ],
198
- Uri (scheme: 'ws' , host: '[fe80::1:2%25eno2]' , port: 2 , path: '/ws' ));
240
+ Uri (scheme: 'ws' , host: '[fe80::1:2%25eno2]' , port: 0 , path: '/ws' ));
199
241
200
242
final List <FlutterView > views = await connection.getFlutterViews ();
201
243
expect (views, isNot (null ));
202
- expect (views.length, 3 );
244
+ expect (views.length, 1 );
203
245
// Since name can be null, check for the ID on all of them.
204
246
expect (views[0 ].id, 'flutterView0' );
205
- expect (views[1 ].id, 'flutterView1' );
206
- expect (views[2 ].id, 'flutterView2' );
207
247
208
248
expect (views[0 ].name, equals (null ));
209
- expect (views[1 ].name, 'file://flutterBinary1' );
210
- expect (views[2 ].name, 'file://flutterBinary2' );
211
249
212
250
// Ensure the ports are all closed after stop was called.
213
251
await connection.stop ();
214
252
expect (forwardedPorts[0 ].stopped, true );
215
- expect (forwardedPorts[1 ].stopped, true );
216
- expect (forwardedPorts[2 ].stopped, true );
217
253
});
218
254
219
- test ('end-to-end with three vms and ipv4' , () async {
255
+ test ('end-to-end with one vm and ipv4' , () async {
220
256
int port = 0 ;
221
257
Future <PortForwarder > fakePortForwardingFunction (
222
258
String address,
@@ -236,49 +272,67 @@ void main() {
236
272
fuchsiaPortForwardingFunction = fakePortForwardingFunction;
237
273
final FakeSshCommandRunner fakeRunner = FakeSshCommandRunner ();
238
274
// Adds some extra junk to make sure the strings will be cleaned up.
239
- fakeRunner.findResponse = < String > ['/hub/blah/blah/blah/vmservice-port\n ' ];
240
- fakeRunner.lsResponse = < String > ['123\n\n\n ' , '456 ' , '789' ];
275
+ fakeRunner.iqueryResponse = < String > [
276
+ '[' ,
277
+ ' {' ,
278
+ ' "data_source": "Inspect",' ,
279
+ ' "metadata": {' ,
280
+ ' "filename": "fuchsia.inspect.Tree",' ,
281
+ ' "component_url": "fuchsia-pkg://fuchsia.com/flutter_runner#meta/flutter_runner.cm",' ,
282
+ ' "timestamp": 12345678901234' ,
283
+ ' },' ,
284
+ ' "moniker": "core/session-manager/session/flutter_runner",' ,
285
+ ' "payload": {' ,
286
+ ' "root": {' ,
287
+ ' "vm_service_port": "12345",' ,
288
+ ' "16859221": {' ,
289
+ ' "empty_tree": "this semantic tree is empty"' ,
290
+ ' },' ,
291
+ ' "build_info": {' ,
292
+ ' "dart_sdk_git_revision": "77e83fcc14fa94049f363d554579f48fbd6bb7a1",' ,
293
+ ' "dart_sdk_semantic_version": "2.19.0-317.0.dev",' ,
294
+ ' "flutter_engine_git_revision": "563b8e830c697a543bf0a8a9f4ae3edfad86ea86",' ,
295
+ ' "fuchsia_sdk_version": "10.20221018.0.1"' ,
296
+ ' },' ,
297
+ ' "vm": {' ,
298
+ ' "dst_status": 1,' ,
299
+ ' "get_profile_status": 0,' ,
300
+ ' "num_get_profile_calls": 1,' ,
301
+ ' "num_intl_provider_errors": 0,' ,
302
+ ' "num_on_change_calls": 0,' ,
303
+ ' "timezone_content_status": 0,' ,
304
+ ' "tz_data_close_status": -1,' ,
305
+ ' "tz_data_status": -1' ,
306
+ ' }' ,
307
+ ' }' ,
308
+ ' },' ,
309
+ ' "version": 1' ,
310
+ ' }' ,
311
+ ' ]'
312
+ ];
241
313
fakeRunner.address = '196.168.1.4' ;
242
314
243
315
final FuchsiaRemoteConnection connection =
244
316
await FuchsiaRemoteConnection .connectWithSshCommandRunner (fakeRunner);
245
317
246
- // [fakePortForwardingFunction] will have returned three different
247
- // forwarded ports, incrementing the port each time by one. (Just a sanity
248
- // check that the forwarding port was called).
249
- expect (forwardedPorts.length, 3 );
250
- expect (forwardedPorts[0 ].remotePort, 123 );
251
- expect (forwardedPorts[1 ].remotePort, 456 );
252
- expect (forwardedPorts[2 ].remotePort, 789 );
253
- expect (forwardedPorts[0 ].port, 0 );
254
- expect (forwardedPorts[1 ].port, 1 );
255
- expect (forwardedPorts[2 ].port, 2 );
318
+ expect (forwardedPorts.length, 1 );
319
+ expect (forwardedPorts[0 ].remotePort, 12345 );
256
320
257
321
// VMs should be accessed via the ipv4 loopback.
258
322
expect (uriConnections[0 ],
259
- Uri (scheme: 'ws' , host: '127.0.0.1' , port: 0 , path: '/ws' ));
260
- expect (uriConnections[1 ],
261
- Uri (scheme: 'ws' , host: '127.0.0.1' , port: 1 , path: '/ws' ));
262
- expect (uriConnections[2 ],
263
- Uri (scheme: 'ws' , host: '127.0.0.1' , port: 2 , path: '/ws' ));
323
+ Uri (scheme: 'ws' , host: '127.0.0.1' , port: 0 , path: '/ws' ));
264
324
265
325
final List <FlutterView > views = await connection.getFlutterViews ();
266
326
expect (views, isNot (null ));
267
- expect (views.length, 3 );
327
+ expect (views.length, 1 );
268
328
// Since name can be null, check for the ID on all of them.
269
329
expect (views[0 ].id, 'flutterView0' );
270
- expect (views[1 ].id, 'flutterView1' );
271
- expect (views[2 ].id, 'flutterView2' );
272
330
273
331
expect (views[0 ].name, equals (null ));
274
- expect (views[1 ].name, 'file://flutterBinary1' );
275
- expect (views[2 ].name, 'file://flutterBinary2' );
276
332
277
333
// Ensure the ports are all closed after stop was called.
278
334
await connection.stop ();
279
335
expect (forwardedPorts[0 ].stopped, true );
280
- expect (forwardedPorts[1 ].stopped, true );
281
- expect (forwardedPorts[2 ].stopped, true );
282
336
});
283
337
284
338
test ('env variable test without remote addr' , () async {
@@ -294,15 +348,11 @@ void main() {
294
348
}
295
349
296
350
class FakeSshCommandRunner extends Fake implements SshCommandRunner {
297
- List <String >? findResponse;
298
- List <String >? lsResponse;
351
+ List <String >? iqueryResponse;
299
352
@override
300
353
Future <List <String >> run (String command) async {
301
- if (command.startsWith ('/bin/find' )) {
302
- return findResponse! ;
303
- }
304
- if (command.startsWith ('/bin/ls' )) {
305
- return lsResponse! ;
354
+ if (command.startsWith ('iquery --format json show' )) {
355
+ return iqueryResponse! ;
306
356
}
307
357
throw UnimplementedError (command);
308
358
}
0 commit comments