From c9e68bda314a9a507f98305059629a896189c65a Mon Sep 17 00:00:00 2001 From: Severin Rudie Date: Mon, 7 Oct 2019 13:07:18 -0700 Subject: [PATCH] For 4780: remove Settings#usePrivateMode and tests --- .../java/org/mozilla/fenix/utils/Settings.kt | 12 ----- .../org/mozilla/fenix/FenixApplicationTest.kt | 49 ------------------- .../org/mozilla/fenix/utils/SettingsTest.kt | 25 ---------- 3 files changed, 86 deletions(-) delete mode 100644 app/src/test/java/org/mozilla/fenix/FenixApplicationTest.kt diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt index e591425d5..965aeba98 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -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 diff --git a/app/src/test/java/org/mozilla/fenix/FenixApplicationTest.kt b/app/src/test/java/org/mozilla/fenix/FenixApplicationTest.kt deleted file mode 100644 index 9f1a966f1..000000000 --- a/app/src/test/java/org/mozilla/fenix/FenixApplicationTest.kt +++ /dev/null @@ -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() } 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() } - } - - @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 } - } -} diff --git a/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt b/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt index 678cbae07..56edcbd44 100644 --- a/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt +++ b/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt @@ -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