|
|
|
@ -38,6 +38,7 @@ import mozilla.components.service.fxa.sync.SyncReason
|
|
|
|
|
import mozilla.components.service.glean.testing.GleanTestRule
|
|
|
|
|
import mozilla.components.support.test.libstate.ext.waitUntilIdle
|
|
|
|
|
import mozilla.components.support.test.robolectric.testContext
|
|
|
|
|
import mozilla.telemetry.glean.internal.ErrorType
|
|
|
|
|
import org.junit.Assert.assertEquals
|
|
|
|
|
import org.junit.Assert.assertNotNull
|
|
|
|
|
import org.junit.Assert.assertNull
|
|
|
|
@ -182,6 +183,40 @@ class RecentSyncedTabFeatureTest {
|
|
|
|
|
verify { appStore.dispatch(AppAction.RecentSyncedTabStateChange(RecentSyncedTabState.Success(expected))) }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun `GIVEN loading state has not been dispatched WHEN status becomes idle THEN timing distribution is not recorded`() = runTest {
|
|
|
|
|
val account = mockk<Account>()
|
|
|
|
|
syncStore.setState(account = account)
|
|
|
|
|
every { appStore.state } returns mockk {
|
|
|
|
|
every { recentSyncedTabState } returns RecentSyncedTabState.Loading
|
|
|
|
|
}
|
|
|
|
|
coEvery { historyStorage.getDetailedVisits(any(), any()) } returns listOf()
|
|
|
|
|
val activeTab = createActiveTab()
|
|
|
|
|
coEvery { syncedTabsStorage.getSyncedDeviceTabs() } returns listOf(
|
|
|
|
|
SyncedDeviceTabs(
|
|
|
|
|
device = deviceAccessed1,
|
|
|
|
|
tabs = listOf(activeTab),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
feature.start()
|
|
|
|
|
syncStore.setState(status = SyncStatus.Idle)
|
|
|
|
|
runCurrent()
|
|
|
|
|
// this does not trigger a loading state, which should only be shown when tabs are loaded
|
|
|
|
|
// during app initialization
|
|
|
|
|
syncStore.setState(status = SyncStatus.Started)
|
|
|
|
|
runCurrent()
|
|
|
|
|
syncStore.setState(status = SyncStatus.Idle)
|
|
|
|
|
runCurrent()
|
|
|
|
|
|
|
|
|
|
assertEquals(
|
|
|
|
|
0,
|
|
|
|
|
RecentSyncedTabs.recentSyncedTabTimeToLoad.testGetNumRecordedErrors(
|
|
|
|
|
ErrorType.INVALID_STATE,
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun `GIVEN tabs from remote and current devices WHEN dispatching recent synced tab THEN current device is filtered out of dispatch`() = runTest {
|
|
|
|
|
val account = mockk<Account>()
|
|
|
|
|