2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-11 13:11:01 +00:00

Fix disabled shortcutButtonTest UI test

This commit is contained in:
AndiAJ 2021-09-24 16:30:25 +03:00 committed by mergify[bot]
parent ba4c44afcf
commit 10f2074749
3 changed files with 25 additions and 2 deletions

View File

@ -6,6 +6,7 @@ package org.mozilla.fenix.helpers.ext
import androidx.test.uiautomator.SearchCondition
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiObject
import org.junit.Assert.assertNotNull
import org.mozilla.fenix.helpers.TestAssetHelper
@ -18,3 +19,8 @@ fun UiDevice.waitNotNull(
searchCondition: SearchCondition<*>,
waitTime: Long = TestAssetHelper.waitingTime
) = assertNotNull(wait(searchCondition, waitTime))
fun UiDevice.waitForAwesomeBarContent(obj: UiObject, waitingTime: Long = TestAssetHelper.waitingTime) {
this.waitForIdle()
assertNotNull(obj.waitForExists(waitingTime))
}

View File

@ -52,7 +52,6 @@ class SearchTest {
}
}
@Ignore("Currently failing at assertSearchEngineResults, will need a re-check")
@Test
fun shortcutButtonTest() {
homeScreen {
@ -63,7 +62,7 @@ class SearchTest {
}.goBack {
}.goBack {
}.openSearch {
// verifySearchWithText()
verifySearchBarEmpty()
clickSearchEngineButton(activityTestRule, "DuckDuckGo")
typeSearch("mozilla")
verifySearchEngineResults(activityTestRule, "DuckDuckGo", 4)

View File

@ -45,6 +45,7 @@ import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.TestHelper.packageName
import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.ext.waitForAwesomeBarContent
import org.mozilla.fenix.helpers.ext.waitNotNull
/**
@ -98,9 +99,18 @@ class SearchRobot {
fun typeSearch(searchTerm: String) {
browserToolbarEditView().setText(searchTerm)
mDevice.waitForIdle()
}
fun clickSearchEngineButton(rule: ComposeTestRule, searchEngineName: String) {
rule.waitForIdle()
mDevice.waitForAwesomeBarContent(
mDevice.findObject(
UiSelector().textContains(searchEngineName)
)
)
rule.onNodeWithText(searchEngineName)
.assertExists()
.assertHasClickAction()
@ -242,6 +252,14 @@ private fun assertSearchEngineURL(searchEngineName: String) {
}
private fun assertSearchEngineResults(rule: ComposeTestRule, searchEngineName: String, count: Int) {
rule.waitForIdle()
mDevice.waitForAwesomeBarContent(
mDevice.findObject(
UiSelector().textContains(searchEngineName)
)
)
rule.onAllNodesWithText(searchEngineName)
.assertCountEquals(count)
}