2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-11 13:11:01 +00:00

For #27753 - Update search engines immediately after changing language

This commit is contained in:
DreVla 2022-11-10 12:51:42 +02:00 committed by mergify[bot]
parent 1b63240f99
commit 807b0567f9
4 changed files with 16 additions and 5 deletions

View File

@ -420,11 +420,7 @@ class SettingsSearchTest {
"Bing",
"Amazon.com",
"DuckDuckGo",
"eBay",
/* Disabled Arabic Wikipedia verification
until https://github.com/mozilla-mobile/fenix/issues/12236 gets fixed
"ويكيبيديا (ar)"
*/
"ويكيبيديا (ar)",
)
}
}

View File

@ -6,6 +6,8 @@ package org.mozilla.fenix.settings.advanced
import android.app.Activity
import android.content.Context
import mozilla.components.browser.state.action.SearchAction
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.support.locale.LocaleManager
import mozilla.components.support.locale.LocaleUseCases
import org.mozilla.fenix.nimbus.FxNimbus
@ -20,6 +22,7 @@ interface LocaleSettingsController {
class DefaultLocaleSettingsController(
private val activity: Activity,
private val localeSettingsStore: LocaleSettingsStore,
private val browserStore: BrowserStore,
private val localeUseCase: LocaleUseCases,
) : LocaleSettingsController {
@ -30,6 +33,7 @@ class DefaultLocaleSettingsController(
return
}
localeSettingsStore.dispatch(LocaleSettingsAction.Select(locale))
browserStore.dispatch(SearchAction.RefreshSearchEnginesAction)
LocaleManager.setNewLocale(activity, localeUseCase, locale)
LocaleManager.updateBaseConfiguration(activity, locale)
@ -44,6 +48,7 @@ class DefaultLocaleSettingsController(
return
}
localeSettingsStore.dispatch(LocaleSettingsAction.Select(localeSettingsStore.state.localeList[0]))
browserStore.dispatch(SearchAction.RefreshSearchEnginesAction)
LocaleManager.resetToSystemDefault(activity, localeUseCase)
LocaleManager.updateBaseConfiguration(activity, localeSettingsStore.state.localeList[0])

View File

@ -58,6 +58,7 @@ class LocaleSettingsFragment : Fragment(), MenuProvider {
controller = DefaultLocaleSettingsController(
activity = requireActivity(),
localeSettingsStore = localeSettingsStore,
browserStore = browserStore,
localeUseCase = localeUseCase,
),
)

View File

@ -14,6 +14,8 @@ import io.mockk.mockkStatic
import io.mockk.spyk
import io.mockk.verify
import io.mockk.verifyAll
import mozilla.components.browser.state.action.SearchAction
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.support.locale.LocaleManager
import mozilla.components.support.locale.LocaleUseCases
import org.junit.Before
@ -24,6 +26,7 @@ class LocaleSettingsControllerTest {
private val activity = mockk<Activity>(relaxed = true)
private val localeSettingsStore: LocaleSettingsStore = mockk(relaxed = true)
private val browserStore: BrowserStore = mockk(relaxed = true)
private val localeUseCases: LocaleUseCases = mockk(relaxed = true)
private val mockState = LocaleSettingsState(mockk(), mockk(), mockk())
@ -35,6 +38,7 @@ class LocaleSettingsControllerTest {
DefaultLocaleSettingsController(
activity,
localeSettingsStore,
browserStore,
localeUseCases,
),
)
@ -53,6 +57,7 @@ class LocaleSettingsControllerTest {
verifyAll(inverse = true) {
localeSettingsStore.dispatch(LocaleSettingsAction.Select(selectedLocale))
browserStore.dispatch(SearchAction.RefreshSearchEnginesAction)
LocaleManager.setNewLocale(activity, locale = selectedLocale)
activity.recreate()
}
@ -77,6 +82,7 @@ class LocaleSettingsControllerTest {
controller.handleLocaleSelected(selectedLocale)
verify { localeSettingsStore.dispatch(LocaleSettingsAction.Select(selectedLocale)) }
verify { browserStore.dispatch(SearchAction.RefreshSearchEnginesAction) }
verify { LocaleManager.setNewLocale(activity, localeUseCases, selectedLocale) }
verify { activity.recreate() }
verify { activity.overridePendingTransition(0, 0) }
@ -101,6 +107,7 @@ class LocaleSettingsControllerTest {
controller.handleLocaleSelected(selectedLocale)
verify { localeSettingsStore.dispatch(LocaleSettingsAction.Select(selectedLocale)) }
verify { browserStore.dispatch(SearchAction.RefreshSearchEnginesAction) }
verify { LocaleManager.setNewLocale(activity, localeUseCases, selectedLocale) }
verify { activity.recreate() }
verify { activity.overridePendingTransition(0, 0) }
@ -120,6 +127,7 @@ class LocaleSettingsControllerTest {
verifyAll(inverse = true) {
localeSettingsStore.dispatch(LocaleSettingsAction.Select(selectedLocale))
browserStore.dispatch(SearchAction.RefreshSearchEnginesAction)
LocaleManager.resetToSystemDefault(activity, localeUseCases)
activity.recreate()
with(controller) {
@ -141,6 +149,7 @@ class LocaleSettingsControllerTest {
controller.handleDefaultLocaleSelected()
verify { localeSettingsStore.dispatch(LocaleSettingsAction.Select(selectedLocale)) }
verify { browserStore.dispatch(SearchAction.RefreshSearchEnginesAction) }
verify { LocaleManager.resetToSystemDefault(activity, localeUseCases) }
verify { activity.recreate() }
verify { activity.overridePendingTransition(0, 0) }