@@ -432,19 +432,18 @@ void main() {
432
432
});
433
433
434
434
group ('screenshot' , () {
435
- MockProcessManager mockProcessManager;
436
-
437
- setUp (() {
438
- mockProcessManager = MockProcessManager ();
439
- });
440
-
441
- test ('is supported on posix platforms' , () {
435
+ testUsingContext ('is supported on posix platforms' , () {
442
436
final FuchsiaDevice device = FuchsiaDevice ('id' , name: 'tester' );
443
437
expect (device.supportsScreenshot, true );
444
- }, testOn: 'posix' );
438
+ }, overrides: < Type , Generator > {
439
+ Platform : () => FakePlatform (
440
+ operatingSystem: 'linux' ,
441
+ ),
442
+ });
445
443
446
444
testUsingContext ('is not supported on Windows' , () {
447
445
final FuchsiaDevice device = FuchsiaDevice ('id' , name: 'tester' );
446
+
448
447
expect (device.supportsScreenshot, false );
449
448
}, overrides: < Type , Generator > {
450
449
Platform : () => FakePlatform (
@@ -458,12 +457,12 @@ void main() {
458
457
() => device.takeScreenshot (globals.fs.file ('file.invalid' )),
459
458
throwsA (equals ('file.invalid must be a .ppm file' )),
460
459
);
461
- }, testOn : 'posix' );
460
+ });
462
461
463
462
testUsingContext ('takeScreenshot throws if screencap failed' , () async {
464
463
final FuchsiaDevice device = FuchsiaDevice ('0.0.0.0' , name: 'tester' );
465
464
466
- when (mockProcessManager .run (
465
+ when (globals.processManager .run (
467
466
const < String > [
468
467
'ssh' ,
469
468
'-F' ,
@@ -480,19 +479,20 @@ void main() {
480
479
throwsA (equals ('Could not take a screenshot on device tester:\n <error-message>' )),
481
480
);
482
481
}, overrides: < Type , Generator > {
483
- ProcessManager : () => mockProcessManager,
482
+ ProcessManager : () => MockProcessManager (),
483
+ FileSystem : () => MemoryFileSystem .test (),
484
484
Platform : () => FakePlatform (
485
485
environment: < String , String > {
486
486
'FUCHSIA_SSH_CONFIG' : '/fuchsia/out/default/.ssh' ,
487
487
},
488
488
operatingSystem: 'linux' ,
489
489
),
490
- }, testOn : 'posix' );
490
+ });
491
491
492
492
testUsingContext ('takeScreenshot throws if scp failed' , () async {
493
493
final FuchsiaDevice device = FuchsiaDevice ('0.0.0.0' , name: 'tester' );
494
494
495
- when (mockProcessManager .run (
495
+ when (globals.processManager .run (
496
496
const < String > [
497
497
'ssh' ,
498
498
'-F' ,
@@ -504,7 +504,7 @@ void main() {
504
504
environment: anyNamed ('environment' ),
505
505
)).thenAnswer ((_) async => ProcessResult (0 , 0 , '' , '' ));
506
506
507
- when (mockProcessManager .run (
507
+ when (globals.processManager .run (
508
508
const < String > [
509
509
'scp' ,
510
510
'-F' ,
@@ -516,7 +516,7 @@ void main() {
516
516
environment: anyNamed ('environment' ),
517
517
)).thenAnswer ((_) async => ProcessResult (0 , 1 , '' , '<error-message>' ));
518
518
519
- when (mockProcessManager .run (
519
+ when (globals.processManager .run (
520
520
const < String > [
521
521
'ssh' ,
522
522
'-F' ,
@@ -533,19 +533,20 @@ void main() {
533
533
throwsA (equals ('Failed to copy screenshot from device:\n <error-message>' )),
534
534
);
535
535
}, overrides: < Type , Generator > {
536
- ProcessManager : () => mockProcessManager,
536
+ ProcessManager : () => MockProcessManager (),
537
+ FileSystem : () => MemoryFileSystem .test (),
537
538
Platform : () => FakePlatform (
538
539
environment: < String , String > {
539
540
'FUCHSIA_SSH_CONFIG' : '/fuchsia/out/default/.ssh' ,
540
541
},
541
542
operatingSystem: 'linux' ,
542
543
),
543
- }, testOn : 'posix' );
544
+ });
544
545
545
546
testUsingContext ("takeScreenshot prints error if can't delete file from device" , () async {
546
547
final FuchsiaDevice device = FuchsiaDevice ('0.0.0.0' , name: 'tester' );
547
548
548
- when (mockProcessManager .run (
549
+ when (globals.processManager .run (
549
550
const < String > [
550
551
'ssh' ,
551
552
'-F' ,
@@ -557,7 +558,7 @@ void main() {
557
558
environment: anyNamed ('environment' ),
558
559
)).thenAnswer ((_) async => ProcessResult (0 , 0 , '' , '' ));
559
560
560
- when (mockProcessManager .run (
561
+ when (globals.processManager .run (
561
562
const < String > [
562
563
'scp' ,
563
564
'-F' ,
@@ -569,7 +570,7 @@ void main() {
569
570
environment: anyNamed ('environment' ),
570
571
)).thenAnswer ((_) async => ProcessResult (0 , 0 , '' , '' ));
571
572
572
- when (mockProcessManager .run (
573
+ when (globals.processManager .run (
573
574
const < String > [
574
575
'ssh' ,
575
576
'-F' ,
@@ -591,7 +592,8 @@ void main() {
591
592
contains ('Failed to delete screenshot.ppm from the device:\n <error-message>' ),
592
593
);
593
594
}, overrides: < Type , Generator > {
594
- ProcessManager : () => mockProcessManager,
595
+ ProcessManager : () => MockProcessManager (),
596
+ FileSystem : () => MemoryFileSystem .test (),
595
597
Platform : () => FakePlatform (
596
598
environment: < String , String > {
597
599
'FUCHSIA_SSH_CONFIG' : '/fuchsia/out/default/.ssh' ,
@@ -603,7 +605,7 @@ void main() {
603
605
testUsingContext ('takeScreenshot returns' , () async {
604
606
final FuchsiaDevice device = FuchsiaDevice ('0.0.0.0' , name: 'tester' );
605
607
606
- when (mockProcessManager .run (
608
+ when (globals.processManager .run (
607
609
const < String > [
608
610
'ssh' ,
609
611
'-F' ,
@@ -615,7 +617,7 @@ void main() {
615
617
environment: anyNamed ('environment' ),
616
618
)).thenAnswer ((_) async => ProcessResult (0 , 0 , '' , '' ));
617
619
618
- when (mockProcessManager .run (
620
+ when (globals.processManager .run (
619
621
const < String > [
620
622
'scp' ,
621
623
'-F' ,
@@ -627,7 +629,7 @@ void main() {
627
629
environment: anyNamed ('environment' ),
628
630
)).thenAnswer ((_) async => ProcessResult (0 , 0 , '' , '' ));
629
631
630
- when (mockProcessManager .run (
632
+ when (globals.processManager .run (
631
633
const < String > [
632
634
'ssh' ,
633
635
'-F' ,
@@ -639,20 +641,18 @@ void main() {
639
641
environment: anyNamed ('environment' ),
640
642
)).thenAnswer ((_) async => ProcessResult (0 , 0 , '' , '' ));
641
643
642
- try {
643
- await device.takeScreenshot (globals.fs.file ('file.ppm' ));
644
- } on Exception catch (e) {
645
- fail ('Unexpected exception: $e ' );
646
- }
644
+ expect (() async => await device.takeScreenshot (globals.fs.file ('file.ppm' )),
645
+ returnsNormally);
647
646
}, overrides: < Type , Generator > {
648
- ProcessManager : () => mockProcessManager,
647
+ ProcessManager : () => MockProcessManager (),
648
+ FileSystem : () => MemoryFileSystem .test (),
649
649
Platform : () => FakePlatform (
650
650
environment: < String , String > {
651
651
'FUCHSIA_SSH_CONFIG' : '/fuchsia/out/default/.ssh' ,
652
652
},
653
653
operatingSystem: 'linux' ,
654
654
),
655
- }, testOn : 'posix' );
655
+ });
656
656
});
657
657
658
658
group ('portForwarder' , () {
0 commit comments