Loading app/src/main/java/org/mozilla/fenix/sync/SyncedTabsLayout.kt +3 −3 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ class SyncedTabsLayout @JvmOverloads constructor( companion object { private fun pullToRefreshEnableState(error: SyncedTabsView.ErrorType) = when (error) { internal fun pullToRefreshEnableState(error: SyncedTabsView.ErrorType) = when (error) { // Disable "pull-to-refresh" when we clearly can't sync tabs, and user needs to take an // action within the app. SyncedTabsView.ErrorType.SYNC_UNAVAILABLE, Loading @@ -97,7 +97,7 @@ class SyncedTabsLayout @JvmOverloads constructor( SyncedTabsView.ErrorType.NO_TABS_AVAILABLE -> true } private fun stringResourceForError(error: SyncedTabsView.ErrorType) = when (error) { internal fun stringResourceForError(error: SyncedTabsView.ErrorType) = when (error) { SyncedTabsView.ErrorType.MULTIPLE_DEVICES_UNAVAILABLE -> R.string.synced_tabs_connect_another_device SyncedTabsView.ErrorType.SYNC_ENGINE_UNAVAILABLE -> R.string.synced_tabs_enable_tab_syncing SyncedTabsView.ErrorType.SYNC_UNAVAILABLE -> R.string.synced_tabs_sign_in_message Loading @@ -105,7 +105,7 @@ class SyncedTabsLayout @JvmOverloads constructor( SyncedTabsView.ErrorType.NO_TABS_AVAILABLE -> R.string.synced_tabs_no_tabs } private fun getErrorItem( internal fun getErrorItem( navController: NavController?, error: SyncedTabsView.ErrorType, @StringRes stringResId: Int Loading app/src/test/java/org/mozilla/fenix/sync/SyncedTabsLayoutTest.kt +50 −1 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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( Loading @@ -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) } } Loading
app/src/main/java/org/mozilla/fenix/sync/SyncedTabsLayout.kt +3 −3 Original line number Diff line number Diff line Loading @@ -84,7 +84,7 @@ class SyncedTabsLayout @JvmOverloads constructor( companion object { private fun pullToRefreshEnableState(error: SyncedTabsView.ErrorType) = when (error) { internal fun pullToRefreshEnableState(error: SyncedTabsView.ErrorType) = when (error) { // Disable "pull-to-refresh" when we clearly can't sync tabs, and user needs to take an // action within the app. SyncedTabsView.ErrorType.SYNC_UNAVAILABLE, Loading @@ -97,7 +97,7 @@ class SyncedTabsLayout @JvmOverloads constructor( SyncedTabsView.ErrorType.NO_TABS_AVAILABLE -> true } private fun stringResourceForError(error: SyncedTabsView.ErrorType) = when (error) { internal fun stringResourceForError(error: SyncedTabsView.ErrorType) = when (error) { SyncedTabsView.ErrorType.MULTIPLE_DEVICES_UNAVAILABLE -> R.string.synced_tabs_connect_another_device SyncedTabsView.ErrorType.SYNC_ENGINE_UNAVAILABLE -> R.string.synced_tabs_enable_tab_syncing SyncedTabsView.ErrorType.SYNC_UNAVAILABLE -> R.string.synced_tabs_sign_in_message Loading @@ -105,7 +105,7 @@ class SyncedTabsLayout @JvmOverloads constructor( SyncedTabsView.ErrorType.NO_TABS_AVAILABLE -> R.string.synced_tabs_no_tabs } private fun getErrorItem( internal fun getErrorItem( navController: NavController?, error: SyncedTabsView.ErrorType, @StringRes stringResId: Int Loading
app/src/test/java/org/mozilla/fenix/sync/SyncedTabsLayoutTest.kt +50 −1 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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( Loading @@ -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) } }