1
0
Fork 0

Added new bookmarks tests (#9878)

Fix for #7417: Fix and re-enable disabled tests
master
Oana Horvath 2020-04-27 18:15:27 +03:00 committed by GitHub
parent a9692d9bce
commit 21894a3cea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 391 additions and 36 deletions

View File

@ -0,0 +1,28 @@
package org.mozilla.fenix.helpers
import androidx.test.espresso.IdlingResource
import androidx.test.espresso.IdlingResource.ResourceCallback
class RecyclerViewIdlingResource constructor(private val recycler: androidx.recyclerview.widget.RecyclerView) :
IdlingResource {
private var callback: ResourceCallback? = null
override fun isIdleNow(): Boolean {
if (recycler.adapter != null && recycler.adapter!!.itemCount > 0) {
if (callback != null) {
callback!!.onTransitionToIdle()
}
return true
}
return false
}
override fun registerIdleTransitionCallback(callback: ResourceCallback) {
this.callback = callback
}
override fun getName(): String {
return RecyclerViewIdlingResource::class.java.name + ":" + recycler.id
}
}

View File

@ -5,23 +5,26 @@
package org.mozilla.fenix.ui
import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
import androidx.test.espresso.IdlingRegistry
import androidx.test.platform.app.InstrumentationRegistry.getInstrumentation
import kotlinx.coroutines.runBlocking
import mozilla.appservices.places.BookmarkRoot
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.bookmarkStorage
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
import org.mozilla.fenix.helpers.HomeActivityTestRule
import org.mozilla.fenix.helpers.RecyclerViewIdlingResource
import org.mozilla.fenix.helpers.TestAssetHelper
import org.mozilla.fenix.helpers.TestHelper.longTapSelectItem
import org.mozilla.fenix.ui.robots.bookmarksMenu
import org.mozilla.fenix.ui.robots.browserScreen
import org.mozilla.fenix.ui.robots.homeScreen
import org.mozilla.fenix.ui.robots.mDevice
import org.mozilla.fenix.ui.robots.multipleSelectionToolbar
import org.mozilla.fenix.ui.robots.navigationToolbar
@ -33,6 +36,11 @@ class BookmarksTest {
private lateinit var mockWebServer: MockWebServer
private val bookmarksFolderName = "New Folder"
private val testBookmark = object {
var title: String = "Bookmark title"
var url: String = "https://www.test.com"
}
private var bookmarksListIdlingResource: RecyclerViewIdlingResource? = null
@get:Rule
val activityTestRule = HomeActivityTestRule()
@ -54,14 +62,28 @@ class BookmarksTest {
val bookmarks = bookmarksStorage?.getTree(BookmarkRoot.Mobile.id)?.children
bookmarks?.forEach { bookmarksStorage.deleteNode(it.guid) }
}
if (bookmarksListIdlingResource != null) {
IdlingRegistry.getInstance().unregister(bookmarksListIdlingResource!!)
}
}
@Test
fun noBookmarkItemsTest() {
fun defaultDesktopBookmarksFoldersTest() {
homeScreen {
}.openThreeDotMenu {
}.openBookmarks {
verifyEmptyBookmarksList()
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
selectFolder("Desktop Bookmarks")
verifyFolderTitle("Bookmarks Menu")
verifyFolderTitle("Bookmarks Toolbar")
verifyFolderTitle("Other Bookmarks")
verifySignInToSyncButton()
}.clickSingInToSyncButton {
verifyTurnOnSyncToolbarTitle()
}
}
@ -90,12 +112,15 @@ class BookmarksTest {
}.openThreeDotMenu {
}.openLibrary {
}.openBookmarks {
verifyBookmarkedURL(defaultWebPage.url)
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
verifyBookmarkedURL(defaultWebPage.url.toString())
verifyBookmarkFavicon(defaultWebPage.url)
}
}
@Ignore("Intermittent failure on Nexus 6: https://github.com/mozilla-mobile/fenix/issues/8772")
@Test
fun createBookmarkFolderTest() {
homeScreen {
@ -105,7 +130,11 @@ class BookmarksTest {
verifyKeyboardVisible()
addNewFolderName(bookmarksFolderName)
saveNewFolder()
getInstrumentation().waitForIdleSync()
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
verifyFolderTitle(bookmarksFolderName)
verifyKeyboardHidden()
}
@ -124,7 +153,7 @@ class BookmarksTest {
}
@Test
fun editBookmarkViewTest() {
fun editBookmarkTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
browserScreen {
@ -132,14 +161,25 @@ class BookmarksTest {
}.openThreeDotMenu {
}.openLibrary {
}.openBookmarks {
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
}.openThreeDotMenu(defaultWebPage.url) {
IdlingRegistry.getInstance().unregister(bookmarksListIdlingResource!!)
}.clickEdit {
verifyEditBookmarksView()
verifyBookmarkNameEditBox()
verifyBookmarkURLEditBox()
verifyParentFolderSelector()
navigateUp()
verifyBookmarksMenuView()
changeBookmarkTitle(testBookmark.title)
changeBookmarkUrl(testBookmark.url)
saveEditBookmark()
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
verifyBookmarkTitle(testBookmark.title)
verifyBookmarkedURL(testBookmark.url)
verifyKeyboardHidden()
}
}
@ -152,12 +192,36 @@ class BookmarksTest {
}.openThreeDotMenu {
}.openLibrary {
}.openBookmarks {
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
}.openThreeDotMenu(defaultWebPage.url) {
}.clickCopy {
verifyCopySnackBarText()
}
}
@Test
fun threeDotMenuShareBookmarkTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
browserScreen {
createBookmark(defaultWebPage.url)
}.openThreeDotMenu {
}.openLibrary {
}.openBookmarks {
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
}.openThreeDotMenu(defaultWebPage.url) {
}.clickShare {
verifyShareOverlay()
verifyShareBookmarkFavicon()
verifyShareBookmarkTitle()
verifyShareBookmarkUrl()
}
}
@Test
fun openBookmarkInNewTabTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
@ -167,6 +231,9 @@ class BookmarksTest {
}.openThreeDotMenu {
}.openLibrary {
}.openBookmarks {
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
}.openThreeDotMenu(defaultWebPage.url) {
}.clickOpenInNewTab {
verifyPageContent(defaultWebPage.content)
@ -184,6 +251,9 @@ class BookmarksTest {
}.openThreeDotMenu {
}.openLibrary {
}.openBookmarks {
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
}.openThreeDotMenu(defaultWebPage.url) {
}.clickOpenInPrivateTab {
verifyPageContent(defaultWebPage.content)
@ -201,9 +271,34 @@ class BookmarksTest {
}.openThreeDotMenu {
}.openLibrary {
}.openBookmarks {
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
}.openThreeDotMenu(defaultWebPage.url) {
}.clickDelete {
verifyDeleteSnackBarText()
verifyUndoDeleteSnackBarButton()
}
}
@Test
fun undoDeleteBookmarkTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
browserScreen {
createBookmark(defaultWebPage.url)
}.openThreeDotMenu {
}.openLibrary {
}.openBookmarks {
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
}.openThreeDotMenu(defaultWebPage.url) {
}.clickDelete {
verifyUndoDeleteSnackBarButton()
clickUndoDeleteButton()
verifySnackBarHidden()
verifyBookmarkedURL(defaultWebPage.url.toString())
}
}
@ -216,6 +311,10 @@ class BookmarksTest {
}.openThreeDotMenu {
}.openLibrary {
}.openBookmarks {
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
longTapSelectItem(defaultWebPage.url)
}
@ -240,6 +339,10 @@ class BookmarksTest {
}.openThreeDotMenu {
}.openLibrary {
}.openBookmarks {
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
longTapSelectItem(defaultWebPage.url)
openActionBarOverflowOrOptionsMenu(activityTestRule.activity)
}
@ -260,6 +363,10 @@ class BookmarksTest {
}.openThreeDotMenu {
}.openLibrary {
}.openBookmarks {
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
longTapSelectItem(defaultWebPage.url)
openActionBarOverflowOrOptionsMenu(activityTestRule.activity)
}
@ -271,7 +378,6 @@ class BookmarksTest {
}
}
@Ignore("Temp disable: Nexus 6 failures - issue: https://github.com/mozilla-mobile/fenix/issues/7417")
@Test
fun deleteMultipleSelectionTest() {
val firstWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
@ -283,6 +389,10 @@ class BookmarksTest {
}.openThreeDotMenu {
}.openLibrary {
}.openBookmarks {
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
longTapSelectItem(firstWebPage.url)
longTapSelectItem(secondWebPage.url)
openActionBarOverflowOrOptionsMenu(activityTestRule.activity)
@ -298,7 +408,7 @@ class BookmarksTest {
}
@Test
fun shareButtonTest() {
fun multipleSelectionShareButtonTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
browserScreen {
@ -306,6 +416,10 @@ class BookmarksTest {
}.openThreeDotMenu {
}.openLibrary {
}.openBookmarks {
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
longTapSelectItem(defaultWebPage.url)
}
@ -318,7 +432,6 @@ class BookmarksTest {
}
}
@Ignore("Temp disable: Nexus 6 failures - issue: https://github.com/mozilla-mobile/fenix/issues/7417")
@Test
fun multipleBookmarkDeletions() {
homeScreen {
@ -344,4 +457,78 @@ class BookmarksTest {
verifyFolderTitle("3")
}
}
@Test
fun changeBookmarkParentFolderTest() {
val defaultWebPage = TestAssetHelper.getGenericAsset(mockWebServer, 1)
browserScreen {
createBookmark(defaultWebPage.url)
}.openThreeDotMenu {
}.openLibrary {
}.openBookmarks {
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
}.openThreeDotMenu(defaultWebPage.url) {
IdlingRegistry.getInstance().unregister(bookmarksListIdlingResource!!)
}.clickEdit {
verifyEditBookmarksView()
changeBookmarkTitle(testBookmark.title)
saveEditBookmark()
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
createFolder(bookmarksFolderName)
IdlingRegistry.getInstance().unregister(bookmarksListIdlingResource!!)
}.openThreeDotMenu(testBookmark.title) {
}.clickEdit {
clickParentFolderSelector()
selectFolder(bookmarksFolderName)
navigateUp()
saveEditBookmark()
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
selectFolder(bookmarksFolderName)
verifyBookmarkedURL(defaultWebPage.url.toString())
IdlingRegistry.getInstance().unregister(bookmarksListIdlingResource!!)
}
}
@Test
fun navigateBookmarksFoldersTest() {
homeScreen {
}.openThreeDotMenu {
}.openBookmarks {
createFolder("1")
getInstrumentation().waitForIdleSync()
selectFolder("1")
createFolder("2")
getInstrumentation().waitForIdleSync()
selectFolder("2")
verifyCurrentFolderTitle("2")
navigateUp()
verifyCurrentFolderTitle("1")
mDevice.pressBack()
verifyBookmarksMenuView()
}
}
@Test
fun cantSelectDesktopFoldersTest() {
homeScreen {
}.openThreeDotMenu {
}.openBookmarks {
bookmarksListIdlingResource =
RecyclerViewIdlingResource(activityTestRule.activity.findViewById(R.id.bookmark_list))
IdlingRegistry.getInstance().register(bookmarksListIdlingResource!!)
longTapDesktopFolder("Desktop Bookmarks")
verifySelectDefaultFolderSnackBarText()
}
}
}

View File

@ -8,9 +8,13 @@ package org.mozilla.fenix.ui.robots
import android.net.Uri
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.clearText
import androidx.test.espresso.action.ViewActions.longClick
import androidx.test.espresso.action.ViewActions.typeText
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
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.withChild
import androidx.test.espresso.matcher.ViewMatchers.withContentDescription
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
@ -20,7 +24,10 @@ import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.uiautomator.By
import androidx.test.uiautomator.Until
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.By.res
import androidx.test.uiautomator.By.text
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiSelector
import org.hamcrest.Matchers.allOf
import org.hamcrest.Matchers.containsString
import org.junit.Assert.assertEquals
@ -40,19 +47,37 @@ class BookmarksRobot {
fun verifyBookmarkFavicon(forUrl: Uri) = assertBookmarkFavicon(forUrl)
fun verifyBookmarkedURL(url: Uri) = assertBookmarkURL(url)
fun verifyBookmarkedURL(url: String) = assertBookmarkURL(url)
fun verifyFolderTitle(title: String) {
mDevice.waitNotNull(
Until.findObject(By.text(title)),
Until.findObject(text(title)),
TestAssetHelper.waitingTime
)
assertFolderTitle(title)
}
fun verifyDeleteSnackBarText() = assertDeleteSnackBarText()
fun verifyBookmarkTitle(title: String) {
mDevice.waitNotNull(
Until.findObject(text(title)),
TestAssetHelper.waitingTime
)
assertBookmarkTitle(title)
}
fun verifyCopySnackBarText() = assertCopySnackBarText()
fun verifyDeleteSnackBarText() = assertSnackBarText("Deleted")
fun verifyUndoDeleteSnackBarButton() = assertUndoDeleteSnackBarButton()
fun verifySnackBarHidden() {
mDevice.waitNotNull(
Until.gone(By.text("UNDO")),
TestAssetHelper.waitingTime
)
onView(withId(R.id.snackbar_layout)).check(doesNotExist())
}
fun verifyCopySnackBarText() = assertSnackBarText("URL copied")
fun verifyEditBookmarksView() = assertEditBookmarksView()
@ -66,6 +91,28 @@ class BookmarksRobot {
fun verifyKeyboardVisible() = assertKeyboardVisibility(isExpectedToBeVisible = true)
fun verifyShareOverlay() = assertShareOverlay()
fun verifyShareBookmarkFavicon() = assertShareBookmarkFavicon()
fun verifyShareBookmarkTitle() = assertShareBookmarkTitle()
fun verifyShareBookmarkUrl() = assertShareBookmarkUrl()
fun verifySelectDefaultFolderSnackBarText() = assertSnackBarText("Cant edit default folders")
fun verifyCurrentFolderTitle(title: String) {
onView(
allOf(
withText(title),
withParent(withId(R.id.navigationToolbar))
)
)
.check(matches(isDisplayed()))
}
fun verifySignInToSyncButton() = signInToSyncButton().check(matches(isDisplayed()))
fun createFolder(name: String) {
clickAddFolderButton()
addNewFolderName(name)
@ -74,15 +121,17 @@ class BookmarksRobot {
fun clickAddFolderButton() {
mDevice.waitNotNull(
Until.findObject(By.res("org.mozilla.fenix.debug:id/add_bookmark_folder")),
Until.findObject(By.desc("Add folder")),
TestAssetHelper.waitingTime
)
addFolderButton().click()
}
fun addNewFolderName(name: String) {
addFolderTitleField().click()
addFolderTitleField().perform(typeText(name))
addFolderTitleField()
.click()
.perform(clearText())
.perform(typeText(name))
}
fun saveNewFolder() {
@ -93,6 +142,33 @@ class BookmarksRobot {
goBackButton().click()
}
fun clickUndoDeleteButton() {
snackBarUndoButton().click()
}
fun changeBookmarkTitle(newTitle: String) {
bookmarkNameEditBox()
.perform(clearText())
.perform(typeText(newTitle))
}
fun changeBookmarkUrl(newUrl: String) {
bookmarkURLEditBox()
.perform(clearText())
.perform(typeText(newUrl))
}
fun saveEditBookmark() {
saveBookmarkButton().click()
mDevice.waitNotNull(Until.findObject(text("Bookmarks")))
}
fun clickParentFolderSelector() = bookmarkFolderSelector().click()
fun selectFolder(title: String) = onView(withText(title)).click()
fun longTapDesktopFolder(title: String) = onView(withText(title)).perform(longClick())
class Transition {
fun goBack(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
goBackButton().click()
@ -102,6 +178,7 @@ class BookmarksRobot {
}
fun openThreeDotMenu(interact: ThreeDotMenuBookmarksRobot.() -> Unit): ThreeDotMenuBookmarksRobot.Transition {
mDevice.waitNotNull(Until.findObject(res("org.mozilla.fenix.debug:id/overflow_menu")))
threeDotMenu().click()
ThreeDotMenuBookmarksRobot().interact()
@ -109,6 +186,7 @@ class BookmarksRobot {
}
fun openThreeDotMenu(bookmarkTitle: String, interact: ThreeDotMenuBookmarksRobot.() -> Unit): ThreeDotMenuBookmarksRobot.Transition {
mDevice.waitNotNull(Until.findObject(res("org.mozilla.fenix.debug:id/overflow_menu")))
threeDotMenu(bookmarkTitle).click()
ThreeDotMenuBookmarksRobot().interact()
@ -121,6 +199,13 @@ class BookmarksRobot {
ThreeDotMenuBookmarksRobot().interact()
return ThreeDotMenuBookmarksRobot.Transition()
}
fun clickSingInToSyncButton(interact: SettingsTurnOnSyncRobot.() -> Unit): SettingsTurnOnSyncRobot.Transition {
signInToSyncButton().click()
SettingsTurnOnSyncRobot().interact()
return SettingsTurnOnSyncRobot.Transition()
}
}
}
@ -131,17 +216,19 @@ fun bookmarksMenu(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transitio
private fun goBackButton() = onView(withContentDescription("Navigate up"))
private fun bookmarkFavicon(url: String) = onView(allOf(
withId(R.id.favicon),
withParent(withParent(
withChild(allOf(withId(R.id.url), withText(url))))
))
private fun bookmarkFavicon(url: String) = onView(
allOf(
withId(R.id.favicon),
withParent(
withParent(
withChild(allOf(withId(R.id.url), withText(url)))
)
)
)
)
private fun bookmarkURL(url: String) = onView(allOf(withId(R.id.url), withText(url)))
private fun folderTitle() = onView(withId(R.id.title))
private fun addFolderButton() = onView(withId(R.id.add_bookmark_folder))
private fun addFolderTitleField() = onView(withId(R.id.bookmarkNameEdit))
@ -166,6 +253,18 @@ private fun threeDotMenu() = onView(withId(R.id.overflow_menu)).check(matches(wi
private fun snackBarText() = onView(withId(R.id.snackbar_text))
private fun snackBarUndoButton() = onView(withId(R.id.snackbar_btn))
private fun bookmarkNameEditBox() = onView(withId(R.id.bookmarkNameEdit))
private fun bookmarkFolderSelector() = onView(withId(R.id.bookmarkParentFolderSelector))
private fun bookmarkURLEditBox() = onView(withId(R.id.bookmarkUrlEdit))
private fun saveBookmarkButton() = onView(withId(R.id.save_bookmark_button))
private fun signInToSyncButton() = onView(withId(R.id.bookmark_folders_sign_in))
private fun assertBookmarksView() {
onView(
allOf(
@ -187,18 +286,20 @@ private fun assertBookmarkFavicon(forUrl: Uri) = bookmarkFavicon(forUrl.toString
)
)
private fun assertBookmarkURL(expectedURL: Uri) = bookmarkURL(expectedURL.toString())
.check(matches(ViewMatchers.isCompletelyDisplayed()))
.check(matches(withText(containsString(expectedURL.toString()))))
private fun assertBookmarkURL(expectedURL: String) =
mDevice.findObject(UiSelector().text(expectedURL))
private fun assertFolderTitle(expectedTitle: String) = folderTitle()
.check(matches(withText(expectedTitle)))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
private fun assertFolderTitle(expectedTitle: String) =
onView(withText(expectedTitle)).check(matches(isDisplayed()))
private fun assertDeleteSnackBarText() =
snackBarText().check(matches(withText(containsString("Deleted"))))
private fun assertBookmarkTitle(expectedTitle: String) =
onView(withText(expectedTitle)).check(matches(isDisplayed()))
private fun assertCopySnackBarText() = snackBarText().check(matches(withText("URL copied")))
private fun assertUndoDeleteSnackBarButton() =
snackBarUndoButton().check(matches(withText("UNDO")))
private fun assertSnackBarText(text: String) =
snackBarText().check(matches(withText(containsString(text))))
private fun assertEditBookmarksView() = onView(withText("Edit bookmark"))
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
@ -222,3 +323,15 @@ private fun assertKeyboardVisibility(isExpectedToBeVisible: Boolean) =
.executeShellCommand("dumpsys input_method | grep mInputShown")
.contains("mInputShown=true")
)
private fun assertShareOverlay() =
onView(withId(R.id.shareWrapper)).check(matches(ViewMatchers.isDisplayed()))
private fun assertShareBookmarkTitle() =
onView(withId(R.id.share_tab_title)).check(matches(ViewMatchers.isDisplayed()))
private fun assertShareBookmarkFavicon() =
onView(withId(R.id.share_tab_favicon)).check(matches(ViewMatchers.isDisplayed()))
private fun assertShareBookmarkUrl() =
onView(withId(R.id.share_tab_url)).check(matches(isDisplayed()))

View File

@ -327,7 +327,7 @@ class BrowserRobot {
)
fun openThreeDotMenu(interact: ThreeDotMenuMainRobot.() -> Unit): ThreeDotMenuMainRobot.Transition {
mDevice.waitForIdle()
mDevice.waitForIdle(waitingTime)
threeDotButton().perform(ViewActions.click())
ThreeDotMenuMainRobot().interact()

View File

@ -5,12 +5,20 @@
package org.mozilla.fenix.ui.robots
import androidx.test.espresso.Espresso
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.assertion.ViewAssertions
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.withParent
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import org.hamcrest.CoreMatchers
import org.hamcrest.Matchers.allOf
import org.mozilla.fenix.R
import org.mozilla.fenix.helpers.click
/**
@ -23,6 +31,8 @@ class SettingsTurnOnSyncRobot {
fun tapOnUseEmailToSignIn() = useEmailButton().click()
fun verifyTurnOnSyncToolbarTitle() = assertTurnOnSyncToolbarTitle()
class Transition {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
@ -45,3 +55,11 @@ private fun assertReadyToScan() = Espresso.onView(ViewMatchers.withText("Ready t
.check(ViewAssertions.matches(ViewMatchers.withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
private fun useEmailButton() = Espresso.onView(ViewMatchers.withText("Use email instead"))
private fun assertTurnOnSyncToolbarTitle() =
onView(
allOf(
withParent(withId(R.id.navigationToolbar)),
withText("Turn on Sync")
)
).check(matches(isDisplayed()))

View File

@ -31,6 +31,13 @@ class ThreeDotMenuBookmarksRobot {
return BookmarksRobot.Transition()
}
fun clickShare(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition {
shareButton().click()
BookmarksRobot().interact()
return BookmarksRobot.Transition()
}
fun clickOpenInNewTab(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
openInNewTabButton().click()
@ -58,6 +65,8 @@ private fun editButton() = onView(withText("Edit"))
private fun copyButton() = onView(withText("Copy"))
private fun shareButton() = onView(withText("Share"))
private fun openInNewTabButton() = onView(withText("Open in new tab"))
private fun openInPrivateTabButton() = onView(withText("Open in private tab"))