mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 23:28:42 +03:00
Merge pull request #4538 from nextcloud/ezaquarii/fix-broken-account-registration
Fix registration of second account on first run
This commit is contained in:
commit
5bcab439b4
2 changed files with 75 additions and 2 deletions
|
@ -33,7 +33,7 @@ import com.owncloud.android.ui.activity.PassCodeActivity
|
|||
internal class OnboardingServiceImpl constructor(
|
||||
private val resources: Resources,
|
||||
private val preferences: AppPreferences,
|
||||
accountProvider: CurrentAccountProvider
|
||||
private val accountProvider: CurrentAccountProvider
|
||||
) : OnboardingService {
|
||||
|
||||
private companion object {
|
||||
|
@ -52,7 +52,10 @@ internal class OnboardingServiceImpl constructor(
|
|||
emptyArray()
|
||||
}
|
||||
|
||||
override val isFirstRun: Boolean = accountProvider.currentAccount == null
|
||||
override val isFirstRun: Boolean
|
||||
get() {
|
||||
return accountProvider.currentAccount == null
|
||||
}
|
||||
|
||||
override fun shouldShowWhatsNew(callingContext: Context): Boolean {
|
||||
return callingContext !is PassCodeActivity && whatsNew.size > 0
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/* Nextcloud Android client application
|
||||
*
|
||||
* @author Chris Narkiewicz
|
||||
* Copyright (C) 2019 Chris Narkiewicz <hello@ezaquarii.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.nextcloud.client.onboarding
|
||||
|
||||
import android.accounts.Account
|
||||
import android.content.res.Resources
|
||||
import com.nextcloud.client.account.CurrentAccountProvider
|
||||
import com.nextcloud.client.preferences.AppPreferences
|
||||
import com.nhaarman.mockitokotlin2.whenever
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.mockito.Mock
|
||||
import org.mockito.MockitoAnnotations
|
||||
|
||||
class OnboardingServiceTest {
|
||||
|
||||
@Mock
|
||||
private lateinit var resources: Resources
|
||||
|
||||
@Mock
|
||||
private lateinit var preferences: AppPreferences
|
||||
|
||||
@Mock
|
||||
private lateinit var currentAccountProvider: CurrentAccountProvider
|
||||
|
||||
@Mock
|
||||
private lateinit var account: Account
|
||||
|
||||
private lateinit var onboardingService: OnboardingServiceImpl
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
MockitoAnnotations.initMocks(this)
|
||||
onboardingService = OnboardingServiceImpl(resources, preferences, currentAccountProvider)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `first run flag toggles with current current account`() {
|
||||
// GIVEN
|
||||
// current account is not set
|
||||
// first run flag is true
|
||||
assertTrue(onboardingService.isFirstRun)
|
||||
|
||||
// WHEN
|
||||
// current account is set
|
||||
whenever(currentAccountProvider.currentAccount).thenReturn(account)
|
||||
|
||||
// THEN
|
||||
// first run flag toggles
|
||||
assertFalse(onboardingService.isFirstRun)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue