2019-05-16 02:32:25 +02:00
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
|
|
@file:Suppress("TooManyFunctions")
|
|
|
|
|
|
|
|
|
|
package org.mozilla.fenix.ui.robots
|
|
|
|
|
|
2020-05-22 20:06:24 +02:00
|
|
|
|
import android.view.View
|
2020-02-06 22:06:28 +01:00
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
2019-05-16 02:32:25 +02:00
|
|
|
|
import androidx.test.espresso.Espresso.onView
|
2020-07-09 18:15:10 +02:00
|
|
|
|
import androidx.test.espresso.Espresso.pressBack
|
2020-05-22 20:06:24 +02:00
|
|
|
|
import androidx.test.espresso.UiController
|
|
|
|
|
import androidx.test.espresso.ViewAction
|
2019-10-28 20:10:19 +01:00
|
|
|
|
import androidx.test.espresso.action.ViewActions
|
2020-05-22 20:06:24 +02:00
|
|
|
|
import androidx.test.espresso.action.ViewActions.click
|
2020-02-07 18:07:17 +01:00
|
|
|
|
import androidx.test.espresso.assertion.ViewAssertions
|
2019-07-16 22:02:12 +02:00
|
|
|
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
2020-03-02 20:40:52 +01:00
|
|
|
|
import androidx.test.espresso.contrib.RecyclerViewActions
|
2020-06-05 19:59:08 +02:00
|
|
|
|
import androidx.test.espresso.matcher.RootMatchers
|
2019-05-16 02:32:25 +02:00
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers
|
2020-03-02 20:40:52 +01:00
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
2020-02-06 22:06:28 +01:00
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
|
2020-05-22 20:06:24 +02:00
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.isAssignableFrom
|
2020-03-02 20:40:52 +01:00
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
|
2019-09-10 21:03:47 +02:00
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
2019-10-28 20:10:19 +01:00
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
2019-11-12 02:10:14 +01:00
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
2019-09-10 21:03:47 +02:00
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withResourceName
|
2019-11-12 02:10:14 +01:00
|
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
2019-05-16 02:32:25 +02:00
|
|
|
|
import androidx.test.platform.app.InstrumentationRegistry
|
2019-07-16 22:02:12 +02:00
|
|
|
|
import androidx.test.uiautomator.By
|
2019-05-16 02:32:25 +02:00
|
|
|
|
import androidx.test.uiautomator.UiDevice
|
2019-07-16 22:02:12 +02:00
|
|
|
|
import androidx.test.uiautomator.Until
|
2020-05-22 20:06:24 +02:00
|
|
|
|
import org.hamcrest.Matcher
|
2019-05-16 02:32:25 +02:00
|
|
|
|
import org.hamcrest.Matchers.allOf
|
|
|
|
|
import org.mozilla.fenix.R
|
2019-07-16 22:02:12 +02:00
|
|
|
|
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
2019-05-16 02:32:25 +02:00
|
|
|
|
import org.mozilla.fenix.helpers.click
|
2019-10-23 23:40:28 +02:00
|
|
|
|
import org.mozilla.fenix.helpers.ext.waitNotNull
|
2019-09-26 23:25:34 +02:00
|
|
|
|
import org.mozilla.fenix.share.ShareFragment
|
2019-05-16 02:32:25 +02:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Implementation of Robot Pattern for the three dot (main) menu.
|
|
|
|
|
*/
|
2019-10-03 18:30:55 +02:00
|
|
|
|
class ThreeDotMenuMainRobot {
|
2019-05-16 02:32:25 +02:00
|
|
|
|
fun verifySettingsButton() = assertSettingsButton()
|
2020-07-09 18:15:10 +02:00
|
|
|
|
fun verifyAddOnsButton() = assertAddOnsButton()
|
2019-10-29 14:36:37 +01:00
|
|
|
|
fun verifyHistoryButton() = assertHistoryButton()
|
|
|
|
|
fun verifyBookmarksButton() = assertBookmarksButton()
|
2020-07-09 18:15:10 +02:00
|
|
|
|
fun verifySyncedTabsButton() = assertSyncedTabsButton()
|
2019-05-16 02:32:25 +02:00
|
|
|
|
fun verifyHelpButton() = assertHelpButton()
|
2019-07-16 22:02:12 +02:00
|
|
|
|
fun verifyThreeDotMenuExists() = threeDotMenuRecyclerViewExists()
|
|
|
|
|
fun verifyForwardButton() = assertForwardButton()
|
2019-11-12 02:10:14 +01:00
|
|
|
|
fun verifyAddBookmarkButton() = assertAddBookmarkButton()
|
|
|
|
|
fun verifyEditBookmarkButton() = assertEditBookmarkButton()
|
2019-07-16 22:02:12 +02:00
|
|
|
|
fun verifyRefreshButton() = assertRefreshButton()
|
2019-08-27 19:56:12 +02:00
|
|
|
|
fun verifyCloseAllTabsButton() = assertCloseAllTabsButton()
|
|
|
|
|
fun verifyShareButton() = assertShareButton()
|
2020-02-07 18:07:17 +01:00
|
|
|
|
fun verifyReaderViewToggle(visible: Boolean) = assertReaderViewToggle(visible)
|
|
|
|
|
fun verifyReaderViewAppearance(visible: Boolean) = assertReaderViewAppearanceButton(visible)
|
2019-09-10 21:03:47 +02:00
|
|
|
|
fun clickShareButton() {
|
|
|
|
|
shareButton().click()
|
2019-11-29 14:31:08 +01:00
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.text("ALL ACTIONS")), waitingTime)
|
2019-09-10 21:03:47 +02:00
|
|
|
|
}
|
2019-09-26 23:25:34 +02:00
|
|
|
|
|
2019-09-13 00:56:36 +02:00
|
|
|
|
fun verifyShareTabButton() = assertShareTabButton()
|
2019-08-27 19:56:12 +02:00
|
|
|
|
fun verifySaveCollection() = assertSaveCollectionButton()
|
2020-05-12 09:51:44 +02:00
|
|
|
|
|
2019-10-28 20:10:19 +01:00
|
|
|
|
fun clickBrowserViewSaveCollectionButton() {
|
|
|
|
|
browserViewSaveCollectionButton().click()
|
|
|
|
|
}
|
2019-12-03 11:44:54 +01:00
|
|
|
|
|
2019-10-28 20:10:19 +01:00
|
|
|
|
fun clickAddNewCollection() {
|
|
|
|
|
addNewCollectionButton().click()
|
|
|
|
|
}
|
2019-12-03 11:44:54 +01:00
|
|
|
|
|
|
|
|
|
fun clickAddBookmarkButton() {
|
|
|
|
|
mDevice.waitNotNull(
|
|
|
|
|
Until.findObject(By.desc("Bookmark")),
|
|
|
|
|
waitingTime
|
|
|
|
|
)
|
2020-05-22 20:06:24 +02:00
|
|
|
|
addBookmarkButton().perform(
|
|
|
|
|
click(
|
|
|
|
|
/* no-op rollback action for when clicks randomly perform a long click, Espresso should attempt to click again
|
|
|
|
|
https://issuetracker.google.com/issues/37078920#comment9
|
|
|
|
|
*/
|
|
|
|
|
object : ViewAction {
|
|
|
|
|
override fun getDescription(): String {
|
|
|
|
|
return "Handle tap->longclick."
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun getConstraints(): Matcher<View> {
|
|
|
|
|
return isAssignableFrom(View::class.java)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun perform(uiController: UiController?, view: View?) {
|
|
|
|
|
// do nothing
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
)
|
2020-05-08 11:58:32 +02:00
|
|
|
|
)
|
2019-12-03 11:44:54 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 20:10:19 +01:00
|
|
|
|
fun verifyCollectionNameTextField() = assertCollectionNameTextField()
|
2019-09-09 20:16:47 +02:00
|
|
|
|
fun verifyFindInPageButton() = assertFindInPageButton()
|
2019-09-26 23:25:34 +02:00
|
|
|
|
fun verifyShareScrim() = assertShareScrim()
|
2019-09-10 21:03:47 +02:00
|
|
|
|
fun verifySendToDeviceTitle() = assertSendToDeviceTitle()
|
|
|
|
|
fun verifyShareALinkTitle() = assertShareALinkTitle()
|
2019-09-11 17:41:05 +02:00
|
|
|
|
fun verifyWhatsNewButton() = assertWhatsNewButton()
|
2020-02-06 22:06:28 +01:00
|
|
|
|
fun verifyAddFirefoxHome() = assertAddToFirefoxHome()
|
2020-07-09 18:15:10 +02:00
|
|
|
|
fun verifyAddToMobileHome() = assertAddToMobileHome()
|
|
|
|
|
fun verifyDesktopSite() = assertDesktopSite()
|
|
|
|
|
fun verifyOpenInAppButton() = assertOpenInAppButton()
|
|
|
|
|
|
|
|
|
|
fun verifyThreeDotMainMenuItems() {
|
|
|
|
|
verifyAddOnsButton()
|
|
|
|
|
verifyHistoryButton()
|
|
|
|
|
verifyBookmarksButton()
|
|
|
|
|
verifySyncedTabsButton()
|
|
|
|
|
verifySettingsButton()
|
|
|
|
|
verifyFindInPageButton()
|
|
|
|
|
verifyAddFirefoxHome()
|
|
|
|
|
verifyAddToMobileHome()
|
|
|
|
|
verifyDesktopSite()
|
|
|
|
|
verifyAddBookmarkButton()
|
|
|
|
|
verifyShareButton()
|
|
|
|
|
verifyForwardButton()
|
|
|
|
|
verifyRefreshButton()
|
|
|
|
|
}
|
2019-05-16 02:32:25 +02:00
|
|
|
|
|
|
|
|
|
class Transition {
|
|
|
|
|
|
2019-07-16 22:02:12 +02:00
|
|
|
|
private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
2019-05-16 02:32:25 +02:00
|
|
|
|
|
2020-07-09 18:15:10 +02:00
|
|
|
|
fun clickAddOnsReportSiteIssue(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
|
|
|
|
addOnsButton().click()
|
|
|
|
|
addOnsReportSiteIssueButton().click()
|
|
|
|
|
|
|
|
|
|
BrowserRobot().interact()
|
|
|
|
|
return BrowserRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-16 02:32:25 +02:00
|
|
|
|
fun openSettings(interact: SettingsRobot.() -> Unit): SettingsRobot.Transition {
|
2020-07-09 18:15:10 +02:00
|
|
|
|
onView(withId(R.id.mozac_browser_menu_recyclerView)).perform(ViewActions.swipeDown())
|
2020-03-02 20:40:52 +01:00
|
|
|
|
onView(allOf(withResourceName("text"), withText(R.string.browser_menu_settings)))
|
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
.check(matches(isCompletelyDisplayed()))
|
|
|
|
|
.perform(ViewActions.click())
|
2019-05-16 02:32:25 +02:00
|
|
|
|
|
|
|
|
|
SettingsRobot().interact()
|
|
|
|
|
return SettingsRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-09 18:15:10 +02:00
|
|
|
|
fun openSyncedTabs(interact: SyncedTabsRobot.() -> Unit): SyncedTabsRobot.Transition {
|
|
|
|
|
onView(withId(R.id.mozac_browser_menu_recyclerView)).perform(ViewActions.swipeDown())
|
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.text("Synced tabs")), waitingTime)
|
|
|
|
|
syncedTabsButton().click()
|
|
|
|
|
|
|
|
|
|
SyncedTabsRobot().interact()
|
|
|
|
|
return SyncedTabsRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-29 14:36:37 +01:00
|
|
|
|
fun openBookmarks(interact: BookmarksRobot.() -> Unit): BookmarksRobot.Transition {
|
2020-07-09 18:15:10 +02:00
|
|
|
|
onView(withId(R.id.mozac_browser_menu_recyclerView)).perform(ViewActions.swipeDown())
|
2019-10-29 14:36:37 +01:00
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.text("Bookmarks")), waitingTime)
|
|
|
|
|
bookmarksButton().click()
|
|
|
|
|
|
|
|
|
|
BookmarksRobot().interact()
|
|
|
|
|
return BookmarksRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun openHistory(interact: HistoryRobot.() -> Unit): HistoryRobot.Transition {
|
2020-07-09 18:15:10 +02:00
|
|
|
|
onView(withId(R.id.mozac_browser_menu_recyclerView)).perform(ViewActions.swipeDown())
|
2019-10-29 14:36:37 +01:00
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.text("History")), waitingTime)
|
|
|
|
|
historyButton().click()
|
|
|
|
|
|
|
|
|
|
HistoryRobot().interact()
|
|
|
|
|
return HistoryRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-09 18:15:10 +02:00
|
|
|
|
fun bookmarkPage(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.desc("Bookmark")), waitingTime)
|
|
|
|
|
addBookmarkButton().click()
|
|
|
|
|
|
|
|
|
|
BrowserRobot().interact()
|
|
|
|
|
return BrowserRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun sharePage(interact: LibrarySubMenusMultipleSelectionToolbarRobot.() -> Unit): LibrarySubMenusMultipleSelectionToolbarRobot.Transition {
|
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.desc("Share")), waitingTime)
|
|
|
|
|
shareButton().click()
|
|
|
|
|
pressBack()
|
|
|
|
|
|
|
|
|
|
LibrarySubMenusMultipleSelectionToolbarRobot().interact()
|
|
|
|
|
return LibrarySubMenusMultipleSelectionToolbarRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-16 02:32:25 +02:00
|
|
|
|
fun openHelp(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
2019-10-23 23:40:28 +02:00
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.text("Help")), waitingTime)
|
2019-05-16 02:32:25 +02:00
|
|
|
|
helpButton().click()
|
|
|
|
|
|
|
|
|
|
BrowserRobot().interact()
|
|
|
|
|
return BrowserRobot.Transition()
|
|
|
|
|
}
|
2019-07-16 22:02:12 +02:00
|
|
|
|
|
|
|
|
|
fun goForward(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
2019-10-23 23:40:28 +02:00
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.desc("Forward")), waitingTime)
|
2019-07-16 22:02:12 +02:00
|
|
|
|
forwardButton().click()
|
|
|
|
|
|
|
|
|
|
BrowserRobot().interact()
|
|
|
|
|
return BrowserRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun goBack(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
2019-11-12 02:10:14 +01:00
|
|
|
|
// Close three dot
|
|
|
|
|
mDevice.pressBack()
|
|
|
|
|
// Nav back to previous page
|
|
|
|
|
mDevice.pressBack()
|
2019-07-16 22:02:12 +02:00
|
|
|
|
|
|
|
|
|
BrowserRobot().interact()
|
|
|
|
|
return BrowserRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-09 18:15:10 +02:00
|
|
|
|
fun goBackToBrowser(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
|
|
|
|
mDevice.pressBack()
|
|
|
|
|
|
|
|
|
|
BrowserRobot().interact()
|
|
|
|
|
return BrowserRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-10 12:05:47 +01:00
|
|
|
|
fun close(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
|
|
|
|
// Close three dot
|
|
|
|
|
mDevice.pressBack()
|
|
|
|
|
|
|
|
|
|
HomeScreenRobot().interact()
|
|
|
|
|
return HomeScreenRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun closeBrowserMenuToBrowser(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
|
|
|
|
// Close three dot
|
|
|
|
|
mDevice.pressBack()
|
|
|
|
|
|
|
|
|
|
BrowserRobot().interact()
|
|
|
|
|
return BrowserRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-16 22:02:12 +02:00
|
|
|
|
fun refreshPage(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
2019-10-23 23:40:28 +02:00
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.desc("Refresh")), waitingTime)
|
2019-07-16 22:02:12 +02:00
|
|
|
|
refreshButton().click()
|
|
|
|
|
|
|
|
|
|
BrowserRobot().interact()
|
|
|
|
|
return BrowserRobot.Transition()
|
|
|
|
|
}
|
2019-08-27 19:56:12 +02:00
|
|
|
|
|
2020-07-21 14:49:24 +02:00
|
|
|
|
fun closeAllTabs(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
2019-08-27 19:56:12 +02:00
|
|
|
|
closeAllTabsButton().click()
|
|
|
|
|
|
2020-07-21 14:49:24 +02:00
|
|
|
|
HomeScreenRobot().interact()
|
|
|
|
|
return HomeScreenRobot.Transition()
|
2019-08-27 19:56:12 +02:00
|
|
|
|
}
|
2019-09-09 20:16:47 +02:00
|
|
|
|
|
|
|
|
|
fun openFindInPage(interact: FindInPageRobot.() -> Unit): FindInPageRobot.Transition {
|
2020-07-09 18:15:10 +02:00
|
|
|
|
onView(withId(R.id.mozac_browser_menu_recyclerView)).perform(ViewActions.swipeDown())
|
2019-10-23 23:40:28 +02:00
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.text("Find in page")), waitingTime)
|
2019-09-09 20:16:47 +02:00
|
|
|
|
findInPageButton().click()
|
|
|
|
|
|
|
|
|
|
FindInPageRobot().interact()
|
|
|
|
|
return FindInPageRobot.Transition()
|
|
|
|
|
}
|
2019-09-11 17:41:05 +02:00
|
|
|
|
|
|
|
|
|
fun openWhatsNew(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
2019-12-02 19:05:55 +01:00
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.text("What’s New")), waitingTime)
|
2019-09-11 17:41:05 +02:00
|
|
|
|
whatsNewButton().click()
|
|
|
|
|
|
|
|
|
|
BrowserRobot().interact()
|
|
|
|
|
return BrowserRobot.Transition()
|
|
|
|
|
}
|
2019-10-28 20:10:19 +01:00
|
|
|
|
|
2020-02-06 22:06:28 +01:00
|
|
|
|
fun typeCollectionName(
|
|
|
|
|
name: String,
|
|
|
|
|
interact: BrowserRobot.() -> Unit
|
|
|
|
|
): BrowserRobot.Transition {
|
|
|
|
|
mDevice.wait(
|
|
|
|
|
Until.findObject(By.res("org.mozilla.fenix.debug:id/name_collection_edittext")),
|
|
|
|
|
waitingTime
|
|
|
|
|
)
|
2019-10-28 20:10:19 +01:00
|
|
|
|
|
2020-02-06 22:06:28 +01:00
|
|
|
|
collectionNameTextField().perform(
|
|
|
|
|
ViewActions.replaceText(name),
|
|
|
|
|
ViewActions.pressImeActionButton()
|
|
|
|
|
)
|
2020-05-12 09:51:44 +02:00
|
|
|
|
// wait for the collection creation wrapper to be dismissed
|
|
|
|
|
mDevice.waitNotNull(Until.gone(By.res("org.mozilla.fenix.debug:id/createCollectionWrapper")))
|
2019-10-28 20:10:19 +01:00
|
|
|
|
|
|
|
|
|
BrowserRobot().interact()
|
|
|
|
|
return BrowserRobot.Transition()
|
|
|
|
|
}
|
2020-02-07 18:07:17 +01:00
|
|
|
|
|
|
|
|
|
fun toggleReaderView(interact: NavigationToolbarRobot.() -> Unit): NavigationToolbarRobot.Transition {
|
|
|
|
|
readerViewToggle().click()
|
|
|
|
|
|
|
|
|
|
NavigationToolbarRobot().interact()
|
|
|
|
|
return NavigationToolbarRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun openReaderViewAppearance(interact: ReaderViewRobot.() -> Unit): ReaderViewRobot.Transition {
|
|
|
|
|
readerViewAppearanceToggle().click()
|
|
|
|
|
|
|
|
|
|
ReaderViewRobot().interact()
|
|
|
|
|
return ReaderViewRobot.Transition()
|
|
|
|
|
}
|
2020-02-06 22:06:28 +01:00
|
|
|
|
|
|
|
|
|
fun addToFirefoxHome(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
|
|
|
|
addToFirefoxHomeButton().click()
|
|
|
|
|
|
|
|
|
|
BrowserRobot().interact()
|
|
|
|
|
return BrowserRobot.Transition()
|
|
|
|
|
}
|
2020-03-05 11:25:48 +01:00
|
|
|
|
|
|
|
|
|
fun openAddToHomeScreen(interact: AddToHomeScreenRobot.() -> Unit): AddToHomeScreenRobot.Transition {
|
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.text("Add to Home screen")), waitingTime)
|
|
|
|
|
addToHomeScreenButton().click()
|
|
|
|
|
|
|
|
|
|
AddToHomeScreenRobot().interact()
|
|
|
|
|
return AddToHomeScreenRobot.Transition()
|
|
|
|
|
}
|
2020-05-12 09:51:44 +02:00
|
|
|
|
|
|
|
|
|
fun selectExistingCollection(title: String, interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.text(title)), waitingTime)
|
|
|
|
|
onView(withText(title)).click()
|
|
|
|
|
|
|
|
|
|
BrowserRobot().interact()
|
|
|
|
|
return BrowserRobot.Transition()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun clickOpenTabsMenuSaveCollection(interact: HomeScreenRobot.() -> Unit): HomeScreenRobot.Transition {
|
|
|
|
|
saveCollectionButton().click()
|
|
|
|
|
|
|
|
|
|
HomeScreenRobot().interact()
|
|
|
|
|
return HomeScreenRobot.Transition()
|
|
|
|
|
}
|
2020-07-09 18:15:10 +02:00
|
|
|
|
|
|
|
|
|
fun openSaveToCollection(interact: ThreeDotMenuMainRobot.() -> Unit): ThreeDotMenuMainRobot.Transition {
|
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.text("Save to collection")), waitingTime)
|
|
|
|
|
saveCollectionButton().click()
|
|
|
|
|
ThreeDotMenuMainRobot().interact()
|
|
|
|
|
return ThreeDotMenuMainRobot.Transition()
|
|
|
|
|
}
|
2019-05-16 02:32:25 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2019-09-10 21:03:47 +02:00
|
|
|
|
|
2019-07-16 22:02:12 +02:00
|
|
|
|
private fun threeDotMenuRecyclerViewExists() {
|
|
|
|
|
onView(withId(R.id.mozac_browser_menu_recyclerView)).check(matches(isDisplayed()))
|
|
|
|
|
}
|
2019-09-26 23:25:34 +02:00
|
|
|
|
|
2020-03-02 20:40:52 +01:00
|
|
|
|
private fun settingsButton() = onView(allOf(withResourceName("text"), withText(R.string.browser_menu_settings)))
|
2019-05-16 02:32:25 +02:00
|
|
|
|
private fun assertSettingsButton() = settingsButton()
|
2020-03-02 20:40:52 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
.check(matches(isCompletelyDisplayed()))
|
2019-05-16 02:32:25 +02:00
|
|
|
|
|
2020-07-09 18:15:10 +02:00
|
|
|
|
private fun addOnsButton() = onView(allOf(withText("Add-ons")))
|
|
|
|
|
private fun assertAddOnsButton() = addOnsButton()
|
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
private fun addOnsReportSiteIssueButton() = onView(allOf(withText("Report Site Issue…")))
|
|
|
|
|
|
2019-10-29 14:36:37 +01:00
|
|
|
|
private fun historyButton() = onView(allOf(withText(R.string.library_history)))
|
|
|
|
|
private fun assertHistoryButton() = historyButton()
|
2020-03-02 20:40:52 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
2019-10-29 14:36:37 +01:00
|
|
|
|
|
|
|
|
|
private fun bookmarksButton() = onView(allOf(withText(R.string.library_bookmarks)))
|
|
|
|
|
private fun assertBookmarksButton() = bookmarksButton()
|
2020-03-02 20:40:52 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
2019-10-29 14:36:37 +01:00
|
|
|
|
|
2020-07-09 18:15:10 +02:00
|
|
|
|
private fun syncedTabsButton() = onView(allOf(withText(R.string.library_synced_tabs)))
|
|
|
|
|
private fun assertSyncedTabsButton() = syncedTabsButton()
|
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
2019-05-16 02:32:25 +02:00
|
|
|
|
private fun helpButton() = onView(allOf(withText(R.string.browser_menu_help)))
|
|
|
|
|
private fun assertHelpButton() = helpButton()
|
2020-03-02 20:40:52 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
2019-07-16 22:02:12 +02:00
|
|
|
|
|
|
|
|
|
private fun forwardButton() = onView(ViewMatchers.withContentDescription("Forward"))
|
|
|
|
|
private fun assertForwardButton() = forwardButton()
|
2020-03-02 20:40:52 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
2019-07-16 22:02:12 +02:00
|
|
|
|
|
2019-11-12 02:10:14 +01:00
|
|
|
|
private fun addBookmarkButton() = onView(ViewMatchers.withContentDescription("Bookmark"))
|
|
|
|
|
private fun assertAddBookmarkButton() = addBookmarkButton()
|
2020-03-02 20:40:52 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
2019-11-12 02:10:14 +01:00
|
|
|
|
|
|
|
|
|
private fun editBookmarkButton() = onView(ViewMatchers.withContentDescription("Edit bookmark"))
|
|
|
|
|
private fun assertEditBookmarkButton() = editBookmarkButton()
|
2020-03-02 20:40:52 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
2019-07-16 22:02:12 +02:00
|
|
|
|
|
|
|
|
|
private fun refreshButton() = onView(ViewMatchers.withContentDescription("Refresh"))
|
|
|
|
|
private fun assertRefreshButton() = refreshButton()
|
2020-03-02 20:40:52 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
2019-08-27 19:56:12 +02:00
|
|
|
|
|
2020-06-05 19:59:08 +02:00
|
|
|
|
private fun closeAllTabsButton() = onView(allOf(withText("Close all tabs"))).inRoot(RootMatchers.isPlatformPopup())
|
2019-08-27 19:56:12 +02:00
|
|
|
|
private fun assertCloseAllTabsButton() = closeAllTabsButton()
|
2020-03-02 20:40:52 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
2019-08-27 19:56:12 +02:00
|
|
|
|
|
2020-06-05 19:59:08 +02:00
|
|
|
|
private fun shareTabButton() = onView(allOf(withText("Share all tabs"))).inRoot(RootMatchers.isPlatformPopup())
|
2019-09-13 00:56:36 +02:00
|
|
|
|
private fun assertShareTabButton() = shareTabButton()
|
2020-03-02 20:40:52 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
2019-09-26 23:25:34 +02:00
|
|
|
|
|
2019-11-12 02:10:14 +01:00
|
|
|
|
private fun shareButton() = onView(ViewMatchers.withContentDescription("Share"))
|
2019-08-27 19:56:12 +02:00
|
|
|
|
private fun assertShareButton() = shareButton()
|
2019-10-28 20:10:19 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
|
|
|
|
|
2020-02-06 22:06:28 +01:00
|
|
|
|
private fun browserViewSaveCollectionButton() = onView(
|
|
|
|
|
allOf(
|
2020-03-19 12:32:19 +01:00
|
|
|
|
withText("Save to collection"),
|
2020-02-06 22:06:28 +01:00
|
|
|
|
withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)
|
|
|
|
|
)
|
|
|
|
|
)
|
2019-08-27 19:56:12 +02:00
|
|
|
|
|
2020-06-05 19:59:08 +02:00
|
|
|
|
private fun saveCollectionButton() = onView(allOf(withText("Save to collection"))).inRoot(RootMatchers.isPlatformPopup())
|
2019-08-27 19:56:12 +02:00
|
|
|
|
private fun assertSaveCollectionButton() = saveCollectionButton()
|
2020-03-02 20:40:52 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
2019-10-28 20:10:19 +01:00
|
|
|
|
|
|
|
|
|
private fun addNewCollectionButton() = onView(allOf(withText("Add new collection")))
|
|
|
|
|
private fun assertaddNewCollectionButton() = addNewCollectionButton()
|
2020-03-02 20:40:52 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
2019-10-28 20:10:19 +01:00
|
|
|
|
|
|
|
|
|
private fun collectionNameTextField() = onView(allOf(withResourceName("name_collection_edittext")))
|
|
|
|
|
private fun assertCollectionNameTextField() = collectionNameTextField()
|
2020-03-02 20:40:52 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
2019-09-09 20:16:47 +02:00
|
|
|
|
|
|
|
|
|
private fun findInPageButton() = onView(allOf(withText("Find in page")))
|
|
|
|
|
private fun assertFindInPageButton() = findInPageButton()
|
2019-09-10 21:03:47 +02:00
|
|
|
|
|
2019-09-26 23:25:34 +02:00
|
|
|
|
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")))
|
|
|
|
|
|
2019-09-10 21:03:47 +02:00
|
|
|
|
private fun assertSendToDeviceTitle() = SendToDeviceTitle()
|
2020-03-02 20:40:52 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
2019-09-10 21:03:47 +02:00
|
|
|
|
|
2019-09-26 23:25:34 +02:00
|
|
|
|
private fun ShareALinkTitle() =
|
2019-11-29 14:31:08 +01:00
|
|
|
|
onView(allOf(withText("ALL ACTIONS"), withResourceName("apps_link_header")))
|
2019-09-26 23:25:34 +02:00
|
|
|
|
|
2019-09-10 21:03:47 +02:00
|
|
|
|
private fun assertShareALinkTitle() = ShareALinkTitle()
|
2019-09-11 17:41:05 +02:00
|
|
|
|
|
2019-12-02 19:05:55 +01:00
|
|
|
|
private fun whatsNewButton() = onView(
|
|
|
|
|
allOf(
|
|
|
|
|
withText("What’s New"),
|
2020-03-02 20:40:52 +01:00
|
|
|
|
withEffectiveVisibility(Visibility.VISIBLE)
|
2020-02-06 22:06:28 +01:00
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
|
2019-09-11 17:41:05 +02:00
|
|
|
|
private fun assertWhatsNewButton() = whatsNewButton()
|
2020-03-02 20:40:52 +01:00
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
2020-02-07 18:07:17 +01:00
|
|
|
|
|
2020-03-05 11:25:48 +01:00
|
|
|
|
private fun addToHomeScreenButton() = onView(withText("Add to Home screen"))
|
|
|
|
|
|
2020-02-07 18:07:17 +01:00
|
|
|
|
private fun readerViewToggle() = onView(allOf(withText(R.string.browser_menu_read)))
|
|
|
|
|
private fun assertReaderViewToggle(visible: Boolean) = readerViewToggle()
|
|
|
|
|
.check(
|
2020-03-02 20:40:52 +01:00
|
|
|
|
if (visible) matches(withEffectiveVisibility(Visibility.VISIBLE)) else ViewAssertions.doesNotExist()
|
2020-02-07 18:07:17 +01:00
|
|
|
|
)
|
2020-02-06 22:06:28 +01:00
|
|
|
|
|
|
|
|
|
private fun readerViewAppearanceToggle() =
|
|
|
|
|
onView(allOf(withText(R.string.browser_menu_read_appearance)))
|
|
|
|
|
|
2020-02-07 18:07:17 +01:00
|
|
|
|
private fun assertReaderViewAppearanceButton(visible: Boolean) = readerViewAppearanceToggle()
|
|
|
|
|
.check(
|
2020-03-02 20:40:52 +01:00
|
|
|
|
if (visible) matches(withEffectiveVisibility(Visibility.VISIBLE)) else ViewAssertions.doesNotExist()
|
2020-02-07 18:07:17 +01:00
|
|
|
|
)
|
2020-02-06 22:06:28 +01:00
|
|
|
|
|
|
|
|
|
private fun addToFirefoxHomeButton() =
|
|
|
|
|
onView(allOf(withText(R.string.browser_menu_add_to_top_sites)))
|
|
|
|
|
private fun assertAddToFirefoxHome() {
|
|
|
|
|
onView(withId(R.id.mozac_browser_menu_recyclerView))
|
|
|
|
|
.perform(
|
|
|
|
|
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
|
|
|
|
hasDescendant(withText(R.string.browser_menu_add_to_top_sites))
|
|
|
|
|
)
|
|
|
|
|
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
}
|
2020-07-09 18:15:10 +02:00
|
|
|
|
|
|
|
|
|
private fun addToMobileHomeButton() =
|
|
|
|
|
onView(allOf(withText(R.string.browser_menu_add_to_homescreen)))
|
|
|
|
|
private fun assertAddToMobileHome() {
|
|
|
|
|
onView(withId(R.id.mozac_browser_menu_recyclerView))
|
|
|
|
|
.perform(
|
|
|
|
|
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
|
|
|
|
hasDescendant(withText(R.string.browser_menu_add_to_homescreen))
|
|
|
|
|
)
|
|
|
|
|
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun desktopSiteButton() =
|
|
|
|
|
onView(allOf(withText(R.string.browser_menu_desktop_site)))
|
|
|
|
|
private fun assertDesktopSite() {
|
|
|
|
|
onView(withId(R.id.mozac_browser_menu_recyclerView))
|
|
|
|
|
.perform(
|
|
|
|
|
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
|
|
|
|
hasDescendant(withText(R.string.browser_menu_desktop_site))
|
|
|
|
|
)
|
|
|
|
|
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun openInAppButton() =
|
|
|
|
|
onView(allOf(withText(R.string.browser_menu_open_app_link)))
|
|
|
|
|
private fun assertOpenInAppButton() {
|
|
|
|
|
onView(withId(R.id.mozac_browser_menu_recyclerView))
|
|
|
|
|
.perform(
|
|
|
|
|
RecyclerViewActions.scrollTo<RecyclerView.ViewHolder>(
|
|
|
|
|
hasDescendant(withText(R.string.browser_menu_open_app_link))
|
|
|
|
|
)
|
|
|
|
|
).check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
}
|