test(tv): follow the native text input contract on Apple TV

71735354 made TvTextInputPresentation.automatic use native platform
input for single-line Apple TV fields, and 829d3745 migrated the search
and Add Jellyfin suites to it. These five cases still expected the
Flutter on-screen keyboard widget and failed looking for a panel that no
longer exists.

Drives the native path instead: each case asserts input is live
(readOnly false), raises the keyboard, then keeps its original
regression intent — the first Back deactivates input and is consumed so
it cannot also pop, and only the second Back pops or cancels.
This commit is contained in:
edde746
2026-07-26 23:05:53 +02:00
parent ef310459e5
commit 01d7d523aa
4 changed files with 32 additions and 11 deletions
@@ -34,18 +34,21 @@ void main() {
),
);
await tester.pumpAndSettle();
final fieldFinder = find.byType(TextField);
expect(FocusManager.instance.primaryFocus?.debugLabel, 'TvVirtualKeyboard');
expect(find.byKey(const Key('tv_virtual_keyboard_panel')), findsOneWidget);
expect(FocusManager.instance.primaryFocus?.debugLabel, 'AddLocalProfile:Name');
expect(find.byKey(const Key('tv_virtual_keyboard_panel')), findsNothing);
expect(tester.widget<TextField>(fieldFinder).readOnly, isFalse);
await tester.sendKeyEvent(LogicalKeyboardKey.select);
await tester.enterText(fieldFinder, 'A');
await tester.pump();
expect(tester.widget<TextField>(find.byType(TextField)).controller!.text, isNotEmpty);
expect(tester.widget<TextField>(fieldFinder).controller!.text, 'A');
await tester.sendKeyEvent(LogicalKeyboardKey.gameButtonB);
await tester.pumpAndSettle();
expect(FocusManager.instance.primaryFocus?.debugLabel, 'AddLocalProfile:Name');
expect(tester.widget<TextField>(fieldFinder).readOnly, isTrue);
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
await tester.pump();
@@ -104,13 +107,17 @@ void main() {
await tester.tap(find.text('Open new profile'));
await tester.pumpAndSettle();
expect(find.text(t.profiles.newProfile), findsOneWidget);
expect(find.byKey(const Key('tv_virtual_keyboard_panel')), findsOneWidget);
final fieldFinder = find.byType(TextField);
expect(find.byKey(const Key('tv_virtual_keyboard_panel')), findsNothing);
expect(tester.widget<TextField>(fieldFinder).readOnly, isFalse);
await tester.showKeyboard(fieldFinder);
await tester.sendKeyEvent(LogicalKeyboardKey.gameButtonB);
await tester.pumpAndSettle();
expect(find.text(t.profiles.newProfile), findsOneWidget);
expect(find.byKey(const Key('tv_virtual_keyboard_panel')), findsNothing);
expect(tester.widget<TextField>(fieldFinder).readOnly, isTrue);
await tester.sendKeyEvent(LogicalKeyboardKey.gameButtonB);
await tester.pumpAndSettle();
@@ -88,13 +88,17 @@ void main() {
await tester.tap(find.text('Open profile'));
await tester.pumpAndSettle();
expect(find.text(t.profiles.connectionsLabel), findsOneWidget);
expect(find.byKey(const Key('tv_virtual_keyboard_panel')), findsOneWidget);
final fieldFinder = find.byType(TextField);
expect(find.byKey(const Key('tv_virtual_keyboard_panel')), findsNothing);
expect(tester.widget<TextField>(fieldFinder).readOnly, isFalse);
await tester.showKeyboard(fieldFinder);
await tester.sendKeyEvent(LogicalKeyboardKey.gameButtonB);
await tester.pumpAndSettle();
expect(find.text(t.profiles.connectionsLabel), findsOneWidget);
expect(find.byKey(const Key('tv_virtual_keyboard_panel')), findsNothing);
expect(tester.widget<TextField>(fieldFinder).readOnly, isTrue);
await tester.sendKeyEvent(LogicalKeyboardKey.gameButtonB);
await tester.pumpAndSettle();
@@ -42,20 +42,25 @@ void main() {
onSave: (value) async => saved.add(value),
);
await tester.pumpAndSettle();
final fieldFinder = find.byType(TextField);
expect(find.byType(AlertDialog), findsOneWidget);
expect(find.byKey(const Key('tv_virtual_keyboard_dialog')), findsOneWidget);
expect(find.byKey(const Key('tv_virtual_keyboard_dialog')), findsNothing);
expect(tester.widget<TextField>(fieldFinder).readOnly, isFalse);
await tester.showKeyboard(fieldFinder);
await tester.sendKeyDownEvent(LogicalKeyboardKey.escape);
await tester.pump();
expect(find.byKey(const Key('tv_virtual_keyboard_dialog')), findsOneWidget);
expect(find.byType(AlertDialog), findsOneWidget);
expect(tester.widget<TextField>(fieldFinder).readOnly, isTrue);
await tester.sendKeyUpEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(find.byKey(const Key('tv_virtual_keyboard_dialog')), findsNothing);
expect(find.byType(AlertDialog), findsOneWidget);
expect(tester.widget<TextField>(fieldFinder).readOnly, isTrue);
expect(tester.takeException(), isNull);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
+8 -3
View File
@@ -88,18 +88,23 @@ void main() {
final result = showTextInputDialog(hostContext, title: 'Name', labelText: 'Name', initialValue: 'TV value');
await tester.pumpAndSettle();
final field = tester.widget<TextField>(find.byType(TextField, skipOffstage: false));
expect(find.byKey(const Key('tv_virtual_keyboard_dialog')), findsOneWidget);
final fieldFinder = find.byType(TextField, skipOffstage: false);
final field = tester.widget<TextField>(fieldFinder);
expect(find.byKey(const Key('tv_virtual_keyboard_dialog')), findsNothing);
expect(field.readOnly, isFalse);
await tester.showKeyboard(fieldFinder);
await tester.sendKeyDownEvent(LogicalKeyboardKey.escape);
await tester.pump();
expect(find.byKey(const Key('tv_virtual_keyboard_dialog')), findsOneWidget);
expect(find.byType(AlertDialog), findsOneWidget);
expect(tester.widget<TextField>(fieldFinder).readOnly, isTrue);
await tester.sendKeyUpEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(find.byKey(const Key('tv_virtual_keyboard_dialog')), findsNothing);
expect(find.byType(AlertDialog), findsOneWidget);
expect(field.focusNode?.hasPrimaryFocus, isTrue);
expect(tester.widget<TextField>(fieldFinder).readOnly, isTrue);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();