fix(tv): preserve native keyboard navigation

close #1051
This commit is contained in:
edde746
2026-05-15 19:05:38 +02:00
parent e37602421b
commit ef4980db09
3 changed files with 169 additions and 1 deletions
@@ -1,4 +1,7 @@
import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:plezy/focus/input_mode_tracker.dart';
import 'package:plezy/profiles/profile.dart';
@@ -11,6 +14,7 @@ Profile _profile(String id) =>
void main() {
tearDown(() {
TvDetectionService.debugSetAppleTVOverride(null);
TvDetectionService.setForceTVSync(false);
});
testWidgets('autofocuses the server URL field', (tester) async {
@@ -31,6 +35,32 @@ void main() {
expect(FocusManager.instance.primaryFocus?.debugLabel, 'AddJellyfin:Url');
});
testWidgets('Android TV remote navigation stays with native URL keyboard', (tester) async {
TvDetectionService.debugSetAppleTVOverride(null);
await TvDetectionService.getInstance(forceTv: true);
TvDetectionService.setForceTVSync(true);
await tester.pumpWidget(const InputModeTracker(child: MaterialApp(home: AddJellyfinScreen())));
await tester.pumpAndSettle();
final urlFocus = FocusManager.instance.primaryFocus!;
expect(urlFocus.debugLabel, 'AddJellyfin:Url');
final result = urlFocus.onKeyEvent!(
urlFocus,
const KeyDownEvent(
physicalKey: PhysicalKeyboardKey.arrowDown,
logicalKey: LogicalKeyboardKey.arrowDown,
timeStamp: Duration.zero,
deviceType: ui.KeyEventDeviceType.directionalPad,
),
);
await tester.pump();
expect(result, KeyEventResult.skipRemainingHandlers);
expect(FocusManager.instance.primaryFocus?.debugLabel, 'AddJellyfin:Url');
});
group('Jellyfin profile binding decisions', () {
test('creates a local profile only on true first-run with no profiles', () {
expect(shouldCreateLocalJellyfinProfile(targetProfile: null, activeProfile: null, hasProfiles: false), isTrue);