|
|
@ -1,11 +1,12 @@
|
|
|
|
package org.mozilla.fenix.ui.robots
|
|
|
|
package org.mozilla.fenix.ui.robots
|
|
|
|
|
|
|
|
|
|
|
|
import android.content.res.Resources
|
|
|
|
|
|
|
|
import androidx.test.uiautomator.By.text
|
|
|
|
import androidx.test.uiautomator.By.text
|
|
|
|
|
|
|
|
import androidx.test.uiautomator.UiObjectNotFoundException
|
|
|
|
import androidx.test.uiautomator.UiScrollable
|
|
|
|
import androidx.test.uiautomator.UiScrollable
|
|
|
|
import androidx.test.uiautomator.UiSelector
|
|
|
|
import androidx.test.uiautomator.UiSelector
|
|
|
|
import androidx.test.uiautomator.Until
|
|
|
|
import androidx.test.uiautomator.Until
|
|
|
|
import org.junit.Assert.assertFalse
|
|
|
|
import org.junit.Assert.assertFalse
|
|
|
|
|
|
|
|
import org.junit.Assert.assertTrue
|
|
|
|
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
|
|
|
import org.mozilla.fenix.helpers.TestAssetHelper.waitingTime
|
|
|
|
import org.mozilla.fenix.helpers.ext.waitNotNull
|
|
|
|
import org.mozilla.fenix.helpers.ext.waitNotNull
|
|
|
|
|
|
|
|
|
|
|
@ -17,23 +18,21 @@ class NotificationRobot {
|
|
|
|
UiSelector().resourceId("com.android.systemui:id/notification_stack_scroller")
|
|
|
|
UiSelector().resourceId("com.android.systemui:id/notification_stack_scroller")
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
mDevice.waitNotNull(
|
|
|
|
val notificationFound: Boolean
|
|
|
|
Until.hasObject(text(notificationMessage)),
|
|
|
|
|
|
|
|
waitingTime
|
|
|
|
notificationFound = try {
|
|
|
|
)
|
|
|
|
notificationTray().getChildByText(
|
|
|
|
|
|
|
|
UiSelector().text(notificationMessage), notificationMessage, true
|
|
|
|
|
|
|
|
).exists()
|
|
|
|
|
|
|
|
} catch (e: UiObjectNotFoundException) {
|
|
|
|
|
|
|
|
false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var notificationFound = false
|
|
|
|
if (!notificationFound) {
|
|
|
|
while (!notificationFound) {
|
|
|
|
// swipe 2 times to expand the silent notifications on API 28 and higher, single-swipe doesn't do it
|
|
|
|
try {
|
|
|
|
notificationTray().swipeUp(2)
|
|
|
|
val notification = notificationTray().getChildByText(
|
|
|
|
val notification = mDevice.findObject(UiSelector().textContains(notificationMessage))
|
|
|
|
UiSelector().text(notificationMessage), notificationMessage,
|
|
|
|
assertTrue(notification.exists())
|
|
|
|
true
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
notification.exists()
|
|
|
|
|
|
|
|
notificationFound = true
|
|
|
|
|
|
|
|
} catch (e: Resources.NotFoundException) {
|
|
|
|
|
|
|
|
e.printStackTrace()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|