Skip to content

SemanticsController.simulatedAccessibilityTraversal broken in multiple views #143405

@Piinks

Description

@Piinks

Found in

In SemanticsController.simulatedAccessibilityTraversal, the start and end parameters are deprecated. They are replaced by startNode and endNode, but writing a test for this in the context of multiple views fails.

I wrote such a test in packages/flutter_test/test/multi_view_controller_test.dart

testWidgets('simulatedAccessibilityTraversal - startNode and endNode in same view', (WidgetTester tester) async {
    tester.binding.ensureSemantics();
    await pumpViews(tester: tester);
    expect(
      tester.semantics.simulatedAccessibilityTraversal(
        startNode: find.semantics.byValue('View2Child1'),
        endNode: find.semantics.byValue('View2Child3'),
      ).map((SemanticsNode node) => node.label),
      <String>[
        'View2Child1',
        'View2Child2',
        'View2Child3',
      ],
    );
  });

but it failed with

Bad state: No element

When the exception was thrown, this was the stack:
#0      Iterable.single (dart:core/iterable.dart:674:25)
#1      SemanticsController.simulatedAccessibilityTraversal (package:flutter_test/src/controller.dart:207:57)

This is coming from here when we are trying to look up the SemanticsOwner:

final SemanticsOwner owner = startNode.evaluate().single.owner!;

The new API works in the single view world, so I am going to move forward with that PR to resolve other issues unrelated to this one.

cc @goderbauer

Metadata

Metadata

Assignees

Labels

a: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: tests"flutter test", flutter_test, or one of our testsfound in release: 3.20Found to occur in 3.20frameworkflutter/packages/flutter repository. See also f: labels.team-frameworkOwned by Framework team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions