@@ -927,6 +927,65 @@ void main() {
927927
928928 semantics.dispose ();
929929 });
930+
931+ for (final Axis axis in Axis .values) {
932+ for (final reverse in < bool > [false , true ]) {
933+ for (final TextDirection textDirection in TextDirection .values) {
934+ testWidgets ('semantics scrolling respects $axis , reverse=$reverse , $textDirection ' , (
935+ WidgetTester tester,
936+ ) async {
937+ final semantics = SemanticsTester (tester);
938+ final controller = ScrollController ();
939+ addTearDown (controller.dispose);
940+ final reversed =
941+ reverse != (axis == Axis .horizontal && textDirection == TextDirection .rtl);
942+ final SemanticsAction action = switch (axis) {
943+ Axis .vertical => reversed ? SemanticsAction .scrollDown : SemanticsAction .scrollUp,
944+ Axis .horizontal => reversed ? SemanticsAction .scrollRight : SemanticsAction .scrollLeft,
945+ };
946+ await tester.pumpWidget (
947+ Directionality (
948+ textDirection: textDirection,
949+ child: ListView (
950+ controller: controller,
951+ scrollDirection: axis,
952+ reverse: reverse,
953+ itemExtent: 100.0 ,
954+ children: List <Widget >.generate (20 , (int i) => Text ('$i ' )),
955+ ),
956+ ),
957+ );
958+ final SemanticsNode scrollable = findNodeWithAction (
959+ tester.binding.pipelineOwner.semanticsOwner! .rootSemanticsNode! ,
960+ action,
961+ )! ;
962+ tester.binding.pipelineOwner.semanticsOwner! .performAction (scrollable.id, action);
963+ await tester.pump ();
964+ expect (controller.offset, 0.0 );
965+ await tester.pump (const Duration (milliseconds: 50 ));
966+ final double expectedOffset = controller.position.viewportDimension * 0.8 ;
967+ expect (controller.offset, greaterThan (0.0 ));
968+ expect (controller.offset, lessThan (expectedOffset));
969+ await tester.pumpAndSettle ();
970+ expect (controller.offset, expectedOffset);
971+ final SemanticsAction oppositeAction = switch (action) {
972+ SemanticsAction .scrollUp => SemanticsAction .scrollDown,
973+ SemanticsAction .scrollDown => SemanticsAction .scrollUp,
974+ SemanticsAction .scrollLeft => SemanticsAction .scrollRight,
975+ _ => SemanticsAction .scrollLeft,
976+ };
977+ tester.binding.pipelineOwner.semanticsOwner! .performAction (scrollable.id, oppositeAction);
978+ await tester.pump ();
979+ await tester.pump (const Duration (milliseconds: 50 ));
980+ expect (controller.offset, greaterThan (0.0 ));
981+ expect (controller.offset, lessThan (expectedOffset));
982+ await tester.pumpAndSettle ();
983+ expect (controller.offset, 0.0 );
984+ semantics.dispose ();
985+ });
986+ }
987+ }
988+ }
930989}
931990
932991SemanticsNode ? findNodeWithAction (SemanticsNode node, SemanticsAction action) {
0 commit comments