Bug: 328779485

Clone this repo:
  1. 00e9b06 Upgrade accessibility-test-framework to c65cab02b2a845c29c3da100d6adefd345a144e3 by Sadaf Ebrahimi · 6 days ago main
  2. 8f37895 Merge 24Q4 into AOSP main by Xin Li · 6 weeks ago simpleperf-release
  3. e7b301d Merge 24Q4 (ab/12406339) into aosp-main-future by Xin Li · 3 months ago tmp_24Q4_merged
  4. 4c730ac Clean up dependencies for "aatf" by Yara Hassan · 7 months ago
  5. 7d21876 Add jsoup to accessibility-test-framework deps by Yara Hassan · 8 months ago android15-tests-dev aml_art_350913340 aml_art_351011240 aml_art_351011340 aml_art_351110180 aml_cbr_350910020 aml_net_350911020 aml_per_350910080 aml_rkp_350910000 aml_sdk_350910000 aml_tet_350911120 aml_uwb_350911040 aml_wif_350912040

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());
}