From fe965a5664e6bd24e422ea0895936d012a7fdf80 Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Mon, 29 Jun 2026 13:12:28 -0700 Subject: [PATCH 1/5] Re-enable action_sheet_test.dart. The only use of TestSemantics in cupertino_ui. I refactored it to use the preferred tester.find.semantics instead. --- .../action_sheet_test.dart | 95 +++++-------------- 1 file changed, 22 insertions(+), 73 deletions(-) rename packages/cupertino_ui/{temporarily_disabled_tests => test}/action_sheet_test.dart (96%) diff --git a/packages/cupertino_ui/temporarily_disabled_tests/action_sheet_test.dart b/packages/cupertino_ui/test/action_sheet_test.dart similarity index 96% rename from packages/cupertino_ui/temporarily_disabled_tests/action_sheet_test.dart rename to packages/cupertino_ui/test/action_sheet_test.dart index 143b82573da5..fb07af9203c9 100644 --- a/packages/cupertino_ui/temporarily_disabled_tests/action_sheet_test.dart +++ b/packages/cupertino_ui/test/action_sheet_test.dart @@ -2,9 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -@Skip( - 'This file is skipped due to a cross-import that needs to be fixed. Tracked in https://github.com/flutter/flutter/issues/177028.', -) // This file is run as part of a reduced test set in CI on Mac and Windows // machines. @Tags(['reduced-test-set']) @@ -19,8 +16,6 @@ import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import '../widgets/semantics_tester.dart'; - void main() { testWidgets('Overall appearance is correct for the light theme', (WidgetTester tester) async { await tester.pumpWidget( @@ -1727,8 +1722,6 @@ void main() { }, skip: isBrowser); // https://github.com/flutter/flutter/issues/56001 testWidgets('Action sheet semantics', (WidgetTester tester) async { - final semantics = SemanticsTester(tester); - await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( CupertinoActionSheet( @@ -1746,74 +1739,30 @@ void main() { await tester.tap(find.text('Go')); await tester.pumpAndSettle(); + final Finder sheetFinder = find.bySemanticsLabel('Alert'); + final SemanticsNode sheet = tester.semantics.find(find.bySemanticsLabel('Alert')); + expect(sheet.role, SemanticsRole.dialog); + expect(sheet, isSemantics(label: 'Alert', namesRoute: true, scopesRoute: true)); expect( - semantics, - hasSemantics( - TestSemantics.root( - children: [ - TestSemantics( - children: [ - TestSemantics( - children: [ - TestSemantics( - flags: [SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute], - label: 'Alert', - role: SemanticsRole.dialog, - children: [ - TestSemantics( - flags: [SemanticsFlag.hasImplicitScrolling], - children: [ - TestSemantics(label: 'The title'), - TestSemantics(label: 'The message'), - ], - ), - TestSemantics( - flags: [SemanticsFlag.hasImplicitScrolling], - children: [ - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.isFocusable, - ], - actions: [ - SemanticsAction.tap, - SemanticsAction.focus, - ], - label: 'One', - ), - TestSemantics( - flags: [ - SemanticsFlag.isButton, - SemanticsFlag.isFocusable, - ], - actions: [ - SemanticsAction.tap, - SemanticsAction.focus, - ], - label: 'Two', - ), - ], - ), - TestSemantics( - flags: [SemanticsFlag.isButton, SemanticsFlag.isFocusable], - actions: [SemanticsAction.tap, SemanticsAction.focus], - label: 'Cancel', - ), - ], - ), - ], - ), - ], - ), - ], - ), - ignoreId: true, - ignoreRect: true, - ignoreTransform: true, - ), + find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('The title')), + findsOneWidget, ); - - semantics.dispose(); + expect( + find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('The message')), + findsOneWidget, + ); + final SemanticsNode buttonOne = tester.semantics.find( + find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('One')), + ); + expect(buttonOne, isSemantics(isButton: true, isFocusable: true)); + final SemanticsNode buttonTwo = tester.semantics.find( + find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('Two')), + ); + expect(buttonTwo, isSemantics(isButton: true, isFocusable: true)); + final SemanticsNode buttonCancel = tester.semantics.find( + find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('Cancel')), + ); + expect(buttonCancel, isSemantics(isButton: true, isFocusable: true)); }); testWidgets('Conflicting scrollbars are not applied by ScrollBehavior to CupertinoActionSheet', ( From 2cca7c1c29fdbb0d3c887f6eae39ed5508e5b548 Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Mon, 29 Jun 2026 14:25:44 -0700 Subject: [PATCH 2/5] Test button actions --- packages/cupertino_ui/test/action_sheet_test.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cupertino_ui/test/action_sheet_test.dart b/packages/cupertino_ui/test/action_sheet_test.dart index fb07af9203c9..adaa6e2d25c3 100644 --- a/packages/cupertino_ui/test/action_sheet_test.dart +++ b/packages/cupertino_ui/test/action_sheet_test.dart @@ -1754,15 +1754,15 @@ void main() { final SemanticsNode buttonOne = tester.semantics.find( find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('One')), ); - expect(buttonOne, isSemantics(isButton: true, isFocusable: true)); + expect(buttonOne, isSemantics(isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true)); final SemanticsNode buttonTwo = tester.semantics.find( find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('Two')), ); - expect(buttonTwo, isSemantics(isButton: true, isFocusable: true)); + expect(buttonTwo, isSemantics(isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true)); final SemanticsNode buttonCancel = tester.semantics.find( find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('Cancel')), ); - expect(buttonCancel, isSemantics(isButton: true, isFocusable: true)); + expect(buttonCancel, isSemantics(isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true)); }); testWidgets('Conflicting scrollbars are not applied by ScrollBehavior to CupertinoActionSheet', ( From 49a84dac970e8bbb798724771f60f1d159bc09ea Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Mon, 29 Jun 2026 15:56:33 -0700 Subject: [PATCH 3/5] SemanticsHandle and formatting --- .../cupertino_ui/test/action_sheet_test.dart | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/cupertino_ui/test/action_sheet_test.dart b/packages/cupertino_ui/test/action_sheet_test.dart index adaa6e2d25c3..4faf91d2abc5 100644 --- a/packages/cupertino_ui/test/action_sheet_test.dart +++ b/packages/cupertino_ui/test/action_sheet_test.dart @@ -1722,6 +1722,9 @@ void main() { }, skip: isBrowser); // https://github.com/flutter/flutter/issues/56001 testWidgets('Action sheet semantics', (WidgetTester tester) async { + final SemanticsHandle semanticsHandle = tester.ensureSemantics(); + addTearDown(semanticsHandle.dispose); + await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( CupertinoActionSheet( @@ -1754,15 +1757,24 @@ void main() { final SemanticsNode buttonOne = tester.semantics.find( find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('One')), ); - expect(buttonOne, isSemantics(isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true)); + expect( + buttonOne, + isSemantics(isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true), + ); final SemanticsNode buttonTwo = tester.semantics.find( find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('Two')), ); - expect(buttonTwo, isSemantics(isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true)); + expect( + buttonTwo, + isSemantics(isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true), + ); final SemanticsNode buttonCancel = tester.semantics.find( find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('Cancel')), ); - expect(buttonCancel, isSemantics(isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true)); + expect( + buttonCancel, + isSemantics(isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true), + ); }); testWidgets('Conflicting scrollbars are not applied by ScrollBehavior to CupertinoActionSheet', ( From 507538c44cb422556dcbe06be8028d6e814534be Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Mon, 29 Jun 2026 18:52:27 -0700 Subject: [PATCH 4/5] No ensureSemantics needed. --- packages/cupertino_ui/test/action_sheet_test.dart | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/cupertino_ui/test/action_sheet_test.dart b/packages/cupertino_ui/test/action_sheet_test.dart index 4faf91d2abc5..69e2733c8ca4 100644 --- a/packages/cupertino_ui/test/action_sheet_test.dart +++ b/packages/cupertino_ui/test/action_sheet_test.dart @@ -1722,9 +1722,6 @@ void main() { }, skip: isBrowser); // https://github.com/flutter/flutter/issues/56001 testWidgets('Action sheet semantics', (WidgetTester tester) async { - final SemanticsHandle semanticsHandle = tester.ensureSemantics(); - addTearDown(semanticsHandle.dispose); - await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( CupertinoActionSheet( From 9969edcc401f9ec849592fac1fc62ab09bb905a8 Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Mon, 29 Jun 2026 19:03:13 -0700 Subject: [PATCH 5/5] Test full semantics tree --- .../cupertino_ui/test/action_sheet_test.dart | 70 +++++++++++-------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/packages/cupertino_ui/test/action_sheet_test.dart b/packages/cupertino_ui/test/action_sheet_test.dart index 69e2733c8ca4..7fcd5fdfae93 100644 --- a/packages/cupertino_ui/test/action_sheet_test.dart +++ b/packages/cupertino_ui/test/action_sheet_test.dart @@ -1739,38 +1739,50 @@ void main() { await tester.tap(find.text('Go')); await tester.pumpAndSettle(); - final Finder sheetFinder = find.bySemanticsLabel('Alert'); final SemanticsNode sheet = tester.semantics.find(find.bySemanticsLabel('Alert')); expect(sheet.role, SemanticsRole.dialog); - expect(sheet, isSemantics(label: 'Alert', namesRoute: true, scopesRoute: true)); expect( - find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('The title')), - findsOneWidget, - ); - expect( - find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('The message')), - findsOneWidget, - ); - final SemanticsNode buttonOne = tester.semantics.find( - find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('One')), - ); - expect( - buttonOne, - isSemantics(isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true), - ); - final SemanticsNode buttonTwo = tester.semantics.find( - find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('Two')), - ); - expect( - buttonTwo, - isSemantics(isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true), - ); - final SemanticsNode buttonCancel = tester.semantics.find( - find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('Cancel')), - ); - expect( - buttonCancel, - isSemantics(isButton: true, isFocusable: true, hasTapAction: true, hasFocusAction: true), + sheet, + isSemantics( + label: 'Alert', + namesRoute: true, + scopesRoute: true, + children: [ + isSemantics( + hasImplicitScrolling: true, + children: [ + isSemantics(label: 'The title'), + isSemantics(label: 'The message'), + ], + ), + isSemantics( + hasImplicitScrolling: true, + children: [ + isSemantics( + label: 'One', + isButton: true, + isFocusable: true, + hasTapAction: true, + hasFocusAction: true, + ), + isSemantics( + label: 'Two', + isButton: true, + isFocusable: true, + hasTapAction: true, + hasFocusAction: true, + ), + ], + ), + isSemantics( + label: 'Cancel', + isButton: true, + isFocusable: true, + hasTapAction: true, + hasFocusAction: true, + ), + ], + ), ); });