@@ -368,6 +368,10 @@ void main() {
368
368
var process = await testRunner.runWebDev (args,
369
369
workingDirectory:
370
370
soundNullSafety ? soundExampleDirectory : exampleDirectory);
371
+
372
+ process.stdoutStream ().listen (Logger .root.fine);
373
+ process.stderrStream ().listen (Logger .root.warning);
374
+
371
375
VmService ? vmService;
372
376
373
377
try {
@@ -412,6 +416,74 @@ void main() {
412
416
await process.shouldExit ();
413
417
}
414
418
}, timeout: const Timeout .factor (2 ));
419
+
420
+ test ('evaluate and get objects' , () async {
421
+ var openPort = await findUnusedPort ();
422
+ // running daemon command that starts dwds without keyboard input
423
+ var args = [
424
+ 'daemon' ,
425
+ 'web:$openPort ' ,
426
+ '--enable-expression-evaluation' ,
427
+ '--verbose' ,
428
+ ];
429
+ var process = await testRunner.runWebDev (args,
430
+ workingDirectory:
431
+ soundNullSafety ? soundExampleDirectory : exampleDirectory);
432
+
433
+ process.stdoutStream ().listen (Logger .root.fine);
434
+ process.stderrStream ().listen (Logger .root.warning);
435
+
436
+ VmService ? vmService;
437
+
438
+ try {
439
+ // Wait for debug service Uri
440
+ String ? wsUri;
441
+ await expectLater (process.stdout, emitsThrough ((message) {
442
+ wsUri = getDebugServiceUri (message as String );
443
+ return wsUri != null ;
444
+ }));
445
+ expect (wsUri, isNotNull);
446
+
447
+ vmService = await vmServiceConnectUri (wsUri! );
448
+ var vm = await vmService.getVM ();
449
+ var isolateId = vm.isolates! .first.id! ;
450
+ var isolate = await vmService.getIsolate (isolateId);
451
+ var libraryId = isolate.rootLib! .id! ;
452
+
453
+ await vmService.streamListen ('Debug' );
454
+
455
+ final result = await vmService.evaluate (
456
+ isolateId, libraryId, '[true, false]' );
457
+ expect (
458
+ result,
459
+ const TypeMatcher <InstanceRef >().having (
460
+ (instance) => instance.classRef? .name,
461
+ 'class name' ,
462
+ 'List<bool>' ));
463
+
464
+ final instanceRef = result as InstanceRef ;
465
+ final list =
466
+ await vmService.getObject (isolateId, instanceRef.id! );
467
+ expect (
468
+ list,
469
+ const TypeMatcher <Instance >().having (
470
+ (instance) => instance.classRef? .name,
471
+ 'class name' ,
472
+ 'List<bool>' ));
473
+
474
+ final elements = (list as Instance ).elements;
475
+ expect (elements, [
476
+ const TypeMatcher <InstanceRef >().having (
477
+ (instance) => instance.valueAsString, 'value' , 'true' ),
478
+ const TypeMatcher <InstanceRef >().having (
479
+ (instance) => instance.valueAsString, 'value' , 'false' ),
480
+ ]);
481
+ } finally {
482
+ await vmService? .dispose ();
483
+ await exitWebdev (process);
484
+ await process.shouldExit ();
485
+ }
486
+ }, timeout: const Timeout .factor (2 ));
415
487
});
416
488
417
489
group ('and --no-enable-expression-evaluation:' , () {
0 commit comments