Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Commit

Permalink
[fenix] For mozilla-mobile/fenix#27522 remove shortcutButtonTest UI t…
Browse files Browse the repository at this point in the history
…est and unused SearchRobot functions
  • Loading branch information
AndiAJ authored and mergify[bot] committed Nov 1, 2022
1 parent 6c8a9d5 commit 07bbb91
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 85 deletions.
26 changes: 0 additions & 26 deletions fenix/app/src/androidTest/java/org/mozilla/fenix/ui/SearchTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -187,7 +177,6 @@ class SearchRobot {
).click()
}

fun verifySearchSettings() = assertSearchSettings()
fun verifySearchEnginePrompt(rule: ComposeTestRule, searchEngineName: String) =
assertSearchEnginePrompt(rule, searchEngineName)
fun verifySearchBarEmpty() = assertSearchBarEmpty()
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 07bbb91

Please sign in to comment.