diff --git a/src/main/java/com/google/android/apps/common/testing/accessibility/framework/integrations/espresso/AccessibilityValidator.java b/src/main/java/com/google/android/apps/common/testing/accessibility/framework/integrations/espresso/AccessibilityValidator.java index 56e1b51..af2e480 100644 --- a/src/main/java/com/google/android/apps/common/testing/accessibility/framework/integrations/espresso/AccessibilityValidator.java +++ b/src/main/java/com/google/android/apps/common/testing/accessibility/framework/integrations/espresso/AccessibilityValidator.java @@ -67,6 +67,8 @@ public final class AccessibilityValidator { private @Nullable Boolean saveViewImages; private int screenshotsCaptured = 0; + private @Nullable Integer customTouchTargetSize; + private @Nullable AccessibilityCheckResultType throwExceptionFor = AccessibilityCheckResultType.ERROR; @@ -175,6 +177,19 @@ public AccessibilityValidator setSaveImages(boolean saveScreenshots, boolean sav return this; } + /** + * Sets a user-defined minimum touch target size for use by {@link + * com.google.android.apps.common.testing.accessibility.framework.checks.TouchTargetSizeCheck}. A + * value set here should override the default value used by the check. + * + * @param touchTargetSize a user-defined minimum touch target size in pixels + */ + @CanIgnoreReturnValue + public AccessibilityValidator setCustomTouchTargetSize(int touchTargetSize) { + this.customTouchTargetSize = touchTargetSize; + return this; + } + /** * Suppresses all results that match the given matcher. Suppressed results will not be included in * any logs or cause any {@code Exception} to be thrown @@ -280,6 +295,10 @@ private ImmutableList runAccessibilityChecks(View } } + if (customTouchTargetSize != null) { + parameters.putCustomTouchTargetSize(customTouchTargetSize); + } + return processResults( view.getContext(), viewChecker.runViewChecksOnView(