fix(player): 修复详情往返播放位置丢失
This commit is contained in:
1 parent
fe49c6d8b2
commit
759a02375a
16 files changed
+464
-5
No files matched your search
@@ -1,9 +1,11 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/core/data/models/drama.dart';
|
||||
import 'package:fruitshorts/core/data/models/watch_progress.dart';
|
||||
import 'package:fruitshorts/core/data/remote/api_client.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/favorite_repository.dart';
|
||||
import 'package:fruitshorts/core/data/repositories/playback_repository.dart';
|
||||
import 'package:fruitshorts/core/data/services/favorite_controller.dart';
|
||||
import 'package:fruitshorts/core/data/services/playback_position_cache.dart';
|
||||
import 'package:fruitshorts/pages/drama_detail/drama_detail_logic.dart';
|
||||
|
||||
import '../support/fake_watch_history.dart';
|
||||
@@ -13,12 +15,14 @@ DramaDetailLogic _logic(
|
||||
Drama drama,
|
||||
FakeWatchHistory history, {
|
||||
FavoriteController? favorites,
|
||||
PlaybackPositionCache? positionCache,
|
||||
}) =>
|
||||
DramaDetailLogic(
|
||||
drama: drama,
|
||||
history: history,
|
||||
playback: FakePlaybackRepository(),
|
||||
favorites: favorites ?? FavoriteController(InMemoryFavoriteRepository()),
|
||||
positionCache: positionCache ?? PlaybackPositionCache(),
|
||||
);
|
||||
|
||||
Drama _card(String id) => Drama(
|
||||
@@ -103,6 +107,31 @@ void main() {
|
||||
logic.dispose();
|
||||
});
|
||||
|
||||
test('should_prefer_recent_local_position_when_loading_continue', () async {
|
||||
final cache = PlaybackPositionCache();
|
||||
cache.save(
|
||||
episodeId: 'signal-3',
|
||||
dramaId: 'signal',
|
||||
position: const Duration(minutes: 1, seconds: 20),
|
||||
duration: const Duration(minutes: 3),
|
||||
);
|
||||
final history = FakeWatchHistory()
|
||||
..records['signal'] = const WatchProgress(
|
||||
dramaId: 'signal',
|
||||
episodeId: 'signal-1',
|
||||
position: Duration(seconds: 5),
|
||||
duration: Duration(minutes: 3),
|
||||
);
|
||||
final logic = _logic(_detail('signal'), history, positionCache: cache);
|
||||
|
||||
await logic.load(() async => _detail('signal'));
|
||||
|
||||
expect(logic.continueIndex, 2);
|
||||
expect(logic.progress?.position, const Duration(seconds: 80));
|
||||
expect(history.reads, isEmpty);
|
||||
logic.dispose();
|
||||
});
|
||||
|
||||
test('should_adjust_favorite_count_only_after_successful_changes', () async {
|
||||
final repository = InMemoryFavoriteRepository(cards: [_favoriteDrama]);
|
||||
final favorites = FavoriteController(repository);
|
||||
|
||||
Reference in new issue
Block a user