Screen-off and network switches often leave ExoPlayer dead without a 4xx status; refresh automatically (and on app resume) instead of waiting for Reload. Co-authored-by: Cursor <cursoragent@cursor.com>
56 lines
1.6 KiB
Dart
56 lines
1.6 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:frosty/screens/channel/video/playback_error_recovery.dart';
|
|
import 'package:frosty/screens/channel/video/video_timing_constants.dart';
|
|
|
|
void main() {
|
|
group('shouldAutoRecoverFromPlayerError', () {
|
|
test('recovers Source error / generic failures under the refresh cap', () {
|
|
expect(
|
|
shouldAutoRecoverFromPlayerError(refreshCapReached: false),
|
|
isTrue,
|
|
);
|
|
expect(
|
|
shouldAutoRecoverFromPlayerError(
|
|
refreshCapReached: false,
|
|
errorCode: null,
|
|
),
|
|
isTrue,
|
|
);
|
|
});
|
|
|
|
test('stops once the refresh cap is reached', () {
|
|
expect(
|
|
shouldAutoRecoverFromPlayerError(refreshCapReached: true),
|
|
isFalse,
|
|
);
|
|
});
|
|
|
|
test('defers mediaServicesWereReset to its dedicated rebuild path', () {
|
|
expect(
|
|
shouldAutoRecoverFromPlayerError(
|
|
refreshCapReached: false,
|
|
errorCode: 'mediaServicesWereReset',
|
|
),
|
|
isFalse,
|
|
);
|
|
});
|
|
});
|
|
|
|
group('playerErrorRetryDelay', () {
|
|
test('refreshes 4xx token failures immediately', () {
|
|
expect(playerErrorRetryDelay(statusCode: 403), Duration.zero);
|
|
expect(playerErrorRetryDelay(statusCode: 404), Duration.zero);
|
|
});
|
|
|
|
test('waits briefly for network / Source errors without status', () {
|
|
expect(
|
|
playerErrorRetryDelay(),
|
|
VideoTimingConstants.initRetryDelay,
|
|
);
|
|
expect(
|
|
playerErrorRetryDelay(statusCode: 500),
|
|
VideoTimingConstants.initRetryDelay,
|
|
);
|
|
});
|
|
});
|
|
}
|