Update IntentProcessor implementation to comply with new interface.
parent
e2bfe8d0db
commit
7b170c4428
|
@ -43,7 +43,7 @@ class FennecWebAppIntentProcessor(
|
||||||
/**
|
/**
|
||||||
* Returns true if this intent should launch a progressive web app created in Fennec.
|
* Returns true if this intent should launch a progressive web app created in Fennec.
|
||||||
*/
|
*/
|
||||||
override fun matches(intent: Intent) =
|
private fun matches(intent: Intent) =
|
||||||
intent.toSafeIntent().action == ACTION_FENNEC_WEBAPP
|
intent.toSafeIntent().action == ACTION_FENNEC_WEBAPP
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -27,7 +27,7 @@ class FennecBookmarkShortcutsIntentProcessor(
|
||||||
/**
|
/**
|
||||||
* Returns true if this Intent is of a Fennec pinned shortcut.
|
* Returns true if this Intent is of a Fennec pinned shortcut.
|
||||||
*/
|
*/
|
||||||
override fun matches(intent: Intent): Boolean {
|
private fun matches(intent: Intent): Boolean {
|
||||||
return intent.toSafeIntent().action == ACTION_FENNEC_HOMESCREEN_SHORTCUT
|
return intent.toSafeIntent().action == ACTION_FENNEC_HOMESCREEN_SHORTCUT
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class NewTabShortcutIntentProcessor : IntentProcessor {
|
||||||
/**
|
/**
|
||||||
* Returns true if this intent processor will handle the intent.
|
* Returns true if this intent processor will handle the intent.
|
||||||
*/
|
*/
|
||||||
override fun matches(intent: Intent): Boolean {
|
private fun matches(intent: Intent): Boolean {
|
||||||
val safeIntent = SafeIntent(intent)
|
val safeIntent = SafeIntent(intent)
|
||||||
return safeIntent.action == ACTION_OPEN_TAB || safeIntent.action == ACTION_OPEN_PRIVATE_TAB
|
return safeIntent.action == ACTION_OPEN_TAB || safeIntent.action == ACTION_OPEN_PRIVATE_TAB
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,7 @@ class IntentReceiverActivityTest {
|
||||||
intent.flags = FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
|
intent.flags = FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
|
||||||
|
|
||||||
`when`(testContext.components.intentProcessors.intentProcessor.process(intent)).thenReturn(true)
|
`when`(testContext.components.intentProcessors.intentProcessor.process(intent)).thenReturn(true)
|
||||||
`when`(testContext.components.intentProcessors.intentProcessor.matches(intent)).thenReturn(true)
|
|
||||||
`when`(testContext.components.intentProcessors.customTabIntentProcessor.process(intent)).thenReturn(false)
|
`when`(testContext.components.intentProcessors.customTabIntentProcessor.process(intent)).thenReturn(false)
|
||||||
`when`(testContext.components.intentProcessors.customTabIntentProcessor.matches(intent)).thenReturn(false)
|
|
||||||
val activity = Robolectric.buildActivity(IntentReceiverActivity::class.java, intent).get()
|
val activity = Robolectric.buildActivity(IntentReceiverActivity::class.java, intent).get()
|
||||||
activity.processIntent(intent)
|
activity.processIntent(intent)
|
||||||
|
|
||||||
|
@ -155,7 +153,6 @@ class IntentReceiverActivityTest {
|
||||||
|
|
||||||
val intent = Intent()
|
val intent = Intent()
|
||||||
`when`(testContext.components.intentProcessors.customTabIntentProcessor.process(intent)).thenReturn(true)
|
`when`(testContext.components.intentProcessors.customTabIntentProcessor.process(intent)).thenReturn(true)
|
||||||
`when`(testContext.components.intentProcessors.customTabIntentProcessor.matches(intent)).thenReturn(true)
|
|
||||||
|
|
||||||
val activity = Robolectric.buildActivity(IntentReceiverActivity::class.java, intent).get()
|
val activity = Robolectric.buildActivity(IntentReceiverActivity::class.java, intent).get()
|
||||||
activity.processIntent(intent)
|
activity.processIntent(intent)
|
||||||
|
@ -176,7 +173,6 @@ class IntentReceiverActivityTest {
|
||||||
|
|
||||||
val intent = Intent()
|
val intent = Intent()
|
||||||
`when`(testContext.components.intentProcessors.privateCustomTabIntentProcessor.process(intent)).thenReturn(true)
|
`when`(testContext.components.intentProcessors.privateCustomTabIntentProcessor.process(intent)).thenReturn(true)
|
||||||
`when`(testContext.components.intentProcessors.privateCustomTabIntentProcessor.matches(intent)).thenReturn(true)
|
|
||||||
|
|
||||||
val activity = Robolectric.buildActivity(IntentReceiverActivity::class.java, intent).get()
|
val activity = Robolectric.buildActivity(IntentReceiverActivity::class.java, intent).get()
|
||||||
activity.processIntent(intent)
|
activity.processIntent(intent)
|
||||||
|
|
|
@ -103,7 +103,6 @@ class IntentProcessorTypeTest {
|
||||||
@Test
|
@Test
|
||||||
fun `get type for generic intent processor`() {
|
fun `get type for generic intent processor`() {
|
||||||
val processor = object : IntentProcessor {
|
val processor = object : IntentProcessor {
|
||||||
override fun matches(intent: Intent) = true
|
|
||||||
override suspend fun process(intent: Intent) = true
|
override suspend fun process(intent: Intent) = true
|
||||||
}
|
}
|
||||||
val type = testContext.components.intentProcessors.getType(processor)
|
val type = testContext.components.intentProcessors.getType(processor)
|
||||||
|
|
|
@ -37,24 +37,13 @@ class FennecBookmarkShortcutsIntentProcessorTest {
|
||||||
private val sessionManager = mockk<SessionManager>(relaxed = true)
|
private val sessionManager = mockk<SessionManager>(relaxed = true)
|
||||||
private val loadUrlUseCase = mockk<SessionUseCases.DefaultLoadUrlUseCase>(relaxed = true)
|
private val loadUrlUseCase = mockk<SessionUseCases.DefaultLoadUrlUseCase>(relaxed = true)
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `only match Fennec pinned shortcut Intents`() {
|
|
||||||
val processor = FennecBookmarkShortcutsIntentProcessor(sessionManager, loadUrlUseCase)
|
|
||||||
|
|
||||||
assertAll {
|
|
||||||
assertThat(processor.matches(Intent(ACTION_FENNEC_HOMESCREEN_SHORTCUT))).isTrue()
|
|
||||||
assertThat(processor.matches(Intent("ShouldNotMatch"))).isFalse()
|
|
||||||
assertThat(processor.matches(Intent())).isFalse()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `do not process blank Intents`() = runBlocking {
|
fun `do not process blank Intents`() = runBlocking {
|
||||||
val processor = FennecBookmarkShortcutsIntentProcessor(sessionManager, loadUrlUseCase)
|
val processor = FennecBookmarkShortcutsIntentProcessor(sessionManager, loadUrlUseCase)
|
||||||
val fennecShortcutsIntent = Intent(ACTION_FENNEC_HOMESCREEN_SHORTCUT)
|
val fennecShortcutsIntent = Intent(ACTION_FENNEC_HOMESCREEN_SHORTCUT)
|
||||||
fennecShortcutsIntent.data = Uri.parse("http://mozilla.org")
|
fennecShortcutsIntent.data = Uri.parse("http://mozilla.org")
|
||||||
|
|
||||||
val wasEmptyIntentProcessed = processor.matches(Intent())
|
val wasEmptyIntentProcessed = processor.process(Intent())
|
||||||
|
|
||||||
assertThat(wasEmptyIntentProcessed).isFalse()
|
assertThat(wasEmptyIntentProcessed).isFalse()
|
||||||
verify {
|
verify {
|
||||||
|
|
Loading…
Reference in New Issue