如何使用 AirTest 为触摸事件使用绝对位置(方向无关紧要)
How to use absolute position for touch event using AirTest (Orientation doesn't matter)
我有一个脚本可以将 adb shell getevent -t
命令的输出解析为更抽象的事件(例如 Type: LONG_CLICK, Location: (x, y)
)。我使用这个解析的输出来重播在使用 AirTest 移动游戏测试框架的 adb
命令期间发生的事件,主要仅使用它们的 android api。一个例子是 运行 AirTest 命令 touch((x,y))
,然而,AirTest touch
命令考虑了设备的方向,而 adb shell getevent -t
没有。这会导致两个坐标系之间的不匹配和不良行为。我想知道有没有办法让 adb
命令根据设备的方向给出相对坐标,或者有没有办法让 AirTest 忽略设备的方向。我已经查看了 android 文档中有关 adb
的 [getevent][1]
命令的内容,但它没有讨论任何可以执行此操作的标志。我也通过了 AirTests documentation 并且没有非 hacky 方法可以做到这一点。我发现的 hacky 方法是进入库的源代码并根据方向注释掉执行翻译的部分,但是,这是不希望的,因为必须更改库的源代码以获得这种行为。
想通了。我可以在执行触摸命令之前直接更改 AirTest 认为的方向:
android = api.device()
android._display_info["orientation"] = 0.0
将方向值设置为 0.0,使用与 adb shell getevent -t
相同的坐标系
我有一个脚本可以将 adb shell getevent -t
命令的输出解析为更抽象的事件(例如 Type: LONG_CLICK, Location: (x, y)
)。我使用这个解析的输出来重播在使用 AirTest 移动游戏测试框架的 adb
命令期间发生的事件,主要仅使用它们的 android api。一个例子是 运行 AirTest 命令 touch((x,y))
,然而,AirTest touch
命令考虑了设备的方向,而 adb shell getevent -t
没有。这会导致两个坐标系之间的不匹配和不良行为。我想知道有没有办法让 adb
命令根据设备的方向给出相对坐标,或者有没有办法让 AirTest 忽略设备的方向。我已经查看了 android 文档中有关 adb
的 [getevent][1]
命令的内容,但它没有讨论任何可以执行此操作的标志。我也通过了 AirTests documentation 并且没有非 hacky 方法可以做到这一点。我发现的 hacky 方法是进入库的源代码并根据方向注释掉执行翻译的部分,但是,这是不希望的,因为必须更改库的源代码以获得这种行为。
想通了。我可以在执行触摸命令之前直接更改 AirTest 认为的方向:
android = api.device()
android._display_info["orientation"] = 0.0
将方向值设置为 0.0,使用与 adb shell getevent -t