Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -280,6 +295,10 @@ private ImmutableList<AccessibilityViewCheckResult> runAccessibilityChecks(View
}
}

if (customTouchTargetSize != null) {
parameters.putCustomTouchTargetSize(customTouchTargetSize);
}

return processResults(
view.getContext(),
viewChecker.runViewChecksOnView(
Expand Down