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

Commit 5994c5d9 authored by Longbo Wei's avatar Longbo Wei Committed by Android (Google) Code Review
Browse files

Merge "a11y: Remove indicator when hovering on directional buttons" into main

parents 9c04f51c 7b4cf9c4
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -152,11 +152,22 @@ public class AutoclickController extends BaseEventStreamTransformation {
                    if (direction == AutoclickScrollPanel.DIRECTION_EXIT) {
                        return;
                    }
                    // For direction buttons, perform scroll action immediately.
                    if (hovered && direction != AutoclickScrollPanel.DIRECTION_NONE) {

                    // Handle all non-exit buttons when hovered.
                    if (hovered) {
                        // Clear the indicator.
                        if (mAutoclickIndicatorScheduler != null) {
                            mAutoclickIndicatorScheduler.cancel();
                            if (mAutoclickIndicatorView != null) {
                                mAutoclickIndicatorView.clearIndicator();
                            }
                        }
                        // Perform scroll action.
                        if (direction != DIRECTION_NONE) {
                            handleScroll(direction);
                        }
                    }
                }
            };

    public AutoclickController(Context context, int userId, AccessibilityTraceManager trace) {
+18 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import static com.google.common.truth.Truth.assertThat;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -864,6 +865,23 @@ public class AutoclickControllerTest {
        assertThat(motionEventCaptor.downEvent).isNull();
    }

    @Test
    @EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR)
    public void scrollPanelController_directionalButtonsHideIndicator() {
        injectFakeMouseActionHoverMoveEvent();

        // Create a spy on the real object to verify method calls.
        AutoclickIndicatorView spyIndicatorView = spy(mController.mAutoclickIndicatorView);
        mController.mAutoclickIndicatorView = spyIndicatorView;

        // Simulate hover on direction button.
        mController.mScrollPanelController.onHoverButtonChange(
                AutoclickScrollPanel.DIRECTION_UP, true);

        // Verify clearIndicator was called.
        verify(spyIndicatorView).clearIndicator();
    }

    @Test
    @EnableFlags(com.android.server.accessibility.Flags.FLAG_ENABLE_AUTOCLICK_INDICATOR)
    public void hoverOnAutoclickPanel_rightClickType_forceTriggerLeftClick() {