2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-17 15:26:23 +00:00
This commit is contained in:
ekager 2020-09-09 14:39:04 -07:00 committed by Jeff Boek
parent c3ba6ed946
commit b2a9e73051
3 changed files with 19 additions and 1 deletions

View File

@ -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()
}
}
}

View File

@ -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()

View File

@ -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"