Skip to content
This repository has been archived by the owner on Jan 12, 2023. It is now read-only.

Commit

Permalink
For #6347 - Upgrade Espresso libraries for API 30 (#6348)
Browse files Browse the repository at this point in the history
* For #6347 - Upgrade Espresso libraries for API 30

misc: fixes

* fix: more fixes

fix: ktlint detekt

fix: notification tray

* fix: reportSiteIssue fix

add RetryTestRule

fix: add RetryTestRule to DownloadFileTest

fix: Add more Retry rules

fix: more RetryTestRule

fix: DownloadFileTest tweak

fix: DownloadFileTest

try: swipeUp in DownloadNotificationTest

fix: ktlint

* fix: add RetryTestRule to MultitaskingTest

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
AaronMT and mergify[bot] authored Feb 14, 2022
1 parent 1f3e0e6 commit 92bf0b6
Show file tree
Hide file tree
Showing 30 changed files with 226 additions and 109 deletions.
13 changes: 8 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -303,13 +303,16 @@ dependencies {
exclude group: 'com.android.support', module: 'design'
exclude group: 'com.android.support', module: 'recyclerview-v7'
}
testImplementation 'androidx.test:core:1.2.0'
testImplementation 'androidx.test:runner:1.2.0'
testImplementation 'androidx.test:rules:1.2.0'
testImplementation 'androidx.test:core:1.4.0'
testImplementation 'androidx.test:runner:1.4.0'
testImplementation 'androidx.test:rules:1.4.0'

androidTestImplementation 'androidx.test:core-ktx:1.4.0'
androidTestImplementation 'androidx.test.ext:junit-ktx:1.1.3'
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestUtil 'androidx.test:orchestrator:1.2.0'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestUtil 'androidx.test:orchestrator:1.4.1'


implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import org.junit.runner.RunWith
import org.mozilla.focus.activity.robots.searchScreen
import org.mozilla.focus.helpers.FeatureSettingsHelper
import org.mozilla.focus.helpers.MainActivityFirstrunTestRule
import org.mozilla.focus.helpers.RetryTestRule
import org.mozilla.focus.helpers.TestHelper.readTestAsset
import org.mozilla.focus.helpers.TestHelper.webPageLoadwaitingTime
import org.mozilla.focus.helpers.TestHelper.waitingTime
import org.mozilla.focus.testAnnotations.SmokeTest
import java.io.IOException

