[fenix] For https://github.com/mozilla-mobile/fenix/issues/4780 switch off private mode (https://github.com/mozilla-mobile/fenix/pull/5614)
* Do not launch in Private Mode When the app launches do not launch in Private Mode in order to prevent usage leaks to other users of the device. * Issue https://github.com/mozilla-mobile/fenix/issues/4780: add comments to use private mode * For https://github.com/mozilla-mobile/fenix/issues/4780: write tests for clear private mode on create app * For https://github.com/mozilla-mobile/fenix/issues/4780: clear private mode when privacy notification is removedpull/600/head
parent
d9881d8211
commit
e8aecbb458
@ -0,0 +1,49 @@
|
|||||||
|
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 alwaysOpenInPrivateMode is active WHEN maybeClearPrivateMode is called THEN private mode should not be changed`() {
|
||||||
|
every { settings.alwaysOpenInPrivateMode } returns true
|
||||||
|
|
||||||
|
application.maybeClearPrivateMode(settings)
|
||||||
|
|
||||||
|
verify(exactly = 0) { settings.usePrivateMode = any<Boolean>() }
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `GIVEN alwaysOpenInPrivateMode is inactive WHEN maybeClearPrivateMode is called THEN private mode should be disabled`() {
|
||||||
|
every { settings.alwaysOpenInPrivateMode } returns false
|
||||||
|
|
||||||
|
application.maybeClearPrivateMode(settings)
|
||||||
|
|
||||||
|
verify(exactly = 1) { settings.usePrivateMode = false }
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue