GitLab is used only for code review, issue tracking and project management. Canonical locations for source code are still https://gitweb.torproject.org/ https://git.torproject.org/ and git-rw.torproject.org.

Unverified Commit a9630984 authored by mergify[bot]'s avatar mergify[bot] Committed by GitHub
Browse files

For #18644: fix metod to verify system notifications (#18721)

(cherry picked from commit 24634850

)
Co-authored-by: default avatarOana Horvath <oana.horvath@softvision.ro>
parent 72c9e3da
......@@ -9,6 +9,7 @@ import androidx.test.espresso.intent.rule.IntentsTestRule
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.ActivityTestRule
import androidx.test.uiautomator.UiDevice
import androidx.test.uiautomator.UiSelector
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.onboarding.FenixOnboarding
import org.mozilla.fenix.ui.robots.appContext
......@@ -37,6 +38,7 @@ class HomeActivityTestRule(
override fun afterActivityFinished() {
super.afterActivityFinished()
setLongTapTimeout(longTapUserPreference)
closeNotificationShade()
}
}
......@@ -65,6 +67,7 @@ class HomeActivityIntentTestRule(
override fun afterActivityFinished() {
super.afterActivityFinished()
setLongTapTimeout(longTapUserPreference)
closeNotificationShade()
}
}
......@@ -79,3 +82,13 @@ private fun skipOnboardingBeforeLaunch() {
// this API so it can be fragile.
FenixOnboarding(appContext).finish()
}
private fun closeNotificationShade() {
val mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation())
if (mDevice.findObject(
UiSelector().resourceId("com.android.systemui:id/notification_stack_scroller")
).exists()
) {
mDevice.pressHome()
}
}
......@@ -13,27 +13,23 @@ import org.mozilla.fenix.helpers.ext.waitNotNull
class NotificationRobot {
fun verifySystemNotificationExists(notificationMessage: String) {
fun notificationTray() = UiScrollable(
UiSelector().resourceId("com.android.systemui:id/notification_stack_scroller")
)
val notificationFound: Boolean
notificationFound = try {
notificationTray().getChildByText(
UiSelector().text(notificationMessage), notificationMessage, true
).exists()
} catch (e: UiObjectNotFoundException) {
false
}
if (!notificationFound) {
// swipe 2 times to expand the silent notifications on API 28 and higher, single-swipe doesn't do it
notificationTray().swipeUp(2)
val notification = mDevice.findObject(UiSelector().textContains(notificationMessage))
assertTrue(notification.exists())
}
var notificationFound = false
do {
try {
notificationFound = notificationTray().getChildByText(
UiSelector().text(notificationMessage), notificationMessage, true
).waitForExists(waitingTime)
assertTrue(notificationFound)
} catch (e: UiObjectNotFoundException) {
notificationTray().scrollForward()
mDevice.waitForIdle()
}
} while (!notificationFound)
}
fun verifySystemNotificationGone(notificationMessage: String) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment