Bug 851861 - v2 - Intermittent testFlingCorrectness, etc al. dragSync() consumers

This commit is contained in:
Mark Capella 2015-01-21 19:23:49 -05:00
Родитель 4ca0bf40d0
Коммит 448ffa6b5d
3 изменённых файлов: 32 добавлений и 0 удалений

Просмотреть файл

@ -129,6 +129,8 @@ class JavaPanZoomController
private boolean mNegateWheelScrollY;
/* Whether the current event has been default-prevented. */
private boolean mDefaultPrevented;
/* Whether longpress events are enabled, or suppressed by robocop tests. */
private boolean isLongpressEnabled;
// Handler to be notified when overscroll occurs
private Overscroll mOverscroll;
@ -139,6 +141,7 @@ class JavaPanZoomController
mX = new AxisX(mSubscroller);
mY = new AxisY(mSubscroller);
mTouchEventHandler = new TouchEventHandler(view.getContext(), view, this);
isLongpressEnabled = true;
checkMainThread();
@ -1348,8 +1351,20 @@ class JavaPanZoomController
mWaitForDoubleTap = false;
}
/**
* MotionEventHelper dragAsync() robocop tests can have us suppress
* longpress events that are spuriously created on slower test devices.
*/
public void setIsLongpressEnabled(boolean isLongpressEnabled) {
this.isLongpressEnabled = isLongpressEnabled;
}
@Override
public void onLongPress(MotionEvent motionEvent) {
if (!isLongpressEnabled) {
return;
}
GeckoEvent e = GeckoEvent.createLongPressEvent(motionEvent);
GeckoAppShell.sendEventToGecko(e);
}

Просмотреть файл

@ -138,6 +138,14 @@ public class LayerView extends FrameLayout implements Tabs.OnTabsChangedListener
GeckoAccessibility.setAccessibilityStateChangeListener(getContext());
}
/**
* MotionEventHelper dragAsync() robocop tests can instruct
* PanZoomController not to generate longpress events.
*/
public void setIsLongpressEnabled(boolean isLongpressEnabled) {
((JavaPanZoomController) mPanZoomController).setIsLongpressEnabled(isLongpressEnabled);
}
private static Point getEventRadius(MotionEvent event) {
return new Point((int)event.getToolMajor() / 2,
(int)event.getToolMinor() / 2);

Просмотреть файл

@ -4,6 +4,9 @@
package org.mozilla.gecko.tests;
import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.gfx.LayerView;
import android.app.Instrumentation;
import android.os.SystemClock;
import android.util.FloatMath;
@ -18,11 +21,13 @@ class MotionEventHelper {
private final Instrumentation mInstrumentation;
private final int mSurfaceOffsetX;
private final int mSurfaceOffsetY;
private final LayerView layerView;
public MotionEventHelper(Instrumentation inst, int surfaceOffsetX, int surfaceOffsetY) {
mInstrumentation = inst;
mSurfaceOffsetX = surfaceOffsetX;
mSurfaceOffsetY = surfaceOffsetY;
layerView = GeckoAppShell.getLayerView();
Log.i(LOGTAG, "Initialized using offset (" + mSurfaceOffsetX + "," + mSurfaceOffsetY + ")");
}
@ -75,6 +80,8 @@ class MotionEventHelper {
Thread t = new Thread() {
@Override
public void run() {
layerView.setIsLongpressEnabled(false);
int numEvents = (int)(durationMillis * DRAG_EVENTS_PER_SECOND / 1000);
float eventDx = (endX - startX) / numEvents;
float eventDy = (endY - startY) / numEvents;
@ -97,6 +104,8 @@ class MotionEventHelper {
// do the last one using endX/endY directly to avoid rounding errors
downTime = move(downTime, endX, endY);
downTime = up(downTime, endX, endY);
layerView.setIsLongpressEnabled(true);
}
};
t.start();