fix(player): 修复详情往返播放位置丢失
This commit is contained in:
1 parent
fe49c6d8b2
commit
759a02375a
16 files changed
+464
-5
No files matched your search
@@ -13,6 +13,7 @@ import 'package:fruitshorts/core/data/repositories/watch_history_repository.dart
|
||||
import 'package:fruitshorts/core/data/services/android_picture_in_picture.dart';
|
||||
import 'package:fruitshorts/core/data/services/catalog_controller.dart';
|
||||
import 'package:fruitshorts/core/data/services/favorite_controller.dart';
|
||||
import 'package:fruitshorts/core/data/services/playback_position_cache.dart';
|
||||
import 'package:fruitshorts/core/data/services/playback_session.dart';
|
||||
import 'package:fruitshorts/core/data/services/video_player_port.dart';
|
||||
import 'package:fruitshorts/core/platform/haptics.dart';
|
||||
@@ -35,12 +36,14 @@ void main() {
|
||||
final history = FakeWatchHistory();
|
||||
final playback = FakePlaybackRepository();
|
||||
final catalog = CatalogController(FakeCatalogRepository(dramas: [drama]));
|
||||
final positionCache = PlaybackPositionCache();
|
||||
final favorites = FavoriteController(
|
||||
InMemoryFavoriteRepository(saved: {drama.id}, cards: [drama]),
|
||||
);
|
||||
final logic = PlayerLogic(
|
||||
history: history,
|
||||
playback: playback,
|
||||
positionCache: positionCache,
|
||||
pictureInPicture: AndroidPictureInPicture(
|
||||
channel: const MethodChannel('test/player_open_detail/pip'),
|
||||
),
|
||||
@@ -74,6 +77,7 @@ void main() {
|
||||
providers: [
|
||||
Provider<WatchHistoryRepository>.value(value: history),
|
||||
Provider<PlaybackRepository>.value(value: playback),
|
||||
Provider<PlaybackPositionCache>.value(value: positionCache),
|
||||
ChangeNotifierProvider<CatalogController>.value(value: catalog),
|
||||
ChangeNotifierProvider<FavoriteController>.value(value: favorites),
|
||||
Provider<Haptics>.value(value: FakeHaptics()),
|
||||
@@ -104,7 +108,11 @@ void main() {
|
||||
expect(player.pauses, 1);
|
||||
expect(player.plays, playsBefore);
|
||||
expect(tracked.controller.value.position, const Duration(seconds: 37));
|
||||
expect(history.writes, isEmpty);
|
||||
expect(history.writes, ['signal-1|37000|false']);
|
||||
expect(
|
||||
positionCache.read('signal-1', dramaId: 'signal')?.position,
|
||||
const Duration(seconds: 37),
|
||||
);
|
||||
|
||||
await tester.pageBack();
|
||||
await tester.pump();
|
||||
@@ -117,7 +125,10 @@ void main() {
|
||||
expect(logic.session.userWantsPlay, isTrue);
|
||||
expect(player.plays, playsBefore + 1);
|
||||
expect(tracked.controller.value.position, const Duration(seconds: 37));
|
||||
expect(history.writes, ['signal-1|37000|false']);
|
||||
expect(history.writes, [
|
||||
'signal-1|37000|false',
|
||||
'signal-1|37000|false',
|
||||
]);
|
||||
|
||||
logic
|
||||
..trackedPlayer = null
|
||||
|
||||
Reference in new issue
Block a user