AccessibilityChecker
@Deprecated @AutoService(AccessibilityChecker.class) public class AccessibilityUtil extends Object implements AccessibilityChecker
ShadowView.checkedPerformClick
to check for accessibility problems.
There is some subtlety to checking a UI for accessibility when it hasn't been rendered. The
better initialized the View, the more accurate the checking will be. At a minimum, the view
should be attached to a proper view hierarchy similar to what's checked for in:q
ShadowView.checkedPerformClick
.
Will be removed after Robolectric 4.4.Constructor | Description |
---|---|
AccessibilityUtil() |
Deprecated.
|
Modifier and Type | Method | Description |
---|---|---|
static List<com.google.android.apps.common.testing.accessibility.framework.AccessibilityViewCheckResult> |
checkView(View view) |
Deprecated.
Check a hierarchy of
View s for accessibility, based on currently set options. |
void |
checkViewAccessibility(Object realView) |
Deprecated.
|
static List<com.google.android.apps.common.testing.accessibility.framework.AccessibilityViewCheckResult> |
checkViewIfCheckingEnabled(View view) |
Deprecated.
Check a hierarchy of
View s for accessibility. |
static boolean |
passesAccessibilityChecksIfEnabled(View view) |
Deprecated.
|
static void |
setRunChecksForRobolectricVersion(AccessibilityChecks.ForRobolectricVersion forVersion) |
Deprecated.
Specify that a specific subset of accessibility checks be run.
|
static void |
setRunChecksFromRootView(boolean runChecksFromRootView) |
Deprecated.
Specify that accessibility checks should be run for all views in the hierarchy whenever a
single view's accessibility is asserted.
|
static void |
setSuppressingResultMatcher(org.hamcrest.Matcher<? super com.google.android.apps.common.testing.accessibility.framework.AccessibilityViewCheckResult> matcher) |
Deprecated.
Suppress all results that match the given matcher.
|
static void |
setThrowExceptionForErrors(boolean throwExceptionForErrors) |
Deprecated.
Control whether or not to throw exceptions when accessibility errors are found.
|
public static List<com.google.android.apps.common.testing.accessibility.framework.AccessibilityViewCheckResult> checkViewIfCheckingEnabled(View view)
View
s for accessibility. Only performs checks if (in decreasing
priority order) accessibility checking is enabled using an AccessibilityChecks
annotation, if the system property robolectric.accessibility.enablechecks
is set to
true
, or if the environment variable robolectric.accessibility.enablechecks
is set to true
.view
- The View
to examinepublic static List<com.google.android.apps.common.testing.accessibility.framework.AccessibilityViewCheckResult> checkView(View view)
View
s for accessibility, based on currently set options.view
- The View
to examine@Deprecated public static boolean passesAccessibilityChecksIfEnabled(View view)
View
s for accessibility. Only performs checks if (in decreasing
priority order) accessibility checking is enabled using an AccessibilityChecks
annotation, if the system property robolectric.accessibility.enablechecks
is set to
true
, or if the environment variable robolectric.accessibility.enablechecks
is set to true
.
Implicitly calls {code setThrowExceptionForErrors(false)} to disable exception throwing. This
method is deprecated, both because of this side effect and because the other methods offer
more control over execution.view
- The View
to examinepublic static void setRunChecksForRobolectricVersion(AccessibilityChecks.ForRobolectricVersion forVersion)
AccessibilityChecks.ForRobolectricVersion
.
If you call this method, the value you pass will take precedence over any value in any
annotations.forVersion
- The version of checks to run for. If null
, throws away the current
value and falls back on the annotation or default.public static void setRunChecksFromRootView(boolean runChecksFromRootView)
runChecksFromRootView
- true
if all views in the hierarchy should be checked.public static void setSuppressingResultMatcher(org.hamcrest.Matcher<? super com.google.android.apps.common.testing.accessibility.framework.AccessibilityViewCheckResult> matcher)
Exception
to be thrown. This capability is useful if there
are known issues, but checks should still look for regressions.matcher
- A matcher to match a AccessibilityViewCheckResult
. null
disables suppression and is the default.public static void setThrowExceptionForErrors(boolean throwExceptionForErrors)
throwExceptionForErrors
- true
to throw an AccessibilityViewCheckException
when there is at least one error result. Default: true
.public void checkViewAccessibility(Object realView)
checkViewAccessibility
in interface AccessibilityChecker