From 4f08a54d60d5f78e6410865c0c558e8c90c19cd8 Mon Sep 17 00:00:00 2001 From: Mihai Branescu Date: Thu, 25 Jun 2020 00:02:01 +0300 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/10467 - removed unused tests and resources related to blue dot notification --- .../java/org/mozilla/fenix/utils/Settings.kt | 5 - app/src/main/res/values/preference_keys.xml | 1 - .../toolbar/BrowserInteractorTest.kt | 9 -- .../DefaultBrowserToolbarControllerTest.kt | 17 --- .../toolbar/DefaultToolbarMenuTest.kt | 109 ------------------ .../org/mozilla/fenix/utils/SettingsTest.kt | 13 --- 6 files changed, 154 deletions(-) delete mode 100644 app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultToolbarMenuTest.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 6a025740bb..727e8d0a12 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -224,11 +224,6 @@ class Settings private constructor( default = "" ) - var readerModeOpened by booleanPreference( - appContext.getPreferenceKey(R.string.pref_key_reader_mode_opened), - default = false - ) - var openInAppOpened by booleanPreference( appContext.getPreferenceKey(R.string.pref_key_open_in_app_opened), default = false diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml index 3e5680287a..2a5dd38f2a 100644 --- a/app/src/main/res/values/preference_keys.xml +++ b/app/src/main/res/values/preference_keys.xml @@ -54,7 +54,6 @@ pref_key_experimentation pref_key_showed_private_mode_cfr pref_key_private_mode_opened - pref_key_reader_mode_opened pref_key_open_in_app_opened pref_key_install_pwa_opened diff --git a/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserInteractorTest.kt b/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserInteractorTest.kt index 04cab6f8b0..474ffc4b48 100644 --- a/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserInteractorTest.kt +++ b/app/src/test/java/org/mozilla/fenix/components/toolbar/BrowserInteractorTest.kt @@ -62,13 +62,4 @@ class BrowserInteractorTest { verify { browserToolbarController.handleToolbarItemInteraction(item) } } - - @Test - fun onBrowserMenuDismissed() { - val itemList: List = listOf() - - interactor.onBrowserMenuDismissed(itemList) - - verify { browserToolbarController.handleBrowserMenuDismissed(itemList) } - } } diff --git a/app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultBrowserToolbarControllerTest.kt b/app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultBrowserToolbarControllerTest.kt index 5e79a46b07..8adeadbcd8 100644 --- a/app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultBrowserToolbarControllerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultBrowserToolbarControllerTest.kt @@ -60,7 +60,6 @@ import org.mozilla.fenix.components.metrics.Event import org.mozilla.fenix.components.metrics.MetricController import org.mozilla.fenix.ext.components import org.mozilla.fenix.ext.nav -import org.mozilla.fenix.ext.settings import org.mozilla.fenix.ext.toTab import org.mozilla.fenix.helpers.FenixRobolectricTestRunner import org.mozilla.fenix.home.Tab @@ -185,22 +184,6 @@ class DefaultBrowserToolbarControllerTest { verify { onTabCounterClicked() } } - @Test - fun `handle BrowserMenu dismissed with all options available`() = runBlockingTest { - val itemList: List = listOf( - ToolbarMenu.Item.AddToHomeScreen, - ToolbarMenu.Item.OpenInApp - ) - - val activity = HomeActivity() - - val controller = createController(scope = this, activity = activity) - controller.handleBrowserMenuDismissed(itemList) - - assertEquals(true, activity.settings().installPwaOpened) - assertEquals(true, activity.settings().openInAppOpened) - } - @Test fun handleToolbarClick() = runBlockingTest { every { currentSession.id } returns "1" diff --git a/app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultToolbarMenuTest.kt b/app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultToolbarMenuTest.kt deleted file mode 100644 index 25006899a1..0000000000 --- a/app/src/test/java/org/mozilla/fenix/components/toolbar/DefaultToolbarMenuTest.kt +++ /dev/null @@ -1,109 +0,0 @@ -package org.mozilla.fenix.components.toolbar - -import android.content.Context -import androidx.lifecycle.LifecycleOwner -import io.mockk.every -import io.mockk.mockk -import io.mockk.mockkStatic -import io.mockk.spyk -import mozilla.components.browser.session.SessionManager -import mozilla.components.browser.state.state.BrowserState -import mozilla.components.browser.state.state.ReaderState -import mozilla.components.browser.state.state.createTab -import mozilla.components.browser.state.store.BrowserStore -import mozilla.components.concept.storage.BookmarksStorage -import mozilla.components.feature.app.links.AppLinkRedirect -import mozilla.components.feature.app.links.AppLinksUseCases -import org.junit.Assert.assertEquals -import org.junit.Before -import org.junit.Test -import org.mozilla.fenix.ext.components -import org.mozilla.fenix.ext.settings -import org.mozilla.fenix.utils.Settings - -class DefaultToolbarMenuTest { - - private lateinit var defaultToolbarMenu: DefaultToolbarMenu - - private val context: Context = mockk(relaxed = true) - private val sessionManager: SessionManager = mockk(relaxed = true) - private val onItemTapped: (ToolbarMenu.Item) -> Unit = {} - private val lifecycleOwner: LifecycleOwner = mockk(relaxed = true) - private val bookmarksStorage: BookmarksStorage = mockk(relaxed = true) - - private val store: BrowserStore = BrowserStore(initialState = BrowserState( - listOf( - createTab("https://www.mozilla.org", id = "readerable-tab", readerState = ReaderState(readerable = true)) - ) - )) - - @Before - fun setUp() { - defaultToolbarMenu = spyk( - DefaultToolbarMenu( - context, - sessionManager, - store, - hasAccountProblem = false, - shouldReverseItems = false, - onItemTapped = onItemTapped, - lifecycleOwner = lifecycleOwner, - bookmarksStorage = bookmarksStorage - ) - ) - - val settings = Settings.getInstance(context, true) - mockkStatic("org.mozilla.fenix.ext.ContextKt") - every { context.settings() } returns settings - } - - @Test - fun `get all low prio highlight items`() { - every { context.components.useCases.webAppUseCases.isPinningSupported() } returns true - every { context.components.useCases.webAppUseCases.isInstallable() } returns true - - val getAppLinkRedirect: AppLinksUseCases.GetAppLinkRedirect = mockk(relaxed = true) - every { context.components.useCases.appLinksUseCases.appLinkRedirect } returns getAppLinkRedirect - val appLinkRedirect: AppLinkRedirect = mockk(relaxed = true) - every { appLinkRedirect.hasExternalApp() } returns true - every { getAppLinkRedirect(any()) } returns appLinkRedirect - - val list = defaultToolbarMenu.getLowPrioHighlightItems() - - assertEquals(ToolbarMenu.Item.InstallToHomeScreen, list[0]) - assertEquals(ToolbarMenu.Item.OpenInApp, list[1]) - } - - @Test - fun `get all low prio highlight items without AddToHomeScreen`() { - val settings = Settings.getInstance(context, true) - mockkStatic("org.mozilla.fenix.ext.ContextKt") - every { context.settings() } returns settings - - every { context.components.useCases.webAppUseCases.isPinningSupported() } returns false - - val getAppLinkRedirect: AppLinksUseCases.GetAppLinkRedirect = mockk(relaxed = true) - every { context.components.useCases.appLinksUseCases.appLinkRedirect } returns getAppLinkRedirect - val appLinkRedirect: AppLinkRedirect = mockk(relaxed = true) - every { appLinkRedirect.hasExternalApp() } returns true - every { getAppLinkRedirect(any()) } returns appLinkRedirect - - val list = defaultToolbarMenu.getLowPrioHighlightItems() - - assertEquals(ToolbarMenu.Item.OpenInApp, list[0]) - } - - @Test - fun `get all low prio highlight items without OpenInApp`() { - every { context.components.useCases.webAppUseCases.isPinningSupported() } returns true - every { context.components.useCases.webAppUseCases.isInstallable() } returns true - - val getAppLinkRedirect: AppLinksUseCases.GetAppLinkRedirect = mockk(relaxed = true) - every { context.components.useCases.appLinksUseCases.appLinkRedirect } returns getAppLinkRedirect - every { getAppLinkRedirect(any()).hasExternalApp() } returns false - - val list = defaultToolbarMenu.getLowPrioHighlightItems() - - assertEquals(ToolbarMenu.Item.InstallToHomeScreen, list[0]) - } -} 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 ba51ff6c9e..65640776a7 100644 --- a/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt +++ b/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt @@ -304,19 +304,6 @@ class SettingsTest { assertFalse(settings.shouldUseTrackingProtection) } - @Test - fun shouldSetReaderModeOpened() { - // When - // Then - assertFalse(settings.readerModeOpened) - - // When - settings.readerModeOpened = true - - // Then - assertTrue(settings.readerModeOpened) - } - @Test fun shouldSetOpenInAppOpened() { // When