|
|
@@ -0,0 +1,71 @@
|
|
|
+import 'package:flutter/material.dart';
|
|
|
+import 'package:flutter_test/flutter_test.dart';
|
|
|
+import 'package:xterm/xterm.dart';
|
|
|
+
|
|
|
+void main() {
|
|
|
+ group('TerminalController', () {
|
|
|
+ testWidgets('setSelectionRange works', (tester) async {
|
|
|
+ final terminal = Terminal();
|
|
|
+ final terminalView = TerminalController();
|
|
|
+
|
|
|
+ await tester.pumpWidget(MaterialApp(
|
|
|
+ home: Scaffold(
|
|
|
+ body: TerminalView(
|
|
|
+ terminal,
|
|
|
+ controller: terminalView,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ));
|
|
|
+
|
|
|
+ terminalView.setSelectionRange(CellOffset(0, 0), CellOffset(2, 2));
|
|
|
+
|
|
|
+ await tester.pump();
|
|
|
+
|
|
|
+ expect(terminalView.selection, isNotNull);
|
|
|
+ });
|
|
|
+
|
|
|
+ testWidgets('setSelectionMode changes BufferRange type', (tester) async {
|
|
|
+ final terminal = Terminal();
|
|
|
+ final terminalView = TerminalController();
|
|
|
+
|
|
|
+ await tester.pumpWidget(MaterialApp(
|
|
|
+ home: Scaffold(
|
|
|
+ body: TerminalView(
|
|
|
+ terminal,
|
|
|
+ controller: terminalView,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ));
|
|
|
+
|
|
|
+ terminalView.setSelectionRange(CellOffset(0, 0), CellOffset(2, 2));
|
|
|
+
|
|
|
+ expect(terminalView.selection, isA<BufferRangeLine>());
|
|
|
+
|
|
|
+ terminalView.setSelectionMode(SelectionMode.block);
|
|
|
+
|
|
|
+ expect(terminalView.selection, isA<BufferRangeBlock>());
|
|
|
+ });
|
|
|
+
|
|
|
+ testWidgets('clearSelection works', (tester) async {
|
|
|
+ final terminal = Terminal();
|
|
|
+ final terminalView = TerminalController();
|
|
|
+
|
|
|
+ await tester.pumpWidget(MaterialApp(
|
|
|
+ home: Scaffold(
|
|
|
+ body: TerminalView(
|
|
|
+ terminal,
|
|
|
+ controller: terminalView,
|
|
|
+ ),
|
|
|
+ ),
|
|
|
+ ));
|
|
|
+
|
|
|
+ terminalView.setSelectionRange(CellOffset(0, 0), CellOffset(2, 2));
|
|
|
+
|
|
|
+ expect(terminalView.selection, isNotNull);
|
|
|
+
|
|
|
+ terminalView.clearSelection();
|
|
|
+
|
|
|
+ expect(terminalView.selection, isNull);
|
|
|
+ });
|
|
|
+ });
|
|
|
+}
|