Upgrade accessibility-test-framework to c65cab02b2a845c29c3da100d6adefd345a144e3 am: 00e9b06337

Original change: https://android-review.googlesource.com/c/platform/external/accessibility-test-framework/+/3454967

Change-Id: If6c4098584dda6e6b4572cd571119010caf73b7d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
tree: 2c166a0466e764abd5321b2229d407306b023382
  1. .github/
  2. gradle/
  3. src/
  4. .gitignore
  5. Android.bp
  6. build.gradle
  7. gradle.properties
  8. gradlew
  9. gradlew.bat
  10. LICENSE
  11. METADATA
  12. MODULE_LICENSE_APACHE2
  13. OWNERS
  14. README.md
README.md

Accessibility Test Framework for Android

To help people with disabilities access Android apps, developers of those apps need to consider how their apps will be presented to accessibility services. Some good practices can be checked by automated tools, such as if a View has a contentDescription. Other rules require human judgment, such as whether or not a contentDescription makes sense to all users.

For more information about Mobile Accessibility, see http://www.w3.org/WAI/mobile/.

This library collects various accessibility-related checks on View objects as well as AccessibilityNodeInfo objects (which the Android framework derives from Views and sends to AccessibilityServices).

Building the Library

The supplied gradle wrapper and build.gradle file can be used to build the Accessibility Test Framework or import the project into Android Studio.

$ ./gradlew build

Sample Usage

Given a view, the following code runs all accessibility checks on all views in the hierarchy rooted at that view and throws an exception if any errors are found:

ImmutableSet<AccessibilityHierarchyCheck> checks =
    AccessibilityCheckPreset.getAccessibilityHierarchyChecksForPreset(
        AccessibilityCheckPreset.LATEST);
AccessibilityHierarchyAndroid hierarchy = AccessibilityHierarchyAndroid.newBuilder(view).build();
List<AccessibilityHierarchyCheckResult> results = new ArrayList<>();
for (AccessibilityHierarchyCheck check : checks) {
  results.addAll(check.runCheckOnHierarchy(hierarchy));
}
List<AccessibilityHierarchyCheckResult> errors =
    AccessibilityCheckResultUtils.getResultsForType(
        results, AccessibilityCheckResultType.ERROR);
if (!errors.isEmpty()) {
  throw new RuntimeException(errors.get(0).getMessage().toString());
}