是否可以对 Android操纵杆API 进行单元测试?例如,Android旧版示例 ApiDemos 具有名为 GameControllerInput 的活动。看起来该活动似乎处理MotionEvents
方法中的传入dispatchGenericMotionEvent
:
@Override
public boolean dispatchGenericMotionEvent(MotionEvent event) {
// Check that the event came from a joystick since a generic motion event
// could be almost anything.
if (isJoystick(event.getSource())
&& event.getAction() == MotionEvent.ACTION_MOVE) {
// Update device state for visualization and logging.
InputDeviceState state = getInputDeviceState(event.getDeviceId());
if (state != null && state.onJoystickMotion(event)) {
mSummaryAdapter.show(state);
}
}
return super.dispatchGenericMotionEvent(event);
}
如何从单元测试应用程序(在测试线程中执行)发送MotionEvents
然后由 GameControllerInput 活动接收?