Move TEST_HARNESS_TRIGGER_TIMEOUT to MotionPauseDetector directly

- Removed TestProtocol.sForcePauseTimeout and
  TestProtocol.REQUEST_SET_FORCE_PAUSE_TIMEOUT
- Instead, add MotionPauseDetector.TEST_HARNESS_TRIGGER_TIMEOUT, which
  is used when Utilities.IS_RUNNING_IN_TEST_HARNESS.

Test: unbundled/launcher/launcher3_test_platform
Fixes: 232548865
Change-Id: I224e99042b41375cab6bffd555434217518958c5
This commit is contained in:
Tony Wickham
2022-06-30 12:16:08 -07:00
parent 51ceb5f200
commit 539c2703ea
4 changed files with 12 additions and 18 deletions
@@ -22,8 +22,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
@@ -43,6 +43,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;
@@ -119,9 +125,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) {