mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
feat(sidecar): implement longPress across backends
This commit is contained in:
1 parent
b3742101d1
commit
33fbf2a68e
1 file changed
+12
@@ -8,6 +8,7 @@ interface DriverBackend {
|
|||||||
fun inputText(text: String)
|
fun inputText(text: String)
|
||||||
fun swipe(fromX: Int, fromY: Int, toX: Int, toY: Int, durationMillis: Long)
|
fun swipe(fromX: Int, fromY: Int, toX: Int, toY: Int, durationMillis: Long)
|
||||||
fun pressKey(key: String)
|
fun pressKey(key: String)
|
||||||
|
fun longPress(x: Int, y: Int)
|
||||||
fun screenshot(): Triple<ByteArray, Int, Int>
|
fun screenshot(): Triple<ByteArray, Int, Int>
|
||||||
fun hierarchy(): String
|
fun hierarchy(): String
|
||||||
fun recentLogs(sinceUnixMillis: Long, minLevel: String): List<LogLine>
|
fun recentLogs(sinceUnixMillis: Long, minLevel: String): List<LogLine>
|
||||||
@@ -405,6 +406,8 @@ class StubDriverBackend(
|
|||||||
private set
|
private set
|
||||||
@Volatile var lastKey: String? = null
|
@Volatile var lastKey: String? = null
|
||||||
private set
|
private set
|
||||||
|
@Volatile var lastLongPress: Pair<Int, Int>? = null
|
||||||
|
private set
|
||||||
|
|
||||||
override fun swipe(fromX: Int, fromY: Int, toX: Int, toY: Int, durationMillis: Long) {
|
override fun swipe(fromX: Int, fromY: Int, toX: Int, toY: Int, durationMillis: Long) {
|
||||||
lastSwipe = SwipeRecord(fromX, fromY, toX, toY, durationMillis)
|
lastSwipe = SwipeRecord(fromX, fromY, toX, toY, durationMillis)
|
||||||
@@ -426,6 +429,11 @@ class StubDriverBackend(
|
|||||||
runAdb(listOf("shell", "input", "keyevent", keyCode))
|
runAdb(listOf("shell", "input", "keyevent", keyCode))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun longPress(x: Int, y: Int) {
|
||||||
|
lastLongPress = x to y
|
||||||
|
runAdb(listOf("shell", "input", "swipe", x.toString(), y.toString(), x.toString(), y.toString(), "600"))
|
||||||
|
}
|
||||||
|
|
||||||
override fun recentLogs(sinceUnixMillis: Long, minLevel: String): List<LogLine> =
|
override fun recentLogs(sinceUnixMillis: Long, minLevel: String): List<LogLine> =
|
||||||
readLogcat(null, sinceUnixMillis, minLevel)
|
readLogcat(null, sinceUnixMillis, minLevel)
|
||||||
|
|
||||||
@@ -513,6 +521,8 @@ class MaestroDriverBackend(private val serial: String?) : DriverBackend {
|
|||||||
|
|
||||||
override fun tap(x: Int, y: Int) = driver.tap(maestro.Point(x, y))
|
override fun tap(x: Int, y: Int) = driver.tap(maestro.Point(x, y))
|
||||||
|
|
||||||
|
override fun longPress(x: Int, y: Int) = driver.longPress(maestro.Point(x, y))
|
||||||
|
|
||||||
override fun tapSelector(selector: String) {
|
override fun tapSelector(selector: String) {
|
||||||
val root = driver.contentDescriptor(false)
|
val root = driver.contentDescriptor(false)
|
||||||
val bounds = findBoundsBySelector(root, selector) ?: return
|
val bounds = findBoundsBySelector(root, selector) ?: return
|
||||||
@@ -710,6 +720,8 @@ class IosDriverBackend(private val udid: String) : DriverBackend {
|
|||||||
|
|
||||||
override fun tap(x: Int, y: Int) = withReconnect { driver.tap(maestro.Point(x, y)) }
|
override fun tap(x: Int, y: Int) = withReconnect { driver.tap(maestro.Point(x, y)) }
|
||||||
|
|
||||||
|
override fun longPress(x: Int, y: Int) = withReconnect { driver.longPress(maestro.Point(x, y)) }
|
||||||
|
|
||||||
override fun tapSelector(selector: String) = withReconnect {
|
override fun tapSelector(selector: String) = withReconnect {
|
||||||
val root = driver.contentDescriptor(false)
|
val root = driver.contentDescriptor(false)
|
||||||
val bounds = findBoundsBySelector(root, selector) ?: return@withReconnect
|
val bounds = findBoundsBySelector(root, selector) ?: return@withReconnect
|
||||||
|
|||||||
Reference in new issue
Block a user