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

Commit

Permalink
run #1
Browse files Browse the repository at this point in the history
  • Loading branch information
Oana Horvath committed Nov 24, 2021
1 parent 693a1dd commit 302b07e
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ShareButtonTest {
// From the 3-dot menu next to the Select share menu
navigationToolbar {
}.openThreeDotMenu {
clickShareButton()
}.clickShareButton {
verifyShareScrim()
verifySendToDeviceTitle()
verifyShareALinkTitle()
Expand Down
54 changes: 34 additions & 20 deletions app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down Expand Up @@ -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"
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ class CollectionRobot {
)
}

fun clickShareCollectionButton() = onView(withId(R.id.collection_share_button)).click()

fun verifyCollectionMenuIsVisible(visible: Boolean) {
collectionThreeDotButton()
.check(
Expand Down Expand Up @@ -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()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -37,15 +36,13 @@ 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.
*/
@Suppress("ForbiddenComment")
class ThreeDotMenuMainRobot {
fun verifyShareAllTabsButton() = assertShareAllTabsButton()
fun clickShareAllTabsButton() = shareAllTabsButton().click()
fun verifySettingsButton() = assertSettingsButton()
fun verifyCustomizeHomeButton() = assertCustomizeHomeButton()
fun verifyAddOnsButton() = assertAddOnsButton()
Expand All @@ -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()
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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() =
Expand Down Expand Up @@ -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"),
Expand Down
8 changes: 5 additions & 3 deletions automation/taskcluster/androidTest/flank-x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 302b07e

Please sign in to comment.