Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0e4f04d8 authored by Andras Kloczl's avatar Andras Kloczl Committed by Alex Chau
Browse files

Fix flaky/failing two panel TAPL tests

Since Cuttlefish emulators are quite slow, some
of the two panel related TAPL tests were failing
due to multiple page changes instead of single ones.

Test: atest -c NexusLauncherTests:com.android.launcher3.ui.workspace.TwoPanelWorkspaceTest
Bug: 236136463
Fix: 252747355
Change-Id: Ib154cf97040fcea3b4d2d7082352c06de74f8c2a
(cherry picked from commit 486f7c87)
Merged-In: Ib154cf97040fcea3b4d2d7082352c06de74f8c2a
parent 9860628f
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -20,12 +20,14 @@ import com.android.launcher3.Alarm;
import com.android.launcher3.CellLayout;
import com.android.launcher3.Launcher;
import com.android.launcher3.OnAlarmListener;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;

public class SpringLoadedDragController implements OnAlarmListener {
    // how long the user must hover over a mini-screen before it unshrinks
    final long ENTER_SPRING_LOAD_HOVER_TIME = 500;
    final long ENTER_SPRING_LOAD_CANCEL_HOVER_TIME = 950;
    private static final long ENTER_SPRING_LOAD_HOVER_TIME = 500;
    private static final long ENTER_SPRING_LOAD_HOVER_TIME_IN_TEST = 1500;
    private static final long ENTER_SPRING_LOAD_CANCEL_HOVER_TIME = 950;

    Alarm mAlarm;

@@ -39,6 +41,13 @@ public class SpringLoadedDragController implements OnAlarmListener {
        mAlarm.setOnAlarmListener(this);
    }

    private long getEnterSpringLoadHoverTime() {
        // Some TAPL tests are flaky on Cuttlefish with a low waiting time
        return Utilities.IS_RUNNING_IN_TEST_HARNESS
                ? ENTER_SPRING_LOAD_HOVER_TIME_IN_TEST
                : ENTER_SPRING_LOAD_HOVER_TIME;
    }

    public void cancel() {
        mAlarm.cancelAlarm();
    }
@@ -46,8 +55,8 @@ public class SpringLoadedDragController implements OnAlarmListener {
    // Set a new alarm to expire for the screen that we are hovering over now
    public void setAlarm(CellLayout cl) {
        mAlarm.cancelAlarm();
        mAlarm.setAlarm((cl == null) ? ENTER_SPRING_LOAD_CANCEL_HOVER_TIME :
            ENTER_SPRING_LOAD_HOVER_TIME);
        mAlarm.setAlarm((cl == null) ? ENTER_SPRING_LOAD_CANCEL_HOVER_TIME
                : getEnterSpringLoadHoverTime());
        mScreen = cl;
    }