mirror of
https://github.com/zarzet/SpotiFLAC-Mobile.git
synced 2026-08-27 13:22:49 +02:00
fix(download): preserve SAF and defer background starts
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:spotiflac_android/providers/download_queue_provider.dart';
|
||||
import 'package:spotiflac_android/services/platform_bridge.dart';
|
||||
|
||||
void main() {
|
||||
group('download storage recovery', () {
|
||||
test('requires reauthorization instead of redirecting SAF downloads', () {
|
||||
expect(
|
||||
storageWriteRecoveryFor(useSaf: true),
|
||||
StorageWriteRecovery.requestSafAccess,
|
||||
);
|
||||
});
|
||||
|
||||
test('keeps automatic fallback for app-managed folders', () {
|
||||
expect(
|
||||
storageWriteRecoveryFor(useSaf: false),
|
||||
StorageWriteRecovery.useAppFolderFallback,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
group('foreground download start policy', () {
|
||||
test('allows service launch only while the app is resumed', () {
|
||||
expect(
|
||||
canStartForegroundDownloadForLifecycle(AppLifecycleState.resumed),
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
canStartForegroundDownloadForLifecycle(AppLifecycleState.inactive),
|
||||
isFalse,
|
||||
);
|
||||
expect(
|
||||
canStartForegroundDownloadForLifecycle(AppLifecycleState.paused),
|
||||
isFalse,
|
||||
);
|
||||
expect(canStartForegroundDownloadForLifecycle(null), isFalse);
|
||||
});
|
||||
|
||||
test('recognizes the typed platform denial', () {
|
||||
expect(
|
||||
isForegroundServiceStartNotAllowed(
|
||||
PlatformException(code: foregroundServiceStartNotAllowedCode),
|
||||
),
|
||||
isTrue,
|
||||
);
|
||||
expect(
|
||||
isForegroundServiceStartNotAllowed(PlatformException(code: 'ERROR')),
|
||||
isFalse,
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user