GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Commit a1541a33 authored by Christian Sadilek's avatar Christian Sadilek Committed by Sebastian Kaspari
Browse files

Closes #17889: Wrong tab selected/reloaded when restored from collection

parent 8ea79cd8
......@@ -215,10 +215,8 @@ class DefaultSessionControlController(
tab,
onTabRestored = {
activity.openToBrowser(BrowserDirection.FromHome)
store.state.selectedTabId?.let {
selectTabUseCase.invoke(it)
reloadUrlUseCase.invoke(it)
}
selectTabUseCase.invoke(it)
reloadUrlUseCase.invoke(it)
},
onFailure = {
activity.openToBrowserAndLoad(
......
......@@ -182,8 +182,8 @@ class DefaultSessionControlControllerTest {
}
@Test
fun `handleCollectionOpenTabClicked onTabRestored`() {
val restoredTab = RecoverableTab(
fun `handleCollectionOpenTabClicked with existing selected tab`() {
val recoverableTab = RecoverableTab(
id = "test",
parentId = null,
url = "https://www.mozilla.org",
......@@ -196,13 +196,42 @@ class DefaultSessionControlControllerTest {
)
val tab = mockk<ComponentTab> {
every { restore(activity, engine, restoreSessionId = false) } returns restoredTab
every { restore(activity, engine, restoreSessionId = false) } returns recoverableTab
}
store.dispatch(TabListAction.AddTabAction(
createTab(id = restoredTab.id, url = restoredTab.url))
).joinBlocking()
store.dispatch(TabListAction.SelectTabAction(restoredTab.id)).joinBlocking()
val restoredTab = createTab(id = recoverableTab.id, url = recoverableTab.url)
val otherTab = createTab(id = "otherTab", url = "https://mozilla.org")
store.dispatch(TabListAction.AddTabAction(otherTab)).joinBlocking()
store.dispatch(TabListAction.SelectTabAction(otherTab.id)).joinBlocking()
store.dispatch(TabListAction.AddTabAction(restoredTab)).joinBlocking()
controller.handleCollectionOpenTabClicked(tab)
verify { metrics.track(Event.CollectionTabRestored) }
verify { activity.openToBrowser(BrowserDirection.FromHome) }
verify { selectTabUseCase.selectTab.invoke(restoredTab.id) }
verify { reloadUrlUseCase.reload.invoke(restoredTab.id) }
}
@Test
fun `handleCollectionOpenTabClicked without existing selected tab`() {
val recoverableTab = RecoverableTab(
id = "test",
parentId = null,
url = "https://www.mozilla.org",
title = "Mozilla",
state = null,
contextId = null,
readerState = ReaderState(),
lastAccess = 0,
private = false
)
val tab = mockk<ComponentTab> {
every { restore(activity, engine, restoreSessionId = false) } returns recoverableTab
}
val restoredTab = createTab(id = recoverableTab.id, url = recoverableTab.url)
store.dispatch(TabListAction.AddTabAction(restoredTab)).joinBlocking()
controller.handleCollectionOpenTabClicked(tab)
verify { metrics.track(Event.CollectionTabRestored) }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment