For #27522 new verifySearchEnginesWithRTLLocale UI test

This commit is contained in:
AndiAJ 2022-10-31 12:29:25 +02:00 committed by mergify[bot]
parent 418302dbfa
commit 3efd1dc9f2
3 changed files with 70 additions and 1 deletions

View File

@ -7,16 +7,20 @@ import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.R
import org.mozilla.fenix.customannotations.SmokeTest
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
import org.mozilla.fenix.helpers.RecyclerViewIdlingResource
import org.mozilla.fenix.helpers.SearchDispatcher
import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
import org.mozilla.fenix.helpers.TestHelper
import org.mozilla.fenix.helpers.TestHelper.appContext
import org.mozilla.fenix.helpers.TestHelper.setTextToClipBoard
import org.mozilla.fenix.helpers.TestHelper.exitMenu
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar
import org.mozilla.fenix.ui.util.ARABIC_LANGUAGE_HEADER
class SettingsSearchTest {
private lateinit var mockWebServer: MockWebServer
@ -383,4 +387,45 @@ class SettingsSearchTest {
verifyUrl("duckduckgo.com/?q=firefox")
}
}
// Expected for app language set to Arabic
@Test
fun verifySearchEnginesWithRTLLocale() {
homeScreen {
}.openThreeDotMenu {
}.openSettings {
}.openSearchSubMenu {
toggleShowSearchShortcuts()
}.goBack {
}.openLanguageSubMenu {
TestHelper.registerAndCleanupIdlingResources(
RecyclerViewIdlingResource(
activityTestRule.activity.findViewById(R.id.locale_list),
2,
),
) {
selectLanguage("Arabic")
verifyLanguageHeaderIsTranslated(ARABIC_LANGUAGE_HEADER)
}
}
exitMenu()
homeScreen {
}.openSearch {
verifyTranslatedFocusedNavigationToolbar("ابحث أو أدخِل عنوانا")
verifySearchEngineShortcuts(
activityTestRule,
"Google",
"Bing",
"Amazon.com",
"DuckDuckGo",
"eBay",
/* Disabled Arabic Wikipedia verification
until https://github.com/mozilla-mobile/fenix/issues/12236 gets fixed
"ويكيبيديا (ar)"
*/
)
}
}
}

View File

@ -323,6 +323,20 @@ class SearchRobot {
awesomeBar.swipeUp(2)
}
fun verifyTranslatedFocusedNavigationToolbar(toolbarHintString: String) =
assertTranslatedFocusedNavigationToolbar(toolbarHintString)
fun verifySearchEngineShortcuts(rule: ComposeTestRule, vararg searchEngines: String) {
mDevice.findObject(
UiSelector().resourceId("$packageName:id/awesome_bar"),
).swipeUp(1)
for (searchEngine in searchEngines) {
rule.waitForIdle()
rule.onNodeWithText(searchEngine).assertIsDisplayed()
}
}
fun verifyTypedToolbarText(expectedText: String) {
mDevice.findObject(UiSelector().resourceId("$packageName:id/toolbar"))
.waitForExists(waitingTime)
@ -552,6 +566,15 @@ private fun assertDefaultSearchEngine(expectedText: String) =
).waitForExists(waitingTime),
)
private fun assertTranslatedFocusedNavigationToolbar(toolbarHintString: String) =
assertTrue(
mDevice.findObject(
UiSelector()
.resourceId("$packageName:id/mozac_browser_toolbar_edit_url_view")
.textContains(toolbarHintString),
).waitForExists(waitingTime),
)
private val awesomeBar =
mDevice.findObject(UiSelector().resourceId("$packageName:id/mozac_browser_toolbar_edit_url_view"))

View File

@ -8,6 +8,7 @@ const val STRING_ONBOARDING_ACCOUNT_SIGN_IN_HEADER = "Pick up where you left off
const val STRING_ONBOARDING_TRACKING_PROTECTION_HEADER = "Privacy protection by default"
const val STRING_ONBOARDING_TOOLBAR_PLACEMENT_HEADER = "Pick your toolbar placement"
const val FRENCH_LANGUAGE_HEADER = "Langues"
const val ROMANIAN_LANGUAGE_HEADER = "Limbă"
const val ARABIC_LANGUAGE_HEADER = "اللغة"
const val FR_SETTINGS = "Paramètres"
const val FRENCH_SYSTEM_LOCALE_OPTION = "Utiliser la langue de lappareil"
const val ROMANIAN_LANGUAGE_HEADER = "Limbă"