mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-19 09:25:34 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/16615: UI smoke test editCustomSearchEngineTest
This commit is contained in:
parent
9954d20d0a
commit
ecdf3415d2
@ -44,6 +44,10 @@ class SmokeTest {
|
||||
private var addonsListIdlingResource: RecyclerViewIdlingResource? = null
|
||||
private var recentlyClosedTabsListIdlingResource: RecyclerViewIdlingResource? = null
|
||||
private val downloadFileName = "Globe.svg"
|
||||
private val searchEngine = object {
|
||||
var title = "Ecosia"
|
||||
var url = "https://www.ecosia.org/search?q=%s"
|
||||
}
|
||||
|
||||
// This finds the dialog fragment child of the homeFragment, otherwise the awesomeBar would return null
|
||||
private fun getAwesomebarView(): View? {
|
||||
@ -466,6 +470,31 @@ class SmokeTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
// Verifies setting as default a customized search engine name and URL
|
||||
fun editCustomSearchEngineTest() {
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openSearchSubMenu {
|
||||
openAddSearchEngineMenu()
|
||||
selectAddCustomSearchEngine()
|
||||
typeCustomEngineDetails(searchEngine.title, searchEngine.url)
|
||||
saveNewSearchEngine()
|
||||
openEngineOverflowMenu("Ecosia")
|
||||
clickEdit()
|
||||
typeCustomEngineDetails("Test", searchEngine.url)
|
||||
saveEditSearchEngine()
|
||||
changeDefaultSearchEngine("Test")
|
||||
}.goBack {
|
||||
}.goBack {
|
||||
}.openSearch {
|
||||
verifyDefaultSearchEngine("Test")
|
||||
clickSearchEngineShortcutButton()
|
||||
verifyEnginesListShortcutContains("Test")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
// Swipes the nav bar left/right to switch between tabs
|
||||
fun swipeToSwitchTabTest() {
|
||||
|
@ -8,20 +8,27 @@ package org.mozilla.fenix.ui.robots
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.action.ViewActions.clearText
|
||||
import androidx.test.espresso.action.ViewActions.click
|
||||
import androidx.test.espresso.action.ViewActions.typeText
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions
|
||||
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withChild
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withParent
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import androidx.test.uiautomator.UiSelector
|
||||
import org.hamcrest.CoreMatchers
|
||||
import org.hamcrest.CoreMatchers.allOf
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
||||
import org.mozilla.fenix.helpers.click
|
||||
|
||||
/**
|
||||
@ -48,13 +55,45 @@ class SettingsSubMenuSearchRobot {
|
||||
|
||||
fun verifyEngineListContains(searchEngineName: String) = assertEngineListContains(searchEngineName)
|
||||
|
||||
fun saveNewSearchEngine() = addSearchEngineSaveButton().click()
|
||||
fun saveNewSearchEngine() {
|
||||
addSearchEngineSaveButton().click()
|
||||
mDevice.findObject(
|
||||
UiSelector().resourceId("org.mozilla.fenix.debug:id/recycler_view")
|
||||
).waitForExists(waitingTime)
|
||||
}
|
||||
|
||||
fun addNewSearchEngine(searchEngineName: String) {
|
||||
selectSearchEngine(searchEngineName)
|
||||
saveNewSearchEngine()
|
||||
}
|
||||
|
||||
fun selectAddCustomSearchEngine() = onView(withText("Other")).click()
|
||||
|
||||
fun typeCustomEngineDetails(engineName: String, engineURL: String) {
|
||||
onView(withId(R.id.edit_engine_name))
|
||||
.perform(clearText())
|
||||
.perform(typeText(engineName))
|
||||
onView(withId(R.id.edit_search_string))
|
||||
.perform(clearText())
|
||||
.perform(typeText(engineURL))
|
||||
}
|
||||
|
||||
fun openEngineOverflowMenu(searchEngineName: String) {
|
||||
mDevice.findObject(
|
||||
UiSelector().resourceId("org.mozilla.fenix.debug:id/overflow_menu")
|
||||
).waitForExists(waitingTime)
|
||||
threeDotMenu(searchEngineName).click()
|
||||
}
|
||||
|
||||
fun clickEdit() = onView(withText("Edit")).click()
|
||||
|
||||
fun saveEditSearchEngine() {
|
||||
onView(withId(R.id.save_button)).click()
|
||||
mDevice.findObject(
|
||||
UiSelector().resourceId("org.mozilla.fenix.debug:id/recycler_view")
|
||||
).waitForExists(waitingTime)
|
||||
}
|
||||
|
||||
class Transition {
|
||||
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||
|
||||
@ -181,3 +220,11 @@ private fun addSearchEngineSaveButton() = onView(withId(R.id.add_search_engine))
|
||||
private fun assertEngineListContains(searchEngineName: String) {
|
||||
onView(withId(R.id.search_engine_group)).check(matches(hasDescendant(withText(searchEngineName))))
|
||||
}
|
||||
|
||||
private fun threeDotMenu(searchEngineName: String) =
|
||||
onView(
|
||||
allOf(
|
||||
withId(R.id.overflow_menu),
|
||||
withParent(withChild(withText(searchEngineName)))
|
||||
)
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user