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

Commit

Permalink
some more changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TejaswiKarasani committed Aug 18, 2020
1 parent 72220b2 commit 0e1f1f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 24 deletions.
8 changes: 5 additions & 3 deletions app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import org.junit.Test
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText
import org.mozilla.fenix.ui.robots.clickUrlbar
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.navigationToolbar
Expand Down Expand Up @@ -266,8 +265,8 @@ class SmokeTest {
verifyKeyboardVisibility()
clickSearchEngineButton()
verifySearchEngineList()
verifySearchEngineIconsList()
changeDefaultSearchEngine("Amazon.com")
verifySearchEngineIcon("Amazon.com")
}.goToSearchEngine {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openTabDrawer {
Expand All @@ -277,6 +276,7 @@ class SmokeTest {
clickSearchEngineButton()
mDevice.waitForIdle()
changeDefaultSearchEngine("Bing")
verifySearchEngineIcon("Bing")
}.goToSearchEngine {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openTabDrawer {
Expand All @@ -286,6 +286,7 @@ class SmokeTest {
clickSearchEngineButton()
mDevice.waitForIdle()
changeDefaultSearchEngine("DuckDuckGo")
verifySearchEngineIcon("DuckDuckGo")
}.goToSearchEngine {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openTabDrawer {
Expand All @@ -295,15 +296,16 @@ class SmokeTest {
clickSearchEngineButton()
mDevice.waitForIdle()
changeDefaultSearchEngine("Twitter")
verifySearchEngineIcon("Twitter")
}.goToSearchEngine {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openTabDrawer {
// Changing search engine to Wikipedia
}.openHomeScreen {
}.openSearch {
clickSearchEngineButton()
scrollToElementByText("Wikipedia")
changeDefaultSearchEngine("Wikipedia")
verifySearchEngineIcon("Wikipedia")
}.goToSearchEngine {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openTabDrawer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import androidx.test.espresso.action.ViewActions.typeText
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.hasSibling
import androidx.test.espresso.matcher.ViewMatchers.Visibility
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
Expand All @@ -36,7 +35,7 @@ import org.junit.Assert.assertEquals
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
import org.mozilla.fenix.helpers.TestHelper.scrollToElementByText
import org.mozilla.fenix.helpers.click
import org.mozilla.fenix.helpers.ext.waitNotNull

/**
Expand All @@ -56,16 +55,9 @@ class SearchRobot {

fun verifyKeyboardVisibility() = assertKeyboardVisibility(isExpectedToBeVisible = true)
fun verifySearchEngineList() = assertSearchEngineList()
fun verifySearchEngineIcon(expectedText: String) = assertSearchEngineIconsList(expectedText)
fun verifySearchEngineIconsList() {
verifySearchEngineIcon("Google")
verifySearchEngineIcon("Amazon.com")
verifySearchEngineIcon("Bing")
verifySearchEngineIcon("DuckDuckGo")
verifySearchEngineIcon("Twitter")
verifySearchEngineIcon("Wikipedia")
fun verifySearchEngineIcon(expectedText: String) {
onView(withContentDescription(expectedText))
}

fun verifyDefaultSearchEngine(expectedText: String) = assertDefaultSearchEngine(expectedText)

fun changeDefaultSearchEngine(searchEngineName: String) =
Expand Down Expand Up @@ -230,31 +222,23 @@ private fun assertKeyboardVisibility(isExpectedToBeVisible: Boolean) = {
}

private fun assertSearchEngineList() {
scrollToElementByText("Google")
onView(withId(R.id.mozac_browser_toolbar_edit_icon)).click()
onView(withText("Google"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
scrollToElementByText("Amazon.com")
onView(withText("Amazon.com"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
scrollToElementByText("Bing")
onView(withText("Bing"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
scrollToElementByText("DuckDuckGo")
onView(withText("DuckDuckGo"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
scrollToElementByText("Twitter")
onView(withText("Twitter"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
scrollToElementByText("Wikipedia")
onView(withText("Wikipedia"))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
}

private fun assertSearchEngineIconsList(expectedText: String) =
onView(allOf(withId(R.id.mozac_browser_awesomebar_icon), hasSibling(withText(expectedText))))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))

private fun selectDefaultSearchEngine(searchEngine: String) {
onView(withId(R.id.mozac_browser_toolbar_edit_icon)).click()
onView(withText(searchEngine))
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
.perform(click())
Expand Down

0 comments on commit 0e1f1f4

Please sign in to comment.