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

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

View File

@@ -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) {

View File

@@ -154,10 +154,6 @@ public class TestInformationHandler implements ResourceBasedOverride {
mDeviceProfile.isTwoPanels);
return response;
case TestProtocol.REQUEST_SET_FORCE_PAUSE_TIMEOUT:
TestProtocol.sForcePauseTimeout = Long.parseLong(arg);
return response;
case TestProtocol.REQUEST_GET_HAD_NONTEST_EVENTS:
response.putBoolean(
TestProtocol.TEST_INFO_RESPONSE_FIELD, TestLogging.sHadEventsNotFromTest);

View File

@@ -124,9 +124,6 @@ public final class TestProtocol {
public static final String REQUEST_GET_OVERVIEW_PAGE_SPACING = "get-overview-page-spacing";
public static final String REQUEST_ENABLE_ROTATION = "enable_rotation";
public static Long sForcePauseTimeout;
public static final String REQUEST_SET_FORCE_PAUSE_TIMEOUT = "set-force-pause-timeout";
public static boolean sDebugTracing = false;
public static final String REQUEST_ENABLE_DEBUG_TRACING = "enable-debug-tracing";
public static final String REQUEST_DISABLE_DEBUG_TRACING = "disable-debug-tracing";

View File

@@ -84,7 +84,6 @@ import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Consumer;
import java.util.function.Function;
@@ -101,7 +100,6 @@ public final class LauncherInstrumentation {
private static final String TAG = "Tapl";
private static final int ZERO_BUTTON_STEPS_FROM_BACKGROUND_TO_HOME = 15;
private static final int GESTURE_STEP_MS = 16;
private static final long FORCE_PAUSE_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(2);
static final Pattern EVENT_TOUCH_DOWN = getTouchEventPattern("ACTION_DOWN");
static final Pattern EVENT_TOUCH_UP = getTouchEventPattern("ACTION_UP");
@@ -362,10 +360,6 @@ public final class LauncherInstrumentation {
return getRealDisplaySize().x / 2f;
}
private void setForcePauseTimeout(long timeout) {
getTestInfo(TestProtocol.REQUEST_SET_FORCE_PAUSE_TIMEOUT, Long.toString(timeout));
}
public void setEnableRotation(boolean on) {
getTestInfo(TestProtocol.REQUEST_ENABLE_ROTATION, Boolean.toString(on));
}
@@ -886,7 +880,6 @@ public final class LauncherInstrumentation {
final String action;
if (getNavigationModel() == NavigationModel.ZERO_BUTTON) {
checkForAnomaly(false, true);
setForcePauseTimeout(FORCE_PAUSE_TIMEOUT_MS);
final Point displaySize = getRealDisplaySize();
// The swipe up to home gesture starts from inside the launcher when the user is