mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/19813: Invalidate tab tray adapter structure on screen rotation. (https://github.com/mozilla-mobile/fenix/pull/20044)
This commit is contained in:
parent
3eb90af822
commit
f20c7ed527
@ -271,6 +271,10 @@ class TabsTrayFragment : AppCompatDialogFragment() {
|
|||||||
super.onConfigurationChanged(newConfig)
|
super.onConfigurationChanged(newConfig)
|
||||||
|
|
||||||
trayBehaviorManager.updateDependingOnOrientation(newConfig.orientation)
|
trayBehaviorManager.updateDependingOnOrientation(newConfig.orientation)
|
||||||
|
|
||||||
|
if (requireContext().settings().gridTabView) {
|
||||||
|
tabsTray.adapter?.notifyDataSetChanged()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
@ -287,9 +291,11 @@ class TabsTrayFragment : AppCompatDialogFragment() {
|
|||||||
getString(R.string.snackbar_deleted_undo),
|
getString(R.string.snackbar_deleted_undo),
|
||||||
{
|
{
|
||||||
requireComponents.useCases.tabsUseCases.undo.invoke()
|
requireComponents.useCases.tabsUseCases.undo.invoke()
|
||||||
tabLayoutMediator.withFeature { it.selectTabAtPosition(
|
tabLayoutMediator.withFeature {
|
||||||
if (isPrivate) Page.PrivateTabs.ordinal else Page.NormalTabs.ordinal
|
it.selectTabAtPosition(
|
||||||
) }
|
if (isPrivate) Page.PrivateTabs.ordinal else Page.NormalTabs.ordinal
|
||||||
|
)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
operation = { },
|
operation = { },
|
||||||
elevation = ELEVATION,
|
elevation = ELEVATION,
|
||||||
|
@ -49,6 +49,7 @@ import org.mozilla.fenix.components.metrics.Event
|
|||||||
import org.mozilla.fenix.components.metrics.MetricController
|
import org.mozilla.fenix.components.metrics.MetricController
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.ext.navigateBlockingForAsyncNavGraph
|
import org.mozilla.fenix.ext.navigateBlockingForAsyncNavGraph
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
import org.mozilla.fenix.helpers.FenixRobolectricTestRunner
|
||||||
import org.mozilla.fenix.home.HomeScreenViewModel
|
import org.mozilla.fenix.home.HomeScreenViewModel
|
||||||
import org.mozilla.fenix.tabstray.browser.BrowserTrayInteractor
|
import org.mozilla.fenix.tabstray.browser.BrowserTrayInteractor
|
||||||
@ -354,6 +355,7 @@ class TabsTrayFragmentTest {
|
|||||||
val trayBehaviorManager: TabSheetBehaviorManager = mockk(relaxed = true)
|
val trayBehaviorManager: TabSheetBehaviorManager = mockk(relaxed = true)
|
||||||
fragment.trayBehaviorManager = trayBehaviorManager
|
fragment.trayBehaviorManager = trayBehaviorManager
|
||||||
val newConfiguration = Configuration()
|
val newConfiguration = Configuration()
|
||||||
|
every { context.settings().gridTabView } returns false
|
||||||
|
|
||||||
fragment.onConfigurationChanged(newConfiguration)
|
fragment.onConfigurationChanged(newConfiguration)
|
||||||
|
|
||||||
@ -370,4 +372,58 @@ class TabsTrayFragmentTest {
|
|||||||
Assert.assertFalse(behavior.skipCollapsed)
|
Assert.assertFalse(behavior.skipCollapsed)
|
||||||
assert(behavior.halfExpandedRatio <= 0.001f)
|
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() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user