Android:如何对操纵杆API进行单元测试?

时间:2013-12-30 12:29:07

标签: android unit-testing

是否可以对 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 活动接收?

0 个答案:

没有答案