|
@@ -7,6 +7,8 @@ import 'package:xterm/xterm.dart';
|
|
|
import '../_fixture/_fixture.dart';
|
|
import '../_fixture/_fixture.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
void main() {
|
|
|
|
|
+ final binding = TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
|
+
|
|
|
testWidgets(
|
|
testWidgets(
|
|
|
'Golden test',
|
|
'Golden test',
|
|
|
(WidgetTester tester) async {
|
|
(WidgetTester tester) async {
|
|
@@ -27,4 +29,46 @@ void main() {
|
|
|
},
|
|
},
|
|
|
skip: !Platform.isMacOS,
|
|
skip: !Platform.isMacOS,
|
|
|
);
|
|
);
|
|
|
|
|
+
|
|
|
|
|
+ group('TerminalView.readOnly', () {
|
|
|
|
|
+ testWidgets('works', (WidgetTester tester) async {
|
|
|
|
|
+ final terminalOutput = <String>[];
|
|
|
|
|
+ final terminal = Terminal(onOutput: terminalOutput.add);
|
|
|
|
|
+
|
|
|
|
|
+ await tester.pumpWidget(MaterialApp(
|
|
|
|
|
+ home: Scaffold(
|
|
|
|
|
+ body: TerminalView(terminal, readOnly: true, autofocus: true),
|
|
|
|
|
+ ),
|
|
|
|
|
+ ));
|
|
|
|
|
+
|
|
|
|
|
+ // https://github.com/flutter/flutter/issues/11181#issuecomment-314936646
|
|
|
|
|
+ await tester.tap(find.byType(TerminalView));
|
|
|
|
|
+ await tester.pump(Duration(seconds: 1));
|
|
|
|
|
+
|
|
|
|
|
+ binding.testTextInput.enterText('ls -al');
|
|
|
|
|
+ await binding.idle();
|
|
|
|
|
+
|
|
|
|
|
+ expect(terminalOutput.join(), isEmpty);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ testWidgets('does not block input when false', (WidgetTester tester) async {
|
|
|
|
|
+ final terminalOutput = <String>[];
|
|
|
|
|
+ final terminal = Terminal(onOutput: terminalOutput.add);
|
|
|
|
|
+
|
|
|
|
|
+ await tester.pumpWidget(MaterialApp(
|
|
|
|
|
+ home: Scaffold(
|
|
|
|
|
+ body: TerminalView(terminal, readOnly: false, autofocus: true),
|
|
|
|
|
+ ),
|
|
|
|
|
+ ));
|
|
|
|
|
+
|
|
|
|
|
+ // https://github.com/flutter/flutter/issues/11181#issuecomment-314936646
|
|
|
|
|
+ await tester.tap(find.byType(TerminalView));
|
|
|
|
|
+ await tester.pump(Duration(seconds: 1));
|
|
|
|
|
+
|
|
|
|
|
+ binding.testTextInput.enterText('ls -al');
|
|
|
|
|
+ await binding.idle();
|
|
|
|
|
+
|
|
|
|
|
+ expect(terminalOutput.join(), 'ls -al');
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|