Ads new voice search UI test
This commit is contained in:
parent
886b4049cb
commit
143df5251f
|
@ -47,6 +47,7 @@ import org.hamcrest.Matcher
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
||||||
|
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTimeShort
|
||||||
import org.mozilla.fenix.helpers.ext.waitNotNull
|
import org.mozilla.fenix.helpers.ext.waitNotNull
|
||||||
import org.mozilla.fenix.helpers.idlingresource.NetworkConnectionIdlingResource
|
import org.mozilla.fenix.helpers.idlingresource.NetworkConnectionIdlingResource
|
||||||
import org.mozilla.fenix.ui.robots.BrowserRobot
|
import org.mozilla.fenix.ui.robots.BrowserRobot
|
||||||
|
@ -226,14 +227,13 @@ object TestHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun returnToBrowser() {
|
// exit from Menus to home screen or browser
|
||||||
val urlBar =
|
fun exitMenu() {
|
||||||
mDevice.findObject(UiSelector().resourceId("$packageName:id/mozac_browser_toolbar_url_view"))
|
val toolbar =
|
||||||
do {
|
mDevice.findObject(UiSelector().resourceId("$packageName:id/toolbar"))
|
||||||
|
while (!toolbar.waitForExists(waitingTimeShort)) {
|
||||||
mDevice.pressBack()
|
mDevice.pressBack()
|
||||||
} while (
|
}
|
||||||
!urlBar.waitForExists(waitingTime)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun UiDevice.waitForObjects(obj: UiObject, waitingTime: Long = TestAssetHelper.waitingTime) {
|
fun UiDevice.waitForObjects(obj: UiObject, waitingTime: Long = TestAssetHelper.waitingTime) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||||
import org.mozilla.fenix.helpers.FeatureSettingsHelper
|
import org.mozilla.fenix.helpers.FeatureSettingsHelper
|
||||||
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
|
import org.mozilla.fenix.helpers.HomeActivityIntentTestRule
|
||||||
import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
|
import org.mozilla.fenix.helpers.TestAssetHelper.getGenericAsset
|
||||||
|
import org.mozilla.fenix.helpers.TestHelper.exitMenu
|
||||||
import org.mozilla.fenix.ui.robots.homeScreen
|
import org.mozilla.fenix.ui.robots.homeScreen
|
||||||
import org.mozilla.fenix.ui.robots.navigationToolbar
|
import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||||
|
|
||||||
|
@ -181,4 +182,24 @@ class SettingsSearchTest {
|
||||||
verifyNoSuggestionsAreDisplayed(activityTestRule, "mozilla firefox")
|
verifyNoSuggestionsAreDisplayed(activityTestRule, "mozilla firefox")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SmokeTest
|
||||||
|
@Test
|
||||||
|
fun toggleVoiceSearchTest() {
|
||||||
|
homeScreen {
|
||||||
|
}.openSearch {
|
||||||
|
verifyVoiceSearchButtonVisibility(true)
|
||||||
|
startVoiceSearch()
|
||||||
|
}.dismissSearchBar {
|
||||||
|
}.openThreeDotMenu {
|
||||||
|
}.openSettings {
|
||||||
|
}.openSearchSubMenu {
|
||||||
|
toggleVoiceSearch()
|
||||||
|
exitMenu()
|
||||||
|
}
|
||||||
|
homeScreen {
|
||||||
|
}.openSearch {
|
||||||
|
verifyVoiceSearchButtonVisibility(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ import androidx.test.uiautomator.Until
|
||||||
import org.hamcrest.CoreMatchers.allOf
|
import org.hamcrest.CoreMatchers.allOf
|
||||||
import org.hamcrest.CoreMatchers.startsWith
|
import org.hamcrest.CoreMatchers.startsWith
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.helpers.Constants.LONG_CLICK_DURATION
|
import org.mozilla.fenix.helpers.Constants.LONG_CLICK_DURATION
|
||||||
|
@ -57,6 +58,23 @@ class SearchRobot {
|
||||||
fun verifySearchView() = assertSearchView()
|
fun verifySearchView() = assertSearchView()
|
||||||
fun verifyBrowserToolbar() = assertBrowserToolbarEditView()
|
fun verifyBrowserToolbar() = assertBrowserToolbarEditView()
|
||||||
fun verifyScanButton() = assertScanButton()
|
fun verifyScanButton() = assertScanButton()
|
||||||
|
|
||||||
|
fun verifyVoiceSearchButtonVisibility(enabled: Boolean) {
|
||||||
|
if (enabled) {
|
||||||
|
assertTrue(voiceSearchButton.waitForExists(waitingTime))
|
||||||
|
} else {
|
||||||
|
assertFalse(voiceSearchButton.waitForExists(waitingTime))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun startVoiceSearch() {
|
||||||
|
voiceSearchButton.click()
|
||||||
|
assertTrue(
|
||||||
|
mDevice.findObject(UiSelector().packageName("com.google.android.googlequicksearchbox"))
|
||||||
|
.exists()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun verifySearchEngineButton() = assertSearchButton()
|
fun verifySearchEngineButton() = assertSearchButton()
|
||||||
fun verifySearchWithText() = assertSearchWithText()
|
fun verifySearchWithText() = assertSearchWithText()
|
||||||
fun verifySearchEngineResults(rule: ComposeTestRule, searchEngineName: String, count: Int) =
|
fun verifySearchEngineResults(rule: ComposeTestRule, searchEngineName: String, count: Int) =
|
||||||
|
@ -447,3 +465,5 @@ private fun assertPastedToolbarText(expectedText: String) {
|
||||||
)
|
)
|
||||||
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private val voiceSearchButton = mDevice.findObject(UiSelector().description("Voice search"))
|
||||||
|
|
|
@ -51,6 +51,15 @@ class SettingsSubMenuSearchRobot {
|
||||||
fun disableShowSearchSuggestions() = toggleShowSearchSuggestions()
|
fun disableShowSearchSuggestions() = toggleShowSearchSuggestions()
|
||||||
fun enableShowSearchShortcuts() = toggleShowSearchShortcuts()
|
fun enableShowSearchShortcuts() = toggleShowSearchShortcuts()
|
||||||
|
|
||||||
|
fun toggleVoiceSearch() {
|
||||||
|
onView(withId(androidx.preference.R.id.recycler_view)).perform(
|
||||||
|
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
||||||
|
hasDescendant(withText("Show voice search"))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
onView(withText("Show voice search")).perform(click())
|
||||||
|
}
|
||||||
|
|
||||||
fun openAddSearchEngineMenu() = addSearchEngineButton().click()
|
fun openAddSearchEngineMenu() = addSearchEngineButton().click()
|
||||||
|
|
||||||
fun verifyAddSearchEngineList() = assertAddSearchEngineList()
|
fun verifyAddSearchEngineList() = assertAddSearchEngineList()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user