fix(player): 记住拖动后的实际播放位置
This commit is contained in:
1 parent
47ca21406a
commit
5268adc999
8 files changed
+352
-67
No files matched your search
@@ -4,6 +4,42 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:fruitshorts/core/data/services/playback_position_cache.dart';
|
||||
|
||||
void main() {
|
||||
test('should_clamp_invalid_or_out_of_range_position_when_caching', () {
|
||||
expect(
|
||||
clampPlaybackPosition(
|
||||
const Duration(seconds: -1),
|
||||
const Duration(seconds: 10),
|
||||
),
|
||||
Duration.zero,
|
||||
);
|
||||
expect(
|
||||
clampPlaybackPosition(
|
||||
const Duration(seconds: 12),
|
||||
const Duration(seconds: 10),
|
||||
),
|
||||
const Duration(seconds: 10),
|
||||
);
|
||||
expect(
|
||||
clampPlaybackPosition(
|
||||
const Duration(seconds: 5),
|
||||
const Duration(seconds: 10),
|
||||
),
|
||||
const Duration(seconds: 5),
|
||||
);
|
||||
|
||||
final cache = PlaybackPositionCache();
|
||||
cache.save(
|
||||
episodeId: 'episode-3',
|
||||
dramaId: 'drama-a',
|
||||
position: const Duration(minutes: 4),
|
||||
duration: const Duration(minutes: 3),
|
||||
);
|
||||
expect(
|
||||
cache.read('episode-3', dramaId: 'drama-a')?.position,
|
||||
const Duration(minutes: 3),
|
||||
);
|
||||
});
|
||||
|
||||
test('should_store_and_read_recent_position_when_drama_matches', () {
|
||||
final now = DateTime(2026, 10, 22, 12);
|
||||
final cache = PlaybackPositionCache(now: () => now);
|
||||
|
||||
Reference in new issue
Block a user