【发布时间】:2022-10-02 04:25:44
【问题描述】:
推荐的方法是什么在喷气背包组合测试中触发后退按钮按下(在真实设备上运行)?
我正在努力:
@get:Rule()
val composeTestRule = createAndroidComposeRule(MyActivity::class.java)
@Test
fun test() {
// Here would be some setup code, assertions and navigating into a second screen
// Navigate back to previous screen
composeTestRule.onRoot().performKeyPress(KeyEvent(NativeKeyEvent(0, KeyEvent.KEYCODE_BACK)))
// continue...
}
但我得到了错误:
java.lang.IllegalStateException: KeyEvent can\'t be processed because this key input node is not active.
我对按键/导航没有任何特殊逻辑,只使用导航撰写库的开箱即用功能。
标签: android-jetpack-compose android-jetpack-compose-testing