1
0
Fork 0

Add install_search_widget

master
James Hugman 2020-06-30 20:12:38 +01:00 committed by Emily Kager
parent 7bd2b5b0c9
commit 1629878a66
3 changed files with 24 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.GlobalDirections
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.components.SearchWidgetCreator
import org.mozilla.fenix.ext.alreadyOnDestination
/**
@ -91,6 +92,11 @@ class DeepLinkIntentProcessor(
val intent = notificationSettings(activity)
activity.startActivity(intent)
}
"install_search_widget" -> {
if (SDK_INT >= Build.VERSION_CODES.O) {
SearchWidgetCreator.createSearchWidget(activity)
}
}
}
}

View File

@ -8,7 +8,9 @@ import android.content.Intent
import androidx.core.net.toUri
import androidx.navigation.NavController
import io.mockk.Called
import io.mockk.every
import io.mockk.mockk
import io.mockk.mockkObject
import io.mockk.verify
import mozilla.appservices.places.BookmarkRoot
import org.junit.Assert.assertFalse
@ -20,6 +22,7 @@ import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.NavGraphDirections
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
import org.mozilla.fenix.components.SearchWidgetCreator
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
@RunWith(FenixRobolectricTestRunner::class)
@ -222,5 +225,16 @@ class DeepLinkIntentProcessorTest {
verify { activity.startActivity(any()) }
}
@Test
fun `process install_search_widget deep link`() {
mockkObject(SearchWidgetCreator)
every { SearchWidgetCreator.createSearchWidget(any()) } returns true
assertTrue(processor.process(testIntent("fenix://install_search_widget"), navController, out))
verify { navController wasNot Called }
verify { out wasNot Called }
verify { activity wasNot Called }
}
private fun testIntent(uri: String) = Intent("", uri.toUri())
}

View File

@ -318,6 +318,10 @@ Here is the list of current deep links available, which can be found here in the
<td>`fenix://settings_notifications`</td>
<td>Opens to the Android notification settings screen for Fenix. **Only works on Android API >=24**</td>
</tr>
<tr>
<td>`fenix://install_search_widget`</td>
<td>Adds the search widget to the users launcher homescreen. **Only works on Android API >=26**</td>
</tr>
</table>
Messages