|
|
|
@ -4,9 +4,13 @@
|
|
|
|
|
|
|
|
|
|
package org.mozilla.fenix.sync
|
|
|
|
|
|
|
|
|
|
import androidx.navigation.NavController
|
|
|
|
|
import io.mockk.mockk
|
|
|
|
|
import mozilla.components.feature.syncedtabs.view.SyncedTabsView.ErrorType
|
|
|
|
|
import org.junit.Assert.assertEquals
|
|
|
|
|
import org.junit.Assert.assertFalse
|
|
|
|
|
import org.junit.Assert.assertNotNull
|
|
|
|
|
import org.junit.Assert.assertNull
|
|
|
|
|
import org.junit.Assert.assertTrue
|
|
|
|
|
import org.junit.Test
|
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
@ -33,7 +37,7 @@ class SyncedTabsLayoutTest {
|
|
|
|
|
SyncedTabsLayout.stringResourceForError(ErrorType.SYNC_ENGINE_UNAVAILABLE)
|
|
|
|
|
)
|
|
|
|
|
assertEquals(
|
|
|
|
|
R.string.synced_tabs_connect_to_sync_account,
|
|
|
|
|
R.string.synced_tabs_sign_in_message,
|
|
|
|
|
SyncedTabsLayout.stringResourceForError(ErrorType.SYNC_UNAVAILABLE)
|
|
|
|
|
)
|
|
|
|
|
assertEquals(
|
|
|
|
@ -45,4 +49,49 @@ class SyncedTabsLayoutTest {
|
|
|
|
|
SyncedTabsLayout.stringResourceForError(ErrorType.NO_TABS_AVAILABLE)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Test
|
|
|
|
|
fun `get error item`() {
|
|
|
|
|
val navController = mockk<NavController>()
|
|
|
|
|
|
|
|
|
|
var errorItem = SyncedTabsLayout.getErrorItem(
|
|
|
|
|
navController,
|
|
|
|
|
ErrorType.MULTIPLE_DEVICES_UNAVAILABLE,
|
|
|
|
|
R.string.synced_tabs_connect_another_device
|
|
|
|
|
)
|
|
|
|
|
assertNull((errorItem as SyncedTabsAdapter.AdapterItem.Error).navController)
|
|
|
|
|
assertEquals(R.string.synced_tabs_connect_another_device, errorItem.descriptionResId)
|
|
|
|
|
|
|
|
|
|
errorItem = SyncedTabsLayout.getErrorItem(
|
|
|
|
|
navController,
|
|
|
|
|
ErrorType.SYNC_ENGINE_UNAVAILABLE,
|
|
|
|
|
R.string.synced_tabs_enable_tab_syncing
|
|
|
|
|
)
|
|
|
|
|
assertNull((errorItem as SyncedTabsAdapter.AdapterItem.Error).navController)
|
|
|
|
|
assertEquals(R.string.synced_tabs_enable_tab_syncing, errorItem.descriptionResId)
|
|
|
|
|
|
|
|
|
|
errorItem = SyncedTabsLayout.getErrorItem(
|
|
|
|
|
navController,
|
|
|
|
|
ErrorType.SYNC_NEEDS_REAUTHENTICATION,
|
|
|
|
|
R.string.synced_tabs_reauth
|
|
|
|
|
)
|
|
|
|
|
assertNull((errorItem as SyncedTabsAdapter.AdapterItem.Error).navController)
|
|
|
|
|
assertEquals(R.string.synced_tabs_reauth, errorItem.descriptionResId)
|
|
|
|
|
|
|
|
|
|
errorItem = SyncedTabsLayout.getErrorItem(
|
|
|
|
|
navController,
|
|
|
|
|
ErrorType.NO_TABS_AVAILABLE,
|
|
|
|
|
R.string.synced_tabs_no_tabs
|
|
|
|
|
)
|
|
|
|
|
assertNull((errorItem as SyncedTabsAdapter.AdapterItem.Error).navController)
|
|
|
|
|
assertEquals(R.string.synced_tabs_no_tabs, errorItem.descriptionResId)
|
|
|
|
|
|
|
|
|
|
errorItem = SyncedTabsLayout.getErrorItem(
|
|
|
|
|
navController,
|
|
|
|
|
ErrorType.SYNC_UNAVAILABLE,
|
|
|
|
|
R.string.synced_tabs_sign_in_message
|
|
|
|
|
)
|
|
|
|
|
assertNotNull((errorItem as SyncedTabsAdapter.AdapterItem.Error).navController)
|
|
|
|
|
assertEquals(R.string.synced_tabs_sign_in_message, errorItem.descriptionResId)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|