大家都说 multitouch unit testing 不能用 standard Android framework Instrumentation来测试。我没试过,就这么一直认为着,没发现谁测成功。

解决方案 »

  1.   

    http://stackoverflow.com/questions/3637044/generating-multitouch-motionevents-for-testing
    这里貌似有人成功了,不过没贴代码
      

  2.   

    MotionEvent.obtain(downTime, SystemClock.uptimeMillis(), MotionEvent.ACTION_UP,
                    2, new int[] {0, 1}, new MotionEvent.PointerCoords[] {pointerCoordsOneEnd, pointerCoordsTwoEnd}, 0, 0.0f, 0.0f, 0, 0, 0, 0);的ACTION设置不正确1按下 → MotionEvent.ACTION_DOWN
    2按下 → MotionEvent.ACTION_POINTER_DOWN+(motionEvent2Index<<MotionEvent.ACTION_POINTER_INDEX_SHIFT)
    移动 → MotionEvent.MOVE
    2离开 → MotionEvent.ACTION_POINTER_UP+(motionEvent2Index<<MotionEvent.ACTION_POINTER_INDEX_SHIFT)
    1离开 → MotionEvent.ACTION_UP其中motionEventXIndex为PointerPropertiesArray, PointerCoords中该MotionEvent的Index