Draft
Add tests for RestoreFromBackupManagerImpl (data transfer support)#826
Conversation
This commit also renames LiveData returning getAll() to allAsLiveData()
This could cause notification and device/app registration to not be done again after the user got logged out and re-logged in.
This avoids clashes with the splashscreen's logo
We are not going to allow reusing them. However, we will probably consider using the "standard" API (over the "classic" one), to allow generating many tokens for cheaper thanks to the shared costly operation.
Make RestoreFromBackupManagerImpl accept injectable userDatabase and tokenGenerator constructor parameters (defaulting to the existing production singletons) so the class can be exercised in isolation. Add RestoreFromBackupManagerImplTest covering the full state-machine: - No users → Settled immediately - Same-device users → Settled immediately (no derivation) - Pre-v9 users with missing binding → binding added, Settled - Multiple users, all missing bindings → bindings added, Settled - Transferred device with successful derivation → token & binding updated - Multiple transferred users, all succeed - Mixed (same-device + transferred) - Derivation failure → RestoringFromBackupFailed state emitted - Failure then retry (generator swapped to success) → Settled - Failure then give-up → failed user removed, Settled - Partial failure (one same-device, one transferred-and-failed) → only failed user removed
|
Copilot
AI
changed the title
[WIP] [WIP] Address feedback and add tests for data transfer support feature
Add tests for RestoreFromBackupManagerImpl (data transfer support)
Jul 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Thanks for the feedback on #825. This PR targets that branch and adds unit test coverage for
RestoreFromBackupManagerImpl.Original PR: #825
Triggering review: #825 (comment)
Approach
To make
RestoreFromBackupManagerImpltestable in isolation, two optional constructor parameters were added — both default to their existing production values so no call sites are affected:userDatabase: UserDatabase— allows injecting an in-memory Room databasetokenGenerator: DerivedTokenGenerator?— allows injecting aFakeDerivedTokenGenerator; falls back to the existing lazyDerivedTokenGeneratorImplwhennullTests follow the existing Robolectric + in-memory DB pattern from
BaseAccountUtilsTest. AcollectStatesUntilSettledhelper drives the entire state machine through a singleflow.first { }call, routing anyRestoringFromBackupFailedthrough anonFailedlambda — avoiding separatelaunchcollectors and the ordering surprises they bring.Test coverage (
RestoreFromBackupManagerImplTest)Settledemitted immediately, no derivationSettledimmediately, no derivationSettledimmediatelySettledSettledRestoringFromBackup → Settled, token & binding updated in DBRestoringFromBackupFailedemitted with correctcausetypeonFailed)Settled, token updated with retried valueregisterRemoveUser,Settled