2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-15 18:12:54 +00:00

For #27522 remove shortcutButtonTest UI test and unused SearchRobot functions

This commit is contained in:
AndiAJ 2022-11-01 12:47:25 +02:00 committed by mergify[bot]
parent 307460c3c3
commit a5c1c578bd
2 changed files with 0 additions and 85 deletions

View File

@ -30,7 +30,6 @@ import org.mozilla.fenix.helpers.TestHelper.exitMenu
import org.mozilla.fenix.helpers.TestHelper.grantPermission
import org.mozilla.fenix.helpers.TestHelper.longTapSelectItem
import org.mozilla.fenix.helpers.TestHelper.setCustomSearchEngine
import org.mozilla.fenix.ui.robots.browserScreen
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.multipleSelectionToolbar
@ -116,31 +115,6 @@ class SearchTest {
}
}
@Test
fun shortcutButtonTest() {
val searchEngineURL = "bing.com/search?q=mozilla%20firefox"
homeScreen {
}.openThreeDotMenu {
}.openSettings {
}.openSearchSubMenu {
toggleShowSearchShortcuts()
}.goBack {
}.goBack {
}.openSearch {
verifySearchBarEmpty()
clickSearchEngineButton(activityTestRule, "Bing")
typeSearch("mozilla")
verifySearchEngineResults(activityTestRule, "mozilla firefox", "Bing")
clickSearchEngineResult(activityTestRule, "mozilla firefox")
}
browserScreen {
waitForPageToLoad()
verifyUrl(searchEngineURL)
}
}
@Test
fun setDefaultSearchEngineFromShortcutsTest() {
homeScreen {

View File

@ -8,13 +8,11 @@ package org.mozilla.fenix.ui.robots
import android.os.Build
import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.assertAny
import androidx.compose.ui.test.assertHasClickAction
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.junit4.android.ComposeNotIdleException
import androidx.compose.ui.test.onAllNodesWithTag
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
@ -32,7 +30,6 @@ import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiSelector
import androidx.test.uiautomator.Until
import org.hamcrest.CoreMatchers.allOf
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
@ -49,9 +46,7 @@ import org.mozilla.fenix.helpers.TestHelper.getStringResource
import org.mozilla.fenix.helpers.TestHelper.isPackageInstalled
import org.mozilla.fenix.helpers.TestHelper.mDevice
import org.mozilla.fenix.helpers.TestHelper.packageName
import org.mozilla.fenix.helpers.TestHelper.waitForObjects
import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.ext.waitNotNull
/**
* Implementation of Robot Pattern for the search fragment.
@ -96,11 +91,6 @@ class SearchRobot {
fun verifySearchEngineButton() = assertSearchButton()
fun verifySearchEngineResults(rule: ComposeTestRule, searchSuggestion: String, searchEngineName: String) {
rule.waitUntil(waitingTime, waitForSearchSuggestions(rule, searchSuggestion, searchEngineName))
rule.onNodeWithText(searchSuggestion).assertIsDisplayed()
}
fun verifySearchEngineSuggestionResults(rule: ComposeTestRule, searchSuggestion: String) {
rule.waitForIdle()
for (i in 1..RETRY_COUNT) {
@ -187,7 +177,6 @@ class SearchRobot {
).click()
}
fun verifySearchSettings() = assertSearchSettings()
fun verifySearchEnginePrompt(rule: ComposeTestRule, searchEngineName: String) =
assertSearchEnginePrompt(rule, searchEngineName)
fun verifySearchBarEmpty() = assertSearchBarEmpty()
@ -245,33 +234,6 @@ class SearchRobot {
mDevice.waitForIdle()
}
fun clickSearchEngineButton(rule: ComposeTestRule, searchEngineName: String) {
rule.waitForIdle()
mDevice.waitForObjects(
mDevice.findObject(
UiSelector().textContains(searchEngineName),
),
)
rule.onNodeWithText(searchEngineName)
.assertExists()
.assertHasClickAction()
.performClick()
}
fun clickSearchEngineResult(rule: ComposeTestRule, searchSuggestion: String) {
mDevice.waitNotNull(
Until.findObjects(By.text(searchSuggestion)),
waitingTime,
)
rule.onNodeWithText(searchSuggestion)
.assertIsDisplayed()
.assertHasClickAction()
.performClick()
}
@OptIn(ExperimentalTestApi::class)
fun scrollToSearchEngineSettings(rule: ComposeTestRule) {
// Soft keyboard is visible on screen on view access; hide it
@ -399,11 +361,6 @@ class SearchRobot {
return BrowserRobot.Transition()
}
fun goToSearchEngine(interact: NavigationToolbarRobot.() -> Unit): NavigationToolbarRobot.Transition {
NavigationToolbarRobot().interact()
return NavigationToolbarRobot.Transition()
}
fun clickSearchEngineSettings(
rule: ComposeTestRule,
interact: SettingsSubMenuSearchRobot.() -> Unit,
@ -436,14 +393,6 @@ private fun clearButton() =
private fun searchWrapper() = mDevice.findObject(UiSelector().resourceId("$packageName:id/search_wrapper"))
private fun waitForSearchSuggestions(rule: ComposeTestRule, searchSuggestion: String, searchEngineName: String): () -> Boolean =
{
rule.waitForIdle()
mDevice.waitForObjects(mDevice.findObject(UiSelector().textContains(searchSuggestion)))
rule.onAllNodesWithTag("mozac.awesomebar.suggestion").assertAny(hasText(searchSuggestion) and hasText(searchEngineName))
mDevice.findObject(UiSelector().textContains(searchSuggestion)).waitForExists(waitingTime)
}
private fun assertSearchEnginePrompt(rule: ComposeTestRule, searchEngineName: String) {
rule.waitForIdle()
rule.onNodeWithText("Search $searchEngineName").assertIsDisplayed()
@ -478,14 +427,6 @@ private fun assertSearchButton() =
).waitForExists(waitingTime),
)
private fun assertSearchWithText() =
onView(allOf(withText("THIS TIME, SEARCH WITH:")))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
private fun assertSearchSettings() =
onView(allOf(withText("Default search engine")))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
private fun assertSearchBarEmpty() =
assertTrue(
mDevice.findObject(