2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-19 09:25:34 +00:00
This commit is contained in:
Mihai Adrian Carare 2021-06-17 13:57:50 +03:00 committed by GitHub
parent 3eb90af822
commit f20c7ed527
2 changed files with 65 additions and 3 deletions

View File

@ -271,6 +271,10 @@ class TabsTrayFragment : AppCompatDialogFragment() {
super.onConfigurationChanged(newConfig)
trayBehaviorManager.updateDependingOnOrientation(newConfig.orientation)
if (requireContext().settings().gridTabView) {
tabsTray.adapter?.notifyDataSetChanged()
}
}
@VisibleForTesting
@ -287,9 +291,11 @@ class TabsTrayFragment : AppCompatDialogFragment() {
getString(R.string.snackbar_deleted_undo),
{
requireComponents.useCases.tabsUseCases.undo.invoke()
tabLayoutMediator.withFeature { it.selectTabAtPosition(
if (isPrivate) Page.PrivateTabs.ordinal else Page.NormalTabs.ordinal
) }
tabLayoutMediator.withFeature {
it.selectTabAtPosition(
if (isPrivate) Page.PrivateTabs.ordinal else Page.NormalTabs.ordinal
)
}
},
operation = { },
elevation = ELEVATION,

View File

@ -49,6 +49,7 @@ import org.mozilla.fenix.components.metrics.Event
import org.mozilla.fenix.components.metrics.MetricController
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.navigateBlockingForAsyncNavGraph
import org.mozilla.fenix.ext.settings
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
import org.mozilla.fenix.home.HomeScreenViewModel
import org.mozilla.fenix.tabstray.browser.BrowserTrayInteractor
@ -354,6 +355,7 @@ class TabsTrayFragmentTest {
val trayBehaviorManager: TabSheetBehaviorManager = mockk(relaxed = true)
fragment.trayBehaviorManager = trayBehaviorManager
val newConfiguration = Configuration()
every { context.settings().gridTabView } returns false
fragment.onConfigurationChanged(newConfiguration)
@ -370,4 +372,58 @@ class TabsTrayFragmentTest {
Assert.assertFalse(behavior.skipCollapsed)
assert(behavior.halfExpandedRatio <= 0.001f)
}
@Test
fun `GIVEN a grid TabView WHEN onConfigurationChanged is called THEN the adapter structure is updated`() {
val tray: ViewPager2 = mockk(relaxed = true)
val store: TabsTrayStore = mockk()
val trayInteractor: TabsTrayInteractor = mockk()
val browserInteractor: BrowserTrayInteractor = mockk()
val navigationInteractor: NavigationInteractor = mockk()
val browserStore: BrowserStore = mockk()
every { fragment.tabsTray } returns tray
every { context.components.core.store } returns browserStore
every { context.settings().gridTabView } returns true
fragment.setupPager(
context, store, trayInteractor, browserInteractor, navigationInteractor
)
val trayBehaviorManager: TabSheetBehaviorManager = mockk(relaxed = true)
fragment.trayBehaviorManager = trayBehaviorManager
val newConfiguration = Configuration()
fragment.onConfigurationChanged(newConfiguration)
verify { tray.adapter?.notifyDataSetChanged() }
}
@Test
fun `GIVEN a list TabView WHEN onConfigurationChanged is called THEN the adapter structure is NOT updated`() {
val tray: ViewPager2 = mockk(relaxed = true)
val store: TabsTrayStore = mockk()
val trayInteractor: TabsTrayInteractor = mockk()
val browserInteractor: BrowserTrayInteractor = mockk()
val navigationInteractor: NavigationInteractor = mockk()
val browserStore: BrowserStore = mockk()
every { fragment.tabsTray } returns tray
every { context.components.core.store } returns browserStore
every { context.settings().gridTabView } returns false
fragment.setupPager(
context, store, trayInteractor, browserInteractor, navigationInteractor
)
val trayBehaviorManager: TabSheetBehaviorManager = mockk(relaxed = true)
fragment.trayBehaviorManager = trayBehaviorManager
val newConfiguration = Configuration()
fragment.onConfigurationChanged(newConfiguration)
verify(exactly = 0) { tray.adapter?.notifyDataSetChanged() }
}
}