Merge "Move TEST_HARNESS_TRIGGER_TIMEOUT to MotionPauseDetector directly" into tm-qpr-dev

This commit is contained in:
Tony Wickham authored and Android (Google) Code Review committed 2022-07-06 16:25:03 +00:00
commit 0c8ceda6e7
4 files changed
+12 -18

No files matched your search

@@ -23,8 +23,8 @@ import android.view.VelocityTracker;
import com.android.launcher3.Alarm;
import com.android.launcher3.R;
import com.android.launcher3.Utilities;
import com.android.launcher3.compat.AccessibilityManagerCompat;
import com.android.launcher3.testing.TestProtocol;
/**
* Given positions along x- or y-axis, tracks velocity and acceleration and determines when there is
@@ -46,6 +46,12 @@ public class MotionPauseDetector {
*/
private static final long HARDER_TRIGGER_TIMEOUT = 400;
/**
* When running in a test harness, if no motion is added for this amount of time, assume the
* motion has paused. (We use an increased timeout since sometimes test devices can be slow.)
*/
private static final long TEST_HARNESS_TRIGGER_TIMEOUT = 2000;
private final float mSpeedVerySlow;
private final float mSpeedSlow;
private final float mSpeedSomewhatFast;
@@ -123,9 +129,11 @@ public class MotionPauseDetector {
* @param pointerIndex Index for the pointer being tracked in the motion event
*/
public void addPosition(MotionEvent ev, int pointerIndex) {
long timeoutMs = TestProtocol.sForcePauseTimeout != null
? TestProtocol.sForcePauseTimeout
: mMakePauseHarderToTrigger ? HARDER_TRIGGER_TIMEOUT : FORCE_PAUSE_TIMEOUT;
long timeoutMs = Utilities.IS_RUNNING_IN_TEST_HARNESS
? TEST_HARNESS_TRIGGER_TIMEOUT
: mMakePauseHarderToTrigger
? HARDER_TRIGGER_TIMEOUT
: FORCE_PAUSE_TIMEOUT;
mForcePauseTimeout.setAlarm(timeoutMs);
float newVelocity = mVelocityProvider.addMotionEvent(ev, ev.getPointerId(pointerIndex));
if (mPreviousVelocity != null) {