mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/13467 For https://github.com/mozilla-mobile/fenix/issues/14910 - Dismiss dialog on blank URL commit
This commit is contained in:
parent
c3ba6ed946
commit
b2a9e73051
@ -33,6 +33,7 @@ class SearchDialogController(
|
||||
private val navController: NavController,
|
||||
private val settings: Settings,
|
||||
private val metrics: MetricController,
|
||||
private val dismissDialog: () -> Unit,
|
||||
private val clearToolbarFocus: () -> Unit
|
||||
) : SearchController {
|
||||
|
||||
@ -45,12 +46,15 @@ class SearchDialogController(
|
||||
activity.startActivity(Intent(activity, CrashListActivity::class.java))
|
||||
}
|
||||
"about:addons" -> {
|
||||
val directions = SearchDialogFragmentDirections.actionGlobalAddonsManagementFragment()
|
||||
val directions =
|
||||
SearchDialogFragmentDirections.actionGlobalAddonsManagementFragment()
|
||||
navController.navigateSafe(R.id.searchDialogFragment, directions)
|
||||
}
|
||||
"moz://a" -> openSearchOrUrl(SupportUtils.getMozillaPageUrl(SupportUtils.MozillaPage.MANIFESTO))
|
||||
else -> if (url.isNotBlank()) {
|
||||
openSearchOrUrl(url)
|
||||
} else {
|
||||
dismissDialog()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,6 +140,7 @@ class SearchDialogFragment : AppCompatDialogFragment(), UserInteractionHandler {
|
||||
navController = findNavController(),
|
||||
settings = requireContext().settings(),
|
||||
metrics = requireComponents.analytics.metrics,
|
||||
dismissDialog = { dismissAllowingStateLoss() },
|
||||
clearToolbarFocus = {
|
||||
toolbarView.view.hideKeyboard()
|
||||
toolbarView.view.clearFocus()
|
||||
|
@ -44,6 +44,7 @@ class SearchDialogControllerTest {
|
||||
@MockK(relaxed = true) private lateinit var settings: Settings
|
||||
@MockK private lateinit var sessionManager: SessionManager
|
||||
@MockK(relaxed = true) private lateinit var clearToolbarFocus: () -> Unit
|
||||
@MockK(relaxed = true) private lateinit var dismissDialog: () -> Unit
|
||||
|
||||
private lateinit var controller: SearchDialogController
|
||||
|
||||
@ -67,6 +68,7 @@ class SearchDialogControllerTest {
|
||||
navController = navController,
|
||||
settings = settings,
|
||||
metrics = metrics,
|
||||
dismissDialog = dismissDialog,
|
||||
clearToolbarFocus = clearToolbarFocus
|
||||
)
|
||||
}
|
||||
@ -93,6 +95,17 @@ class SearchDialogControllerTest {
|
||||
verify { metrics.track(Event.EnteredUrl(false)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
fun handleBlankUrlCommitted() {
|
||||
val url = ""
|
||||
|
||||
controller.handleUrlCommitted(url)
|
||||
|
||||
verify {
|
||||
dismissDialog()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun handleSearchCommitted() {
|
||||
val searchTerm = "Firefox"
|
||||
|
Loading…
Reference in New Issue
Block a user