1
0
Fork 0

Close #7749: Fix broken IntentReceiverActivity tests

master
Jonathan Almeida 2020-04-17 21:34:14 -04:00 committed by Jonathan Almeida
parent e995a98819
commit 9f95cff6c4
2 changed files with 21 additions and 3 deletions

View File

@ -35,8 +35,10 @@ class IntentReceiverActivityTest {
val intent = Intent()
intent.flags = FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY
`when`(testContext.components.intentProcessors.migrationIntentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.intentProcessor.process(intent)).thenReturn(true)
`when`(testContext.components.intentProcessors.customTabIntentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.fennecPageShortcutIntentProcessor.process(intent)).thenReturn(false)
val activity = Robolectric.buildActivity(IntentReceiverActivity::class.java, intent).get()
activity.processIntent(intent)
@ -54,8 +56,10 @@ class IntentReceiverActivityTest {
val intent = Intent()
intent.action = NewTabShortcutIntentProcessor.ACTION_OPEN_PRIVATE_TAB
`when`(testContext.components.intentProcessors.migrationIntentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.intentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.customTabIntentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.fennecPageShortcutIntentProcessor.process(intent)).thenReturn(false)
val activity = Robolectric.buildActivity(IntentReceiverActivity::class.java, intent).get()
activity.processIntent(intent)
@ -74,8 +78,10 @@ class IntentReceiverActivityTest {
val intent = Intent()
intent.action = NewTabShortcutIntentProcessor.ACTION_OPEN_TAB
`when`(testContext.components.intentProcessors.intentProcessor.process(intent)).thenReturn(true)
`when`(testContext.components.intentProcessors.migrationIntentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.intentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.customTabIntentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.fennecPageShortcutIntentProcessor.process(intent)).thenReturn(false)
val activity = Robolectric.buildActivity(IntentReceiverActivity::class.java, intent).get()
activity.processIntent(intent)
@ -83,7 +89,7 @@ class IntentReceiverActivityTest {
val actualIntent = shadow.peekNextStartedActivity()
assertEquals(HomeActivity::class.java.name, actualIntent.component?.className)
assertEquals(false, actualIntent.hasExtra(HomeActivity.PRIVATE_BROWSING_MODE))
assertEquals(false, actualIntent.getBooleanExtra(HomeActivity.PRIVATE_BROWSING_MODE, false))
assertEquals(false, actualIntent.getBooleanExtra(HomeActivity.OPEN_TO_BROWSER, true))
}
@ -92,8 +98,10 @@ class IntentReceiverActivityTest {
testContext.settings().openLinksInAPrivateTab = false
val intent = Intent()
`when`(testContext.components.intentProcessors.migrationIntentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.intentProcessor.process(intent)).thenReturn(true)
`when`(testContext.components.intentProcessors.customTabIntentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.fennecPageShortcutIntentProcessor.process(intent)).thenReturn(false)
val activity = Robolectric.buildActivity(IntentReceiverActivity::class.java, intent).get()
activity.processIntent(intent)
@ -101,7 +109,7 @@ class IntentReceiverActivityTest {
val actualIntent = shadow.peekNextStartedActivity()
assertEquals(HomeActivity::class.java.name, actualIntent.component?.className)
assertEquals(false, actualIntent.getBooleanExtra(HomeActivity.OPEN_TO_BROWSER, true))
assertEquals(true, actualIntent.getBooleanExtra(HomeActivity.OPEN_TO_BROWSER, true))
}
@Test
@ -109,8 +117,10 @@ class IntentReceiverActivityTest {
testContext.settings().openLinksInAPrivateTab = true
val intent = Intent()
`when`(testContext.components.intentProcessors.migrationIntentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.privateIntentProcessor.process(intent)).thenReturn(true)
`when`(testContext.components.intentProcessors.privateCustomTabIntentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.fennecPageShortcutIntentProcessor.process(intent)).thenReturn(false)
val activity = Robolectric.buildActivity(IntentReceiverActivity::class.java, intent).get()
activity.processIntent(intent)
@ -125,8 +135,10 @@ class IntentReceiverActivityTest {
testContext.settings().openLinksInAPrivateTab = false
val intent = Intent()
`when`(testContext.components.intentProcessors.migrationIntentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.intentProcessor.process(intent)).thenReturn(true)
`when`(testContext.components.intentProcessors.customTabIntentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.fennecPageShortcutIntentProcessor.process(intent)).thenReturn(false)
val activity = Robolectric.buildActivity(IntentReceiverActivity::class.java, intent).get()
activity.processIntent(intent)
@ -142,6 +154,8 @@ class IntentReceiverActivityTest {
testContext.settings().openLinksInAPrivateTab = false
val intent = Intent()
`when`(testContext.components.intentProcessors.migrationIntentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.fennecPageShortcutIntentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.customTabIntentProcessor.process(intent)).thenReturn(true)
val activity = Robolectric.buildActivity(IntentReceiverActivity::class.java, intent).get()
@ -161,7 +175,9 @@ class IntentReceiverActivityTest {
testContext.settings().openLinksInAPrivateTab = true
val intent = Intent()
`when`(testContext.components.intentProcessors.migrationIntentProcessor.process(intent)).thenReturn(false)
`when`(testContext.components.intentProcessors.privateCustomTabIntentProcessor.process(intent)).thenReturn(true)
`when`(testContext.components.intentProcessors.fennecPageShortcutIntentProcessor.process(intent)).thenReturn(false)
val activity = Robolectric.buildActivity(IntentReceiverActivity::class.java, intent).get()
activity.processIntent(intent)

View File

@ -35,6 +35,8 @@ class TestComponents(private val context: Context) : Components(context) {
`when`(processors.intentProcessor).thenReturn(mock())
`when`(processors.customTabIntentProcessor).thenReturn(mock())
`when`(processors.privateCustomTabIntentProcessor).thenReturn(mock())
`when`(processors.migrationIntentProcessor).thenReturn(mock())
`when`(processors.fennecPageShortcutIntentProcessor).thenReturn(mock())
processors
}
override val analytics by lazy { Analytics(context) }