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

Commit dc546aff authored by Gavin Williams's avatar Gavin Williams
Browse files

Autoclick: Update test click type switching logic

The CL http://ag/34037532 changed the autoclick panel to intialize as
opened instead of closed. This broke the assumed starting state for the
tests.

So update the test logic to reflect the panel can be in either
open/closed state before beginning the test and trying to change a click
type.

Bug: 424607661, 423981983
Test: AutoclickClickTypeTests, AutoclickPanelTests
Flag: com.android.server.accessibility.enable_autoclick_indicator
Change-Id: I2bd862e36b8cc6a145c7955f251132f32761fb88
parent 9082c0a6
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -117,18 +117,22 @@ class AutoclickClickTypeTests {
        // autoclick.
        desktopMouseTestRule.move(DEFAULT_DISPLAY, targetXPx = 0, targetYPx = 0)

        if (!isAutoclickPanelOpen()) {
            // The click type button group starts closed so click it to open the panel.
            val clickTypeButtonGroup = findObject(
                By.res(CLICK_TYPE_BUTTON_GROUP_ID)
            )
            desktopMouseTestRule.move(
            DEFAULT_DISPLAY, clickTypeButtonGroup.visibleCenter.x, clickTypeButtonGroup.visibleCenter.y
                DEFAULT_DISPLAY,
                clickTypeButtonGroup.visibleCenter.x,
                clickTypeButtonGroup.visibleCenter.y
            )

            // Wait for the panel to fully open before attempting to select a click type.
            waitAndAssert {
                isAutoclickPanelOpen()
            }
        }

        desktopMouseTestRule.move(DEFAULT_DISPLAY, targetXPx = 0, targetYPx = 0)
        val targetClickTypeButton = findObject(By.res(clickTypeResourceId))
+16 −9
Original line number Diff line number Diff line
@@ -79,8 +79,7 @@ class AutoclickPanelTests {
        uiDevice = UiDevice.getInstance(instrumentation)

        // Move the cursor to the edge of the screen once to trigger the Autoclick panel creation.
        var bounds = windowManager.currentWindowMetrics.bounds
        desktopMouseTestRule.move(DEFAULT_DISPLAY, bounds.width() - 1, bounds.height() - 1)
        desktopMouseTestRule.move(DEFAULT_DISPLAY, 0, 0)
    }

    private fun findObject(selector: BySelector): UiObject2 {
@@ -100,12 +99,23 @@ class AutoclickPanelTests {
        uiDevice.waitForIdle(DELAY_FOR_ANIMATION.inWholeMilliseconds)
    }

    private fun clickLeftClickButton() {
        clickClickTypeButton(LEFT_CLICK_BUTTON_LAYOUT_ID)
    private fun clickLongPressButton() {

        if (!isAutoclickPanelOpen()) {
            clickClickTypeButton(CLICK_TYPE_BUTTON_GROUP_ID)

            // Wait for the panel to fully open before attempting to select a click type.
            waitAndAssert {
                isAutoclickPanelOpen()
            }
        }

    private fun clickLongPressButton() {
        clickClickTypeButton(LONG_PRESS_BUTTON_LAYOUT_ID)

        // Wait for the panel to close as the signal that the click type was selected.
        waitAndAssert {
            !isAutoclickPanelOpen()
        }
    }

    private fun clickPositionButton() {
@@ -159,9 +169,6 @@ class AutoclickPanelTests {

    @Test
    fun switchClickType_LongPressClickTypeIsSelected() {
        // Click the left click button to open the panel.
        clickLeftClickButton()

        // Click the long press button then verify only the long press button is visible with all
        // other click type buttons hidden.
        clickLongPressButton()