commit | ed9d9a3123db38f3b63bbf98c636a3a680398b59 | [log] [tgz] |
---|---|---|
author | Yara Hassan <yaraabdullatif@google.com> | Mon Mar 25 13:57:06 2024 +0000 |
committer | Yara Hassan <yaraabdullatif@google.com> | Mon Mar 25 14:49:03 2024 +0000 |
tree | 1e03ac9360b87dcca1c4cea1d82ae6e25cfe4e45 | |
parent | 858625c4d9ad2acddee5cfbc1dedd54c76da9365 [diff] |
Add metadata files for accessibility-test-framework Third-Party Import of: https://github.com/google/Accessibility-Test-Framework-for-Android Request Document: go/android3p For CL Reviewers: go/android3p#cl-review For Build Team: go/ab-third-party-imports Bug: http://b/328779485#comment1 Test: N/A -- follow-up CL needed to fix dependencies Change-Id: I10ca668915841f0e5e99cdd5b4ce6c04fb079b2c
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).
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
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()); }