Commit 4b997c13 authored by Jeff Boek's avatar Jeff Boek
Browse files

No Issue - Fixes UI Tests with new search experience

parent f734509a
......@@ -254,11 +254,9 @@ class HistoryTest {
navigationToolbar {
}.enterURLAndEnterToBrowser(firstWebPage.url) {
}.openTabDrawer { }.openHomeScreen { }
navigationToolbar {
}.enterURLAndEnterToBrowser(secondWebPage.url) {
mDevice.waitForIdle()
}.openTabDrawer {
}.openNewTab {
}.submitQuery(secondWebPage.url.toString()) {
}.openThreeDotMenu {
}.openHistory {
longTapSelectItem(firstWebPage.url)
......
......@@ -57,7 +57,7 @@ class SearchTest {
}.goBack {
}.goBack {
}.openSearch {
verifySearchWithText()
// verifySearchWithText()
clickSearchEngineButton("DuckDuckGo")
typeSearch("mozilla")
verifySearchEngineResults("DuckDuckGo")
......
......@@ -191,7 +191,8 @@ class SettingsBasicsTest {
}.enterURLAndEnterToBrowser(webpage) {
checkTextSizeOnWebsite(textSizePercentage, fenixApp.components)
}.openTabDrawer {
}.openHomeScreen {
}.openNewTab {
}.dismiss {
}.openThreeDotMenu {
}.openSettings {
}.openAccessibilitySubMenu {
......
......@@ -194,7 +194,8 @@ class SettingsPrivacyTest {
// Click save to save the login
saveLoginFromPrompt("Save")
}.openTabDrawer {
}.openHomeScreen {
}.openNewTab {
}.dismiss {
}.openThreeDotMenu {
}.openSettings {
TestHelper.scrollToElementByText("Logins and passwords")
......@@ -219,7 +220,8 @@ class SettingsPrivacyTest {
// Don't save the login, add to exceptions
saveLoginFromPrompt("Never save")
}.openTabDrawer {
}.openHomeScreen {
}.openNewTab {
}.dismiss {
}.openThreeDotMenu {
}.openSettings {
}.openLoginsAndPasswordSubMenu {
......@@ -274,7 +276,7 @@ class SettingsPrivacyTest {
browserScreen {
}.openTabDrawer {
verifyPrivateModeSelected()
}.openHomeScreen { }
}.openNewTab { }.dismiss { }
setOpenLinksInPrivateOff()
......@@ -321,7 +323,7 @@ class SettingsPrivacyTest {
clickAddAutomaticallyButton()
}.openHomeScreenShortcut(pageShortcutName) {
}.openTabDrawer {
}.openHomeScreen { }
}.openNewTab { }.dismiss { }
setOpenLinksInPrivateOff()
restartApp(activityTestRule)
......@@ -331,7 +333,8 @@ class SettingsPrivacyTest {
}.searchAndOpenHomeScreenShortcut(pageShortcutName) {
}.openTabDrawer {
verifyNormalModeSelected()
}.openHomeScreen {
}.openNewTab {
}.dismiss {
}.openThreeDotMenu {
}.openSettings {
}.openPrivateBrowsingSubMenu {
......
......@@ -4,7 +4,6 @@
package org.mozilla.fenix.ui
import androidx.core.net.toUri
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import okhttp3.mockwebserver.MockWebServer
......@@ -58,7 +57,8 @@ class SmokeTest {
}.goBackToWebsite {
}.openTabDrawer {
verifyExistingTabList()
}.openHomeScreen {
}.openNewTab {
}.dismiss {
verifyHomeScreen()
}
}
......@@ -106,7 +106,8 @@ class SmokeTest {
}.addToFirefoxHome {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
}.openHomeScreen {
}.openNewTab {
}.dismiss {
verifyExistingTopSitesTabs(defaultWebPage.title)
}.openTabDrawer {
}.openTab(defaultWebPage.title) {
......@@ -132,13 +133,11 @@ class SmokeTest {
verifyUrl(defaultWebPage.url.toString())
}.openTabDrawer {
closeTabViaXButton(defaultWebPage.title)
}.openHomeScreen {
navigationToolbar {
}.enterURLAndEnterToBrowser(youtubeUrl.toUri()) {
verifyBlueDot()
}.openThreeDotMenu {
verifyOpenInAppButton()
}
}.openNewTab {
}.submitQuery(youtubeUrl) {
verifyBlueDot()
}.openThreeDotMenu {
verifyOpenInAppButton()
}
}
......@@ -185,7 +184,8 @@ class SmokeTest {
}.addToFirefoxHome {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
}.openHomeScreen {
}.openNewTab {
}.dismiss {
togglePrivateBrowsingModeOnOff()
verifyExistingTopSitesTabs(defaultWebPage.title)
togglePrivateBrowsingModeOnOff()
......@@ -209,13 +209,11 @@ class SmokeTest {
verifyUrl(defaultWebPage.url.toString())
}.openTabDrawer {
closeTabViaXButton(defaultWebPage.title)
}.openHomeScreen {
navigationToolbar {
}.enterURLAndEnterToBrowser(youtubeUrl.toUri()) {
verifyBlueDot()
}.openThreeDotMenu {
verifyOpenInAppButton()
}
}.openNewTab {
}.submitQuery(youtubeUrl) {
verifyBlueDot()
}.openThreeDotMenu {
verifyOpenInAppButton()
}
}
}
......@@ -240,7 +238,8 @@ class SmokeTest {
verifyUrl("webcompat.com/issues/new")
verifyTabCounter("2")
}.openTabDrawer {
}.openHomeScreen {
}.openNewTab {
}.dismiss {
}.openThreeDotMenu {
}.openSettings {
}.openEnhancedTrackingProtectionSubMenu {
......@@ -270,9 +269,7 @@ class SmokeTest {
}.goToSearchEngine {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openTabDrawer {
// Changing search engine to Bing
}.openHomeScreen {
}.openSearch {
}.openNewTab {
clickSearchEngineButton()
mDevice.waitForIdle()
changeDefaultSearchEngine("Bing")
......@@ -280,9 +277,7 @@ class SmokeTest {
}.goToSearchEngine {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openTabDrawer {
// Changing search engine to DuckDuckGo
}.openHomeScreen {
}.openSearch {
}.openNewTab {
clickSearchEngineButton()
mDevice.waitForIdle()
changeDefaultSearchEngine("DuckDuckGo")
......@@ -290,9 +285,7 @@ class SmokeTest {
}.goToSearchEngine {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openTabDrawer {
// Changing search engine to Twitter
}.openHomeScreen {
}.openSearch {
}.openNewTab {
clickSearchEngineButton()
mDevice.waitForIdle()
changeDefaultSearchEngine("Twitter")
......@@ -300,9 +293,7 @@ class SmokeTest {
}.goToSearchEngine {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openTabDrawer {
// Changing search engine to Wikipedia
}.openHomeScreen {
}.openSearch {
}.openNewTab {
clickSearchEngineButton()
changeDefaultSearchEngine("Wikipedia")
verifySearchEngineIcon("Wikipedia")
......@@ -310,8 +301,7 @@ class SmokeTest {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openTabDrawer {
// Checking whether the next search will be with default or not
}.openHomeScreen {
}.openSearch {
}.openNewTab {
}.goToSearchEngine {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openNavigationToolbar {
......
......@@ -186,8 +186,8 @@ class TabbedBrowsingTest {
browserScreen {
}.openTabDrawer {
verifyExistingOpenTabs("Test_Page_1")
}.openHomeScreen {
}
}.openNewTab {
}.dismiss { }
}
@Test
......@@ -285,8 +285,8 @@ class TabbedBrowsingTest {
verifyTabTrayOverflowMenu(true)
verifyExistingOpenTabs(defaultWebPage.title)
verifyCloseTabsButton(defaultWebPage.title)
}.openHomeScreen {
}
}.openNewTab {
}.dismiss { }
}
@Test
......
......@@ -68,13 +68,14 @@ class ThreeDotMenuMainTest {
}.openHelp {
verifyHelpUrl()
}.openTabDrawer {
}.openHomeScreen {
}.openNewTab {
}.dismiss {
}.openThreeDotMenu {
}.openWhatsNew {
verifyWhatsNewURL()
}.openTabDrawer {
}.openHomeScreen {
}
}.openNewTab {
}.dismiss { }
homeScreen {
}.openThreeDotMenu {
......
......@@ -58,7 +58,8 @@ class TopSitesTest {
}.addToFirefoxHome {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
}.openHomeScreen {
}.openNewTab {
}.dismiss {
verifyExistingTopSitesList()
verifyExistingTopSitesTabs(defaultWebPageTitle)
}
......@@ -76,13 +77,15 @@ class TopSitesTest {
}.addToFirefoxHome {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
}.openHomeScreen {
}.openNewTab {
}.dismiss {
verifyExistingTopSitesList()
verifyExistingTopSitesTabs(defaultWebPageTitle)
}.openTopSiteTabWithTitle(title = defaultWebPageTitle) {
verifyUrl(defaultWebPage.url.toString().replace("http://", ""))
}.openTabDrawer {
}.openHomeScreen {
}.openNewTab {
}.dismiss {
verifyExistingTopSitesList()
verifyExistingTopSitesTabs(defaultWebPageTitle)
}.openContextMenuOnTopSitesWithTitle(defaultWebPageTitle) {
......@@ -105,7 +108,8 @@ class TopSitesTest {
}.addToFirefoxHome {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
}.openHomeScreen {
}.openNewTab {
}.dismiss {
verifyExistingTopSitesList()
verifyExistingTopSitesTabs(defaultWebPageTitle)
}.openContextMenuOnTopSitesWithTitle(defaultWebPageTitle) {
......@@ -127,7 +131,8 @@ class TopSitesTest {
}.addToFirefoxHome {
verifySnackBarText("Added to top sites!")
}.openTabDrawer {
}.openHomeScreen {
}.openNewTab {
}.dismiss {
verifyExistingTopSitesList()
verifyExistingTopSitesTabs(defaultWebPageTitle)
}.openContextMenuOnTopSitesWithTitle(defaultWebPageTitle) {
......
......@@ -26,6 +26,7 @@ import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.Until
import kotlinx.android.synthetic.main.fragment_search_dialog.view.*
import org.hamcrest.CoreMatchers.anyOf
import org.hamcrest.CoreMatchers.containsString
import org.hamcrest.CoreMatchers.not
......@@ -250,7 +251,7 @@ private fun assertSuggestionsAreEqualTo(suggestionSize: Int, searchTerm: String)
awesomeBar().perform(typeText(searchTerm))
mDevice.waitForIdle()
onView(withId(R.id.awesomeBar)).check(suggestionsAreEqualTo(suggestionSize))
onView(withId(R.id.awesome_bar)).check(suggestionsAreEqualTo(suggestionSize))
}
private fun assertSuggestionsAreMoreThan(suggestionSize: Int, searchTerm: String) {
......@@ -258,7 +259,7 @@ private fun assertSuggestionsAreMoreThan(suggestionSize: Int, searchTerm: String
awesomeBar().perform(typeText(searchTerm))
mDevice.waitForIdle()
onView(withId(R.id.awesomeBar)).check(suggestionsAreGreaterThan(suggestionSize))
onView(withId(R.id.awesome_bar)).check(suggestionsAreGreaterThan(suggestionSize))
}
private fun assertNoHistoryBookmarks() {
......
......@@ -106,10 +106,10 @@ class SearchRobot {
fun scrollToSearchEngineSettings() {
// Soft keyboard is visible on screen on view access; hide it
onView(allOf(withId(R.id.search_layout))).perform(
onView(allOf(withId(R.id.search_wrapper))).perform(
closeSoftKeyboard()
)
onView(allOf(withId(R.id.awesomeBar))).perform(ViewActions.swipeUp())
onView(allOf(withId(R.id.awesome_bar))).perform(ViewActions.swipeUp())
}
fun clickSearchEngineSettings() {
......@@ -123,6 +123,13 @@ class SearchRobot {
class Transition {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
fun dismiss(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
mDevice.waitForIdle()
mDevice.pressBack()
HomeScreenRobot().interact()
return HomeScreenRobot.Transition()
}
fun openBrowser(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.waitForIdle()
browserToolbarEditView().perform(typeText("mozilla\n"))
......@@ -131,6 +138,14 @@ class SearchRobot {
return BrowserRobot.Transition()
}
fun submitQuery(query: String, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.waitForIdle()
browserToolbarEditView().perform(typeText(query + "\n"))
BrowserRobot().interact()
return BrowserRobot.Transition()
}
fun goToSearchEngine(interact: NavigationToolbarRobot.() -> Unit): NavigationToolbarRobot.Transition {
NavigationToolbarRobot().interact()
return NavigationToolbarRobot.Transition()
......@@ -138,7 +153,7 @@ class SearchRobot {
}
}
private fun awesomeBar() = onView(withId(R.id.awesomeBar))
private fun awesomeBar() = onView(withId(R.id.awesome_bar))
private fun browserToolbarEditView() =
onView(Matchers.allOf(withId(R.id.mozac_browser_toolbar_edit_url_view)))
......@@ -165,6 +180,8 @@ private fun scanButton(): ViewInteraction {
private fun clearButton() = onView(withId(R.id.mozac_browser_toolbar_clear_view))
private fun searchWrapper() = onView(withId(R.id.search_wrapper))
private fun assertSearchEngineURL(searchEngineName: String) {
mDevice.waitNotNull(
Until.findObject(By.textContains("${searchEngineName.toLowerCase()}.com/?q=mozilla")),
......
......@@ -135,12 +135,12 @@ class TabDrawerRobot {
return BrowserRobot.Transition()
}
fun openHomeScreen(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
fun openNewTab(interact: SearchRobot.() -> Unit): SearchRobot.Transition {
mDevice.waitForIdle()
newTabButton().perform(click())
HomeScreenRobot().interact()
return HomeScreenRobot.Transition()
SearchRobot().interact()
return SearchRobot.Transition()
}
fun toggleToNormalTabs(interact: TabDrawerRobot.() -> Unit): Transition {
......
......@@ -16,7 +16,6 @@ import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.accessibility.AccessibilityEvent
import android.widget.Button
import android.widget.LinearLayout
import android.widget.PopupWindow
......@@ -412,19 +411,6 @@ class HomeFragment : Fragment() {
}
}
val args by navArgs<HomeFragmentArgs>()
if (view.context.settings().accessibilityServicesEnabled &&
args.focusOnAddressBar
) {
// We cannot put this in the fragment_home.xml file as it breaks tests
view.toolbar_wrapper.isFocusableInTouchMode = true
viewLifecycleOwner.lifecycleScope.launch {
view.toolbar_wrapper?.requestFocus()
view.toolbar_wrapper?.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED)
}
}
if (browsingModeManager.mode.isPrivate) {
requireActivity().window.addFlags(FLAG_SECURE)
} else {
......@@ -445,7 +431,7 @@ class HomeFragment : Fragment() {
updateTabCounter(requireComponents.core.store.state)
if (args.focusOnAddressBar && FeatureFlags.newSearchExperience) {
if (bundleArgs.getBoolean(FOCUS_ON_ADDRESS_BAR) && FeatureFlags.newSearchExperience) {
navigateToSearch()
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment