From 01d7d523aa583b5c9b8f910dba2389d21dc0e591 Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Sun, 26 Jul 2026 23:04:55 +0200 Subject: [PATCH] test(tv): follow the native text input contract on Apple TV MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../profile/add_local_profile_screen_test.dart | 17 ++++++++++++----- .../profile/profile_detail_screen_test.dart | 6 +++++- test/screens/settings/settings_utils_test.dart | 9 +++++++-- test/utils/dialogs_test.dart | 11 ++++++++--- 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/test/screens/profile/add_local_profile_screen_test.dart b/test/screens/profile/add_local_profile_screen_test.dart index 2f80e234..6d7ee2c7 100644 --- a/test/screens/profile/add_local_profile_screen_test.dart +++ b/test/screens/profile/add_local_profile_screen_test.dart @@ -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(fieldFinder).readOnly, isFalse); - await tester.sendKeyEvent(LogicalKeyboardKey.select); + await tester.enterText(fieldFinder, 'A'); await tester.pump(); - expect(tester.widget(find.byType(TextField)).controller!.text, isNotEmpty); + expect(tester.widget(fieldFinder).controller!.text, 'A'); await tester.sendKeyEvent(LogicalKeyboardKey.gameButtonB); await tester.pumpAndSettle(); expect(FocusManager.instance.primaryFocus?.debugLabel, 'AddLocalProfile:Name'); + expect(tester.widget(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(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(fieldFinder).readOnly, isTrue); await tester.sendKeyEvent(LogicalKeyboardKey.gameButtonB); await tester.pumpAndSettle(); diff --git a/test/screens/profile/profile_detail_screen_test.dart b/test/screens/profile/profile_detail_screen_test.dart index ff3f4f0b..d1137cb4 100644 --- a/test/screens/profile/profile_detail_screen_test.dart +++ b/test/screens/profile/profile_detail_screen_test.dart @@ -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(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(fieldFinder).readOnly, isTrue); await tester.sendKeyEvent(LogicalKeyboardKey.gameButtonB); await tester.pumpAndSettle(); diff --git a/test/screens/settings/settings_utils_test.dart b/test/screens/settings/settings_utils_test.dart index a202cd55..0ab8b399 100644 --- a/test/screens/settings/settings_utils_test.dart +++ b/test/screens/settings/settings_utils_test.dart @@ -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(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(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(fieldFinder).readOnly, isTrue); expect(tester.takeException(), isNull); await tester.sendKeyEvent(LogicalKeyboardKey.escape); diff --git a/test/utils/dialogs_test.dart b/test/utils/dialogs_test.dart index 8a0c72e6..179d5577 100644 --- a/test/utils/dialogs_test.dart +++ b/test/utils/dialogs_test.dart @@ -88,18 +88,23 @@ void main() { final result = showTextInputDialog(hostContext, title: 'Name', labelText: 'Name', initialValue: 'TV value'); await tester.pumpAndSettle(); - final field = tester.widget(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(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(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(fieldFinder).readOnly, isTrue); await tester.sendKeyEvent(LogicalKeyboardKey.escape); await tester.pumpAndSettle();