HI all: sourcefile:android-sdk-linux/sources/android-15/android/test/ TouchUtils.java
public static int dragViewToX(InstrumentationTestCase test, View v, int gravity, int toX) { int[] xy = new int[2]; getStartLocation(v, gravity, xy); final int fromX = xy[0]; final int fromY = xy[1]; int deltaX = fromX - toX; drag(test, fromX, toX, fromY, fromY, deltaX); return deltaX; } public static void drag(InstrumentationTestCase test, float fromX, float toX, float fromY, float toY, int stepCount) { Instrumentation inst = test.getInstrumentation(); long downTime = SystemClock.uptimeMillis(); long eventTime = SystemClock.uptimeMillis(); float y = fromY; float x = fromX; float yStep = (toY - fromY) / stepCount; float xStep = (toX - fromX) / stepCount; MotionEvent event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_DOWN, x, y, 0); inst.sendPointerSync(event); inst.waitForIdleSync(); for (int i = 0; i < stepCount; ++i) { y += yStep; x += xStep; eventTime = SystemClock.uptimeMillis(); event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_MOVE, x, y, 0); inst.sendPointerSync(event); inst.waitForIdleSync(); } eventTime = SystemClock.uptimeMillis(); event = MotionEvent.obtain(downTime, eventTime, MotionEvent.ACTION_UP, x, y, 0); inst.sendPointerSync(event); inst.waitForIdleSync(); } If the fromX is samller than toX, deltaX is negative, so stepCount is negative too, It seems never move. Am i make a bad decision? Please help me! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en