diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/ShareButtonTest.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/ShareButtonTest.kt index 2329bde05002..a991dd8ac4d0 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/ShareButtonTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/ShareButtonTest.kt @@ -56,7 +56,7 @@ class ShareButtonTest { // From the 3-dot menu next to the Select share menu navigationToolbar { }.openThreeDotMenu { - clickShareButton() + }.clickShareButton { verifyShareScrim() verifySendToDeviceTitle() verifyShareALinkTitle() 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 c778e3d35e30..a9fca8d5e77f 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt @@ -879,22 +879,26 @@ class SmokeTest { @Test fun shareCollectionTest() { - val webPage = TestAssetHelper.getGenericAsset(mockWebServer, 1) + val firstWebsite = TestAssetHelper.getGenericAsset(mockWebServer, 1) + val secondWebsite = TestAssetHelper.getGenericAsset(mockWebServer, 2) + val sharingApp = "Copy to clipboard" + val urlString = "${secondWebsite.url}\n\n${firstWebsite.url}" navigationToolbar { - }.enterURLAndEnterToBrowser(webPage.url) { + }.enterURLAndEnterToBrowser(firstWebsite.url) { }.openTabDrawer { - createCollection(webPage.title, collectionName) - snackBarButtonClick("VIEW") - } - - homeScreen { + createCollection(firstWebsite.title, collectionName) + }.openNewTab { + }.submitQuery(secondWebsite.url.toString()) { + }.openThreeDotMenu { + }.openSaveToCollection { + }.selectExistingCollection(collectionName) { + }.goToHomescreen { }.expandCollection(collectionName) { - clickShareCollectionButton() - } - - homeScreen { - verifyShareTabsOverlay() + }.clickShareCollectionButton { + verifyShareTabsOverlay(firstWebsite.title, secondWebsite.title) + selectAppToShareWith(sharingApp) + verifyShareIntent(urlString, collectionName) } } @@ -964,21 +968,31 @@ class SmokeTest { @Test fun shareTabsFromTabsTrayTest() { - val website = TestAssetHelper.getGenericAsset(mockWebServer, 1) + val firstWebsite = TestAssetHelper.getGenericAsset(mockWebServer, 1) + val secondWebsite = TestAssetHelper.getGenericAsset(mockWebServer, 2) + val firstWebsiteTitle = firstWebsite.title + val secondWebsiteTitle = secondWebsite.title + val sharingApp = "Copy to clipboard" + val urlString = "${firstWebsite.url}\n\n${secondWebsite.url}" homeScreen { }.openNavigationToolbar { - }.enterURLAndEnterToBrowser(website.url) { - mDevice.waitForIdle() + }.enterURLAndEnterToBrowser(firstWebsite.url) { + }.openTabDrawer { + }.openNewTab { + }.submitQuery(secondWebsite.url.toString()) { }.openTabDrawer { - verifyNormalModeSelected() - verifyExistingTabList() verifyExistingOpenTabs("Test_Page_1") - verifyTabTrayOverflowMenu(true) + verifyExistingOpenTabs("Test_Page_2") }.openTabsListThreeDotMenu { verifyShareAllTabsButton() - clickShareAllTabsButton() - verifyShareTabsOverlay() + }.clickShareAllTabsButton { + verifyShareTabsOverlay(firstWebsiteTitle, secondWebsiteTitle) + selectAppToShareWith(sharingApp) + verifyShareIntent( + urlString, + "$firstWebsiteTitle, $secondWebsiteTitle" + ) } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/CollectionRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/CollectionRobot.kt index 60ddb1d03698..9a45e5043032 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/CollectionRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/CollectionRobot.kt @@ -94,8 +94,6 @@ class CollectionRobot { ) } - fun clickShareCollectionButton() = onView(withId(R.id.collection_share_button)).click() - fun verifyCollectionMenuIsVisible(visible: Boolean) { collectionThreeDotButton() .check( @@ -240,6 +238,14 @@ class CollectionRobot { BrowserRobot().interact() return BrowserRobot.Transition() } + + fun clickShareCollectionButton(interact: ShareOverlayRobot.() -> Unit + ): ShareOverlayRobot.Transition { + onView(withId(R.id.collection_share_button)).click() + + ShareOverlayRobot().interact() + return ShareOverlayRobot.Transition() + } } } diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt index e6666c4e6fce..2f2529cfcfed 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/HomeScreenRobot.kt @@ -136,8 +136,6 @@ class HomeScreenRobot { fun verifyCollectionIcon() = onView(withId(R.id.collection_icon)).check(matches(isDisplayed())) - fun verifyShareTabsOverlay() = assertShareTabsOverlay() - fun togglePrivateBrowsingModeOnOff() { onView(ViewMatchers.withResourceName("privateBrowsingButton")) .perform(click()) @@ -584,13 +582,6 @@ private fun assertTopSiteContextMenuItems() { ) } -private fun assertShareTabsOverlay() { - onView(withId(R.id.shared_site_list)).check(matches(isDisplayed())) - onView(withId(R.id.share_tab_title)).check(matches(isDisplayed())) - onView(withId(R.id.share_tab_favicon)).check(matches(isDisplayed())) - onView(withId(R.id.share_tab_url)).check(matches(isDisplayed())) -} - private fun assertJumpBackInSectionIsDisplayed() = jumpBackInSection().check(matches(isDisplayed())) private fun assertJumpBackInSectionIsNotDisplayed() = jumpBackInSection().check(doesNotExist()) diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ShareOverlayRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ShareOverlayRobot.kt new file mode 100644 index 000000000000..e582740c9b51 --- /dev/null +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ShareOverlayRobot.kt @@ -0,0 +1,80 @@ +package org.mozilla.fenix.ui.robots + +import android.content.Intent +import androidx.test.espresso.Espresso.onView +import androidx.test.espresso.assertion.ViewAssertions.matches +import androidx.test.espresso.intent.Intents +import androidx.test.espresso.intent.matcher.IntentMatchers +import androidx.test.espresso.matcher.ViewMatchers +import androidx.test.espresso.matcher.ViewMatchers.hasSibling +import androidx.test.espresso.matcher.ViewMatchers.isDisplayed +import androidx.test.espresso.matcher.ViewMatchers.withId +import androidx.test.espresso.matcher.ViewMatchers.withText +import androidx.test.uiautomator.UiSelector +import org.hamcrest.Matchers.allOf +import org.mozilla.fenix.R +import org.mozilla.fenix.share.ShareFragment + +class ShareOverlayRobot { + fun verifyShareTabsOverlay(vararg tabsTitles: String) { + onView(withId(R.id.shared_site_list)) + .check(matches(isDisplayed())) + for (tabs in tabsTitles) { + onView(withText(tabs)) + .check( + matches( + allOf( + hasSibling(withId(R.id.share_tab_favicon)), + hasSibling(withId(R.id.share_tab_url)) + ) + ) + ) + } + } + + fun selectAppToShareWith(appName: String) = + mDevice.findObject(UiSelector().text(appName)).click() + + fun verifyShareScrim() = assertShareScrim() + + fun verifySendToDeviceTitle() = assertSendToDeviceTitle() + + fun verifyShareALinkTitle() = assertShareALinkTitle() + + fun verifyShareIntent(text: String, subject: String) { + Intents.intended( + allOf( + IntentMatchers.hasExtra(Intent.EXTRA_TEXT, text), + IntentMatchers.hasExtra(Intent.EXTRA_SUBJECT, subject) + ) + ) + } + + class Transition +} + +private fun shareScrim() = onView(ViewMatchers.withResourceName("closeSharingScrim")) + +private fun assertShareScrim() = + shareScrim().check(matches(ViewMatchers.withAlpha(ShareFragment.SHOW_PAGE_ALPHA))) + +private fun SendToDeviceTitle() = + onView( + allOf( + ViewMatchers.withText("SEND TO DEVICE"), + ViewMatchers.withResourceName("accountHeaderText") + ) + ) + +private fun assertSendToDeviceTitle() = SendToDeviceTitle() + .check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))) + +private fun shareALinkTitle() = + onView( + allOf( + ViewMatchers.withText("ALL ACTIONS"), + ViewMatchers.withResourceName("apps_link_header") + ) + ) + +private fun assertShareALinkTitle() = shareALinkTitle() \ No newline at end of file diff --git a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ThreeDotMenuMainRobot.kt b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ThreeDotMenuMainRobot.kt index fb91e5296907..4d0d87ebea4c 100644 --- a/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ThreeDotMenuMainRobot.kt +++ b/app/src/androidTest/java/org/mozilla/fenix/ui/robots/ThreeDotMenuMainRobot.kt @@ -21,7 +21,6 @@ import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed import androidx.test.espresso.matcher.ViewMatchers.isDisplayed import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility import androidx.test.espresso.matcher.ViewMatchers.withId -import androidx.test.espresso.matcher.ViewMatchers.withResourceName import androidx.test.espresso.matcher.ViewMatchers.withText import androidx.test.platform.app.InstrumentationRegistry import androidx.test.uiautomator.By @@ -37,7 +36,6 @@ import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime import org.mozilla.fenix.helpers.TestHelper.packageName import org.mozilla.fenix.helpers.click import org.mozilla.fenix.helpers.ext.waitNotNull -import org.mozilla.fenix.share.ShareFragment /** * Implementation of Robot Pattern for the three dot (main) menu. @@ -45,7 +43,6 @@ import org.mozilla.fenix.share.ShareFragment @Suppress("ForbiddenComment") class ThreeDotMenuMainRobot { fun verifyShareAllTabsButton() = assertShareAllTabsButton() - fun clickShareAllTabsButton() = shareAllTabsButton().click() fun verifySettingsButton() = assertSettingsButton() fun verifyCustomizeHomeButton() = assertCustomizeHomeButton() fun verifyAddOnsButton() = assertAddOnsButton() @@ -66,19 +63,11 @@ class ThreeDotMenuMainRobot { onView(withId(R.id.mozac_browser_menu_menuView)).perform(swipeUp()) } - fun clickShareButton() { - shareButton().click() - mDevice.waitNotNull(Until.findObject(By.text("ALL ACTIONS")), waitingTime) - } - fun verifyShareTabButton() = assertShareTabButton() fun verifySaveCollection() = assertSaveCollectionButton() fun verifySelectTabs() = assertSelectTabsButton() fun verifyFindInPageButton() = assertFindInPageButton() - fun verifyShareScrim() = assertShareScrim() - fun verifySendToDeviceTitle() = assertSendToDeviceTitle() - fun verifyShareALinkTitle() = assertShareALinkTitle() fun verifyWhatsNewButton() = assertWhatsNewButton() fun verifyAddToTopSitesButton() = assertAddToTopSitesButton() fun verifyAddToMobileHome() = assertAddToMobileHome() @@ -235,6 +224,14 @@ class ThreeDotMenuMainRobot { return BrowserRobot.Transition() } + fun clickShareButton(interact: ShareOverlayRobot.() -> Unit): ShareOverlayRobot.Transition { + shareButton().click() + mDevice.waitNotNull(Until.findObject(By.text("ALL ACTIONS")), waitingTime) + + ShareOverlayRobot().interact() + return ShareOverlayRobot.Transition() + } + fun close(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition { // Close three dot mDevice.pressBack() @@ -364,6 +361,14 @@ class ThreeDotMenuMainRobot { BrowserRobot().interact() return BrowserRobot.Transition() } + + fun clickShareAllTabsButton(interact: ShareOverlayRobot.() -> Unit + ): ShareOverlayRobot.Transition { + shareAllTabsButton().click() + + ShareOverlayRobot().interact() + return ShareOverlayRobot.Transition() + } } } private fun threeDotMenuRecyclerView() = @@ -454,22 +459,6 @@ private fun findInPageButton() = onView(allOf(withText("Find in page"))) private fun assertFindInPageButton() = findInPageButton() -private fun shareScrim() = onView(withResourceName("closeSharingScrim")) - -private fun assertShareScrim() = - shareScrim().check(matches(ViewMatchers.withAlpha(ShareFragment.SHOW_PAGE_ALPHA))) - -private fun SendToDeviceTitle() = - onView(allOf(withText("SEND TO DEVICE"), withResourceName("accountHeaderText"))) - -private fun assertSendToDeviceTitle() = SendToDeviceTitle() - .check(matches(withEffectiveVisibility(Visibility.VISIBLE))) - -private fun shareALinkTitle() = - onView(allOf(withText("ALL ACTIONS"), withResourceName("apps_link_header"))) - -private fun assertShareALinkTitle() = shareALinkTitle() - private fun whatsNewButton() = onView( allOf( withText("What’s New"), diff --git a/automation/taskcluster/androidTest/flank-x86.yml b/automation/taskcluster/androidTest/flank-x86.yml index 8ea8f47f560b..94ce504c6456 100644 --- a/automation/taskcluster/androidTest/flank-x86.yml +++ b/automation/taskcluster/androidTest/flank-x86.yml @@ -38,8 +38,10 @@ gcloud: performance-metrics: true test-targets: - - notPackage org.mozilla.fenix.screenshots - - notPackage org.mozilla.fenix.syncintegration +# - notPackage org.mozilla.fenix.screenshots +# - notPackage org.mozilla.fenix.syncintegration + - class org.mozilla.fenix.ui.SmokeTest#shareCollectionTest + - class org.mozilla.fenix.ui.SmokeTest#shareTabsFromTabsTrayTest device: - model: Pixel2 @@ -53,7 +55,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: 1 + num-test-runs: 5 ### 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