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

Commit

Permalink
run #2
Browse files Browse the repository at this point in the history
  • Loading branch information
Oana Horvath committed Nov 24, 2021
1 parent 302b07e commit 87c8019
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 96 deletions.
13 changes: 13 additions & 0 deletions app/src/androidTest/java/org/mozilla/fenix/ui/ContextMenusTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,17 @@ class ContextMenusTest {
verifyNoLinkImageContextMenuItems(imageResource.url)
}
}

@Test
fun shareSelectedTextTest() {
val genericURL = TestAssetHelper.getGenericAsset(mockWebServer, 1)

navigationToolbar {
}.enterURLAndEnterToBrowser(genericURL.url) {
mDevice.waitForIdle()
longClickMatchingText(genericURL.content)
}.clickShareSelectedText {
verifyAndroidShareLayout()
}
}
}
65 changes: 0 additions & 65 deletions app/src/androidTest/java/org/mozilla/fenix/ui/ShareButtonTest.kt

This file was deleted.

14 changes: 8 additions & 6 deletions app/src/androidTest/java/org/mozilla/fenix/ui/SmokeTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,10 @@ class SmokeTest {
navigationToolbar {
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
}.openThreeDotMenu {
}.sharePage {
verifyShareAppsLayout()
}.clickShareButton {
verifyShareTabLayout()
verifySendToDeviceTitle()
verifyShareALinkTitle()
}
}

