From 8ef3bca69f0e18b41b849450da14eaf19dabf196 Mon Sep 17 00:00:00 2001 From: zarzet <42882290+zarzet@users.noreply.github.com> Date: Mon, 19 Oct 2026 04:25:30 +0700 Subject: [PATCH] test(queue): remove real waits from the startup flush test The startup flush test slept 1.24 s, mostly three 400 ms windows that must outlast the 350 ms persistence debounce. The body now runs in VirtualTime, so those waits and the debounce timer advance on virtual time while platform-channel replies stay real. No production change; the test body and assertions are unchanged. --- test/download_queue_startup_flush_test.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/download_queue_startup_flush_test.dart b/test/download_queue_startup_flush_test.dart index 3f1584d7..d2959fb6 100644 --- a/test/download_queue_startup_flush_test.dart +++ b/test/download_queue_startup_flush_test.dart @@ -13,6 +13,7 @@ import 'package:spotiflac_android/providers/settings_provider.dart'; import 'package:spotiflac_android/services/app_state_database.dart'; import 'support/fixed_settings.dart'; +import 'support/virtual_time.dart'; const _earlyTrack = Track( id: 'example:early', @@ -24,9 +25,11 @@ const _earlyTrack = Track( void main() { TestWidgetsFlutterBinding.ensureInitialized(); + // The waits run on virtual time, including the 350 ms persistence debounce + // they must outlast. test( 'startup restores, merges and retries only complete owned snapshots', - () async { + () => VirtualTime().run(() async { SharedPreferences.setMockInitialValues({ 'app_state_migrated_queue_to_sqlite_v1': true, 'download_queue_user_paused_v1': true, @@ -407,6 +410,6 @@ void main() { expect([writes, deletes], [7, 0]); explicitRetry.dispose(); await (await AppStateDatabase.instance.database).close(); - }, + }), ); }