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-02-06 22:06:28 +01:00
|
|
|
import android.content.Context
|
2020-01-13 18:24:23 +01:00
|
|
|
import android.content.Intent
|
2019-11-12 02:10:14 +01:00
|
|
|
import android.net.Uri
|
2019-05-16 02:32:25 +02:00
|
|
|
import androidx.test.espresso.Espresso.onView
|
2020-06-13 15:51:40 +02:00
|
|
|
import androidx.test.espresso.Espresso.pressBack
|
2019-10-29 14:36:37 +01:00
|
|
|
import androidx.test.espresso.action.ViewActions
|
2019-05-16 02:32:25 +02:00
|
|
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
2020-01-13 18:24:23 +01:00
|
|
|
import androidx.test.espresso.intent.Intents
|
|
|
|
import androidx.test.espresso.intent.matcher.BundleMatchers
|
|
|
|
import androidx.test.espresso.intent.matcher.IntentMatchers
|
2020-07-03 19:48:46 +02:00
|
|
|
import androidx.test.espresso.matcher.RootMatchers.isDialog
|
2019-10-29 14:36:37 +01:00
|
|
|
import androidx.test.espresso.matcher.ViewMatchers
|
2020-06-13 15:51:40 +02:00
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.Visibility
|
2020-07-14 18:30:17 +02:00
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
|
2020-07-03 19:48:46 +02:00
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
2019-10-29 14:36:37 +01:00
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
2019-05-16 02:32:25 +02:00
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
2020-07-21 15:33:06 +02:00
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withResourceName
|
2019-05-16 02:32:25 +02:00
|
|
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
|
|
|
import androidx.test.platform.app.InstrumentationRegistry
|
2019-07-16 22:02:12 +02:00
|
|
|
import androidx.test.uiautomator.By
|
2020-03-10 10:44:21 +01:00
|
|
|
import androidx.test.uiautomator.By.text
|
2019-05-16 02:32:25 +02:00
|
|
|
import androidx.test.uiautomator.UiDevice
|
2020-03-10 10:44:21 +01:00
|
|
|
import androidx.test.uiautomator.UiSelector
|
2019-07-16 22:02:12 +02:00
|
|
|
import androidx.test.uiautomator.Until
|
2020-03-31 20:11:41 +02:00
|
|
|
import androidx.test.uiautomator.Until.hasObject
|
2020-01-13 18:24:23 +01:00
|
|
|
import org.hamcrest.CoreMatchers.allOf
|
2019-05-16 02:32:25 +02:00
|
|
|
import org.hamcrest.CoreMatchers.containsString
|
2020-02-06 22:06:28 +01:00
|
|
|
import org.junit.Assert.assertTrue
|
2019-05-16 02:32:25 +02:00
|
|
|
import org.mozilla.fenix.R
|
2020-02-06 22:06:28 +01:00
|
|
|
import org.mozilla.fenix.ext.components
|
2020-07-03 19:48:46 +02:00
|
|
|
import org.mozilla.fenix.helpers.Constants.LONG_CLICK_DURATION
|
2020-03-13 16:16:47 +01:00
|
|
|
import org.mozilla.fenix.helpers.TestAssetHelper
|
2020-03-10 10:44:21 +01:00
|
|
|
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
2019-07-16 22:02:12 +02:00
|
|
|
import org.mozilla.fenix.helpers.click
|
2019-10-23 23:40:28 +02:00
|
|
|
import org.mozilla.fenix.helpers.ext.waitNotNull
|
2019-05-16 02:32:25 +02:00
|
|
|
|
|
|
|
class BrowserRobot {
|
2020-05-18 18:58:53 +02:00
|
|
|
|
|
|
|
fun verifyBrowserScreen() {
|
|
|
|
onView(ViewMatchers.withResourceName("browserLayout"))
|
|
|
|
.check(matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE)))
|
|
|
|
}
|
|
|
|
|
2020-02-06 22:06:28 +01:00
|
|
|
fun verifyCurrentPrivateSession(context: Context) {
|
|
|
|
val session = context.components.core.sessionManager.selectedSession
|
|
|
|
assertTrue("Current session is private", session?.private!!)
|
|
|
|
}
|
|
|
|
|
2020-01-31 20:58:02 +01:00
|
|
|
fun verifyUrl(url: String) {
|
2019-05-16 02:32:25 +02:00
|
|
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
2020-01-13 18:24:23 +01:00
|
|
|
mDevice.waitNotNull(
|
|
|
|
Until.findObject(By.res("org.mozilla.fenix.debug:id/mozac_browser_toolbar_url_view")),
|
2020-03-10 10:44:21 +01:00
|
|
|
waitingTime
|
2020-01-13 18:24:23 +01:00
|
|
|
)
|
2020-03-13 16:16:47 +01:00
|
|
|
TestAssetHelper.waitingTime
|
2019-05-16 02:32:25 +02:00
|
|
|
onView(withId(R.id.mozac_browser_toolbar_url_view))
|
2020-03-31 20:11:41 +02:00
|
|
|
.check(matches(withText(containsString(url.replace("http://", "")))))
|
2019-05-16 02:32:25 +02:00
|
|
|
}
|
|
|
|
|
2019-12-27 16:55:35 +01:00
|
|
|
fun verifyHelpUrl() {
|
2020-03-20 21:48:54 +01:00
|
|
|
verifyUrl("support.mozilla.org/")
|
2019-12-27 16:55:35 +01:00
|
|
|
}
|
|
|
|
|
2019-09-11 17:41:05 +02:00
|
|
|
fun verifyWhatsNewURL() {
|
2020-03-20 21:48:54 +01:00
|
|
|
verifyUrl("support.mozilla.org/")
|
2019-12-27 16:55:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fun verifyRateOnGooglePlayURL() {
|
2020-03-20 21:48:54 +01:00
|
|
|
verifyUrl("play.google.com/store/apps/details?id=org.mozilla.fenix")
|
2019-09-11 17:41:05 +02:00
|
|
|
}
|
|
|
|
|
2019-07-16 22:02:12 +02:00
|
|
|
/* Asserts that the text within DOM element with ID="testContent" has the given text, i.e.
|
|
|
|
* document.querySelector('#testContent').innerText == expectedText
|
2020-06-19 00:25:14 +02:00
|
|
|
*
|
2019-07-16 22:02:12 +02:00
|
|
|
*/
|
2020-06-19 00:25:14 +02:00
|
|
|
|
2020-07-08 11:59:53 +02:00
|
|
|
fun verifyPageContent(expectedText: String) {
|
|
|
|
assertTrue(mDevice.findObject(UiSelector().text(expectedText)).waitForExists(waitingTime))
|
|
|
|
}
|
2019-07-16 22:02:12 +02:00
|
|
|
|
2019-08-27 19:56:12 +02:00
|
|
|
fun verifyTabCounter(expectedText: String) {
|
|
|
|
onView(withId(R.id.counter_text))
|
2019-10-04 14:24:41 +02:00
|
|
|
.check((matches(withText(containsString(expectedText)))))
|
2019-09-14 02:30:53 +02:00
|
|
|
}
|
|
|
|
|
2020-01-13 18:24:23 +01:00
|
|
|
fun verifySnackBarText(expectedText: String) {
|
|
|
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
2020-03-10 10:44:21 +01:00
|
|
|
mDevice.waitNotNull(Until.findObject(text(expectedText)), waitingTime)
|
2020-02-06 22:06:28 +01:00
|
|
|
|
|
|
|
onView(withText(expectedText)).check(
|
|
|
|
matches(isCompletelyDisplayed())
|
|
|
|
)
|
2020-01-13 18:24:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fun verifyLinkContextMenuItems(containsURL: Uri) {
|
|
|
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
|
|
|
mDevice.waitNotNull(
|
|
|
|
Until.findObject(By.textContains(containsURL.toString())),
|
2020-03-10 10:44:21 +01:00
|
|
|
waitingTime
|
2020-01-13 18:24:23 +01:00
|
|
|
)
|
|
|
|
mDevice.waitNotNull(
|
2020-03-10 10:44:21 +01:00
|
|
|
Until.findObject(text("Open link in new tab")),
|
|
|
|
waitingTime
|
2020-01-13 18:24:23 +01:00
|
|
|
)
|
|
|
|
mDevice.waitNotNull(
|
2020-03-10 10:44:21 +01:00
|
|
|
Until.findObject(text("Open link in private tab")),
|
|
|
|
waitingTime
|
2020-01-13 18:24:23 +01:00
|
|
|
)
|
2020-03-10 10:44:21 +01:00
|
|
|
mDevice.waitNotNull(Until.findObject(text("Copy link")), waitingTime)
|
|
|
|
mDevice.waitNotNull(Until.findObject(text("Share link")), waitingTime)
|
2020-01-13 18:24:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fun verifyLinkImageContextMenuItems(containsURL: Uri) {
|
|
|
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
|
|
|
mDevice.waitNotNull(Until.findObject(By.textContains(containsURL.toString())))
|
|
|
|
mDevice.waitNotNull(
|
2020-03-10 10:44:21 +01:00
|
|
|
Until.findObject(text("Open link in new tab")), waitingTime
|
2020-01-13 18:24:23 +01:00
|
|
|
)
|
|
|
|
mDevice.waitNotNull(
|
2020-03-10 10:44:21 +01:00
|
|
|
Until.findObject(text("Open link in private tab")), waitingTime
|
2020-01-13 18:24:23 +01:00
|
|
|
)
|
2020-03-10 10:44:21 +01:00
|
|
|
mDevice.waitNotNull(Until.findObject(text("Copy link")), waitingTime)
|
|
|
|
mDevice.waitNotNull(Until.findObject(text("Share link")), waitingTime)
|
2020-01-13 18:24:23 +01:00
|
|
|
mDevice.waitNotNull(
|
2020-03-10 10:44:21 +01:00
|
|
|
Until.findObject(text("Open image in new tab")), waitingTime
|
2020-01-13 18:24:23 +01:00
|
|
|
)
|
2020-03-10 10:44:21 +01:00
|
|
|
mDevice.waitNotNull(Until.findObject(text("Save image")), waitingTime)
|
2020-01-13 18:24:23 +01:00
|
|
|
mDevice.waitNotNull(
|
2020-03-10 10:44:21 +01:00
|
|
|
Until.findObject(text("Copy image location")), waitingTime
|
2020-01-13 18:24:23 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-06-13 15:51:40 +02:00
|
|
|
fun verifyNavURLBar() = assertNavURLBar()
|
|
|
|
|
|
|
|
fun verifySecureConnectionLockIcon() = assertSecureConnectionLockIcon()
|
|
|
|
|
|
|
|
fun verifyEnhancedTrackingProtectionSwitch() = assertEnhancedTrackingProtectionSwitch()
|
|
|
|
|
2020-07-21 15:33:06 +02:00
|
|
|
fun clickEnhancedTrackingProtectionSwitchOffOn() = onView(withResourceName("switch_widget")).click()
|
|
|
|
|
2020-06-13 15:51:40 +02:00
|
|
|
fun verifyProtectionSettingsButton() = assertProtectionSettingsButton()
|
|
|
|
|
|
|
|
fun verifyEnhancedTrackingOptions() {
|
|
|
|
clickEnhancedTrackingProtectionPanel()
|
|
|
|
verifyEnhancedTrackingProtectionSwitch()
|
|
|
|
verifyProtectionSettingsButton()
|
|
|
|
}
|
|
|
|
|
|
|
|
fun verifyMenuButton() = assertMenuButton()
|
|
|
|
|
2020-07-09 18:15:10 +02:00
|
|
|
fun verifyBlueDot() = assertBlueDot()
|
|
|
|
|
2020-06-13 15:51:40 +02:00
|
|
|
fun verifyNavURLBarItems() {
|
|
|
|
verifyEnhancedTrackingOptions()
|
|
|
|
pressBack()
|
|
|
|
waitingTime
|
|
|
|
verifySecureConnectionLockIcon()
|
|
|
|
verifyTabCounter("1")
|
|
|
|
verifyNavURLBar()
|
|
|
|
verifyMenuButton()
|
|
|
|
}
|
|
|
|
|
2020-07-03 19:48:46 +02:00
|
|
|
fun verifyNoLinkImageContextMenuItems(containsURL: Uri) {
|
2020-01-13 18:24:23 +01:00
|
|
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
2020-07-03 19:48:46 +02:00
|
|
|
mDevice.waitNotNull(Until.findObject(By.textContains(containsURL.toString())))
|
2020-01-13 18:24:23 +01:00
|
|
|
mDevice.waitNotNull(
|
2020-03-10 10:44:21 +01:00
|
|
|
Until.findObject(text("Open image in new tab")),
|
|
|
|
waitingTime
|
2020-01-13 18:24:23 +01:00
|
|
|
)
|
2020-03-10 10:44:21 +01:00
|
|
|
mDevice.waitNotNull(Until.findObject(text("Save image")), waitingTime)
|
2020-01-13 18:24:23 +01:00
|
|
|
mDevice.waitNotNull(
|
2020-03-10 10:44:21 +01:00
|
|
|
Until.findObject(text("Copy image location")), waitingTime
|
2020-01-13 18:24:23 +01:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2020-07-03 19:48:46 +02:00
|
|
|
fun dismissContentContextMenu(containsURL: Uri) {
|
|
|
|
onView(withText(containsURL.toString()))
|
|
|
|
.inRoot(isDialog())
|
|
|
|
.check(matches(isDisplayed()))
|
|
|
|
.perform(ViewActions.pressBack())
|
|
|
|
}
|
|
|
|
|
2020-06-13 15:51:40 +02:00
|
|
|
fun clickEnhancedTrackingProtectionPanel() = enhancedTrackingProtectionPanel().click()
|
|
|
|
|
2020-07-21 15:33:06 +02:00
|
|
|
fun verifyEnhancedTrackingProtectionPanelNotVisible() = assertEnhancedTrackingProtectionPanelNotVisible()
|
|
|
|
|
2020-01-13 18:24:23 +01:00
|
|
|
fun clickContextOpenLinkInNewTab() {
|
|
|
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
|
|
|
mDevice.waitNotNull(
|
2020-03-10 10:44:21 +01:00
|
|
|
Until.findObject(text("Open link in new tab")),
|
|
|
|
waitingTime
|
2020-01-13 18:24:23 +01:00
|
|
|
)
|
|
|
|
|
2020-03-10 10:44:21 +01:00
|
|
|
val menuOpenInNewTab = mDevice.findObject(text("Open link in new tab"))
|
2020-01-13 18:24:23 +01:00
|
|
|
menuOpenInNewTab.click()
|
|
|
|
}
|
|
|
|
|
|
|
|
fun clickContextOpenLinkInPrivateTab() {
|
|
|
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
|
|
|
mDevice.waitNotNull(
|
2020-03-10 10:44:21 +01:00
|
|
|
Until.findObject(text("Open link in private tab")),
|
|
|
|
waitingTime
|
2020-01-13 18:24:23 +01:00
|
|
|
)
|
|
|
|
|
2020-03-10 10:44:21 +01:00
|
|
|
val menuOpenInPrivateTab = mDevice.findObject(text("Open link in private tab"))
|
2020-01-13 18:24:23 +01:00
|
|
|
menuOpenInPrivateTab.click()
|
|
|
|
}
|
|
|
|
|
|
|
|
fun clickContextCopyLink() {
|
|
|
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
2020-03-10 10:44:21 +01:00
|
|
|
mDevice.waitNotNull(Until.findObject(text("Copy link")), waitingTime)
|
2020-01-13 18:24:23 +01:00
|
|
|
|
2020-03-10 10:44:21 +01:00
|
|
|
val menuCopyLink = mDevice.findObject(text("Copy link"))
|
2020-01-13 18:24:23 +01:00
|
|
|
menuCopyLink.click()
|
|
|
|
}
|
|
|
|
|
|
|
|
fun clickContextShareLink(url: Uri) {
|
|
|
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
2020-03-10 10:44:21 +01:00
|
|
|
mDevice.waitNotNull(Until.findObject(text("Share link")), waitingTime)
|
2020-01-13 18:24:23 +01:00
|
|
|
|
2020-03-10 10:44:21 +01:00
|
|
|
val menuShareLink = mDevice.findObject(text("Share link"))
|
2020-01-13 18:24:23 +01:00
|
|
|
menuShareLink.click()
|
|
|
|
|
|
|
|
// verify share intent is launched and matched with associated passed in URL
|
|
|
|
Intents.intended(
|
|
|
|
allOf(
|
|
|
|
IntentMatchers.hasAction(Intent.ACTION_CHOOSER),
|
|
|
|
IntentMatchers.hasExtras(
|
|
|
|
allOf(
|
|
|
|
BundleMatchers.hasEntry(
|
|
|
|
Intent.EXTRA_INTENT,
|
|
|
|
allOf(
|
|
|
|
IntentMatchers.hasAction(Intent.ACTION_SEND),
|
|
|
|
IntentMatchers.hasType("text/plain"),
|
|
|
|
IntentMatchers.hasExtra(
|
|
|
|
Intent.EXTRA_TEXT,
|
|
|
|
url.toString()
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
fun clickContextCopyImageLocation() {
|
|
|
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
|
|
|
mDevice.waitNotNull(
|
2020-03-10 10:44:21 +01:00
|
|
|
Until.findObject(text("Copy image location")),
|
|
|
|
waitingTime
|
2020-01-13 18:24:23 +01:00
|
|
|
)
|
|
|
|
|
2020-03-10 10:44:21 +01:00
|
|
|
val menuCopyImageLocation = mDevice.findObject(text("Copy image location"))
|
2020-01-13 18:24:23 +01:00
|
|
|
menuCopyImageLocation.click()
|
|
|
|
}
|
|
|
|
|
|
|
|
fun clickContextOpenImageNewTab() {
|
|
|
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
|
|
|
mDevice.waitNotNull(
|
2020-03-10 10:44:21 +01:00
|
|
|
Until.findObject(text("Open image in new tab")),
|
|
|
|
waitingTime
|
2020-01-13 18:24:23 +01:00
|
|
|
)
|
|
|
|
|
2020-03-10 10:44:21 +01:00
|
|
|
val menuOpenImageNewTab = mDevice.findObject(text("Open image in new tab"))
|
2020-01-13 18:24:23 +01:00
|
|
|
menuOpenImageNewTab.click()
|
|
|
|
}
|
|
|
|
|
|
|
|
fun clickContextSaveImage() {
|
|
|
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
2020-03-10 10:44:21 +01:00
|
|
|
mDevice.waitNotNull(Until.findObject(text("Save image")), waitingTime)
|
2020-01-13 18:24:23 +01:00
|
|
|
|
2020-03-10 10:44:21 +01:00
|
|
|
val menuSaveImage = mDevice.findObject(text("Save image"))
|
2020-01-13 18:24:23 +01:00
|
|
|
menuSaveImage.click()
|
|
|
|
}
|
|
|
|
|
2019-11-12 02:10:14 +01:00
|
|
|
fun createBookmark(url: Uri) {
|
|
|
|
navigationToolbar {
|
|
|
|
}.enterURLAndEnterToBrowser(url) {
|
|
|
|
}.openThreeDotMenu {
|
|
|
|
clickAddBookmarkButton()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-02 23:15:00 +01:00
|
|
|
fun clickLinkMatchingText(expectedText: String) {
|
|
|
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
2020-03-10 10:44:21 +01:00
|
|
|
mDevice.waitNotNull(Until.findObject(text(expectedText)), waitingTime)
|
2019-12-02 23:15:00 +01:00
|
|
|
|
2020-03-10 10:44:21 +01:00
|
|
|
val element = mDevice.findObject(text(expectedText))
|
2019-12-02 23:15:00 +01:00
|
|
|
element.click()
|
|
|
|
}
|
|
|
|
|
2020-01-13 18:24:23 +01:00
|
|
|
fun longClickMatchingText(expectedText: String) {
|
|
|
|
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
2020-03-10 10:44:21 +01:00
|
|
|
mDevice.waitNotNull(Until.findObject(text(expectedText)), waitingTime)
|
2020-01-13 18:24:23 +01:00
|
|
|
|
2020-03-10 10:44:21 +01:00
|
|
|
val element = mDevice.findObject(text(expectedText))
|
2020-07-03 19:48:46 +02:00
|
|
|
element.click(LONG_CLICK_DURATION)
|
2020-01-13 18:24:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fun snackBarButtonClick(expectedText: String) {
|
|
|
|
onView(allOf(withId(R.id.snackbar_btn), withText(expectedText))).check(
|
|
|
|
matches(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE))
|
|
|
|
).perform(ViewActions.click())
|
|
|
|
}
|
|
|
|
|
2020-02-19 13:23:25 +01:00
|
|
|
fun verifySaveLoginPromptIsShown() {
|
2020-03-10 10:44:21 +01:00
|
|
|
mDevice.waitNotNull(Until.findObjects(text("test@example.com")), waitingTime)
|
2020-02-19 13:23:25 +01:00
|
|
|
val submitButton = mDevice.findObject(By.res("submit"))
|
2020-03-10 10:44:21 +01:00
|
|
|
submitButton.clickAndWait(Until.newWindow(), waitingTime)
|
2020-02-19 13:23:25 +01:00
|
|
|
// Click save to save the login
|
2020-03-10 10:44:21 +01:00
|
|
|
mDevice.waitNotNull(Until.findObjects(text("Save")))
|
2020-02-19 13:23:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fun saveLoginFromPrompt(optionToSaveLogin: String) {
|
2020-03-10 10:44:21 +01:00
|
|
|
mDevice.findObject(text(optionToSaveLogin)).click()
|
2020-02-19 13:23:25 +01:00
|
|
|
}
|
|
|
|
|
2020-03-31 20:11:41 +02:00
|
|
|
fun clickMediaPlayerPlayButton() {
|
|
|
|
mDevice.waitNotNull(
|
|
|
|
hasObject(
|
|
|
|
By
|
|
|
|
.clazz("android.widget.Button")
|
|
|
|
.textContains("Play")
|
|
|
|
),
|
|
|
|
waitingTime
|
|
|
|
)
|
|
|
|
mediaPlayerPlayButton().click()
|
|
|
|
}
|
|
|
|
|
|
|
|
fun waitForPlaybackToStart() {
|
2020-07-08 11:59:53 +02:00
|
|
|
val playStateMessage = mDevice.findObject(UiSelector().text("Media file is playing"))
|
|
|
|
assertTrue(playStateMessage.waitForExists(waitingTime))
|
2020-03-31 20:11:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
fun verifyMediaIsPaused() {
|
2020-07-08 11:59:53 +02:00
|
|
|
val pausedStateMessage = mDevice.findObject(UiSelector().text("Media file is paused"))
|
|
|
|
assertTrue(pausedStateMessage.waitForExists(waitingTime))
|
2020-03-31 20:11:41 +02:00
|
|
|
}
|
|
|
|
|
2019-07-16 22:02:12 +02:00
|
|
|
class Transition {
|
|
|
|
private val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
|
2019-10-29 14:36:37 +01:00
|
|
|
private fun threeDotButton() = onView(
|
2020-03-10 10:44:21 +01:00
|
|
|
allOf(
|
2019-10-29 14:36:37 +01:00
|
|
|
ViewMatchers.withContentDescription(
|
|
|
|
"Menu"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
fun openThreeDotMenu(interact: ThreeDotMenuMainRobot.() -> Unit): ThreeDotMenuMainRobot.Transition {
|
2020-04-27 17:15:27 +02:00
|
|
|
mDevice.waitForIdle(waitingTime)
|
2019-10-29 14:36:37 +01:00
|
|
|
threeDotButton().perform(ViewActions.click())
|
|
|
|
|
|
|
|
ThreeDotMenuMainRobot().interact()
|
|
|
|
return ThreeDotMenuMainRobot.Transition()
|
|
|
|
}
|
2019-07-16 22:02:12 +02:00
|
|
|
|
|
|
|
fun openNavigationToolbar(interact: NavigationToolbarRobot.() -> Unit): NavigationToolbarRobot.Transition {
|
2020-07-23 23:17:54 +02:00
|
|
|
mDevice.waitForIdle(waitingTime)
|
2019-07-16 22:02:12 +02:00
|
|
|
navURLBar().click()
|
|
|
|
|
|
|
|
NavigationToolbarRobot().interact()
|
|
|
|
return NavigationToolbarRobot.Transition()
|
|
|
|
}
|
2019-08-20 22:10:08 +02:00
|
|
|
|
2020-06-05 19:59:08 +02:00
|
|
|
fun openTabDrawer(interact: TabDrawerRobot.() -> Unit): TabDrawerRobot.Transition {
|
2020-06-13 15:51:40 +02:00
|
|
|
mDevice.waitForIdle(waitingTime)
|
2019-08-20 22:10:08 +02:00
|
|
|
tabsCounter().click()
|
|
|
|
|
2019-10-23 23:40:28 +02:00
|
|
|
mDevice.waitNotNull(
|
2020-06-05 19:59:08 +02:00
|
|
|
Until.findObject(By.res("org.mozilla.fenix.debug:id/tab_layout")),
|
2020-03-10 10:44:21 +01:00
|
|
|
waitingTime
|
2019-10-23 23:40:28 +02:00
|
|
|
)
|
2019-10-08 01:49:47 +02:00
|
|
|
|
2020-06-05 19:59:08 +02:00
|
|
|
TabDrawerRobot().interact()
|
|
|
|
return TabDrawerRobot.Transition()
|
2019-08-20 22:10:08 +02:00
|
|
|
}
|
2020-03-10 10:44:21 +01:00
|
|
|
|
2020-07-14 18:30:17 +02:00
|
|
|
fun openTabButtonShortcutsMenu(interact: NavigationToolbarRobot.() -> Unit): NavigationToolbarRobot.Transition {
|
|
|
|
mDevice.waitForIdle(waitingTime)
|
|
|
|
|
|
|
|
tabsCounter().perform(
|
|
|
|
ViewActions.longClick()
|
|
|
|
)
|
|
|
|
|
|
|
|
NavigationToolbarRobot().interact()
|
|
|
|
return NavigationToolbarRobot.Transition()
|
|
|
|
}
|
|
|
|
|
2020-03-31 20:11:41 +02:00
|
|
|
fun openNotificationShade(interact: NotificationRobot.() -> Unit): NotificationRobot.Transition {
|
|
|
|
mDevice.openNotification()
|
2020-03-10 10:44:21 +01:00
|
|
|
|
2020-03-31 20:11:41 +02:00
|
|
|
NotificationRobot().interact()
|
|
|
|
return NotificationRobot.Transition()
|
2020-03-10 10:44:21 +01:00
|
|
|
}
|
2019-05-16 02:32:25 +02:00
|
|
|
}
|
|
|
|
}
|
2019-07-13 01:19:08 +02:00
|
|
|
|
|
|
|
fun browserScreen(interact: BrowserRobot.() -> Unit): BrowserRobot.Transition {
|
|
|
|
BrowserRobot().interact()
|
|
|
|
return BrowserRobot.Transition()
|
|
|
|
}
|
2019-07-16 22:02:12 +02:00
|
|
|
|
2019-10-04 14:24:41 +02:00
|
|
|
private fun dismissOnboardingButton() = onView(withId(R.id.close_onboarding))
|
2019-12-27 16:55:35 +01:00
|
|
|
|
2019-10-28 20:10:19 +01:00
|
|
|
fun dismissTrackingOnboarding() {
|
2020-03-10 10:44:21 +01:00
|
|
|
mDevice.wait(Until.findObject(By.res("close_onboarding")), waitingTime)
|
2019-10-28 20:10:19 +01:00
|
|
|
dismissOnboardingButton().click()
|
|
|
|
}
|
2019-09-14 02:30:53 +02:00
|
|
|
|
2019-07-16 22:02:12 +02:00
|
|
|
fun navURLBar() = onView(withId(R.id.mozac_browser_toolbar_url_view))
|
2019-08-20 22:10:08 +02:00
|
|
|
|
2020-06-13 15:51:40 +02:00
|
|
|
private fun assertNavURLBar() = navURLBar()
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
|
|
|
|
fun enhancedTrackingProtectionPanel() = onView(withId(R.id.mozac_browser_toolbar_tracking_protection_indicator))
|
|
|
|
|
2020-07-21 15:33:06 +02:00
|
|
|
private fun assertEnhancedTrackingProtectionPanelNotVisible() {
|
|
|
|
enhancedTrackingProtectionPanel()
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.GONE)))
|
|
|
|
}
|
|
|
|
|
2020-06-13 15:51:40 +02:00
|
|
|
private fun assertEnhancedTrackingProtectionSwitch() {
|
|
|
|
withText(R.id.trackingProtectionSwitch)
|
|
|
|
.matches(withEffectiveVisibility(Visibility.VISIBLE))
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun assertProtectionSettingsButton() {
|
|
|
|
onView(withId(R.id.protection_settings))
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun assertSecureConnectionLockIcon() {
|
|
|
|
onView(withId(R.id.mozac_browser_toolbar_security_indicator))
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun menuButton() = onView(withId(R.id.icon))
|
|
|
|
|
|
|
|
private fun assertMenuButton() {
|
|
|
|
menuButton()
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun tabsCounter() = onView(withId(R.id.counter_box))
|
2020-03-10 10:44:21 +01:00
|
|
|
|
2020-03-31 20:11:41 +02:00
|
|
|
private fun mediaPlayerPlayButton() =
|
|
|
|
mDevice.findObject(
|
|
|
|
By
|
|
|
|
.clazz("android.widget.Button")
|
|
|
|
.textContains("Play")
|
|
|
|
)
|
2020-07-09 18:15:10 +02:00
|
|
|
|
|
|
|
private fun assertBlueDot() {
|
|
|
|
onView(withId(R.id.notification_dot))
|
|
|
|
.check(matches(withEffectiveVisibility(Visibility.VISIBLE)))
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun addOnsReportSiteIssue() = onView(withText("Report Site Issue"))
|