-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds ATF Accessibility checks to roboscreenshots (#2448)
This commit adds accessibility tests for the Box composable. It also adds a shadow for AccessibilityManager and a non-shadow shadow for AccessibilityNodeInfo. The dependencies are updated to include the Accessibility Test Framework. Adds Accessibility testing utilities to roboscreenshots to allow for accessibility tests in Robolectric screenshots.
- Loading branch information
Showing
14 changed files
with
117 additions
and
16 deletions.
There are no files selected for viewing
4 changes: 2 additions & 2 deletions
4
...images/com.google.android.horologist.compose.material_StepperA11yTest_float.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...s/images/com.google.android.horologist.compose.material_StepperA11yTest_int.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...st.health.composables.screens_MetricsScreenA11yTest_metricsScreenTwoMetrics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions
4
...ealth.composables.screens_MetricsScreenA11yTest_metricsScreenTwoMetrics_rtl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...oid.horologist.media.ui_MediaPlayerA11yScreenshotTest_mediaPlayerLargeRound.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...in/java/com/google/android/horologist/screenshots/a11y/ExtraShadowAccessibilityManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2024 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.android.horologist.screenshots.a11y | ||
|
||
import android.annotation.SuppressLint | ||
import android.view.accessibility.AccessibilityManager | ||
import org.robolectric.annotation.Implementation | ||
import org.robolectric.annotation.Implements | ||
import org.robolectric.shadows.ShadowAccessibilityManager | ||
import org.robolectric.versioning.AndroidVersions.U | ||
|
||
@Implements(AccessibilityManager::class) | ||
internal class ExtraShadowAccessibilityManager : ShadowAccessibilityManager() { | ||
|
||
/** | ||
* This shadow method is required because {@link | ||
* android.view.accessibility.DirectAccessibilityConnection} calls it to determine if any | ||
* transformations have occurred on this window. | ||
*/ | ||
@SuppressLint("PrivateApi") | ||
@Implementation(minSdk = U.SDK_INT) | ||
fun getWindowTransformationSpec(windowId: Int): Any { | ||
val instance = | ||
Class.forName("android.view.accessibility.IAccessibilityManager\$WindowTransformationSpec") | ||
.getDeclaredConstructor().newInstance() | ||
|
||
return instance | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...va/com/google/android/horologist/screenshots/a11y/NonShadowShadowAccessibilityNodeInfo.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright 2024 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.google.android.horologist.screenshots.a11y | ||
|
||
import android.view.accessibility.AccessibilityNodeInfo | ||
import org.robolectric.annotation.Implements | ||
|
||
@Implements(AccessibilityNodeInfo::class) | ||
internal class NonShadowShadowAccessibilityNodeInfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters