Accessibility-Test-Framework-for-Android icon indicating copy to clipboard operation
Accessibility-Test-Framework-for-Android copied to clipboard

An unexpected SpeakableText check result

Open Nancy945 opened this issue 4 years ago • 2 comments

For this layout, SpeakableTextPresentCheck tells me the view of "id_test1" is RESULT_ID_SHOULD_NOT_FOCUS. In fact,talkback would focus it. Is it a bug?

<RelativeLayout
    android:id="@+id/id_test1"
    android:layout_width="wrap_content"
    android:layout_height="60dp"
    android:clickable="true">
    <RelativeLayout
        android:id="@+id/id_test2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <TextView
            android:id="@+id/id_test3"
            android:text="foo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>
    </RelativeLayout>
</RelativeLayout>

Nancy945 avatar Jan 08 '21 12:01 Nancy945

Thanks for the report -- I'll take a look at what might be going on here. Just glancing at the layout, I believe I'd expect:

  • No result for id_test1, since it would be focused, but should have a spoken description of "foo" aggregated from the id_test3 TextView
  • A NOT_RUN result for id_test2 of RESULT_ID_NOT_IMPORTANT_FOR_ACCESSIBILITY
  • A NOT_RUN result for id_test3 of RESULT_ID_SHOULD_NOT_FOCUS, since id_test1 would be the focus-qualifying element which would include its text.

Would you share some info on how you're invoking SpeakableTextPresentCheck? Is this from an Espresso test, Accessibility Scanner, or something else?

caseyburkhardt avatar Jan 15 '21 04:01 caseyburkhardt

Thanks for your reply. I downloaded the source code and resolved the dependency problems.I did not change any key source code. Then I ran the following code when a button clicked in a demo project without any test framework.

    Set<AccessibilityHierarchyCheck> checks =AccessibilityCheckPreset.getAccessibilityHierarchyChecksForPreset(AccessibilityCheckPreset.LATEST);
    AccessibilityHierarchy hierarchy = AccessibilityHierarchy.newBuilder(findViewById(R.id.id_test1)).build();
    List<AccessibilityHierarchyCheckResult> results = new ArrayList<>();
    for (AccessibilityHierarchyCheck check : checks) {
        if(check instanceof SpeakableTextPresentCheck){
            results.addAll(check.runCheckOnHierarchy(hierarchy));
        }
    }

and I get the result with 2 suggestions

id/id_test1,description:This item would not be focused by a screen reader id/id_test2,description:This item was not found to be important for accessibility.

I can't understand the first suggestion, because I actually focused id_test1 when using talkback,and I know it is reasonable.

Nancy945 avatar Jan 15 '21 11:01 Nancy945