feat(app): 播放器增加清晰度档位入口
This commit is contained in:
1 parent
30a5fa0776
commit
2b2b7e9913
9 files changed
+242
-1
No files matched your search
@@ -0,0 +1,29 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/core/data/models/play_ticket.dart';
|
||||
|
||||
void main() {
|
||||
test('should_parse_all_qualities_when_ticket_returns_multiple_tracks', () {
|
||||
final ticket = PlayTicket.fromJson(const {
|
||||
'episodeId': '12',
|
||||
'accessible': true,
|
||||
'accessType': 'FREE',
|
||||
'playUrl': '/files/episode/12.m3u8?e=1&s=abc',
|
||||
'qualities': ['AUTO', '720P', '1080P'],
|
||||
});
|
||||
|
||||
expect(ticket.qualities, ['AUTO', '720P', '1080P']);
|
||||
});
|
||||
|
||||
test('should_default_to_empty_qualities_when_field_is_missing', () {
|
||||
final ticket = PlayTicket.fromJson(const {
|
||||
'episodeId': '12',
|
||||
'accessible': true,
|
||||
'accessType': 'FREE',
|
||||
'playUrl': '/files/episode/12.mp4',
|
||||
});
|
||||
|
||||
expect(ticket.qualities, isEmpty);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/core/data/models/drama.dart';
|
||||
import 'package:fruitshorts/core/data/models/play_ticket.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/playback_repository.dart';
|
||||
import 'package:fruitshorts/core/data/services/android_picture_in_picture.dart';
|
||||
import 'package:fruitshorts/pages/player/player_logic.dart';
|
||||
|
||||
import '../support/fake_watch_history.dart';
|
||||
|
||||
void main() {
|
||||
test('should_expose_ticket_qualities_when_ticket_is_loaded', () async {
|
||||
final logic = PlayerLogic(
|
||||
history: FakeWatchHistory(),
|
||||
playback: FakePlaybackRepository(
|
||||
ticket: const PlayTicket(
|
||||
episodeId: '12',
|
||||
accessible: true,
|
||||
accessType: PlayTicket.free,
|
||||
playUrl: '/files/episode/12.m3u8?e=1&s=abc',
|
||||
qualities: ['AUTO', '720P', '1080P'],
|
||||
),
|
||||
),
|
||||
pictureInPicture: AndroidPictureInPicture(
|
||||
channel: const MethodChannel('test/player_quality/pip'),
|
||||
),
|
||||
);
|
||||
logic.sessionEpisodes = [
|
||||
Episode(
|
||||
id: '12',
|
||||
number: 1,
|
||||
title: 'Episode 1',
|
||||
isFree: true,
|
||||
),
|
||||
];
|
||||
|
||||
final ready = await logic.ensureTicket(0);
|
||||
|
||||
expect(ready, isTrue);
|
||||
expect(logic.qualities, ['AUTO', '720P', '1080P']);
|
||||
});
|
||||
}
|
||||
@@ -38,8 +38,15 @@ void main() {
|
||||
expect(find.byType(PageView), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('player-more')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('player-more-quality')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-more-download')), findsOneWidget);
|
||||
expect(find.byKey(const Key('player-more-pip')), findsOneWidget);
|
||||
await tester.tap(find.byKey(const Key('player-more-quality')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.byKey(const Key('player-quality-sheet')), findsOneWidget);
|
||||
expect(find.text('720P'), findsOneWidget);
|
||||
await tester.binding.handlePopRoute();
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// Author: fruit.com.cn
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/l10n/app_localizations.dart';
|
||||
import 'package:fruitshorts/pages/player/widgets/quality_sheet.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('should_list_every_returned_quality_when_sheet_opens', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
locale: const Locale('en'),
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: const Scaffold(
|
||||
body: QualitySheet(qualities: ['AUTO', '720P', '1080P']),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('Auto'), findsOneWidget);
|
||||
expect(find.text('720P'), findsOneWidget);
|
||||
expect(find.text('1080P'), findsOneWidget);
|
||||
expect(find.byIcon(Icons.check_rounded), findsOneWidget);
|
||||
expect(
|
||||
find.text('HLS adjusts the bitrate automatically for your connection.'),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user