@@ -23,6 +23,7 @@ import 'package:flutter_tools/src/base/file_system.dart';
23
23
import 'package:flutter_tools/src/base/io.dart' ;
24
24
import 'package:flutter_tools/src/base/logger.dart' ;
25
25
import 'package:flutter_tools/src/base/platform.dart' ;
26
+ import 'package:flutter_tools/src/base/terminal.dart' ;
26
27
import 'package:flutter_tools/src/base/user_messages.dart' ;
27
28
import 'package:flutter_tools/src/build_info.dart' ;
28
29
import 'package:flutter_tools/src/cache.dart' ;
@@ -47,14 +48,14 @@ import '../../src/fakes.dart';
47
48
import '../../src/test_flutter_command_runner.dart' ;
48
49
49
50
void main () {
51
+ setUpAll (() {
52
+ Cache .disableLocking ();
53
+ });
54
+
50
55
group ('run' , () {
51
56
FakeDeviceManager mockDeviceManager;
52
57
FileSystem fileSystem;
53
58
54
- setUpAll (() {
55
- Cache .disableLocking ();
56
- });
57
-
58
59
setUp (() {
59
60
mockDeviceManager = FakeDeviceManager ();
60
61
fileSystem = MemoryFileSystem .test ();
@@ -657,6 +658,35 @@ void main() {
657
658
});
658
659
});
659
660
661
+ group ('terminal' , () {
662
+ FakeAnsiTerminal fakeTerminal;
663
+
664
+ setUp (() {
665
+ fakeTerminal = FakeAnsiTerminal ();
666
+ });
667
+
668
+ testUsingContext ('Flutter run sets terminal singleCharMode to false on exit' , () async {
669
+ final FakeResidentRunner residentRunner = FakeResidentRunner ();
670
+ final TestRunCommandWithFakeResidentRunner command = TestRunCommandWithFakeResidentRunner ();
671
+ command.fakeResidentRunner = residentRunner;
672
+
673
+ await createTestCommandRunner (command).run (< String > [
674
+ 'run' ,
675
+ '--no-pub' ,
676
+ ]);
677
+ // The sync completer where we initially set `terminal.singleCharMode` to
678
+ // `true` does not execute in unit tests, so explicitly check the
679
+ // `setSingleCharModeHistory` that the finally block ran, setting this
680
+ // back to `false`.
681
+ expect (fakeTerminal.setSingleCharModeHistory, contains (false ));
682
+ }, overrides: < Type , Generator > {
683
+ AnsiTerminal : () => fakeTerminal,
684
+ Cache : () => Cache .test (processManager: FakeProcessManager .any ()),
685
+ FileSystem : () => MemoryFileSystem .test (),
686
+ ProcessManager : () => FakeProcessManager .any (),
687
+ });
688
+ });
689
+
660
690
testUsingContext ('Flutter run catches service has disappear errors and throws a tool exit' , () async {
661
691
final FakeResidentRunner residentRunner = FakeResidentRunner ();
662
692
residentRunner.rpcError = RPCError ('flutter._listViews' , RPCErrorCodes .kServiceDisappeared, '' );
@@ -1021,3 +1051,17 @@ class CapturingAppDomain extends AppDomain {
1021
1051
throwToolExit ('' );
1022
1052
}
1023
1053
}
1054
+
1055
+ class FakeAnsiTerminal extends Fake implements AnsiTerminal {
1056
+ @override
1057
+ bool usesTerminalUi = false ;
1058
+
1059
+ /// A list of all the calls to the [singleCharMode] setter.
1060
+ List <bool > setSingleCharModeHistory = < bool > [];
1061
+
1062
+ @override
1063
+ set singleCharMode (bool value) => setSingleCharModeHistory.add (value);
1064
+
1065
+ @override
1066
+ bool get singleCharMode => setSingleCharModeHistory.last;
1067
+ }
0 commit comments