Create homeview share dialog UITest (#5160)
Share Button UI test added Collection test steps createdmaster
parent
9dd9400600
commit
a1be6183f3
|
@ -0,0 +1,72 @@
|
|||
/* 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.Rule
|
||||
import org.junit.Before
|
||||
import org.junit.After
|
||||
import org.junit.Ignore
|
||||
import org.junit.Test
|
||||
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||
|
||||
/**
|
||||
* Tests for verifying basic functionality of history
|
||||
*
|
||||
*/
|
||||
|
||||
class CollectionTest {
|
||||
/* 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 {
|
||||
setDispatcher(AndroidAssetDispatcher())
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
mockWebServer.shutdown()
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun AddTabToCollectionTest() {
|
||||
// open a webpage, and add currently opened tab to existing collection
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun OpenTabFromCollectionTest() {
|
||||
// Open one tab from Collection in the Homescreen view
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun RenameCollectionTest() {
|
||||
// Rename Collection from the Homescreen
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
fun DeleteCollectionTest() {
|
||||
// Delete Collection from the Homescreen
|
||||
}
|
||||
|
||||
fun CreateCollection() {
|
||||
// Open 3 webpages, and save each of them to a single collection
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
/* 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 {
|
||||
setDispatcher(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) {
|
||||
verifyPageContent(defaultWebPage.content)
|
||||
}
|
||||
|
||||
// From the 3-dot menu next to the Select share menu
|
||||
navigationToolbar {
|
||||
}.openThreeDotMenu {
|
||||
|
||||
// Verify Share button exists, and click it
|
||||
verifyShareButton()
|
||||
clickShareButton()
|
||||
|
||||
// Verify title
|
||||
// Verify Send to Device title
|
||||
// Verify Share a link title
|
||||
verifyShareDialogTitle()
|
||||
verifySendToDeviceTitle()
|
||||
verifyShareALinkTitle()
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,9 +9,10 @@ package org.mozilla.fenix.ui.robots
|
|||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withResourceName
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import androidx.test.uiautomator.By
|
||||
import androidx.test.uiautomator.UiDevice
|
||||
|
@ -34,8 +35,15 @@ class ThreeDotMenuRobot {
|
|||
fun verifyRefreshButton() = assertRefreshButton()
|
||||
fun verifyCloseAllTabsButton() = assertCloseAllTabsButton()
|
||||
fun verifyShareButton() = assertShareButton()
|
||||
fun clickShareButton() {
|
||||
shareButton().click()
|
||||
mDevice.wait(Until.findObject(By.text("SHARE A LINK")), waitingTime)
|
||||
}
|
||||
fun verifySaveCollection() = assertSaveCollectionButton()
|
||||
fun verifyFindInPageButton() = assertFindInPageButton()
|
||||
fun verifyShareDialogTitle() = assertShareDialogTitle()
|
||||
fun verifySendToDeviceTitle() = assertSendToDeviceTitle()
|
||||
fun verifyShareALinkTitle() = assertShareALinkTitle()
|
||||
|
||||
class Transition {
|
||||
|
||||
|
@ -106,6 +114,7 @@ class ThreeDotMenuRobot {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun threeDotMenuRecyclerViewExists() {
|
||||
onView(withId(R.id.mozac_browser_menu_recyclerView)).check(matches(isDisplayed()))
|
||||
}
|
||||
|
@ -137,7 +146,7 @@ private fun closeAllTabsButton() = onView(allOf(withText("Close all tabs")))
|
|||
private fun assertCloseAllTabsButton() = closeAllTabsButton()
|
||||
.check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||
|
||||
private fun shareButton() = onView(allOf(withText("Share tabs")))
|
||||
private fun shareButton() = onView(allOf(withText("Share")))
|
||||
private fun assertShareButton() = shareButton()
|
||||
.check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||
|
||||
|
@ -147,4 +156,13 @@ private fun assertSaveCollectionButton() = saveCollectionButton()
|
|||
|
||||
private fun findInPageButton() = onView(allOf(withText("Find in page")))
|
||||
private fun assertFindInPageButton() = findInPageButton()
|
||||
private fun ShareDialogTitle() = onView(allOf(withText("Send and Share"), withResourceName("closeButton")))
|
||||
private fun assertShareDialogTitle() = ShareDialogTitle()
|
||||
.check(matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
||||
|
||||
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("SHARE A LINK"), withResourceName("link_header")))
|
||||
private fun assertShareALinkTitle() = ShareALinkTitle()
|
||||
|
|
Loading…
Reference in New Issue