For #21002: improves the share tabs smoke tests coverage
parent
693a1dd8f7
commit
aff3e4b9dd
@ -1,65 +0,0 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
package org.mozilla.fenix.ui
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
import okhttp3.mockwebserver.MockWebServer
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper
|
||||
import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||
|
||||
/**
|
||||
* Tests for verifying basic functionality of history
|
||||
*
|
||||
*/
|
||||
|
||||
class ShareButtonTest {
|
||||
/* ktlint-disable no-blank-line-before-rbrace */ // This imposes unreadable grouping.
|
||||
|
||||
private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
||||
private lateinit var mockWebServer: MockWebServer
|
||||
|
||||
@get:Rule
|
||||
val activityTestRule = HomeActivityTestRule()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
mockWebServer = MockWebServer().apply {
|
||||
dispatcher = AndroidAssetDispatcher()
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
mockWebServer.shutdown()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun ShareButtonAppearanceTest() {
|
||||
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
|
||||
|
||||
// - Visit a URL, wait until it's loaded
|
||||
navigationToolbar {
|
||||
}.enterURLAndEnterToBrowser(defaultWebPage.url) {
|
||||
mDevice.waitForIdle()
|
||||
}
|
||||
|
||||
// From the 3-dot menu next to the Select share menu
|
||||
navigationToolbar {
|
||||
}.openThreeDotMenu {
|
||||
clickShareButton()
|
||||
verifyShareScrim()
|
||||
verifySendToDeviceTitle()
|
||||
verifyShareALinkTitle()
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
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.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.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()))
|
||||
for (tabs in tabsTitles) {
|
||||
onView(withText(tabs))
|
||||
.check(
|
||||
matches(
|
||||
allOf(
|
||||
hasSibling(withId(R.id.share_tab_favicon)),
|
||||
hasSibling(withId(R.id.share_tab_url))
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// This function verifies the share layout when a single tab is shared - no tab info shown
|
||||
fun verifyShareTabLayout() = assertShareTabLayout()
|
||||
|
||||
// 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 verifySharedTabsIntent(text: String, subject: String) {
|
||||
Intents.intended(
|
||||
allOf(
|
||||
IntentMatchers.hasExtra(Intent.EXTRA_TEXT, text),
|
||||
IntentMatchers.hasExtra(Intent.EXTRA_SUBJECT, subject)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
class Transition
|
||||
}
|
||||
|
||||
private fun shareTabsLayout() = onView(withResourceName("shareWrapper"))
|
||||
|
||||
private fun assertShareTabLayout() =
|
||||
shareTabsLayout().check(matches(isDisplayed()))
|
||||
|
||||
private fun sendToDeviceTitle() =
|
||||
onView(
|
||||
allOf(
|
||||
withText("SEND TO DEVICE"),
|
||||
withResourceName("accountHeaderText")
|
||||
)
|
||||
)
|
||||
|
||||
private fun assertSendToDeviceTitle() = sendToDeviceTitle()
|
||||
.check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||
|
||||
private fun shareALinkTitle() =
|
||||
onView(
|
||||
allOf(
|
||||
withText("ALL ACTIONS"),
|
||||
withResourceName("apps_link_header")
|
||||
)
|
||||
)
|
||||
|
||||
private fun assertShareALinkTitle() = shareALinkTitle()
|
Loading…
Reference in New Issue