Bug 1826590 - Fix ClassCastException in ShareControllerTest.

Also verify dismiss calls.
fenix/116.0
mcarare 1 year ago committed by mergify[bot]
parent a731b1dbbd
commit e01dd40dc2

@ -18,6 +18,7 @@ import io.mockk.slot
import io.mockk.spyk
import io.mockk.verify
import io.mockk.verifyOrder
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.test.advanceUntilIdle
import mozilla.components.concept.engine.prompt.ShareData
import mozilla.components.concept.sync.Device
@ -417,16 +418,18 @@ class ShareControllerTest {
val deviceId = slot<String>()
val tabsShared = slot<List<TabData>>()
every { sendTabUseCases.sendToDeviceAsync(any(), any<List<TabData>>()) } returns CompletableDeferred(true)
every { navController.currentDestination?.id } returns R.id.shareFragment
controller.handleShareToDevice(deviceToShareTo)
assertNotNull(SyncAccount.sendTab.testGetValue())
assertEquals(1, SyncAccount.sendTab.testGetValue()!!.size)
assertNull(SyncAccount.sendTab.testGetValue()!!.single().extra)
// Verify all the needed methods are called.
verify {
verifyOrder {
sendTabUseCases.sendToDeviceAsync(capture(deviceId), capture(tabsShared))
// dismiss() is also to be called, but at the moment cannot test it in a coroutine.
dismiss(ShareController.Result.SUCCESS)
}
assertTrue(deviceId.isCaptured)
@ -438,6 +441,9 @@ class ShareControllerTest {
@Test
@Suppress("DeferredResultUnused")
fun `handleShareToAllDevices calls handleShareToDevice multiple times`() {
every { sendTabUseCases.sendToAllAsync(any<List<TabData>>()) } returns CompletableDeferred(true)
every { navController.currentDestination?.id } returns R.id.shareFragment
val devicesToShareTo = listOf(
Device(
"deviceId0",
@ -466,7 +472,7 @@ class ShareControllerTest {
verifyOrder {
sendTabUseCases.sendToAllAsync(capture(tabsShared))
// dismiss() is also to be called, but at the moment cannot test it in a coroutine.
dismiss(ShareController.Result.SUCCESS)
}
// SendTabUseCases should send a the `shareTabs` mapped to tabData

Loading…
Cancel
Save