Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
run #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Oana Horvath committed Feb 18, 2022
1 parent b4cebe5 commit 8d18a7f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
4 changes: 2 additions & 2 deletions app/src/androidTest/java/org/mozilla/fenix/ui/SearchTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class SearchTest {
verifySearchBarEmpty()
clickSearchEngineButton(activityTestRule, "DuckDuckGo")
typeSearch("mozilla")
verifySearchEngineResults(activityTestRule, "DuckDuckGo", 4)
verifySearchEngineResults(3)
clickSearchEngineResult(activityTestRule, "DuckDuckGo")
verifySearchEngineURL("DuckDuckGo")
}
Expand Down Expand Up @@ -140,7 +140,7 @@ class SearchTest {

@SmokeTest
@Test
fun testSearchGroupInRecentlyVisited() {
fun searchGroupShowsInRecentlyVisitedTest() {
val firstPage = searchMockServer.url("generic1.html").toString()
val secondPage = searchMockServer.url("generic2.html").toString()
val searchString = "http://localhost:${searchMockServer.port}/searchResults.html?search={searchTerms}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class HomeScreenRobot {

fun verifyRecentlyVisitedSearchGroupDisplayed(shouldBeDisplayed: Boolean, searchTerm: String, groupSize: Int) {
// checks if the search group exists in the Recently visited section

recentlyVisitedList.waitForExists(waitingTime)
scrollToElementByText("Recently visited")

if (shouldBeDisplayed) {
Expand Down
32 changes: 16 additions & 16 deletions app/src/androidTest/java/org/mozilla/fenix/ui/robots/SearchRobot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
package org.mozilla.fenix.ui.robots

import androidx.compose.ui.test.ExperimentalTestApi
import androidx.compose.ui.test.assertCountEquals
import androidx.compose.ui.test.assertHasClickAction
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.ComposeTestRule
Expand All @@ -33,6 +32,7 @@ import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiObject
import androidx.test.uiautomator.UiScrollable
import androidx.test.uiautomator.UiSelector
import androidx.test.uiautomator.Until
import org.hamcrest.CoreMatchers.allOf
Expand Down Expand Up @@ -77,8 +77,8 @@ class SearchRobot {

fun verifySearchEngineButton() = assertSearchButton()
fun verifySearchWithText() = assertSearchWithText()
fun verifySearchEngineResults(rule: ComposeTestRule, searchEngineName: String, count: Int) =
assertSearchEngineResults(rule, searchEngineName, count)
fun verifySearchEngineResults(count: Int) =
assertSearchEngineResults(count)
fun verifySearchEngineSuggestionResults(rule: ComposeTestRule, searchSuggestion: String) =
assertSearchEngineSuggestionResults(rule, searchSuggestion)
fun verifyNoSuggestionsAreDisplayed(rule: ComposeTestRule, searchSuggestion: String) =
Expand Down Expand Up @@ -149,7 +149,7 @@ class SearchRobot {
fun clickSearchEngineResult(rule: ComposeTestRule, searchEngineName: String) {
mDevice.waitNotNull(
Until.findObjects(By.text(searchEngineName)),
TestAssetHelper.waitingTime
waitingTime
)

rule.onAllNodesWithText(searchEngineName)
Expand Down Expand Up @@ -263,17 +263,17 @@ private fun browserToolbarEditView() =
mDevice.findObject(UiSelector().resourceId("$packageName:id/mozac_browser_toolbar_edit_url_view"))

private fun denyPermissionButton(): UiObject {
mDevice.waitNotNull(Until.findObjects(By.text("Deny")), TestAssetHelper.waitingTime)
mDevice.waitNotNull(Until.findObjects(By.text("Deny")), waitingTime)
return mDevice.findObject(UiSelector().text("Deny"))
}

private fun allowPermissionButton(): UiObject {
mDevice.waitNotNull(Until.findObjects(By.text("Allow")), TestAssetHelper.waitingTime)
mDevice.waitNotNull(Until.findObjects(By.text("Allow")), waitingTime)
return mDevice.findObject(UiSelector().text("Allow"))
}

private fun scanButton(): ViewInteraction {
mDevice.waitNotNull(Until.findObject(By.res("org.mozilla.fenix.debug:id/search_scan_button")), TestAssetHelper.waitingTime)
mDevice.waitNotNull(Until.findObject(By.res("org.mozilla.fenix.debug:id/search_scan_button")), waitingTime)
return onView(allOf(withId(R.id.qr_scan_button)))
}

Expand All @@ -285,23 +285,18 @@ private fun searchWrapper() = mDevice.findObject(UiSelector().resourceId("$packa
private fun assertSearchEngineURL(searchEngineName: String) {
mDevice.waitNotNull(
Until.findObject(By.textContains("${searchEngineName.lowercase()}.com/?q=mozilla")),
TestAssetHelper.waitingTime
waitingTime
)
onView(allOf(withText(startsWith("${searchEngineName.lowercase()}.com"))))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
}

private fun assertSearchEngineResults(rule: ComposeTestRule, searchEngineName: String, count: Int) {
rule.waitForIdle()

private fun assertSearchEngineResults(minCount: Int) {
mDevice.waitForObjects(
mDevice.findObject(
UiSelector().textContains(searchEngineName)
)
searchSuggestionsList.getChild(UiSelector().index(minCount))
)

rule.onAllNodesWithText(searchEngineName)
.assertCountEquals(count)
assertTrue(searchSuggestionsList.childCount >= minCount)
}

private fun assertSearchEngineSuggestionResults(rule: ComposeTestRule, searchResult: String) {
Expand Down Expand Up @@ -472,3 +467,8 @@ private val awesomeBar =
mDevice.findObject(UiSelector().resourceId("$packageName:id/mozac_browser_toolbar_edit_url_view"))

private val voiceSearchButton = mDevice.findObject(UiSelector().description("Voice search"))

private val searchSuggestionsList =
UiScrollable(
UiSelector().className("android.widget.ScrollView")
)
7 changes: 5 additions & 2 deletions automation/taskcluster/androidTest/flank-x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ gcloud:
test-targets:
# - notPackage org.mozilla.fenix.screenshots
# - notPackage org.mozilla.fenix.syncintegration
- class org.mozilla.fenix.ui.SearchTest
- class org.mozilla.fenix.ui.SearchTest#shortcutButtonTest
- class org.mozilla.fenix.ui.SearchTest#searchGroupShowsInRecentlyVisitedTest
- class org.mozilla.fenix.ui.SearchTest#noCurrentSearchGroupFromPrivateBrowsingTest
- class org.mozilla.fenix.ui.SearchTest#noRecentlyVisitedSearchGroupInPrivateBrowsingTest
- class org.mozilla.fenix.ui.SettingsSearchTest#editCustomSearchEngineTest

device:
Expand All @@ -55,7 +58,7 @@ flank:
max-test-shards: -1
# num-test-runs: the amount of times to run the tests.
# 1 runs the tests once. 10 runs all the tests 10x
num-test-runs: 5
num-test-runs: 20
### Output Style flag
## Output style of execution status. May be one of [verbose, multi, single, compact].
## For runs with only one test execution the default value is 'verbose', in other cases
Expand Down

0 comments on commit 8d18a7f

Please sign in to comment.