mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
For #27522 new toggleSearchEnginesShortcutListTest UI test
This commit is contained in:
parent
3efd1dc9f2
commit
9c46639331
@ -152,8 +152,8 @@ class SearchTest {
|
||||
}.goBack {
|
||||
}.openSearch {
|
||||
scrollToSearchEngineSettings(activityTestRule)
|
||||
clickSearchEngineSettings(activityTestRule)
|
||||
verifySearchSettings()
|
||||
}.clickSearchEngineSettings(activityTestRule) {
|
||||
verifySearchToolbar()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -428,4 +428,60 @@ class SettingsSearchTest {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Expected for en-us defaults
|
||||
@Test
|
||||
fun toggleSearchEnginesShortcutListTest() {
|
||||
homeScreen {
|
||||
}.openThreeDotMenu {
|
||||
}.openSettings {
|
||||
}.openSearchSubMenu {
|
||||
verifyShowSearchEnginesToggleState(false)
|
||||
toggleShowSearchShortcuts()
|
||||
verifyShowSearchEnginesToggleState(true)
|
||||
}
|
||||
|
||||
exitMenu()
|
||||
|
||||
homeScreen {
|
||||
}.openSearch {
|
||||
verifySearchEngineShortcuts(
|
||||
activityTestRule,
|
||||
"Google",
|
||||
"Bing",
|
||||
"Amazon.com",
|
||||
"DuckDuckGo",
|
||||
"eBay",
|
||||
"Wikipedia",
|
||||
)
|
||||
}.clickSearchEngineSettings(activityTestRule) {
|
||||
toggleShowSearchShortcuts()
|
||||
verifyShowSearchEnginesToggleState(false)
|
||||
}
|
||||
|
||||
exitMenu()
|
||||
|
||||
homeScreen {
|
||||
}.openSearch {
|
||||
verifySearchEngineShortcutsAreNotDisplayed(
|
||||
activityTestRule,
|
||||
"Google",
|
||||
"Bing",
|
||||
"Amazon.com",
|
||||
"DuckDuckGo",
|
||||
"eBay",
|
||||
"Wikipedia",
|
||||
)
|
||||
clickSearchEngineShortcutButton()
|
||||
verifySearchEngineShortcuts(
|
||||
activityTestRule,
|
||||
"Google",
|
||||
"Bing",
|
||||
"Amazon.com",
|
||||
"DuckDuckGo",
|
||||
"eBay",
|
||||
"Wikipedia",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -286,13 +286,6 @@ class SearchRobot {
|
||||
.performScrollToIndex(5)
|
||||
}
|
||||
|
||||
fun clickSearchEngineSettings(rule: ComposeTestRule) {
|
||||
rule.onNodeWithText("Search engine settings")
|
||||
.assertIsDisplayed()
|
||||
.assertHasClickAction()
|
||||
.performClick()
|
||||
}
|
||||
|
||||
fun clickClearButton() {
|
||||
clearButton().click()
|
||||
}
|
||||
@ -337,6 +330,17 @@ class SearchRobot {
|
||||
}
|
||||
}
|
||||
|
||||
fun verifySearchEngineShortcutsAreNotDisplayed(rule: ComposeTestRule, vararg searchEngines: String) {
|
||||
mDevice.findObject(
|
||||
UiSelector().resourceId("$packageName:id/pill_wrapper_divider"),
|
||||
).waitForExists(waitingTime)
|
||||
|
||||
for (searchEngine in searchEngines) {
|
||||
rule.waitForIdle()
|
||||
rule.onNodeWithText(searchEngine).assertDoesNotExist()
|
||||
}
|
||||
}
|
||||
|
||||
fun verifyTypedToolbarText(expectedText: String) {
|
||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/toolbar"))
|
||||
.waitForExists(waitingTime)
|
||||
@ -399,6 +403,19 @@ class SearchRobot {
|
||||
NavigationToolbarRobot().interact()
|
||||
return NavigationToolbarRobot.Transition()
|
||||
}
|
||||
|
||||
fun clickSearchEngineSettings(
|
||||
rule: ComposeTestRule,
|
||||
interact: SettingsSubMenuSearchRobot.() -> Unit,
|
||||
): SettingsSubMenuSearchRobot.Transition {
|
||||
rule.onNodeWithText("Search engine settings")
|
||||
.assertIsDisplayed()
|
||||
.assertHasClickAction()
|
||||
.performClick()
|
||||
|
||||
SettingsSubMenuSearchRobot().interact()
|
||||
return SettingsSubMenuSearchRobot.Transition()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -289,6 +289,8 @@ class SettingsSubMenuSearchRobot {
|
||||
)
|
||||
}
|
||||
|
||||
fun verifyShowSearchEnginesToggleState(enabled: Boolean) = assertShowSearchEnginesToggle(enabled)
|
||||
|
||||
class Transition {
|
||||
fun goBack(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
|
||||
mDevice.waitForIdle()
|
||||
@ -385,6 +387,33 @@ private fun assertEngineListDoesNotContain(searchEngineName: String) {
|
||||
private fun assertThreeDotButtonIsNotDisplayed(searchEngineName: String) =
|
||||
threeDotMenu(searchEngineName).check(matches(not(isDisplayed())))
|
||||
|
||||
private fun assertShowSearchEnginesToggle(enabled: Boolean) =
|
||||
if (enabled) {
|
||||
onView(withText(R.string.preferences_show_search_engines))
|
||||
.check(
|
||||
matches(
|
||||
hasCousin(
|
||||
allOf(
|
||||
withClassName(endsWith("Switch")),
|
||||
ViewMatchers.isChecked(),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
} else {
|
||||
onView(withText(R.string.preferences_show_search_engines))
|
||||
.check(
|
||||
matches(
|
||||
hasCousin(
|
||||
allOf(
|
||||
withClassName(endsWith("Switch")),
|
||||
ViewMatchers.isNotChecked(),
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
private fun threeDotMenu(searchEngineName: String) =
|
||||
onView(
|
||||
allOf(
|
||||
|
Loading…
Reference in New Issue
Block a user