Expand All @@ -30,6 +31,10 @@ class AddToHomescreenTest {
@get: Rule
var mActivityTestRule = MainActivityFirstrunTestRule(showFirstRun = false)

@Rule
@JvmField
val retryTestRule = RetryTestRule(3)

@Before
fun setup() {
webServer = MockWebServer()
Expand Down Expand Up @@ -64,7 +69,7 @@ class AddToHomescreenTest {
// Open website, and click 'Add to homescreen'
searchScreen {
}.loadPage(pageUrl) {
progressBar.waitUntilGone(webPageLoadwaitingTime)
progressBar.waitUntilGone(waitingTime)
}.openThreeDotMenu {
}.openAddToHSDialog {
addShortcutWithTitle(pageTitle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* 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("DEPRECATION")

package org.mozilla.focus.activity

import android.app.PendingIntent
Expand Down Expand Up @@ -32,7 +34,7 @@ import org.mozilla.focus.activity.robots.searchScreen
import org.mozilla.focus.helpers.FeatureSettingsHelper
import org.mozilla.focus.helpers.TestHelper.createMockResponseFromAsset
import org.mozilla.focus.helpers.TestHelper.mDevice
import org.mozilla.focus.helpers.TestHelper.webPageLoadwaitingTime
import org.mozilla.focus.helpers.TestHelper.waitingTime
import org.mozilla.focus.testAnnotations.SmokeTest
import org.mozilla.focus.utils.IntentUtils
import java.io.IOException
Expand Down Expand Up @@ -76,7 +78,7 @@ class CustomTabTest {
val customTabActivity = launchActivity<IntentReceiverActivity>(createCustomTabIntent(customTabPage))

browserScreen {
progressBar.waitUntilGone(webPageLoadwaitingTime)
progressBar.waitUntilGone(waitingTime)
verifyPageContent(TEST_PAGE_HEADER_TEXT)
verifyPageURL(customTabPage)
}
Expand Down Expand Up @@ -113,7 +115,7 @@ class CustomTabTest {

launchActivity<IntentReceiverActivity>(createCustomTabIntent(customTabPage))
customTab {
progressBar.waitUntilGone(webPageLoadwaitingTime)
progressBar.waitUntilGone(waitingTime)
verifyPageURL(customTabPage)
openCustomTabMenu()
clickOpenInFocusButton()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ package org.mozilla.focus.activity

import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.GrantPermissionRule
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
Expand All @@ -14,10 +13,12 @@ import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.mozilla.focus.activity.robots.downloadRobot
import org.mozilla.focus.activity.robots.notificationTray
import org.mozilla.focus.activity.robots.searchScreen
import org.mozilla.focus.helpers.DeleteFilesHelper.deleteFileUsingDisplayName
import org.mozilla.focus.helpers.FeatureSettingsHelper
import org.mozilla.focus.helpers.MainActivityIntentsTestRule
import org.mozilla.focus.helpers.RetryTestRule
import org.mozilla.focus.helpers.TestHelper
import org.mozilla.focus.helpers.TestHelper.mDevice
import org.mozilla.focus.helpers.TestHelper.readTestAsset
Expand All @@ -34,11 +35,9 @@ class DownloadFileTest {
@get:Rule
var mActivityTestRule = MainActivityIntentsTestRule(showFirstRun = false)

@get:Rule
var mGrantPermissions = GrantPermissionRule.grant(
android.Manifest.permission.WRITE_EXTERNAL_STORAGE,
android.Manifest.permission.READ_EXTERNAL_STORAGE
)
@Rule
@JvmField
val retryTestRule = RetryTestRule(3)

@Before
fun setUp() {
Expand Down Expand Up @@ -90,6 +89,11 @@ class DownloadFileTest {
val downloadPageUrl = webServer.url("").toString()
val downloadFileName = "download.jpg"

notificationTray {
mDevice.openNotification()
clearNotifications()
}

// Load website with service worker
searchScreen {
}.loadPage(downloadPageUrl) { }
Expand All @@ -104,7 +108,9 @@ class DownloadFileTest {
clickDownloadButton()
verifySnackBarText("finished")
mDevice.openNotification()
verifyDownloadNotification()
notificationTray {
verifyDownloadNotification("Download completed", downloadFileName)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ import org.mozilla.focus.activity.robots.homeScreen
import org.mozilla.focus.activity.robots.searchScreen
import org.mozilla.focus.helpers.FeatureSettingsHelper
import org.mozilla.focus.helpers.MainActivityFirstrunTestRule
import org.mozilla.focus.helpers.RetryTestRule
import org.mozilla.focus.helpers.TestHelper.createMockResponseFromAsset
import org.mozilla.focus.helpers.TestHelper.exitToBrowser
import org.mozilla.focus.helpers.TestHelper.exitToTop
import org.mozilla.focus.helpers.TestHelper.webPageLoadwaitingTime
import org.mozilla.focus.helpers.TestHelper.waitingTime
import org.mozilla.focus.testAnnotations.SmokeTest
import java.io.IOException

Expand All @@ -31,6 +32,10 @@ class EnhancedTrackingProtectionSettingsTest {
@get: Rule
var mActivityTestRule = MainActivityFirstrunTestRule(showFirstRun = false)

@Rule
@JvmField
val retryTestRule = RetryTestRule(3)

@Before
fun setUp() {
featureSettingsHelper.setShieldIconCFREnabled(false)
Expand Down Expand Up @@ -263,12 +268,19 @@ class EnhancedTrackingProtectionSettingsTest {
@Test
fun addURLToTPExceptionsListTest() {
webServer.enqueue(createMockResponseFromAsset("plain_test.html"))
webServer.enqueue(createMockResponseFromAsset("etpPages/otherTrackers.html"))
val genericPage = webServer.url("plain_test.html").toString()
val trackingPage = webServer.url("etpPages/otherTrackers.html").toString()

searchScreen {
}.loadPage(genericPage) {
verifyPageContent("focus test page")
}.openSearchBar {
}.loadPage(trackingPage) {
verifyPageContent("Tracker Blocking")
}.openSiteSecurityInfoSheet {
}.clickTrackingProtectionSwitch {
progressBar.waitUntilGone(waitingTime)
}.openMainMenu {
}.openSettings {
}.openPrivacySettingsMenu {
Expand All @@ -281,13 +293,19 @@ class EnhancedTrackingProtectionSettingsTest {
@Test
fun removeOneExceptionURLTest() {
webServer.enqueue(createMockResponseFromAsset("plain_test.html"))
webServer.enqueue(createMockResponseFromAsset("etpPages/otherTrackers.html"))
val genericPage = webServer.url("plain_test.html").toString()
val trackingPage = webServer.url("etpPages/otherTrackers.html").toString()

searchScreen {
}.loadPage(genericPage) {
verifyPageContent("focus test page")
}.openSearchBar {
}.loadPage(trackingPage) {
verifyPageContent("Tracker Blocking")
}.openSiteSecurityInfoSheet {
}.clickTrackingProtectionSwitch {
progressBar.waitUntilGone(webPageLoadwaitingTime)
progressBar.waitUntilGone(waitingTime)
}.openMainMenu {
}.openSettings {
}.openPrivacySettingsMenu {
Expand All @@ -306,19 +324,25 @@ class EnhancedTrackingProtectionSettingsTest {
@Test
fun removeAllExceptionURLTest() {
webServer.enqueue(createMockResponseFromAsset("plain_test.html"))
webServer.enqueue(createMockResponseFromAsset("etpPages/otherTrackers.html"))
val genericPage = webServer.url("plain_test.html").toString()
val trackingPage = webServer.url("etpPages/otherTrackers.html").toString()

searchScreen {
}.loadPage(genericPage) {
verifyPageContent("focus test page")
}.openSearchBar {
}.loadPage(trackingPage) {
verifyPageContent("Tracker Blocking")
}.openSiteSecurityInfoSheet {
}.clickTrackingProtectionSwitch {
progressBar.waitUntilGone(waitingTime)
}.openMainMenu {
}.openSettings {
}.openPrivacySettingsMenu {
openExceptionsList()
removeAllExceptions()
// Failing due to: https://github.com/mozilla-mobile/focus-android/issues/5738
// verifyExceptionsListDisabled()
verifyExceptionsListDisabled()
exitToBrowser()
}
browserScreen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.mozilla.focus.activity.robots.notificationTray
import org.mozilla.focus.activity.robots.searchScreen
import org.mozilla.focus.helpers.FeatureSettingsHelper
import org.mozilla.focus.helpers.MainActivityFirstrunTestRule
import org.mozilla.focus.helpers.RetryTestRule
import org.mozilla.focus.helpers.TestHelper.getStringResource
import org.mozilla.focus.helpers.TestHelper.mDevice
import org.mozilla.focus.helpers.TestHelper.pressHomeKey
Expand All @@ -41,6 +42,10 @@ class EraseBrowsingDataTest {
@get: Rule
var mActivityTestRule = MainActivityFirstrunTestRule(showFirstRun = false)

@Rule
@JvmField
val retryTestRule = RetryTestRule(3)

@Before
fun setUp() {
webServer = MockWebServer()
Expand Down Expand Up @@ -142,6 +147,7 @@ class EraseBrowsingDataTest {
mDevice.openNotification()
notificationTray {
verifySystemNotificationExists(getStringResource(R.string.notification_erase_text))
expandEraseBrowsingNotification()
}.clickNotificationMessage {
// Wait for launcher
assertThat(launcherPackage, IsNull.notNullValue())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import org.mozilla.focus.activity.robots.searchScreen
import org.mozilla.focus.ext.components
import org.mozilla.focus.helpers.FeatureSettingsHelper
import org.mozilla.focus.helpers.MainActivityFirstrunTestRule
import org.mozilla.focus.helpers.RetryTestRule
import org.mozilla.focus.helpers.TestHelper.clickSnackBarActionButton
import org.mozilla.focus.helpers.TestHelper.createMockResponseFromAsset
import org.mozilla.focus.helpers.TestHelper.getStringResource
Expand All @@ -40,6 +41,10 @@ class MultitaskingTest {
@get: Rule
var mActivityTestRule = MainActivityFirstrunTestRule(showFirstRun = false)

@Rule
@JvmField
val retryTestRule = RetryTestRule(3)

@Before
@Throws(Exception::class)
fun startWebServer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import org.mozilla.focus.helpers.FeatureSettingsHelper
import org.mozilla.focus.helpers.MainActivityFirstrunTestRule
import org.mozilla.focus.helpers.TestHelper.exitToTop
import org.mozilla.focus.helpers.TestHelper.pressEnterKey
import org.mozilla.focus.helpers.TestHelper.webPageLoadwaitingTime
import org.mozilla.focus.helpers.TestHelper.waitingTime
import org.mozilla.focus.testAnnotations.SmokeTest

// This test checks the search engine can be changed and that search suggestions appear
Expand Down Expand Up @@ -123,7 +123,7 @@ class SearchTest {
}
browserScreen {
verifyPageContent(searchString)
progressBar.waitUntilGone(webPageLoadwaitingTime)
progressBar.waitUntilGone(waitingTime)
}.openSearchBar {
// Tap URL bar, check it displays search term (instead of URL)
verifySearchEditBarContainsText(searchString)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.mozilla.focus.helpers.FeatureSettingsHelper
import org.mozilla.focus.helpers.MainActivityFirstrunTestRule
import org.mozilla.focus.helpers.TestHelper.mDevice
import org.mozilla.focus.helpers.TestHelper.readTestAsset
import org.mozilla.focus.helpers.TestHelper.webPageLoadwaitingTime
import org.mozilla.focus.helpers.TestHelper.waitingTime
import org.mozilla.focus.testAnnotations.SmokeTest
import java.io.IOException

Expand Down Expand Up @@ -60,7 +60,7 @@ class ShareWebsiteTest {
/* Go to a webpage */
searchScreen {
}.loadPage(webServer.url("").toString()) {
progressBar.waitUntilGone(webPageLoadwaitingTime)
progressBar.waitUntilGone(waitingTime)
}.openMainMenu {
}.openShareScreen {
verifyShareAppsListOpened()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.mozilla.focus.activity.robots.homeScreen
import org.mozilla.focus.activity.robots.searchScreen
import org.mozilla.focus.helpers.FeatureSettingsHelper
import org.mozilla.focus.helpers.MainActivityFirstrunTestRule
import org.mozilla.focus.helpers.RetryTestRule
import org.mozilla.focus.helpers.TestHelper
import org.mozilla.focus.testAnnotations.SmokeTest

Expand All @@ -25,6 +26,10 @@ class ThreeDotMainMenuTest {
@get: Rule
val mActivityTestRule = MainActivityFirstrunTestRule(showFirstRun = false)

@Rule
@JvmField
val retryTestRule = RetryTestRule(3)

@Before
fun startWebServer() {
webServer = MockWebServer()
Expand Down Expand Up @@ -59,7 +64,7 @@ class ThreeDotMainMenuTest {
verifyPageContent("Tab 1")
}.openMainMenu {
verifyShareButtonExists()
verifyAddToHSButtonExists()
verifyAddToHomeButtonExists()
verifyFindInPageExists()
verifyOpenInButtonExists()
verifyRequestDesktopSiteExists()
Expand Down
Loading

0 comments on commit 92bf0b6

Please sign in to comment.