0

[XR] Tab tearing is enabled in the multi-modal aimimg input.

Test: Manually verified on Moohan. Recording is https://drive.google.com/file/d/10-PuQg45eL3fQUSHwzA534MjilwZB2Fz/view?usp=drive_link&resourcekey=0-XiVtwzedlbkXCXIIPC_ovw.

Bug: 396459019
Change-Id: I7f5666e35841acd13b5e1fb9f4c390282d16fba2
Fixed: 396459019
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6508406
Reviewed-by: Sirisha Kavuluru <skavuluru@google.com>
Reviewed-by: Wenyu Fu <wenyufu@chromium.org>
Commit-Queue: Wenyu Fu <wenyufu@chromium.org>
Auto-Submit: Gurmeet Kalra <gurmeetk@google.com>
Cr-Commit-Position: refs/heads/main@{#1455088}
This commit is contained in:
Gurmeet Kalra
2025-05-02 11:10:42 -07:00
committed by Chromium LUCI CQ
parent a33bc5006e
commit c5fcdaa40b
2 changed files with 55 additions and 1 deletions
ui/android
java
src
org
junit
src

@ -42,6 +42,7 @@ import org.chromium.ui.base.MimeTypeUtils;
import org.chromium.ui.dragdrop.AnimatedImageDragShadowBuilder.CursorOffset;
import org.chromium.ui.dragdrop.AnimatedImageDragShadowBuilder.DragShadowSpec;
import org.chromium.ui.dragdrop.DragDropMetricUtils.UrlIntentSource;
import org.chromium.ui.util.XrUtils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@ -149,8 +150,11 @@ public class DragAndDropDelegateImpl implements DragAndDropDelegate, DragStateTr
private static boolean isA11yStateEnabled() {
// Drag and drop is disabled when gesture related a11y service is enabled.
// See https://crbug.com/1250067.
// On XR devices, gesture control is always enabled. Therefore, to verify accessibility
// (A11y) status on these devices for drag and drop functionalities, we examine the
// `isTouchExplorationEnabled` state, effectively limiting our check to this condition.
return AccessibilityState.isTouchExplorationEnabled()
|| AccessibilityState.isPerformGesturesEnabled();
|| (AccessibilityState.isPerformGesturesEnabled() && !XrUtils.isXrDevice());
}
private boolean startDragAndDropInternal(

@ -46,6 +46,7 @@ import org.chromium.base.metrics.RecordHistogram;
import org.chromium.base.test.BaseRobolectricTestRunner;
import org.chromium.ui.accessibility.AccessibilityState;
import org.chromium.ui.dragdrop.DragAndDropDelegateImpl.DragTargetType;
import org.chromium.ui.util.XrUtils;
import org.chromium.url.JUnitTestGURLs;
/** Unit tests for {@link DragAndDropDelegateImpl}. */
@ -645,6 +646,55 @@ public class DragAndDropDelegateImplUnitTest {
verify(mDragAndDropPermissions).release();
}
@Test
public void testStartDragAndDrop_WithAndWithoutGesturesEnabled_SupportedOnXrDevice() {
XrUtils.setXrDeviceForTesting(true);
final Bitmap shadowImage = Bitmap.createBitmap(1, 1, Bitmap.Config.ALPHA_8);
final DropDataAndroid dropData = DropDataAndroid.create("text", null, null, null, null);
// A11y default setting with isTouchExplorationEnabled=false and
// isPerformGesturesEnabled=true on XR
AccessibilityState.setIsTouchExplorationEnabledForTesting(false);
AccessibilityState.setIsPerformGesturesEnabledForTesting(true);
Assert.assertTrue(
"Drag and drop should start.", calllStartDragAndDrop(shadowImage, dropData));
// A11y setting with isTouchExplorationEnabled=true and isPerformGesturesEnabled=false on XR
AccessibilityState.setIsTouchExplorationEnabledForTesting(true);
AccessibilityState.setIsPerformGesturesEnabledForTesting(false);
Assert.assertFalse(
"Drag and drop should not start when isTouchExplorationEnabled=true.",
calllStartDragAndDrop(shadowImage, dropData));
// A11y setting with isTouchExplorationEnabled=true and isPerformGesturesEnabled=true on XR
AccessibilityState.setIsTouchExplorationEnabledForTesting(true);
AccessibilityState.setIsPerformGesturesEnabledForTesting(true);
Assert.assertFalse(
"Drag and drop should not start when isTouchExplorationEnabled=true.",
calllStartDragAndDrop(shadowImage, dropData));
// A11y setting with isTouchExplorationEnabled=false and isPerformGesturesEnabled=false on
// XR
AccessibilityState.setIsTouchExplorationEnabledForTesting(false);
AccessibilityState.setIsPerformGesturesEnabledForTesting(false);
Assert.assertTrue(
"Drag and drop should start.", calllStartDragAndDrop(shadowImage, dropData));
XrUtils.resetXrDeviceForTesting();
}
private boolean calllStartDragAndDrop(Bitmap shadowImage, DropDataAndroid dropData) {
return mDragAndDropDelegateImpl.startDragAndDrop(
mContainerView,
shadowImage,
dropData,
mContainerView.getContext(),
/* cursorOffsetX= */ 0,
/* cursorOffsetY= */ 0,
/* dragObjRectWidth= */ 100,
/* dragObjRectHeight= */ 200);
}
private DragEvent mockDragEvent(int action) {
DragEvent event = Mockito.mock(DragEvent.class);
when(event.getX()).thenReturn(DRAG_START_X_DP);