2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00
This commit is contained in:
Roger Yang 2021-05-03 17:27:19 -04:00 committed by GitHub
parent 77a0d7df2b
commit 0884711ab1
13 changed files with 126 additions and 64 deletions

View File

@ -223,8 +223,7 @@ class BookmarksTest {
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!) IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
}.openThreeDotMenu(defaultWebPage.url) { }.openThreeDotMenu(defaultWebPage.url) {
}.clickOpenInNewTab { }.clickOpenInNewTab {
verifyUrl(defaultWebPage.url.toString()) verifyTabTrayIsOpened()
}.openTabDrawer {
verifyNormalModeSelected() verifyNormalModeSelected()
} }
} }
@ -242,8 +241,7 @@ class BookmarksTest {
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!) IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
}.openThreeDotMenu(defaultWebPage.url) { }.openThreeDotMenu(defaultWebPage.url) {
}.clickOpenInPrivateTab { }.clickOpenInPrivateTab {
verifyUrl(defaultWebPage.url.toString()) verifyTabTrayIsOpened()
}.openTabDrawer {
verifyPrivateModeSelected() verifyPrivateModeSelected()
} }
} }

View File

@ -149,8 +149,7 @@ class HistoryTest {
IdlingRegistry.getInstance().register(historyListIdlingResource!!) IdlingRegistry.getInstance().register(historyListIdlingResource!!)
}.openThreeDotMenu { }.openThreeDotMenu {
}.clickOpenInNormalTab { }.clickOpenInNormalTab {
verifyUrl(firstWebPage.url.toString()) verifyTabTrayIsOpened()
}.openTabDrawer {
verifyNormalModeSelected() verifyNormalModeSelected()
} }
} }
@ -170,8 +169,7 @@ class HistoryTest {
IdlingRegistry.getInstance().register(historyListIdlingResource!!) IdlingRegistry.getInstance().register(historyListIdlingResource!!)
}.openThreeDotMenu { }.openThreeDotMenu {
}.clickOpenInPrivateTab { }.clickOpenInPrivateTab {
verifyUrl(firstWebPage.url.toString()) verifyTabTrayIsOpened()
}.openTabDrawer {
verifyPrivateModeSelected() verifyPrivateModeSelected()
} }
} }

View File

