From 2ad016ba240d7a0eeea2603b78a81692e60b341a Mon Sep 17 00:00:00 2001 From: Alexandru2909 Date: Tue, 20 Jun 2023 15:04:08 +0300 Subject: [PATCH] Bug 1839358 - Allow open tabs containing mobile subdomains to be displayed as suggestions in the awesome bar --- .../mozilla/fenix/search/awesomebar/AwesomeBarView.kt | 6 +++--- .../fenix/search/awesomebar/AwesomeBarViewTest.kt | 11 ++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/search/awesomebar/AwesomeBarView.kt b/app/src/main/java/org/mozilla/fenix/search/awesomebar/AwesomeBarView.kt index fa1b8917bb..2286fa723e 100644 --- a/app/src/main/java/org/mozilla/fenix/search/awesomebar/AwesomeBarView.kt +++ b/app/src/main/java/org/mozilla/fenix/search/awesomebar/AwesomeBarView.kt @@ -493,8 +493,8 @@ class AwesomeBarView( searchEngineSource: SearchEngineSource, filterByCurrentEngine: Boolean = false, ): SessionSuggestionProvider { - val searchEngineHostFilter = when (filterByCurrentEngine) { - true -> searchEngineSource.searchEngine?.resultsUrl?.host + val searchEngineUriFilter = when (filterByCurrentEngine) { + true -> searchEngineSource.searchEngine?.resultsUrl false -> null } @@ -506,7 +506,7 @@ class AwesomeBarView( getDrawable(activity, R.drawable.ic_search_results_tab), excludeSelectedSession = !fromHomeFragment, suggestionsHeader = activity.getString(R.string.firefox_suggest_header), - resultsHostFilter = searchEngineHostFilter, + resultsUriFilter = searchEngineUriFilter, ) } diff --git a/app/src/test/java/org/mozilla/fenix/search/awesomebar/AwesomeBarViewTest.kt b/app/src/test/java/org/mozilla/fenix/search/awesomebar/AwesomeBarViewTest.kt index 42f425e769..3cbc2a0aa2 100644 --- a/app/src/test/java/org/mozilla/fenix/search/awesomebar/AwesomeBarViewTest.kt +++ b/app/src/test/java/org/mozilla/fenix/search/awesomebar/AwesomeBarViewTest.kt @@ -640,19 +640,20 @@ class AwesomeBarViewTest { val localSessionsProviders = result.filterIsInstance() assertEquals(1, localSessionsProviders.size) - assertNull(localSessionsProviders[0].resultsHostFilter) + assertNull(localSessionsProviders[0].resultsUriFilter) } @Test fun `GIVEN normal browsing mode and needing to show filtered local tabs suggestions WHEN configuring providers THEN add the tabs provider with an engine filter`() { val settings: Settings = mockk(relaxed = true) + val url = Uri.parse("https://www.test.com") every { activity.settings() } returns settings every { activity.browsingModeManager.mode } returns BrowsingMode.Normal val state = getSearchProviderState( showAllSessionSuggestions = false, searchEngineSource = SearchEngineSource.Shortcut( mockk(relaxed = true) { - every { resultsUrl.host } returns "test" + every { resultsUrl } returns url }, ), ) @@ -661,7 +662,7 @@ class AwesomeBarViewTest { val localSessionsProviders = result.filterIsInstance() assertEquals(1, localSessionsProviders.size) - assertEquals("test", localSessionsProviders[0].resultsHostFilter) + assertEquals(url, localSessionsProviders[0].resultsUriFilter) } @Test @@ -827,8 +828,8 @@ class AwesomeBarViewTest { assertEquals("www.test.com", syncedTabsProviders[1].resultsHostFilter) // the filtered synced tabs provider val localTabsProviders: List = result.filterIsInstance() assertEquals(2, localTabsProviders.size) - assertNull(localTabsProviders[0].resultsHostFilter) // the general tabs provider - assertEquals("www.test.com", localTabsProviders[1].resultsHostFilter) // the filtered tabs provider + assertNull(localTabsProviders[0].resultsUriFilter) // the general tabs provider + assertEquals(url, localTabsProviders[1].resultsUriFilter) // the filtered tabs provider assertEquals(1, result.filterIsInstance().size) }