From bd7ca49b176b3d17fabc5539db0119889d68702c Mon Sep 17 00:00:00 2001 From: Kershan Date: Mon, 29 Mar 2021 16:14:15 +0100 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/18453 - Show SUMO for default browser deeplink on Android { diff --git a/app/src/test/java/org/mozilla/fenix/home/intent/DeepLinkIntentProcessorTest.kt b/app/src/test/java/org/mozilla/fenix/home/intent/DeepLinkIntentProcessorTest.kt index 959200d5e5..88b022db7e 100644 --- a/app/src/test/java/org/mozilla/fenix/home/intent/DeepLinkIntentProcessorTest.kt +++ b/app/src/test/java/org/mozilla/fenix/home/intent/DeepLinkIntentProcessorTest.kt @@ -6,6 +6,9 @@ package org.mozilla.fenix.home.intent import android.content.Intent import android.net.Uri +import android.os.Build.VERSION_CODES.M +import android.os.Build.VERSION_CODES.N +import android.os.Build.VERSION_CODES.P import androidx.core.net.toUri import androidx.navigation.NavController import io.mockk.Called @@ -27,6 +30,8 @@ import org.mozilla.fenix.NavGraphDirections import org.mozilla.fenix.browser.browsingmode.BrowsingMode import org.mozilla.fenix.components.SearchWidgetCreator import org.mozilla.fenix.helpers.FenixRobolectricTestRunner +import org.mozilla.fenix.settings.SupportUtils +import org.robolectric.annotation.Config @RunWith(FenixRobolectricTestRunner::class) class DeepLinkIntentProcessorTest { @@ -244,9 +249,31 @@ class DeepLinkIntentProcessorTest { } @Test - fun `process make_default_browser deep link`() { + @Config(minSdk = N, maxSdk = P) + fun `process make_default_browser deep link for above API 23`() { assertTrue(processor.process(testIntent("make_default_browser"), navController, out)) + verify { activity.startActivity(any()) } + verify { navController wasNot Called } + verify { out wasNot Called } + } + + @Test + @Config(maxSdk = M) + fun `process make_default_browser deep link for API 23 and below`() { + assertTrue(processor.process(testIntent("make_default_browser"), navController, out)) + + verify { + activity.openToBrowserAndLoad( + searchTermOrURL = SupportUtils.getSumoURLForTopic( + activity, + SupportUtils.SumoTopic.SET_AS_DEFAULT_BROWSER + ), + newTab = true, + from = BrowserDirection.FromGlobal, + flags = EngineSession.LoadUrlFlags.external() + ) + } verify { navController wasNot Called } verify { out wasNot Called } } diff --git a/docs/mma.md b/docs/mma.md index ab632d0f1b..92e41d690b 100644 --- a/docs/mma.md +++ b/docs/mma.md @@ -357,7 +357,7 @@ Here is the list of current deep links available, which can be found here in the `fenix://make_default_browser` - Opens to the Android default apps settings screen. **Only works on Android API >=24** + Opens to the Android default apps settings screen. If Android API <= 23 opens tab to support page defined in SupportUtils.SumoTopic.SET_AS_DEFAULT_BROWSER `fenix://settings_notifications`