From 60fa4b0c25513c87332c03bd38ddf422d2d6a2d2 Mon Sep 17 00:00:00 2001 From: laghee <20972610+laghee@users.noreply.github.com> Date: Mon, 20 Jan 2025 14:56:15 +0100 Subject: [PATCH] Tried, failed to fix globe icon; mvp for related tests (cherry picked from commit 51d4367af50c251ba963a42f89086ded3e41c657) --- .../browser/omnibar/OmnibarLayoutViewModel.kt | 1 + .../omnibar/OmnibarLayoutViewModelTest.kt | 22 +++++++++++++++++++ ...iciousSiteBlockerWebViewIntegrationTest.kt | 1 + 3 files changed, 24 insertions(+) diff --git a/app/src/main/java/com/duckduckgo/app/browser/omnibar/OmnibarLayoutViewModel.kt b/app/src/main/java/com/duckduckgo/app/browser/omnibar/OmnibarLayoutViewModel.kt index fb2ca1d0ef4b..58c796be9502 100644 --- a/app/src/main/java/com/duckduckgo/app/browser/omnibar/OmnibarLayoutViewModel.kt +++ b/app/src/main/java/com/duckduckgo/app/browser/omnibar/OmnibarLayoutViewModel.kt @@ -304,6 +304,7 @@ class OmnibarLayoutViewModel @Inject constructor( Error -> GLOBE NewTab -> SEARCH SSLWarning -> GLOBE + MaliciousSiteWarning -> GLOBE else -> SEARCH } } diff --git a/app/src/test/java/com/duckduckgo/app/browser/omnibar/OmnibarLayoutViewModelTest.kt b/app/src/test/java/com/duckduckgo/app/browser/omnibar/OmnibarLayoutViewModelTest.kt index 906e4e78e1d8..b862dff97c38 100644 --- a/app/src/test/java/com/duckduckgo/app/browser/omnibar/OmnibarLayoutViewModelTest.kt +++ b/app/src/test/java/com/duckduckgo/app/browser/omnibar/OmnibarLayoutViewModelTest.kt @@ -294,6 +294,17 @@ class OmnibarLayoutViewModelTest { } } + @Test + fun whenViewModeChangedToMaliciousSiteWarningThenViewStateCorrect() = runTest { + testee.onViewModeChanged(ViewMode.MaliciousSiteWarning) + + testee.viewState.test { + val viewState = awaitItem() + assertTrue(viewState.leadingIconState == LeadingIconState.GLOBE) + assertTrue(viewState.scrollingEnabled) + } + } + @Test fun whenViewModeChangedToNewTabThenViewStateCorrect() = runTest { testee.onViewModeChanged(ViewMode.NewTab) @@ -338,6 +349,17 @@ class OmnibarLayoutViewModelTest { } } + @Test + fun whenViewModeChangedToMaliciousSiteWarningAndFocusThenViewStateCorrect() = runTest { + testee.onOmnibarFocusChanged(true, RANDOM_URL) + testee.onViewModeChanged(ViewMode.MaliciousSiteWarning) + + testee.viewState.test { + val viewState = expectMostRecentItem() + assertTrue(viewState.leadingIconState == LeadingIconState.SEARCH) + } + } + @Test fun whenViewModeChangedToNewTabAndFocusThenViewStateCorrect() = runTest { testee.onOmnibarFocusChanged(true, RANDOM_URL) diff --git a/app/src/test/java/com/duckduckgo/app/browser/webview/RealMaliciousSiteBlockerWebViewIntegrationTest.kt b/app/src/test/java/com/duckduckgo/app/browser/webview/RealMaliciousSiteBlockerWebViewIntegrationTest.kt index e5bc0fd7841e..3837a2d663f6 100644 --- a/app/src/test/java/com/duckduckgo/app/browser/webview/RealMaliciousSiteBlockerWebViewIntegrationTest.kt +++ b/app/src/test/java/com/duckduckgo/app/browser/webview/RealMaliciousSiteBlockerWebViewIntegrationTest.kt @@ -44,6 +44,7 @@ class RealMaliciousSiteBlockerWebViewIntegrationTest { dispatchers = coroutineRule.testDispatcherProvider, appCoroutineScope = coroutineRule.testScope, isMainProcess = true, + exemptedUrlsHolder = ExemptedUrlsHolder(), ) @Before