mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] For FNXV2-17067: always show home in background behind search dialog (https://github.com/mozilla-mobile/fenix/pull/20573)
* Navigate to home on toolbar click. Handle back press from search dialog Update tests to show home behind search dialog. Remove unused test. Jump back in show all button is clickable behind search dialog Recently saved bookmarks show all button is clickable behind search dialog * Add feature flag * Past explorations show all button is clickable behind search dialog Handle keyboard in controllers instead of viewholders. Update tests. Allow collections to be visible behind search dialog Dismiss keyboard and search dialog with navigateUp instead of just dismissing the keyboard Verify navigateUp in tests Adding ignore for flaky UI test Only resize home behind search dialog Add ignore for collection intermittent test Cleanup
This commit is contained in:
parent
33b08b6b83
commit
7273536742
@ -9,6 +9,7 @@ import androidx.test.uiautomator.UiDevice
|
|||||||
import okhttp3.mockwebserver.MockWebServer
|
import okhttp3.mockwebserver.MockWebServer
|
||||||
import org.junit.After
|
import org.junit.After
|
||||||
import org.junit.Before
|
import org.junit.Before
|
||||||
|
import org.junit.Ignore
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||||
@ -165,6 +166,7 @@ class CollectionTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@Ignore("To be fixed in https://github.com/mozilla-mobile/fenix/issues/20702")
|
||||||
fun swipeToRemoveTabFromCollectionTest() {
|
fun swipeToRemoveTabFromCollectionTest() {
|
||||||
val firstWebPage = getGenericAsset(mockWebServer, 1)
|
val firstWebPage = getGenericAsset(mockWebServer, 1)
|
||||||
val secondWebPage = getGenericAsset(mockWebServer, 2)
|
val secondWebPage = getGenericAsset(mockWebServer, 2)
|
||||||
|
@ -575,6 +575,7 @@ class SmokeTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
// Saves a login, then changes it and verifies the update
|
// Saves a login, then changes it and verifies the update
|
||||||
|
@Ignore("To be fixed in https://github.com/mozilla-mobile/fenix/issues/20702")
|
||||||
fun updateSavedLoginTest() {
|
fun updateSavedLoginTest() {
|
||||||
val saveLoginTest =
|
val saveLoginTest =
|
||||||
TestAssetHelper.getSaveLoginAsset(mockWebServer)
|
TestAssetHelper.getSaveLoginAsset(mockWebServer)
|
||||||
@ -601,7 +602,7 @@ class SmokeTest {
|
|||||||
verifySavedLoginFromPrompt()
|
verifySavedLoginFromPrompt()
|
||||||
viewSavedLoginDetails()
|
viewSavedLoginDetails()
|
||||||
revealPassword()
|
revealPassword()
|
||||||
verifyPasswordSaved("test")
|
verifyPasswordSaved("test") // failing here locally
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,4 +66,9 @@ object FeatureFlags {
|
|||||||
* type need to present.
|
* type need to present.
|
||||||
*/
|
*/
|
||||||
val androidAutofill = Config.channel.isNightlyOrDebug || Config.channel.isBeta
|
val androidAutofill = Config.channel.isNightlyOrDebug || Config.channel.isBeta
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enables showing the home screen behind the search dialog
|
||||||
|
*/
|
||||||
|
val showHomeBehindSearch = Config.channel.isNightlyOrDebug
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ import mozilla.components.concept.engine.EngineView
|
|||||||
import mozilla.components.feature.tabs.TabsUseCases
|
import mozilla.components.feature.tabs.TabsUseCases
|
||||||
import mozilla.components.support.ktx.kotlin.isUrl
|
import mozilla.components.support.ktx.kotlin.isUrl
|
||||||
import mozilla.components.ui.tabcounter.TabCounterMenu
|
import mozilla.components.ui.tabcounter.TabCounterMenu
|
||||||
|
import org.mozilla.fenix.FeatureFlags
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.browser.BrowserAnimator.Companion.getToolbarNavOptions
|
import org.mozilla.fenix.browser.BrowserAnimator.Companion.getToolbarNavOptions
|
||||||
@ -91,8 +92,12 @@ class DefaultBrowserToolbarController(
|
|||||||
|
|
||||||
override fun handleToolbarClick() {
|
override fun handleToolbarClick() {
|
||||||
metrics.track(Event.SearchBarTapped(Event.SearchBarTapped.Source.BROWSER))
|
metrics.track(Event.SearchBarTapped(Event.SearchBarTapped.Source.BROWSER))
|
||||||
navController.nav(
|
if (FeatureFlags.showHomeBehindSearch) {
|
||||||
R.id.browserFragment,
|
navController.navigate(
|
||||||
|
BrowserFragmentDirections.actionGlobalHome()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
navController.navigate(
|
||||||
BrowserFragmentDirections.actionGlobalSearchDialog(
|
BrowserFragmentDirections.actionGlobalSearchDialog(
|
||||||
currentSession?.id
|
currentSession?.id
|
||||||
),
|
),
|
||||||
|
@ -4,13 +4,14 @@
|
|||||||
|
|
||||||
package org.mozilla.fenix.historymetadata.controller
|
package org.mozilla.fenix.historymetadata.controller
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting
|
||||||
|
import androidx.annotation.VisibleForTesting.PRIVATE
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import mozilla.components.concept.storage.HistoryMetadataKey
|
import mozilla.components.concept.storage.HistoryMetadataKey
|
||||||
import mozilla.components.feature.tabs.TabsUseCases
|
import mozilla.components.feature.tabs.TabsUseCases
|
||||||
import org.mozilla.fenix.BrowserDirection
|
import org.mozilla.fenix.BrowserDirection
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.nav
|
|
||||||
import org.mozilla.fenix.historymetadata.HistoryMetadataGroup
|
import org.mozilla.fenix.historymetadata.HistoryMetadataGroup
|
||||||
import org.mozilla.fenix.historymetadata.interactor.HistoryMetadataInteractor
|
import org.mozilla.fenix.historymetadata.interactor.HistoryMetadataInteractor
|
||||||
import org.mozilla.fenix.home.HomeFragmentAction
|
import org.mozilla.fenix.home.HomeFragmentAction
|
||||||
@ -67,7 +68,10 @@ class DefaultHistoryMetadataController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun handleHistoryShowAllClicked() {
|
override fun handleHistoryShowAllClicked() {
|
||||||
navController.nav(R.id.homeFragment, HomeFragmentDirections.actionGlobalHistoryFragment())
|
dismissSearchDialogIfDisplayed()
|
||||||
|
navController.navigate(
|
||||||
|
HomeFragmentDirections.actionGlobalHistoryFragment()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleToggleHistoryMetadataGroupExpanded(historyMetadataGroup: HistoryMetadataGroup) {
|
override fun handleToggleHistoryMetadataGroupExpanded(historyMetadataGroup: HistoryMetadataGroup) {
|
||||||
@ -77,4 +81,11 @@ class DefaultHistoryMetadataController(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting(otherwise = PRIVATE)
|
||||||
|
fun dismissSearchDialogIfDisplayed() {
|
||||||
|
if (navController.currentDestination?.id == R.id.searchDialogFragment) {
|
||||||
|
navController.navigateUp()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,14 @@
|
|||||||
|
|
||||||
package org.mozilla.fenix.home.recentbookmarks.controller
|
package org.mozilla.fenix.home.recentbookmarks.controller
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting
|
||||||
|
import androidx.annotation.VisibleForTesting.PRIVATE
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import mozilla.appservices.places.BookmarkRoot
|
import mozilla.appservices.places.BookmarkRoot
|
||||||
import mozilla.components.concept.storage.BookmarkNode
|
import mozilla.components.concept.storage.BookmarkNode
|
||||||
import org.mozilla.fenix.BrowserDirection
|
import org.mozilla.fenix.BrowserDirection
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.nav
|
|
||||||
import org.mozilla.fenix.home.HomeFragmentDirections
|
import org.mozilla.fenix.home.HomeFragmentDirections
|
||||||
import org.mozilla.fenix.home.recentbookmarks.interactor.RecentBookmarksInteractor
|
import org.mozilla.fenix.home.recentbookmarks.interactor.RecentBookmarksInteractor
|
||||||
|
|
||||||
@ -40,6 +41,7 @@ class DefaultRecentBookmarksController(
|
|||||||
) : RecentBookmarksController {
|
) : RecentBookmarksController {
|
||||||
|
|
||||||
override fun handleBookmarkClicked(bookmark: BookmarkNode) {
|
override fun handleBookmarkClicked(bookmark: BookmarkNode) {
|
||||||
|
dismissSearchDialogIfDisplayed()
|
||||||
activity.openToBrowserAndLoad(
|
activity.openToBrowserAndLoad(
|
||||||
searchTermOrURL = bookmark.url!!,
|
searchTermOrURL = bookmark.url!!,
|
||||||
newTab = true,
|
newTab = true,
|
||||||
@ -48,7 +50,16 @@ class DefaultRecentBookmarksController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun handleShowAllBookmarksClicked() {
|
override fun handleShowAllBookmarksClicked() {
|
||||||
val directions = HomeFragmentDirections.actionGlobalBookmarkFragment(BookmarkRoot.Mobile.id)
|
dismissSearchDialogIfDisplayed()
|
||||||
navController.nav(R.id.homeFragment, directions)
|
navController.navigate(
|
||||||
|
HomeFragmentDirections.actionGlobalBookmarkFragment(BookmarkRoot.Mobile.id)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@VisibleForTesting(otherwise = PRIVATE)
|
||||||
|
fun dismissSearchDialogIfDisplayed() {
|
||||||
|
if (navController.currentDestination?.id == R.id.searchDialogFragment) {
|
||||||
|
navController.navigateUp()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
package org.mozilla.fenix.home.recenttabs.controller
|
package org.mozilla.fenix.home.recenttabs.controller
|
||||||
|
|
||||||
|
import androidx.annotation.VisibleForTesting
|
||||||
|
import androidx.annotation.VisibleForTesting.PRIVATE
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import mozilla.components.browser.state.store.BrowserStore
|
import mozilla.components.browser.state.store.BrowserStore
|
||||||
import mozilla.components.feature.tabs.TabsUseCases.SelectTabUseCase
|
import mozilla.components.feature.tabs.TabsUseCases.SelectTabUseCase
|
||||||
@ -11,7 +13,6 @@ import org.mozilla.fenix.R
|
|||||||
import org.mozilla.fenix.components.metrics.Event
|
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.inProgressMediaTab
|
import org.mozilla.fenix.ext.inProgressMediaTab
|
||||||
import org.mozilla.fenix.ext.nav
|
|
||||||
import org.mozilla.fenix.home.HomeFragmentDirections
|
import org.mozilla.fenix.home.HomeFragmentDirections
|
||||||
import org.mozilla.fenix.home.recenttabs.interactor.RecentTabInteractor
|
import org.mozilla.fenix.home.recenttabs.interactor.RecentTabInteractor
|
||||||
|
|
||||||
@ -45,7 +46,6 @@ class DefaultRecentTabsController(
|
|||||||
) : RecentTabController {
|
) : RecentTabController {
|
||||||
|
|
||||||
override fun handleRecentTabClicked(tabId: String) {
|
override fun handleRecentTabClicked(tabId: String) {
|
||||||
|
|
||||||
if (tabId == store.state.inProgressMediaTab?.id) {
|
if (tabId == store.state.inProgressMediaTab?.id) {
|
||||||
metrics.track(Event.OpenInProgressMediaTab)
|
metrics.track(Event.OpenInProgressMediaTab)
|
||||||
} else {
|
} else {
|
||||||
@ -57,10 +57,15 @@ class DefaultRecentTabsController(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun handleRecentTabShowAllClicked() {
|
override fun handleRecentTabShowAllClicked() {
|
||||||
|
dismissSearchDialogIfDisplayed()
|
||||||
metrics.track(Event.ShowAllRecentTabs)
|
metrics.track(Event.ShowAllRecentTabs)
|
||||||
navController.nav(
|
navController.navigate(HomeFragmentDirections.actionGlobalTabsTrayFragment())
|
||||||
R.id.homeFragment,
|
}
|
||||||
HomeFragmentDirections.actionGlobalTabsTrayFragment()
|
|
||||||
)
|
@VisibleForTesting(otherwise = PRIVATE)
|
||||||
|
fun dismissSearchDialogIfDisplayed() {
|
||||||
|
if (navController.currentDestination?.id == R.id.searchDialogFragment) {
|
||||||
|
navController.navigateUp()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,7 @@ import mozilla.components.support.ktx.android.view.hideKeyboard
|
|||||||
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged
|
import mozilla.components.support.ktx.kotlinx.coroutines.flow.ifChanged
|
||||||
import mozilla.components.ui.autocomplete.InlineAutocompleteEditText
|
import mozilla.components.ui.autocomplete.InlineAutocompleteEditText
|
||||||
import org.mozilla.fenix.BrowserDirection
|
import org.mozilla.fenix.BrowserDirection
|
||||||
|
import org.mozilla.fenix.FeatureFlags
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
import org.mozilla.fenix.components.metrics.Event
|
||||||
@ -86,10 +87,20 @@ class SearchDialogFragment : AppCompatDialogFragment(), UserInteractionHandler {
|
|||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
// https://github.com/mozilla-mobile/fenix/issues/14279
|
|
||||||
// To prevent GeckoView from resizing we're going to change the softInputMode to not adjust
|
if (FeatureFlags.showHomeBehindSearch) {
|
||||||
// the size of the window.
|
// This will need to be handled for the update to R. We need to resize here in order to
|
||||||
requireActivity().window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING)
|
// see the whole homescreen behind the search dialog.
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
requireActivity().window.setSoftInputMode(
|
||||||
|
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
// https://github.com/mozilla-mobile/fenix/issues/14279
|
||||||
|
// To prevent GeckoView from resizing we're going to change the softInputMode to not adjust
|
||||||
|
// the size of the window.
|
||||||
|
requireActivity().window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING)
|
||||||
|
}
|
||||||
// Refocus the toolbar editing and show keyboard if the QR fragment isn't showing
|
// Refocus the toolbar editing and show keyboard if the QR fragment isn't showing
|
||||||
if (childFragmentManager.findFragmentByTag(QR_FRAGMENT_TAG) == null) {
|
if (childFragmentManager.findFragmentByTag(QR_FRAGMENT_TAG) == null) {
|
||||||
toolbarView.view.edit.focus()
|
toolbarView.view.edit.focus()
|
||||||
@ -400,6 +411,14 @@ class SearchDialogFragment : AppCompatDialogFragment(), UserInteractionHandler {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
|
if (FeatureFlags.showHomeBehindSearch) {
|
||||||
|
val args by navArgs<SearchDialogFragmentArgs>()
|
||||||
|
args.sessionId?.let {
|
||||||
|
findNavController().navigate(
|
||||||
|
SearchDialogFragmentDirections.actionGlobalBrowser(null)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
view?.hideKeyboard()
|
view?.hideKeyboard()
|
||||||
dismissAllowingStateLoss()
|
dismissAllowingStateLoss()
|
||||||
true
|
true
|
||||||
|
@ -7,5 +7,6 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="56dp"
|
android:layout_height="56dp"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
|
android:layout_marginTop="40dp"
|
||||||
android:text="@string/collections_header"
|
android:text="@string/collections_header"
|
||||||
android:textAppearance="@style/HeaderTextStyle" />
|
android:textAppearance="@style/HeaderTextStyle" />
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:clipChildren="false"
|
android:clipChildren="false"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:layout_marginBottom="48dp"
|
android:layout_marginBottom="88dp"
|
||||||
android:padding="16dp"
|
android:padding="16dp"
|
||||||
android:scrollbars="none"
|
android:scrollbars="none"
|
||||||
android:transitionGroup="false"
|
android:transitionGroup="false"
|
||||||
|
@ -223,25 +223,19 @@ class DefaultBrowserToolbarControllerTest {
|
|||||||
val controller = createController()
|
val controller = createController()
|
||||||
controller.handleToolbarClick()
|
controller.handleToolbarClick()
|
||||||
|
|
||||||
val expected = BrowserFragmentDirections.actionGlobalSearchDialog(
|
val homeDirections = BrowserFragmentDirections.actionGlobalHome()
|
||||||
|
val searchDialogDirections = BrowserFragmentDirections.actionGlobalSearchDialog(
|
||||||
sessionId = "1"
|
sessionId = "1"
|
||||||
)
|
)
|
||||||
|
|
||||||
verify { metrics.track(Event.SearchBarTapped(Event.SearchBarTapped.Source.BROWSER)) }
|
verify {
|
||||||
verify { navController.navigate(expected, any<NavOptions>()) }
|
metrics.track(Event.SearchBarTapped(Event.SearchBarTapped.Source.BROWSER))
|
||||||
}
|
}
|
||||||
|
verify {
|
||||||
@Test
|
// shows the home screen "behind" the search dialog
|
||||||
fun handleToolbarClick_useNewSearchExperience() {
|
navController.navigate(homeDirections)
|
||||||
val controller = createController()
|
navController.navigate(searchDialogDirections, any<NavOptions>())
|
||||||
controller.handleToolbarClick()
|
}
|
||||||
|
|
||||||
val expected = BrowserFragmentDirections.actionGlobalSearchDialog(
|
|
||||||
sessionId = "1"
|
|
||||||
)
|
|
||||||
|
|
||||||
verify { metrics.track(Event.SearchBarTapped(Event.SearchBarTapped.Source.BROWSER)) }
|
|
||||||
verify { navController.navigate(expected, any<NavOptions>()) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
package org.mozilla.fenix.historymetadata.controller
|
package org.mozilla.fenix.historymetadata.controller
|
||||||
|
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
import io.mockk.spyk
|
import io.mockk.spyk
|
||||||
import io.mockk.verify
|
import io.mockk.verify
|
||||||
@ -22,7 +23,6 @@ import org.junit.Test
|
|||||||
import org.mozilla.fenix.BrowserDirection
|
import org.mozilla.fenix.BrowserDirection
|
||||||
import org.mozilla.fenix.HomeActivity
|
import org.mozilla.fenix.HomeActivity
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.ext.nav
|
|
||||||
import org.mozilla.fenix.historymetadata.HistoryMetadataGroup
|
import org.mozilla.fenix.historymetadata.HistoryMetadataGroup
|
||||||
import org.mozilla.fenix.home.HomeFragmentAction
|
import org.mozilla.fenix.home.HomeFragmentAction
|
||||||
import org.mozilla.fenix.home.HomeFragmentDirections
|
import org.mozilla.fenix.home.HomeFragmentDirections
|
||||||
@ -43,10 +43,14 @@ class HistoryMetadataControllerTest {
|
|||||||
private val selectOrAddUseCase: SelectOrAddUseCase = mockk(relaxed = true)
|
private val selectOrAddUseCase: SelectOrAddUseCase = mockk(relaxed = true)
|
||||||
private val navController = mockk<NavController>(relaxed = true)
|
private val navController = mockk<NavController>(relaxed = true)
|
||||||
|
|
||||||
private lateinit var controller: HistoryMetadataController
|
private lateinit var controller: DefaultHistoryMetadataController
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
|
every { navController.currentDestination } returns mockk {
|
||||||
|
every { id } returns R.id.homeFragment
|
||||||
|
}
|
||||||
|
|
||||||
controller = spyk(
|
controller = spyk(
|
||||||
DefaultHistoryMetadataController(
|
DefaultHistoryMetadataController(
|
||||||
activity = activity,
|
activity = activity,
|
||||||
@ -87,8 +91,8 @@ class HistoryMetadataControllerTest {
|
|||||||
controller.handleHistoryShowAllClicked()
|
controller.handleHistoryShowAllClicked()
|
||||||
|
|
||||||
verify {
|
verify {
|
||||||
navController.nav(
|
controller.dismissSearchDialogIfDisplayed()
|
||||||
R.id.homeFragment,
|
navController.navigate(
|
||||||
HomeFragmentDirections.actionGlobalHistoryFragment()
|
HomeFragmentDirections.actionGlobalHistoryFragment()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@
|
|||||||
package org.mozilla.fenix.home.recentbookmarks
|
package org.mozilla.fenix.home.recentbookmarks
|
||||||
|
|
||||||
import androidx.navigation.NavController
|
import androidx.navigation.NavController
|
||||||
import androidx.navigation.NavOptions
|
|
||||||
import io.mockk.Runs
|
import io.mockk.Runs
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.just
|
import io.mockk.just
|
||||||
@ -38,14 +37,13 @@ class DefaultRecentBookmarksControllerTest {
|
|||||||
|
|
||||||
private val activity: HomeActivity = mockk(relaxed = true)
|
private val activity: HomeActivity = mockk(relaxed = true)
|
||||||
private val navController: NavController = mockk(relaxUnitFun = true)
|
private val navController: NavController = mockk(relaxUnitFun = true)
|
||||||
|
|
||||||
private lateinit var controller: DefaultRecentBookmarksController
|
private lateinit var controller: DefaultRecentBookmarksController
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
every { activity.openToBrowserAndLoad(any(), any(), any()) } just Runs
|
every { activity.openToBrowserAndLoad(any(), any(), any()) } just Runs
|
||||||
every { navController.currentDestination } returns mockk {
|
every { navController.navigateUp() } returns true
|
||||||
every { id } returns R.id.homeFragment
|
|
||||||
}
|
|
||||||
|
|
||||||
controller = spyk(
|
controller = spyk(
|
||||||
DefaultRecentBookmarksController(
|
DefaultRecentBookmarksController(
|
||||||
@ -62,6 +60,10 @@ class DefaultRecentBookmarksControllerTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `WHEN a recently saved bookmark is clicked THEN the selected bookmark is opened`() {
|
fun `WHEN a recently saved bookmark is clicked THEN the selected bookmark is opened`() {
|
||||||
|
every { navController.currentDestination } returns mockk {
|
||||||
|
every { id } returns R.id.homeFragment
|
||||||
|
}
|
||||||
|
|
||||||
val bookmark = BookmarkNode(
|
val bookmark = BookmarkNode(
|
||||||
type = BookmarkNodeType.ITEM,
|
type = BookmarkNodeType.ITEM,
|
||||||
guid = "guid#${Math.random() * 1000}",
|
guid = "guid#${Math.random() * 1000}",
|
||||||
@ -76,19 +78,49 @@ class DefaultRecentBookmarksControllerTest {
|
|||||||
controller.handleBookmarkClicked(bookmark)
|
controller.handleBookmarkClicked(bookmark)
|
||||||
|
|
||||||
verify {
|
verify {
|
||||||
|
controller.dismissSearchDialogIfDisplayed()
|
||||||
activity.openToBrowserAndLoad(
|
activity.openToBrowserAndLoad(
|
||||||
searchTermOrURL = bookmark.url!!,
|
searchTermOrURL = bookmark.url!!,
|
||||||
newTab = true,
|
newTab = true,
|
||||||
from = BrowserDirection.FromHome
|
from = BrowserDirection.FromHome
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
verify(exactly = 0) {
|
||||||
|
navController.navigateUp()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `WHEN show all recently saved bookmark is clicked THEN the bookmarks root is opened`() {
|
fun `WHEN show all recently saved bookmark is clicked THEN the bookmarks root is opened`() {
|
||||||
|
every { navController.currentDestination } returns mockk {
|
||||||
|
every { id } returns R.id.homeFragment
|
||||||
|
}
|
||||||
|
|
||||||
controller.handleShowAllBookmarksClicked()
|
controller.handleShowAllBookmarksClicked()
|
||||||
|
|
||||||
val directions = HomeFragmentDirections.actionGlobalBookmarkFragment(BookmarkRoot.Mobile.id)
|
val directions = HomeFragmentDirections.actionGlobalBookmarkFragment(BookmarkRoot.Mobile.id)
|
||||||
verify { navController.navigate(directions, any<NavOptions>()) }
|
verify {
|
||||||
|
controller.dismissSearchDialogIfDisplayed()
|
||||||
|
navController.navigate(directions)
|
||||||
|
}
|
||||||
|
verify(exactly = 0) {
|
||||||
|
navController.navigateUp()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `WHEN show all is clicked from behind search dialog THEN open bookmarks root`() {
|
||||||
|
every { navController.currentDestination } returns mockk {
|
||||||
|
every { id } returns R.id.searchDialogFragment
|
||||||
|
}
|
||||||
|
|
||||||
|
controller.handleShowAllBookmarksClicked()
|
||||||
|
|
||||||
|
val directions = HomeFragmentDirections.actionGlobalBookmarkFragment(BookmarkRoot.Mobile.id)
|
||||||
|
verify {
|
||||||
|
controller.dismissSearchDialogIfDisplayed()
|
||||||
|
navController.navigateUp()
|
||||||
|
navController.navigate(directions)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,8 @@ class RecentTabControllerTest {
|
|||||||
private val metrics: MetricController = mockk(relaxed = true)
|
private val metrics: MetricController = mockk(relaxed = true)
|
||||||
|
|
||||||
private lateinit var store: BrowserStore
|
private lateinit var store: BrowserStore
|
||||||
private lateinit var controller: RecentTabController
|
|
||||||
|
private lateinit var controller: DefaultRecentTabsController
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setup() {
|
fun setup() {
|
||||||
@ -51,17 +52,18 @@ class RecentTabControllerTest {
|
|||||||
selectTabUseCase = selectTabUseCase.selectTab,
|
selectTabUseCase = selectTabUseCase.selectTab,
|
||||||
navController = navController,
|
navController = navController,
|
||||||
metrics = metrics,
|
metrics = metrics,
|
||||||
store = store
|
store = store,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
every { navController.navigateUp() } returns true
|
||||||
every { navController.currentDestination } returns mockk {
|
|
||||||
every { id } returns R.id.homeFragment
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun handleRecentTabClicked() {
|
fun handleRecentTabClicked() {
|
||||||
|
every { navController.currentDestination } returns mockk {
|
||||||
|
every { id } returns R.id.homeFragment
|
||||||
|
}
|
||||||
|
|
||||||
val tab = createTab(
|
val tab = createTab(
|
||||||
url = "https://mozilla.org",
|
url = "https://mozilla.org",
|
||||||
title = "Mozilla"
|
title = "Mozilla"
|
||||||
@ -79,13 +81,38 @@ class RecentTabControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun handleRecentTabShowAllClicked() {
|
fun handleRecentTabShowAllClickedFromHome() {
|
||||||
|
every { navController.currentDestination } returns mockk {
|
||||||
|
every { id } returns R.id.homeFragment
|
||||||
|
}
|
||||||
|
|
||||||
controller.handleRecentTabShowAllClicked()
|
controller.handleRecentTabShowAllClicked()
|
||||||
|
|
||||||
verify {
|
verify {
|
||||||
|
controller.dismissSearchDialogIfDisplayed()
|
||||||
navController.navigate(
|
navController.navigate(
|
||||||
match<NavDirections> { it.actionId == R.id.action_global_tabsTrayFragment },
|
match<NavDirections> { it.actionId == R.id.action_global_tabsTrayFragment }
|
||||||
null
|
)
|
||||||
|
metrics.track(Event.ShowAllRecentTabs)
|
||||||
|
}
|
||||||
|
verify(exactly = 0) {
|
||||||
|
navController.navigateUp()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun handleRecentTabShowAllClickedFromSearchDialog() {
|
||||||
|
every { navController.currentDestination } returns mockk {
|
||||||
|
every { id } returns R.id.searchDialogFragment
|
||||||
|
}
|
||||||
|
|
||||||
|
controller.handleRecentTabShowAllClicked()
|
||||||
|
|
||||||
|
verify {
|
||||||
|
controller.dismissSearchDialogIfDisplayed()
|
||||||
|
navController.navigateUp()
|
||||||
|
navController.navigate(
|
||||||
|
match<NavDirections> { it.actionId == R.id.action_global_tabsTrayFragment }
|
||||||
)
|
)
|
||||||
metrics.track(Event.ShowAllRecentTabs)
|
metrics.track(Event.ShowAllRecentTabs)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user