Expand Down Expand Up @@ -881,7 +883,7 @@ class SmokeTest {
fun shareCollectionTest() {
val firstWebsite = TestAssetHelper.getGenericAsset(mockWebServer, 1)
val secondWebsite = TestAssetHelper.getGenericAsset(mockWebServer, 2)
val sharingApp = "Copy to clipboard"
val sharingApp = "Gmail"
val urlString = "${secondWebsite.url}\n\n${firstWebsite.url}"

navigationToolbar {
Expand All @@ -898,7 +900,7 @@ class SmokeTest {
}.clickShareCollectionButton {
verifyShareTabsOverlay(firstWebsite.title, secondWebsite.title)
selectAppToShareWith(sharingApp)
verifyShareIntent(urlString, collectionName)
verifySharedTabsIntent(urlString, collectionName)
}
}

Expand Down Expand Up @@ -972,7 +974,7 @@ class SmokeTest {
val secondWebsite = TestAssetHelper.getGenericAsset(mockWebServer, 2)
val firstWebsiteTitle = firstWebsite.title
val secondWebsiteTitle = secondWebsite.title
val sharingApp = "Copy to clipboard"
val sharingApp = "Gmail"
val urlString = "${firstWebsite.url}\n\n${secondWebsite.url}"

homeScreen {
Expand All @@ -989,7 +991,7 @@ class SmokeTest {
}.clickShareAllTabsButton {
verifyShareTabsOverlay(firstWebsiteTitle, secondWebsiteTitle)
selectAppToShareWith(sharingApp)
verifyShareIntent(
verifySharedTabsIntent(
urlString,
"$firstWebsiteTitle, $secondWebsiteTitle"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,14 @@ class BrowserRobot {
HomeScreenRobot().interact()
return HomeScreenRobot.Transition()
}

fun clickShareSelectedText(interact: ShareOverlayRobot.() -> Unit): ShareOverlayRobot.Transition {
val shareTextButton = org.mozilla.fenix.ui.robots.mDevice.findObject(By.textContains("Share"))
shareTextButton.click()

ShareOverlayRobot().interact()
return ShareOverlayRobot.Transition()
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.ViewInteraction
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.closeSoftKeyboard
import androidx.test.espresso.action.ViewActions.pressImeActionButton
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
Expand Down Expand Up @@ -214,9 +215,9 @@ class SearchRobot {

fun submitQuery(query: String, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
sessionLoadedIdlingResource = SessionLoadedIdlingResource()
mDevice.waitForIdle()
browserToolbarEditView().waitForExists(waitingTime)
browserToolbarEditView().setText(query)
mDevice.pressEnter()
pressImeActionButton()

runWithIdleRes(sessionLoadedIdlingResource) {
assertTrue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@ 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.withResourceName
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.uiautomator.By
import androidx.test.uiautomator.UiSelector
import androidx.test.uiautomator.Until
import org.hamcrest.Matchers.allOf
import org.mozilla.fenix.R
import org.mozilla.fenix.share.ShareFragment
import org.mozilla.fenix.helpers.ext.waitNotNull

class ShareOverlayRobot {

// This function verifies the share layout when more than one tab is shared - a list of tabs is shown
fun verifyShareTabsOverlay(vararg tabsTitles: String) {
onView(withId(R.id.shared_site_list))
.check(matches(isDisplayed()))
Expand All @@ -32,16 +37,22 @@ class ShareOverlayRobot {
}
}

fun selectAppToShareWith(appName: String) =
mDevice.findObject(UiSelector().text(appName)).click()
// This function verifies the share layout when a single tab is shared - no tab info shown
fun verifyShareTabLayout() = assertShareTabLayout()

fun verifyShareScrim() = assertShareScrim()
// this verifies the Android sharing layout - not customized for sharing tabs
fun verifyAndroidShareLayout() {
mDevice.waitNotNull(Until.findObject(By.res("android:id/resolver_list")))
}

fun selectAppToShareWith(appName: String) =
mDevice.findObject(UiSelector().text(appName)).clickAndWaitForNewWindow()

fun verifySendToDeviceTitle() = assertSendToDeviceTitle()

fun verifyShareALinkTitle() = assertShareALinkTitle()

fun verifyShareIntent(text: String, subject: String) {
fun verifySharedTabsIntent(text: String, subject: String) {
Intents.intended(
allOf(
IntentMatchers.hasExtra(Intent.EXTRA_TEXT, text),
Expand All @@ -53,28 +64,28 @@ class ShareOverlayRobot {
class Transition
}

private fun shareScrim() = onView(ViewMatchers.withResourceName("closeSharingScrim"))
private fun shareTabsLayout() = onView(withResourceName("shareWrapper"))

private fun assertShareScrim() =
shareScrim().check(matches(ViewMatchers.withAlpha(ShareFragment.SHOW_PAGE_ALPHA)))
private fun assertShareTabLayout() =
shareTabsLayout().check(matches(isDisplayed()))

private fun SendToDeviceTitle() =
private fun sendToDeviceTitle() =
onView(
allOf(
ViewMatchers.withText("SEND TO DEVICE"),
ViewMatchers.withResourceName("accountHeaderText")
withText("SEND TO DEVICE"),
withResourceName("accountHeaderText")
)
)

private fun assertSendToDeviceTitle() = SendToDeviceTitle()
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")
withText("ALL ACTIONS"),
withResourceName("apps_link_header")
)
)

private fun assertShareALinkTitle() = shareALinkTitle()
private fun assertShareALinkTitle() = shareALinkTitle()
Original file line number Diff line number Diff line change
Expand Up @@ -175,13 +175,6 @@ class ThreeDotMenuMainRobot {
return BrowserRobot.Transition()
}

fun sharePage(interact: LibrarySubMenusMultipleSelectionToolbarRobot.() -> Unit): LibrarySubMenusMultipleSelectionToolbarRobot.Transition {
shareButton().click()

LibrarySubMenusMultipleSelectionToolbarRobot().interact()
return LibrarySubMenusMultipleSelectionToolbarRobot.Transition()
}

fun openHelp(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
mDevice.waitNotNull(Until.findObject(By.text("Help")), waitingTime)
helpButton().click()
Expand Down
4 changes: 3 additions & 1 deletion automation/taskcluster/androidTest/flank-x86.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ gcloud:
# - notPackage org.mozilla.fenix.syncintegration
- class org.mozilla.fenix.ui.SmokeTest#shareCollectionTest
- class org.mozilla.fenix.ui.SmokeTest#shareTabsFromTabsTrayTest
- class org.mozilla.fenix.ui.SmokeTest#mainMenuShareButtonTest
- class org.mozilla.fenix.ui.ContextMenusTest#shareSelectedTextTest

device:
- model: Pixel2
Expand All @@ -55,7 +57,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: 5
num-test-runs: 50
### 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 87c8019

Please sign in to comment.