@ -80,6 +80,7 @@ class TabDrawerRobot {
fun verifySelectTabsButton() = assertSelectTabsButton() fun verifySelectTabsButton() = assertSelectTabsButton()
fun verifyTabTrayOverflowMenu(visibility: Boolean) = assertTabTrayOverflowButton(visibility) fun verifyTabTrayOverflowMenu(visibility: Boolean) = assertTabTrayOverflowButton(visibility)
fun verifyTabTrayIsOpened() = assertTabTrayDoesExist()
fun verifyTabTrayIsClosed() = assertTabTrayDoesNotExist() fun verifyTabTrayIsClosed() = assertTabTrayDoesNotExist()
fun verifyHalfExpandedRatio() = assertMinisculeHalfExpandedRatio() fun verifyHalfExpandedRatio() = assertMinisculeHalfExpandedRatio()
fun verifyBehaviorState(expectedState: Int) = assertBehaviorState(expectedState) fun verifyBehaviorState(expectedState: Int) = assertBehaviorState(expectedState)
@ -421,6 +422,11 @@ private fun assertTabTrayOverflowButton(visible: Boolean) =
onView(withId(R.id.tab_tray_overflow)) onView(withId(R.id.tab_tray_overflow))
.check(matches(withEffectiveVisibility(visibleOrGone(visible)))) .check(matches(withEffectiveVisibility(visibleOrGone(visible))))
private fun assertTabTrayDoesExist() {
onView(withId(R.id.tab_wrapper))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
}
private fun assertTabTrayDoesNotExist() { private fun assertTabTrayDoesNotExist() {
onView(withId(R.id.tab_wrapper)) onView(withId(R.id.tab_wrapper))
.check(doesNotExist()) .check(doesNotExist())

View File

@ -38,18 +38,18 @@ class ThreeDotMenuBookmarksRobot {
return BookmarksRobot.Transition() return BookmarksRobot.Transition()
} }
fun clickOpenInNewTab(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun clickOpenInNewTab(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
openInNewTabButton().click() openInNewTabButton().click()
BrowserRobot().interact() TabDrawerRobot().interact()
return BrowserRobot.Transition() return TabDrawerRobot.Transition()
} }
fun clickOpenInPrivateTab(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun clickOpenInPrivateTab(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
openInPrivateTabButton().click() openInPrivateTabButton().click()
BrowserRobot().interact() TabDrawerRobot().interact()
return BrowserRobot.Transition() return TabDrawerRobot.Transition()
} }
fun clickDelete(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition { fun clickDelete(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition {

View File

@ -41,16 +41,16 @@ class ThreeDotMenuHistoryItemRobot {
return LibrarySubMenusMultipleSelectionToolbarRobot.Transition() return LibrarySubMenusMultipleSelectionToolbarRobot.Transition()
} }
fun clickOpenInNormalTab(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun clickOpenInNormalTab(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
openInNewNormalTabButton().click() openInNewNormalTabButton().click()
BrowserRobot().interact() TabDrawerRobot().interact()
return BrowserRobot.Transition() return TabDrawerRobot.Transition()
} }
fun clickOpenInPrivateTab(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition { fun clickOpenInPrivateTab(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
openInNewPrivateTabButton().click() openInNewPrivateTabButton().click()
BrowserRobot().interact() TabDrawerRobot().interact()
return BrowserRobot.Transition() return TabDrawerRobot.Transition()
} }
fun clickDelete(interact: HistoryRobot.() -> Unit): HistoryRobot.Transition { fun clickDelete(interact: HistoryRobot.() -> Unit): HistoryRobot.Transition {

View File

@ -14,6 +14,7 @@ import kotlinx.coroutines.launch
import mozilla.appservices.places.BookmarkRoot import mozilla.appservices.places.BookmarkRoot
import mozilla.components.concept.engine.prompt.ShareData import mozilla.components.concept.engine.prompt.ShareData
import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.feature.tabs.TabsUseCases
import mozilla.components.service.fxa.sync.SyncReason import mozilla.components.service.fxa.sync.SyncReason
import org.mozilla.fenix.BrowserDirection import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.HomeActivity
@ -55,11 +56,13 @@ class DefaultBookmarkController(
private val scope: CoroutineScope, private val scope: CoroutineScope,
private val store: BookmarkFragmentStore, private val store: BookmarkFragmentStore,
private val sharedViewModel: BookmarksSharedViewModel, private val sharedViewModel: BookmarksSharedViewModel,
private val tabsUseCases: TabsUseCases?,
private val loadBookmarkNode: suspend (String) -> BookmarkNode?, private val loadBookmarkNode: suspend (String) -> BookmarkNode?,
private val showSnackbar: (String) -> Unit, private val showSnackbar: (String) -> Unit,
private val deleteBookmarkNodes: (Set<BookmarkNode>, Event) -> Unit, private val deleteBookmarkNodes: (Set<BookmarkNode>, Event) -> Unit,
private val deleteBookmarkFolder: (Set<BookmarkNode>) -> Unit, private val deleteBookmarkFolder: (Set<BookmarkNode>) -> Unit,
private val invokePendingDeletion: () -> Unit private val invokePendingDeletion: () -> Unit,
private val showTabTray: () -> Unit
) : BookmarkController { ) : BookmarkController {
private val resources: Resources = activity.resources private val resources: Resources = activity.resources
@ -70,7 +73,7 @@ class DefaultBookmarkController(
} }
override fun handleBookmarkTapped(item: BookmarkNode) { override fun handleBookmarkTapped(item: BookmarkNode) {
openInNewTab(item.url!!, true, BrowserDirection.FromBookmarks, activity.browsingModeManager.mode) openInNewTabAndShow(item.url!!, true, BrowserDirection.FromBookmarks, activity.browsingModeManager.mode)
} }
override fun handleBookmarkExpand(folder: BookmarkNode) { override fun handleBookmarkExpand(folder: BookmarkNode) {
@ -126,7 +129,8 @@ class DefaultBookmarkController(
} }
override fun handleOpeningBookmark(item: BookmarkNode, mode: BrowsingMode) { override fun handleOpeningBookmark(item: BookmarkNode, mode: BrowsingMode) {
openInNewTab(item.url!!, true, BrowserDirection.FromBookmarks, mode) openInNewTab(item.url!!, mode)
showTabTray()
} }
override fun handleBookmarkDeletion(nodes: Set<BookmarkNode>, eventType: Event) { override fun handleBookmarkDeletion(nodes: Set<BookmarkNode>, eventType: Event) {
@ -169,7 +173,7 @@ class DefaultBookmarkController(
} }
} }
private fun openInNewTab( private fun openInNewTabAndShow(
searchTermOrURL: String, searchTermOrURL: String,
newTab: Boolean, newTab: Boolean,
from: BrowserDirection, from: BrowserDirection,
@ -182,6 +186,18 @@ class DefaultBookmarkController(
} }
} }
private fun openInNewTab(
url: String,
mode: BrowsingMode
) {
invokePendingDeletion.invoke()
activity.browsingModeManager.mode = BrowsingMode.fromBoolean(mode == BrowsingMode.Private)
tabsUseCases?.let { tabsUseCases ->
val addTab = if (mode == BrowsingMode.Private) tabsUseCases.addPrivateTab else tabsUseCases.addTab
addTab.invoke(url)
}
}
private fun navigateToGivenDirection(directions: NavDirections) { private fun navigateToGivenDirection(directions: NavDirections) {
invokePendingDeletion.invoke() invokePendingDeletion.invoke()
navController.nav(R.id.bookmarkFragment, directions) navController.nav(R.id.bookmarkFragment, directions)

View File

@ -92,11 +92,13 @@ class BookmarkFragment : LibraryPageFragment<BookmarkNode>(), UserInteractionHan
scope = viewLifecycleOwner.lifecycleScope, scope = viewLifecycleOwner.lifecycleScope,
store = bookmarkStore, store = bookmarkStore,
sharedViewModel = sharedViewModel, sharedViewModel = sharedViewModel,
tabsUseCases = activity?.components?.useCases?.tabsUseCases,
loadBookmarkNode = ::loadBookmarkNode, loadBookmarkNode = ::loadBookmarkNode,
showSnackbar = ::showSnackBarWithText, showSnackbar = ::showSnackBarWithText,
deleteBookmarkNodes = ::deleteMulti, deleteBookmarkNodes = ::deleteMulti,
deleteBookmarkFolder = ::showRemoveFolderDialog, deleteBookmarkFolder = ::showRemoveFolderDialog,
invokePendingDeletion = ::invokePendingDeletion invokePendingDeletion = ::invokePendingDeletion,
showTabTray = ::showTabTray
), ),
metrics = metrics!! metrics = metrics!!
) )
@ -243,7 +245,7 @@ class BookmarkFragment : LibraryPageFragment<BookmarkNode>(), UserInteractionHan
private fun showTabTray() { private fun showTabTray() {
invokePendingDeletion() invokePendingDeletion()
navigateToBookmarkFragment(BookmarkFragmentDirections.actionGlobalTabTrayDialogFragment()) navigateToBookmarkFragment(BookmarkFragmentDirections.actionGlobalTabsTrayFragment())
} }
private fun navigateToBookmarkFragment(directions: NavDirections) { private fun navigateToBookmarkFragment(directions: NavDirections) {

View File

@ -21,7 +21,8 @@ import org.mozilla.fenix.ext.navigateBlockingForAsyncNavGraph
@Suppress("TooManyFunctions") @Suppress("TooManyFunctions")
interface HistoryController { interface HistoryController {
fun handleOpen(item: HistoryItem, mode: BrowsingMode? = null) fun handleOpen(item: HistoryItem)
fun handleOpenInNewTab(item: HistoryItem, mode: BrowsingMode)
fun handleSelect(item: HistoryItem) fun handleSelect(item: HistoryItem)
fun handleDeselect(item: HistoryItem) fun handleDeselect(item: HistoryItem)
fun handleBackPressed(): Boolean fun handleBackPressed(): Boolean
@ -42,15 +43,20 @@ class DefaultHistoryController(
private val snackbar: FenixSnackbar, private val snackbar: FenixSnackbar,
private val clipboardManager: ClipboardManager, private val clipboardManager: ClipboardManager,
private val scope: CoroutineScope, private val scope: CoroutineScope,
private val openToBrowser: (item: HistoryItem, mode: BrowsingMode?) -> Unit, private val openToBrowser: (item: HistoryItem) -> Unit,
private val openInNewTab: (item: HistoryItem, mode: BrowsingMode) -> Unit,
private val displayDeleteAll: () -> Unit, private val displayDeleteAll: () -> Unit,
private val invalidateOptionsMenu: () -> Unit, private val invalidateOptionsMenu: () -> Unit,
private val deleteHistoryItems: (Set<HistoryItem>) -> Unit, private val deleteHistoryItems: (Set<HistoryItem>) -> Unit,
private val syncHistory: suspend () -> Unit, private val syncHistory: suspend () -> Unit,
private val metrics: MetricController private val metrics: MetricController
) : HistoryController { ) : HistoryController {
override fun handleOpen(item: HistoryItem, mode: BrowsingMode?) { override fun handleOpen(item: HistoryItem) {
openToBrowser(item, mode) openToBrowser(item)
}
override fun handleOpenInNewTab(item: HistoryItem, mode: BrowsingMode) {
openInNewTab(item, mode)
} }
override fun handleSelect(item: HistoryItem) { override fun handleSelect(item: HistoryItem) {

View File

@ -80,22 +80,23 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
) )
} }
val historyController: HistoryController = DefaultHistoryController( val historyController: HistoryController = DefaultHistoryController(
historyStore, store = historyStore,
findNavController(), navController = findNavController(),
resources, resources = resources,
FenixSnackbar.make( snackbar = FenixSnackbar.make(
view = view, view = view,
duration = FenixSnackbar.LENGTH_LONG, duration = FenixSnackbar.LENGTH_LONG,
isDisplayedWithBrowserToolbar = false isDisplayedWithBrowserToolbar = false
), ),
activity?.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager, clipboardManager = activity?.getSystemService(CLIPBOARD_SERVICE) as ClipboardManager,
lifecycleScope, scope = lifecycleScope,
::openItem, openToBrowser = ::openItem,
::displayDeleteAllDialog, openInNewTab = ::openItemAndShowTray,
::invalidateOptionsMenu, displayDeleteAll = ::displayDeleteAllDialog,
::deleteHistoryItems, invalidateOptionsMenu = ::invalidateOptionsMenu,
::syncHistory, deleteHistoryItems = ::deleteHistoryItems,
requireComponents.analytics.metrics syncHistory = ::syncHistory,
metrics = requireComponents.analytics.metrics
) )
historyInteractor = HistoryInteractor( historyInteractor = HistoryInteractor(
historyController historyController
@ -216,7 +217,7 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
invokePendingDeletion() invokePendingDeletion()
findNavController().nav( findNavController().nav(
R.id.historyFragment, R.id.historyFragment,
HistoryFragmentDirections.actionGlobalTabTrayDialogFragment() HistoryFragmentDirections.actionGlobalTabsTrayFragment()
) )
} }
@ -247,14 +248,8 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
_historyView = null _historyView = null
} }
private fun openItem(item: HistoryItem, mode: BrowsingMode? = null) { private fun openItem(item: HistoryItem) {
when (mode?.isPrivate) { requireComponents.analytics.metrics.track(Event.HistoryItemOpened)
true -> requireComponents.analytics.metrics.track(Event.HistoryOpenedInPrivateTab)
false -> requireComponents.analytics.metrics.track(Event.HistoryOpenedInNewTab)
null -> requireComponents.analytics.metrics.track(Event.HistoryItemOpened)
}
mode?.let { (activity as HomeActivity).browsingModeManager.mode = it }
(activity as HomeActivity).openToBrowserAndLoad( (activity as HomeActivity).openToBrowserAndLoad(
searchTermOrURL = item.url, searchTermOrURL = item.url,
@ -263,6 +258,22 @@ class HistoryFragment : LibraryPageFragment<HistoryItem>(), UserInteractionHandl
) )
} }
private fun openItemAndShowTray(item: HistoryItem, mode: BrowsingMode) {
when (mode.isPrivate) {
true -> requireComponents.analytics.metrics.track(Event.HistoryOpenedInPrivateTab)
false -> requireComponents.analytics.metrics.track(Event.HistoryOpenedInNewTab)
}
val homeActivity = activity as HomeActivity
homeActivity.browsingModeManager.mode = mode
homeActivity.components.useCases.tabsUseCases.let { tabsUseCases ->
val addTab = if (mode == BrowsingMode.Private) tabsUseCases.addPrivateTab else tabsUseCases.addTab
addTab.invoke(item.url)
}
showTabTray()
}
private fun displayDeleteAllDialog() { private fun displayDeleteAllDialog() {
activity?.let { activity -> activity?.let { activity ->
AlertDialog.Builder(activity).apply { AlertDialog.Builder(activity).apply {

View File

@ -43,11 +43,11 @@ class HistoryInteractor(
} }
override fun onOpenInNormalTab(item: HistoryItem) { override fun onOpenInNormalTab(item: HistoryItem) {
historyController.handleOpen(item, BrowsingMode.Normal) historyController.handleOpenInNewTab(item, BrowsingMode.Normal)
} }
override fun onOpenInPrivateTab(item: HistoryItem) { override fun onOpenInPrivateTab(item: HistoryItem) {
historyController.handleOpen(item, BrowsingMode.Private) historyController.handleOpenInNewTab(item, BrowsingMode.Private)
} }
override fun onDeleteAll() { override fun onDeleteAll() {

View File

@ -27,6 +27,7 @@ import kotlinx.coroutines.test.TestCoroutineScope
import mozilla.appservices.places.BookmarkRoot import mozilla.appservices.places.BookmarkRoot
import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNode
import mozilla.components.concept.storage.BookmarkNodeType import mozilla.components.concept.storage.BookmarkNodeType
import mozilla.components.feature.tabs.TabsUseCases
import org.junit.After import org.junit.After
import org.junit.Assert.assertEquals import org.junit.Assert.assertEquals
import org.junit.Before import org.junit.Before
@ -54,14 +55,18 @@ class BookmarkControllerTest {
private val clipboardManager: ClipboardManager = mockk(relaxUnitFun = true) private val clipboardManager: ClipboardManager = mockk(relaxUnitFun = true)
private val navController: NavController = mockk(relaxed = true) private val navController: NavController = mockk(relaxed = true)
private val sharedViewModel: BookmarksSharedViewModel = mockk() private val sharedViewModel: BookmarksSharedViewModel = mockk()
private val tabsUseCases: TabsUseCases = mockk()
private val loadBookmarkNode: suspend (String) -> BookmarkNode? = mockk(relaxed = true) private val loadBookmarkNode: suspend (String) -> BookmarkNode? = mockk(relaxed = true)
private val showSnackbar: (String) -> Unit = mockk(relaxed = true) private val showSnackbar: (String) -> Unit = mockk(relaxed = true)
private val deleteBookmarkNodes: (Set<BookmarkNode>, Event) -> Unit = mockk(relaxed = true) private val deleteBookmarkNodes: (Set<BookmarkNode>, Event) -> Unit = mockk(relaxed = true)
private val deleteBookmarkFolder: (Set<BookmarkNode>) -> Unit = mockk(relaxed = true) private val deleteBookmarkFolder: (Set<BookmarkNode>) -> Unit = mockk(relaxed = true)
private val invokePendingDeletion: () -> Unit = mockk(relaxed = true) private val invokePendingDeletion: () -> Unit = mockk(relaxed = true)
private val showTabTray: () -> Unit = mockk(relaxed = true)
private val homeActivity: HomeActivity = mockk(relaxed = true) private val homeActivity: HomeActivity = mockk(relaxed = true)
private val services: Services = mockk(relaxed = true) private val services: Services = mockk(relaxed = true)
private val addNewTabUseCase: TabsUseCases.AddNewTabUseCase = mockk(relaxed = true)
private val addNewPrivateTabUseCase: TabsUseCases.AddNewPrivateTabUseCase = mockk(relaxed = true)
private val item = private val item =
BookmarkNode(BookmarkNodeType.ITEM, "456", "123", 0, "Mozilla", "http://mozilla.org", null) BookmarkNode(BookmarkNodeType.ITEM, "456", "123", 0, "Mozilla", "http://mozilla.org", null)
@ -100,6 +105,8 @@ class BookmarkControllerTest {
} }
every { bookmarkStore.dispatch(any()) } returns mockk() every { bookmarkStore.dispatch(any()) } returns mockk()
every { sharedViewModel.selectedFolder = any() } just runs every { sharedViewModel.selectedFolder = any() } just runs
every { tabsUseCases.addTab } returns addNewTabUseCase
every { tabsUseCases.addPrivateTab } returns addNewPrivateTabUseCase
controller = DefaultBookmarkController( controller = DefaultBookmarkController(
activity = homeActivity, activity = homeActivity,
@ -108,11 +115,13 @@ class BookmarkControllerTest {
scope = scope, scope = scope,
store = bookmarkStore, store = bookmarkStore,
sharedViewModel = sharedViewModel, sharedViewModel = sharedViewModel,
tabsUseCases = tabsUseCases,
loadBookmarkNode = loadBookmarkNode, loadBookmarkNode = loadBookmarkNode,
showSnackbar = showSnackbar, showSnackbar = showSnackbar,
deleteBookmarkNodes = deleteBookmarkNodes, deleteBookmarkNodes = deleteBookmarkNodes,
deleteBookmarkFolder = deleteBookmarkFolder, deleteBookmarkFolder = deleteBookmarkFolder,
invokePendingDeletion = invokePendingDeletion invokePendingDeletion = invokePendingDeletion,
showTabTray = showTabTray
) )
} }
@ -267,6 +276,16 @@ class BookmarkControllerTest {
} }
} }
@Test
fun `handleBookmarkTapped should open the bookmark`() {
controller.handleBookmarkTapped(item)
verifyOrder {
invokePendingDeletion.invoke()
homeActivity.openToBrowserAndLoad(item.url!!, true, BrowserDirection.FromBookmarks)
}
}
@Test @Test
fun `handleOpeningBookmark should open the bookmark a new 'Normal' tab`() { fun `handleOpeningBookmark should open the bookmark a new 'Normal' tab`() {
controller.handleOpeningBookmark(item, BrowsingMode.Normal) controller.handleOpeningBookmark(item, BrowsingMode.Normal)
@ -274,7 +293,9 @@ class BookmarkControllerTest {
verifyOrder { verifyOrder {
invokePendingDeletion.invoke() invokePendingDeletion.invoke()
homeActivity.browsingModeManager.mode = BrowsingMode.Normal homeActivity.browsingModeManager.mode = BrowsingMode.Normal
homeActivity.openToBrowserAndLoad(item.url!!, true, BrowserDirection.FromBookmarks) tabsUseCases.addTab
addNewTabUseCase.invoke(item.url!!)
showTabTray
} }
} }
@ -285,7 +306,9 @@ class BookmarkControllerTest {
verifyOrder { verifyOrder {
invokePendingDeletion.invoke() invokePendingDeletion.invoke()
homeActivity.browsingModeManager.mode = BrowsingMode.Private homeActivity.browsingModeManager.mode = BrowsingMode.Private
homeActivity.openToBrowserAndLoad(item.url!!, true, BrowserDirection.FromBookmarks) tabsUseCases.addPrivateTab
addNewPrivateTabUseCase.invoke(item.url!!)
showTabTray
} }
} }

View File

@ -41,7 +41,8 @@ class HistoryControllerTest {
private val resources: Resources = mockk(relaxed = true) private val resources: Resources = mockk(relaxed = true)
private val snackbar: FenixSnackbar = mockk(relaxed = true) private val snackbar: FenixSnackbar = mockk(relaxed = true)
private val clipboardManager: ClipboardManager = mockk(relaxed = true) private val clipboardManager: ClipboardManager = mockk(relaxed = true)
private val openInBrowser: (HistoryItem, BrowsingMode?) -> Unit = mockk(relaxed = true) private val openInBrowser: (HistoryItem) -> Unit = mockk(relaxed = true)
private val openAndShowTray: (HistoryItem, BrowsingMode) -> Unit = mockk(relaxed = true)
private val displayDeleteAll: () -> Unit = mockk(relaxed = true) private val displayDeleteAll: () -> Unit = mockk(relaxed = true)
private val invalidateOptionsMenu: () -> Unit = mockk(relaxed = true) private val invalidateOptionsMenu: () -> Unit = mockk(relaxed = true)
private val deleteHistoryItems: (Set<HistoryItem>) -> Unit = mockk(relaxed = true) private val deleteHistoryItems: (Set<HistoryItem>) -> Unit = mockk(relaxed = true)
@ -55,6 +56,7 @@ class HistoryControllerTest {
clipboardManager, clipboardManager,
scope, scope,
openInBrowser, openInBrowser,
openAndShowTray,
displayDeleteAll, displayDeleteAll,
invalidateOptionsMenu, invalidateOptionsMenu,
deleteHistoryItems, deleteHistoryItems,
@ -77,25 +79,25 @@ class HistoryControllerTest {
controller.handleOpen(historyItem) controller.handleOpen(historyItem)
verify { verify {
openInBrowser(historyItem, null) openInBrowser(historyItem)
} }
} }
@Test @Test
fun onOpenItemInNormalMode() { fun onOpenItemInNormalMode() {
controller.handleOpen(historyItem, BrowsingMode.Normal) controller.handleOpenInNewTab(historyItem, BrowsingMode.Normal)
verify { verify {
openInBrowser(historyItem, BrowsingMode.Normal) openAndShowTray(historyItem, BrowsingMode.Normal)
} }
} }
@Test @Test
fun onOpenItemInPrivateMode() { fun onOpenItemInPrivateMode() {
controller.handleOpen(historyItem, BrowsingMode.Private) controller.handleOpenInNewTab(historyItem, BrowsingMode.Private)
verify { verify {
openInBrowser(historyItem, BrowsingMode.Private) openAndShowTray(historyItem, BrowsingMode.Private)
} }
} }

View File

@ -89,7 +89,7 @@ class HistoryInteractorTest {
interactor.onOpenInNormalTab(historyItem) interactor.onOpenInNormalTab(historyItem)
verifyAll { verifyAll {
controller.handleOpen(historyItem, BrowsingMode.Normal) controller.handleOpenInNewTab(historyItem, BrowsingMode.Normal)
} }
} }
@ -98,7 +98,7 @@ class HistoryInteractorTest {
interactor.onOpenInPrivateTab(historyItem) interactor.onOpenInPrivateTab(historyItem)
verifyAll { verifyAll {
controller.handleOpen(historyItem, BrowsingMode.Private) controller.handleOpenInNewTab(historyItem, BrowsingMode.Private)
} }
} }