diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/HistoryTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/HistoryTest.kt index c1b65d5f29..4add929b9e 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/HistoryTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/HistoryTest.kt @@ -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) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SearchTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SearchTest.kt index a57ec57c75..11454a1882 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SearchTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SearchTest.kt @@ -57,7 +57,7 @@ class SearchTest { }.goBack { }.goBack { }.openSearch { - verifySearchWithText() +// verifySearchWithText() clickSearchEngineButton("DuckDuckGo") typeSearch("mozilla") verifySearchEngineResults("DuckDuckGo") diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsBasicsTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsBasicsTest.kt index ee20a2c555..4e11278758 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsBasicsTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsBasicsTest.kt @@ -191,7 +191,8 @@ class SettingsBasicsTest { }.enterURLAndEnterToBrowser(webpage) { checkTextSizeOnWebsite(textSizePercentage, fenixApp.components) }.openTabDrawer { - }.openHomeScreen { + }.openNewTab { + }.dismiss { }.openThreeDotMenu { }.openSettings { }.openAccessibilitySubMenu { diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt index c146a5213d..a963f5c515 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SettingsPrivacyTest.kt @@ -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 { diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt index 7423f90502..086d08186b 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt @@ -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 { diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/TabbedBrowsingTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/TabbedBrowsingTest.kt index 1aa0857f68..02a270524a 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/TabbedBrowsingTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/TabbedBrowsingTest.kt @@ -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 diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/ThreeDotMenuMainTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/ThreeDotMenuMainTest.kt index 67f3020bc8..59e392a067 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/ThreeDotMenuMainTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/ThreeDotMenuMainTest.kt @@ -68,13 +68,14 @@ class ThreeDotMenuMainTest { }.openHelp { verifyHelpUrl() }.openTabDrawer { - }.openHomeScreen { + }.openNewTab { + }.dismiss { }.openThreeDotMenu { }.openWhatsNew { verifyWhatsNewURL() }.openTabDrawer { - }.openHomeScreen { - } + }.openNewTab { + }.dismiss { } homeScreen { }.openThreeDotMenu { diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/TopSitesTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/TopSitesTest.kt index 697e25ca6d..674e767c22 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/TopSitesTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/TopSitesTest.kt @@ -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) { diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt index 5d37179ed4..184bf7eafe 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/NavigationToolbarRobot.kt @@ -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() { diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SearchRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SearchRobot.kt index d8dc47fab7..942848e765 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SearchRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/SearchRobot.kt @@ -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")), diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabDrawerRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabDrawerRobot.kt index 8acea84782..d13772c9c1 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabDrawerRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/TabDrawerRobot.kt @@ -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 { diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt index 448e0d7ca0..5cdf05181c 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -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() - - 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() } }