mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-17 15:26:23 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/9783: bring app in focus with sendSingleTapToScreen for UI test (https://github.com/mozilla-mobile/fenix/pull/10136)
This commit is contained in:
parent
7cfc281d66
commit
4f5ebf1ebc
@ -11,6 +11,11 @@ import android.net.Uri
|
||||
import android.os.Build
|
||||
import android.preference.PreferenceManager
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.ViewAction
|
||||
import androidx.test.espresso.action.CoordinatesProvider
|
||||
import androidx.test.espresso.action.GeneralClickAction
|
||||
import androidx.test.espresso.action.Press
|
||||
import androidx.test.espresso.action.Tap
|
||||
import androidx.test.espresso.action.ViewActions.longClick
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||
@ -89,4 +94,20 @@ object TestHelper {
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
fun sendSingleTapToScreen(x: Int, y: Int): ViewAction? {
|
||||
return GeneralClickAction(
|
||||
Tap.SINGLE,
|
||||
CoordinatesProvider { view ->
|
||||
val screenPos = IntArray(2)
|
||||
view.getLocationOnScreen(screenPos)
|
||||
val screenX = screenPos[0] + x.toFloat()
|
||||
val screenY = screenPos[1] + y.toFloat()
|
||||
floatArrayOf(screenX, screenY)
|
||||
},
|
||||
Press.FINGER,
|
||||
0,
|
||||
0
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ import org.junit.Test
|
||||
import org.mozilla.fenix.helpers.AndroidAssetDispatcher
|
||||
import org.mozilla.fenix.helpers.HomeActivityTestRule
|
||||
import org.mozilla.fenix.helpers.TestAssetHelper
|
||||
import org.mozilla.fenix.helpers.TestHelper.sendSingleTapToScreen
|
||||
import org.mozilla.fenix.helpers.ext.waitNotNull
|
||||
import org.mozilla.fenix.ui.robots.homeScreen
|
||||
import org.mozilla.fenix.ui.robots.navigationToolbar
|
||||
@ -267,7 +268,9 @@ class TabbedBrowsingTest {
|
||||
notificationShade {
|
||||
verifyPrivateTabsNotification()
|
||||
}.clickClosePrivateTabsNotification {
|
||||
verifyPrivateSessionMessage()
|
||||
// Tap an empty spot on the app homescreen to make sure it's into focus
|
||||
sendSingleTapToScreen(20, 20)
|
||||
verifyPrivateSessionMessage(visible = true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -559,7 +559,7 @@ const val PRIVATE_SESSION_MESSAGE =
|
||||
" else who uses this device."
|
||||
|
||||
private fun assertPrivateSessionMessage(visible: Boolean) =
|
||||
onView(allOf(withText(PRIVATE_SESSION_MESSAGE)))
|
||||
onView(withId(R.id.private_session_description))
|
||||
.check(
|
||||
if (visible) matches(withEffectiveVisibility(Visibility.VISIBLE)) else doesNotExist()
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user