diff options
3 files changed, 27 insertions, 3 deletions
diff --git a/tests/accessibilityservice/res/values/dimens.xml b/tests/accessibilityservice/res/values/dimens.xml new file mode 100644 index 00000000000..a50549c55ed --- /dev/null +++ b/tests/accessibilityservice/res/values/dimens.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8"?> + +<!-- + ~ Copyright (C) 2023 The Android Open Source Project + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + --> + +<resources> + <dimen name="button_touchable_width_increment_amount">48dp</dimen> +</resources>
\ No newline at end of file diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java index 416621310d5..00034c159e5 100644 --- a/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java +++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/AccessibilityEndToEndTest.java @@ -865,7 +865,8 @@ public class AccessibilityEndToEndTest { final Button buttonWithTooltip = mActivity.findViewById(R.id.buttonWithTooltip); final int[] buttonWithTooltipLocation = new int[2]; buttonWithTooltip.getLocationOnScreen(buttonWithTooltipLocation); - final int touchableSize = 48; + final int touchableSize = resources.getDimensionPixelSize( + R.dimen.button_touchable_width_increment_amount); final int hoverRight = buttonWithTooltipLocation[0] + touchableSize / 2; final int hoverLeft = buttonLocation[0] + button.getWidth() + touchableSize / 2; final int hoverMiddle = (hoverLeft + hoverRight) / 2; @@ -920,8 +921,9 @@ public class AccessibilityEndToEndTest { throws Throwable { mActivity.waitForEnterAnimationComplete(); - final int touchableSize = 48; final Resources resources = sInstrumentation.getTargetContext().getResources(); + final int touchableSize = resources.getDimensionPixelSize( + R.dimen.button_touchable_width_increment_amount); final String targetResourceName = resources.getResourceName(R.id.buttonDelegated); final View textView = mActivity.findViewById(R.id.delegateText); final Button target = mActivity.findViewById(R.id.buttonDelegated); diff --git a/tests/accessibilityservice/src/android/accessibilityservice/cts/activities/AccessibilityEndToEndActivity.java b/tests/accessibilityservice/src/android/accessibilityservice/cts/activities/AccessibilityEndToEndActivity.java index 0e16b790e8c..7f2b95d48d3 100644 --- a/tests/accessibilityservice/src/android/accessibilityservice/cts/activities/AccessibilityEndToEndActivity.java +++ b/tests/accessibilityservice/src/android/accessibilityservice/cts/activities/AccessibilityEndToEndActivity.java @@ -74,7 +74,8 @@ public class AccessibilityEndToEndActivity extends AccessibilityTestActivity { ListView listView = (ListView) findViewById(R.id.listview); listView.setAdapter(listAdapter); - final int touchableSize = 48; + final int touchableSize = getResources().getDimensionPixelSize( + R.dimen.button_touchable_width_increment_amount); Button button = findViewById(R.id.button); Function<View, Rect> withTouchableAtRight = (v) -> new Rect( v.getLeft(), 0, v.getRight() + touchableSize, v.getHeight()); |