|
|
|
@ -26,6 +26,7 @@ import org.junit.Assert.assertTrue
|
|
|
|
|
import org.junit.Test
|
|
|
|
|
import org.junit.runner.RunWith
|
|
|
|
|
import org.mozilla.fenix.BrowserDirection
|
|
|
|
|
import org.mozilla.fenix.NavGraphDirections
|
|
|
|
|
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
|
|
|
|
|
import org.mozilla.fenix.browser.browsingmode.BrowsingModeManager
|
|
|
|
|
import org.mozilla.fenix.ext.components
|
|
|
|
@ -93,6 +94,7 @@ class ExternalAppBrowserActivityTest {
|
|
|
|
|
val bundle: Bundle = mockk()
|
|
|
|
|
every { bundle.getString(any()) } returns ""
|
|
|
|
|
every { intent.extras } returns bundle
|
|
|
|
|
every { intent.getBooleanExtra(any(), any()) } returns false
|
|
|
|
|
return intent
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
@ -107,6 +109,76 @@ class ExternalAppBrowserActivityTest {
|
|
|
|
|
verify { activity.finishAndRemoveTask() }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun `GIVEN intent isSandboxCustomTab is true WHEN getNavDirections called THEN actionGlobalExternalAppBrowser isSandboxCustomTab is true`() {
|
|
|
|
|
val activity = spyk(
|
|
|
|
|
object : ExternalAppBrowserActivity() {
|
|
|
|
|
public override fun getNavDirections(
|
|
|
|
|
from: BrowserDirection,
|
|
|
|
|
customTabSessionId: String?,
|
|
|
|
|
): NavDirections? {
|
|
|
|
|
return super.getNavDirections(from, customTabSessionId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun getIntent(): Intent {
|
|
|
|
|
val intent: Intent = mockk()
|
|
|
|
|
val bundle: Bundle = mockk()
|
|
|
|
|
every { bundle.getString(any()) } returns ""
|
|
|
|
|
every { intent.getBooleanExtra(any(), any()) } returns true
|
|
|
|
|
every { intent.extras } returns bundle
|
|
|
|
|
return intent
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
val customTabSessionId = "id"
|
|
|
|
|
val directions = activity.getNavDirections(BrowserDirection.FromGlobal, customTabSessionId)
|
|
|
|
|
assertNotNull(directions)
|
|
|
|
|
verify(exactly = 0) { activity.finishAndRemoveTask() }
|
|
|
|
|
|
|
|
|
|
val expected = NavGraphDirections.actionGlobalExternalAppBrowser(
|
|
|
|
|
activeSessionId = customTabSessionId,
|
|
|
|
|
webAppManifest = null,
|
|
|
|
|
isSandboxCustomTab = true,
|
|
|
|
|
)
|
|
|
|
|
assertEquals(expected, directions)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun `GIVEN intent isSandboxCustomTab is false WHEN getNavDirections called THEN actionGlobalExternalAppBrowser isSandboxCustomTab is false`() {
|
|
|
|
|
val activity = spyk(
|
|
|
|
|
object : ExternalAppBrowserActivity() {
|
|
|
|
|
public override fun getNavDirections(
|
|
|
|
|
from: BrowserDirection,
|
|
|
|
|
customTabSessionId: String?,
|
|
|
|
|
): NavDirections? {
|
|
|
|
|
return super.getNavDirections(from, customTabSessionId)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun getIntent(): Intent {
|
|
|
|
|
val intent: Intent = mockk()
|
|
|
|
|
val bundle: Bundle = mockk()
|
|
|
|
|
every { bundle.getString(any()) } returns ""
|
|
|
|
|
every { intent.getBooleanExtra(any(), any()) } returns false
|
|
|
|
|
every { intent.extras } returns bundle
|
|
|
|
|
return intent
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
val customTabSessionId = "id"
|
|
|
|
|
val directions = activity.getNavDirections(BrowserDirection.FromGlobal, customTabSessionId)
|
|
|
|
|
assertNotNull(directions)
|
|
|
|
|
verify(exactly = 0) { activity.finishAndRemoveTask() }
|
|
|
|
|
|
|
|
|
|
val expected = NavGraphDirections.actionGlobalExternalAppBrowser(
|
|
|
|
|
activeSessionId = customTabSessionId,
|
|
|
|
|
webAppManifest = null,
|
|
|
|
|
isSandboxCustomTab = false,
|
|
|
|
|
)
|
|
|
|
|
assertEquals(expected, directions)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun `ExternalAppBrowserActivity with matching external tab`() {
|
|
|
|
|
val store = BrowserStore(
|
|
|
|
|