test(tv): update keyboard focus expectations

This commit is contained in:
edde746
2026-05-26 23:00:44 +02:00
parent a101ee76d6
commit 39709e5c42
3 changed files with 36 additions and 22 deletions
@@ -30,6 +30,12 @@ void main() {
);
await tester.pumpAndSettle();
expect(FocusManager.instance.primaryFocus?.debugLabel, 'TvVirtualKeyboard');
expect(find.byKey(const Key('tv_virtual_keyboard_panel')), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.gameButtonB);
await tester.pumpAndSettle();
expect(FocusManager.instance.primaryFocus?.debugLabel, 'AddLocalProfile:Name');
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
@@ -45,7 +51,7 @@ void main() {
expect(FocusManager.instance.primaryFocus?.debugLabel, 'AddLocalProfile:Cancel');
});
testWidgets('Android TV native keyboard done leaves profile name input', (tester) async {
testWidgets('Android TV virtual keyboard done leaves profile name input', (tester) async {
TvDetectionService.debugSetAppleTVOverride(null);
await TvDetectionService.getInstance(forceTv: true);
TvDetectionService.setForceTVSync(true);
@@ -57,11 +63,10 @@ void main() {
);
await tester.pumpAndSettle();
expect(FocusManager.instance.primaryFocus?.debugLabel, 'AddLocalProfile:Name');
expect(FocusManager.instance.primaryFocus?.debugLabel, 'TvVirtualKeyboard');
await tester.showKeyboard(find.byType(TextField));
await tester.testTextInput.receiveAction(TextInputAction.done);
await tester.pump();
await tester.tap(find.byIcon(Icons.check_rounded));
await tester.pumpAndSettle();
expect(FocusManager.instance.primaryFocus?.debugLabel, 'AddLocalProfile:SetPin');
});
@@ -90,6 +95,13 @@ 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);
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);
await tester.sendKeyEvent(LogicalKeyboardKey.gameButtonB);
await tester.pumpAndSettle();
@@ -85,6 +85,13 @@ 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);
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);
await tester.sendKeyEvent(LogicalKeyboardKey.gameButtonB);
await tester.pumpAndSettle();
@@ -1,5 +1,3 @@
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
@@ -26,16 +24,17 @@ void main() {
expect(field.autofocus, isTrue);
});
testWidgets('TV initial focus stays on the server URL field', (tester) async {
testWidgets('TV initial focus opens the server URL keyboard', (tester) async {
TvDetectionService.debugSetAppleTVOverride(true);
await tester.pumpWidget(const InputModeTracker(child: MaterialApp(home: AddJellyfinScreen())));
await tester.pumpAndSettle();
expect(FocusManager.instance.primaryFocus?.debugLabel, 'AddJellyfin:Url');
expect(FocusManager.instance.primaryFocus?.debugLabel, 'TvVirtualKeyboard');
expect(find.byKey(const Key('tv_virtual_keyboard_panel')), findsOneWidget);
});
testWidgets('Android TV remote navigation stays with native URL keyboard', (tester) async {
testWidgets('Android TV remote navigation stays with virtual URL keyboard', (tester) async {
TvDetectionService.debugSetAppleTVOverride(null);
await TvDetectionService.getInstance(forceTv: true);
TvDetectionService.setForceTVSync(true);
@@ -43,21 +42,17 @@ void main() {
await tester.pumpWidget(const InputModeTracker(child: MaterialApp(home: AddJellyfinScreen())));
await tester.pumpAndSettle();
final urlFocus = FocusManager.instance.primaryFocus!;
expect(urlFocus.debugLabel, 'AddJellyfin:Url');
expect(FocusManager.instance.primaryFocus?.debugLabel, 'TvVirtualKeyboard');
final result = urlFocus.onKeyEvent!(
urlFocus,
const KeyDownEvent(
physicalKey: PhysicalKeyboardKey.arrowDown,
logicalKey: LogicalKeyboardKey.arrowDown,
timeStamp: Duration.zero,
deviceType: ui.KeyEventDeviceType.directionalPad,
),
);
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
await tester.pump();
expect(result, KeyEventResult.skipRemainingHandlers);
expect(FocusManager.instance.primaryFocus?.debugLabel, 'TvVirtualKeyboard');
expect(find.byKey(const Key('tv_virtual_keyboard_panel')), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.gameButtonB);
await tester.pumpAndSettle();
expect(FocusManager.instance.primaryFocus?.debugLabel, 'AddJellyfin:Url');
});