For 4780: remove Settings#usePrivateMode and tests
parent
dd6439269b
commit
c9e68bda31
|
@ -83,18 +83,6 @@ class Settings private constructor(
|
|||
default = ""
|
||||
)
|
||||
|
||||
/**
|
||||
* Warning: when possible, prefer to set this via [BrowsingModeManager].
|
||||
*
|
||||
* [BrowsingModeManager] defines a callback to be hit whenever this setting changes. For
|
||||
* example, setting this value directly at the wrong time could cause the private theme to
|
||||
* not be applied.
|
||||
*/
|
||||
var usePrivateMode by booleanPreference(
|
||||
appContext.getPreferenceKey(R.string.pref_key_private_mode),
|
||||
default = false
|
||||
)
|
||||
|
||||
var openLinksInAPrivateTab by booleanPreference(
|
||||
appContext.getPreferenceKey(R.string.pref_key_open_links_in_a_private_tab),
|
||||
default = false
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
package org.mozilla.fenix
|
||||
|
||||
import io.mockk.MockKAnnotations
|
||||
import io.mockk.every
|
||||
import io.mockk.impl.annotations.MockK
|
||||
import io.mockk.just
|
||||
import io.mockk.runs
|
||||
import io.mockk.verify
|
||||
import kotlinx.coroutines.ObsoleteCoroutinesApi
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@ObsoleteCoroutinesApi
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(application = TestApplication::class)
|
||||
class FenixApplicationTest {
|
||||
|
||||
lateinit var application: FenixApplication
|
||||
@MockK lateinit var settings: Settings
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
MockKAnnotations.init(this)
|
||||
every { settings setProperty "usePrivateMode" value any<Boolean>() } just runs
|
||||
application = TestApplication()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN openLinksInAPrivateTab is active WHEN maybeClearPrivateMode is called THEN private mode should not be changed`() {
|
||||
every { settings.openLinksInAPrivateTab } returns true
|
||||
|
||||
application.maybeClearPrivateMode(settings)
|
||||
|
||||
verify(exactly = 0) { settings.usePrivateMode = any<Boolean>() }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `GIVEN openLinksInAPrivateTab is inactive WHEN maybeClearPrivateMode is called THEN private mode should be disabled`() {
|
||||
every { settings.openLinksInAPrivateTab } returns false
|
||||
|
||||
application.maybeClearPrivateMode(settings)
|
||||
|
||||
verify(exactly = 1) { settings.usePrivateMode = false }
|
||||
}
|
||||
}
|
|
@ -35,25 +35,6 @@ class SettingsTest {
|
|||
settings = testContext.settings().apply(Settings::clear)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun usePrivateMode() {
|
||||
// When just created
|
||||
// Then
|
||||
assertFalse(settings.usePrivateMode)
|
||||
|
||||
// When
|
||||
settings.usePrivateMode = true
|
||||
|
||||
// Then
|
||||
assertTrue(settings.usePrivateMode)
|
||||
|
||||
// When
|
||||
settings.usePrivateMode = false
|
||||
|
||||
// Then
|
||||
assertFalse(settings.usePrivateMode)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun launchLinksInPrivateTab() {
|
||||
// When just created
|
||||
|
@ -65,12 +46,6 @@ class SettingsTest {
|
|||
|
||||
// Then
|
||||
assertTrue(settings.openLinksInAPrivateTab)
|
||||
|
||||
// When
|
||||
settings.openLinksInAPrivateTab = false
|
||||
|
||||
// Then
|
||||
assertFalse(settings.usePrivateMode)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue