For #19797 - Remove FenixAccountManager#signedInToFxa

After the changes from this patch this api is not used anymore so to prevent
future misuses of it this is removed in favor of the new "accountState".
upstream-sync
Mugurell 3 years ago
parent 1fc3bb84ca
commit 19af5e9b15

@ -34,16 +34,6 @@ open class FenixAccountManager(context: Context) {
AccountState.AUTHENTICATED
}
}
/**
* Check if the current account is signed in and authenticated.
*/
fun signedInToFxa(): Boolean {
val account = accountManager.authenticatedAccount()
val needsReauth = accountManager.accountNeedsReauth()
return account != null && !needsReauth
}
}
/**

@ -11,9 +11,7 @@ import mozilla.components.concept.sync.OAuthAccount
import mozilla.components.concept.sync.Profile
import mozilla.components.service.fxa.manager.FxaAccountManager
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertSame
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
@ -64,42 +62,6 @@ class FenixAccountManagerTest {
assertEquals(null, result)
}
@Test
fun `GIVEN an account is signed in and authenticated THEN check returns true`() {
every { accountManagerComponent.authenticatedAccount() } returns account
every { accountManagerComponent.accountNeedsReauth() } returns false
every { context.components.backgroundServices.accountManager } returns accountManagerComponent
fenixFxaManager = FenixAccountManager(context)
val signedIn = fenixFxaManager.signedInToFxa()
assertTrue(signedIn)
}
@Test
fun `GIVEN an account is signed in and NOT authenticated THEN check returns false`() {
every { accountManagerComponent.authenticatedAccount() } returns account
every { accountManagerComponent.accountNeedsReauth() } returns true
every { context.components.backgroundServices.accountManager } returns accountManagerComponent
fenixFxaManager = FenixAccountManager(context)
val signedIn = fenixFxaManager.signedInToFxa()
assertFalse(signedIn)
}
@Test
fun `GIVEN an account is not signed in THEN check returns false`() {
every { accountManagerComponent.authenticatedAccount() } returns null
every { accountManagerComponent.accountNeedsReauth() } returns true
every { context.components.backgroundServices.accountManager } returns accountManagerComponent
fenixFxaManager = FenixAccountManager(context)
val signedIn = fenixFxaManager.signedInToFxa()
assertFalse(signedIn)
}
@Test
fun `GIVEN no account exists WHEN accountState is called THEN it returns AccountState#NO_ACCOUNT`() {
every { context.components.backgroundServices.accountManager } returns accountManagerComponent

Loading…
Cancel
Save