mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
feat(driver): add escape to the pressKey surface
escape is a key a spec has real use for and no platform could send it. android maps it to KEYCODE_ESCAPE, the ios companion to HID usage 41 and the in-simulator runner to XCUIKeyboardKey.escape, and the Key union accepts it so it can be written at all.
This commit is contained in:
1 parent
4b7a3878ac
commit
da3cc5f68c
12 files changed
+106
-10
No files matched your search
@@ -513,6 +513,7 @@ class StubDriverBackend(
|
||||
"home" to "KEYCODE_HOME",
|
||||
"enter" to "KEYCODE_ENTER",
|
||||
"tab" to "KEYCODE_TAB",
|
||||
"escape" to "KEYCODE_ESCAPE",
|
||||
"up" to "KEYCODE_DPAD_UP",
|
||||
"down" to "KEYCODE_DPAD_DOWN",
|
||||
"left" to "KEYCODE_DPAD_LEFT",
|
||||
@@ -1207,6 +1208,7 @@ private fun keyCodeToMaestro(adbKeyCode: String): maestro.KeyCode? =
|
||||
"KEYCODE_HOME" -> maestro.KeyCode.HOME
|
||||
"KEYCODE_ENTER" -> maestro.KeyCode.ENTER
|
||||
"KEYCODE_TAB" -> maestro.KeyCode.TAB
|
||||
"KEYCODE_ESCAPE" -> maestro.KeyCode.ESCAPE
|
||||
"KEYCODE_DPAD_UP" -> maestro.KeyCode.REMOTE_UP
|
||||
"KEYCODE_DPAD_DOWN" -> maestro.KeyCode.REMOTE_DOWN
|
||||
"KEYCODE_DPAD_LEFT" -> maestro.KeyCode.REMOTE_LEFT
|
||||
|
||||
@@ -212,4 +212,17 @@ class InputTextTest {
|
||||
assertEquals(maestro.KeyCode.ENTER, maestroKeyFor("enter"))
|
||||
assertFailsWith<IllegalArgumentException> { maestroKeyFor("zorp") }
|
||||
}
|
||||
|
||||
// escape is a documented key. Missing from the table it throws on the adb
|
||||
// backend and, when a table entry has no device-driver equivalent, the
|
||||
// device backend used to drop the press with no error at all.
|
||||
@Test fun escapeReachesBothAndroidBackends() {
|
||||
val commands = mutableListOf<List<String>>()
|
||||
StubDriverBackend("android") { commands.add(it) }.pressKey("escape")
|
||||
assertEquals(
|
||||
listOf(listOf("shell", "input", "keyevent", "KEYCODE_ESCAPE")),
|
||||
commands,
|
||||
)
|
||||
assertEquals(maestro.KeyCode.ESCAPE, maestroKeyFor("escape"))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user