import 'package:flutter_test/flutter_test.dart';
import 'package:smplayer/features/settings/widgets/player_engine_row.dart';
import 'package:smplayer/providers/player_engine_override_provider.dart';

void main() {
  group('PlayerEngineRow.visibleOptions', () {
    test('Android 含 4 项', () {
      final opts = PlayerEngineRow.visibleOptions(isAndroid: true);
      expect(opts, [
        PlayerEngineOverride.auto,
        PlayerEngineOverride.fvp,
        PlayerEngineOverride.mpv,
        PlayerEngineOverride.media3,
      ]);
    });

    test('桌面含 3 项，不含 media3', () {
      final opts = PlayerEngineRow.visibleOptions(isAndroid: false);
      expect(opts, [
        PlayerEngineOverride.auto,
        PlayerEngineOverride.fvp,
        PlayerEngineOverride.mpv,
      ]);
      expect(opts.contains(PlayerEngineOverride.media3), isFalse);
    });
  });

  group('PlayerEngineRow.coerceValue', () {
    test('桌面 stale media3 → auto', () {
      expect(
        PlayerEngineRow.coerceValue(
          PlayerEngineOverride.media3,
          isAndroid: false,
        ),
        PlayerEngineOverride.auto,
      );
    });

    test('Android media3 保持 media3', () {
      expect(
        PlayerEngineRow.coerceValue(
          PlayerEngineOverride.media3,
          isAndroid: true,
        ),
        PlayerEngineOverride.media3,
      );
    });

    test('其它值在两个平台都原样保留', () {
      for (final v in [
        PlayerEngineOverride.auto,
        PlayerEngineOverride.fvp,
        PlayerEngineOverride.mpv,
      ]) {
        expect(PlayerEngineRow.coerceValue(v, isAndroid: true), v);
        expect(PlayerEngineRow.coerceValue(v, isAndroid: false), v);
      }
    });
  });
}
