Skip to content

Commit fe965a5

Browse files
committed
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.
1 parent 44be986 commit fe965a5

1 file changed

Lines changed: 22 additions & 73 deletions

File tree

packages/cupertino_ui/temporarily_disabled_tests/action_sheet_test.dart renamed to packages/cupertino_ui/test/action_sheet_test.dart

Lines changed: 22 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5-
@Skip(
6-
'This file is skipped due to a cross-import that needs to be fixed. Tracked in https://github.com/flutter/flutter/issues/177028.',
7-
)
85
// This file is run as part of a reduced test set in CI on Mac and Windows
96
// machines.
107
@Tags(<String>['reduced-test-set'])
@@ -19,8 +16,6 @@ import 'package:flutter/services.dart';
1916

2017
import 'package:flutter_test/flutter_test.dart';
2118

22-
import '../widgets/semantics_tester.dart';
23-
2419
void main() {
2520
testWidgets('Overall appearance is correct for the light theme', (WidgetTester tester) async {
2621
await tester.pumpWidget(
@@ -1727,8 +1722,6 @@ void main() {
17271722
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/56001
17281723

17291724
testWidgets('Action sheet semantics', (WidgetTester tester) async {
1730-
final semantics = SemanticsTester(tester);
1731-
17321725
await tester.pumpWidget(
17331726
createAppWithButtonThatLaunchesActionSheet(
17341727
CupertinoActionSheet(
@@ -1746,74 +1739,30 @@ void main() {
17461739
await tester.tap(find.text('Go'));
17471740
await tester.pumpAndSettle();
17481741

1742+
final Finder sheetFinder = find.bySemanticsLabel('Alert');
1743+
final SemanticsNode sheet = tester.semantics.find(find.bySemanticsLabel('Alert'));
1744+
expect(sheet.role, SemanticsRole.dialog);
1745+
expect(sheet, isSemantics(label: 'Alert', namesRoute: true, scopesRoute: true));
17491746
expect(
1750-
semantics,
1751-
hasSemantics(
1752-
TestSemantics.root(
1753-
children: <TestSemantics>[
1754-
TestSemantics(
1755-
children: <TestSemantics>[
1756-
TestSemantics(
1757-
children: <TestSemantics>[
1758-
TestSemantics(
1759-
flags: <SemanticsFlag>[SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute],
1760-
label: 'Alert',
1761-
role: SemanticsRole.dialog,
1762-
children: <TestSemantics>[
1763-
TestSemantics(
1764-
flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
1765-
children: <TestSemantics>[
1766-
TestSemantics(label: 'The title'),
1767-
TestSemantics(label: 'The message'),
1768-
],
1769-
),
1770-
TestSemantics(
1771-
flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling],
1772-
children: <TestSemantics>[
1773-
TestSemantics(
1774-
flags: <SemanticsFlag>[
1775-
SemanticsFlag.isButton,
1776-
SemanticsFlag.isFocusable,
1777-
],
1778-
actions: <SemanticsAction>[
1779-
SemanticsAction.tap,
1780-
SemanticsAction.focus,
1781-
],
1782-
label: 'One',
1783-
),
1784-
TestSemantics(
1785-
flags: <SemanticsFlag>[
1786-
SemanticsFlag.isButton,
1787-
SemanticsFlag.isFocusable,
1788-
],
1789-
actions: <SemanticsAction>[
1790-
SemanticsAction.tap,
1791-
SemanticsAction.focus,
1792-
],
1793-
label: 'Two',
1794-
),
1795-
],
1796-
),
1797-
TestSemantics(
1798-
flags: <SemanticsFlag>[SemanticsFlag.isButton, SemanticsFlag.isFocusable],
1799-
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
1800-
label: 'Cancel',
1801-
),
1802-
],
1803-
),
1804-
],
1805-
),
1806-
],
1807-
),
1808-
],
1809-
),
1810-
ignoreId: true,
1811-
ignoreRect: true,
1812-
ignoreTransform: true,
1813-
),
1747+
find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('The title')),
1748+
findsOneWidget,
18141749
);
1815-
1816-
semantics.dispose();
1750+
expect(
1751+
find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('The message')),
1752+
findsOneWidget,
1753+
);
1754+
final SemanticsNode buttonOne = tester.semantics.find(
1755+
find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('One')),
1756+
);
1757+
expect(buttonOne, isSemantics(isButton: true, isFocusable: true));
1758+
final SemanticsNode buttonTwo = tester.semantics.find(
1759+
find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('Two')),
1760+
);
1761+
expect(buttonTwo, isSemantics(isButton: true, isFocusable: true));
1762+
final SemanticsNode buttonCancel = tester.semantics.find(
1763+
find.descendant(of: sheetFinder, matching: find.bySemanticsLabel('Cancel')),
1764+
);
1765+
expect(buttonCancel, isSemantics(isButton: true, isFocusable: true));
18171766
});
18181767

18191768
testWidgets('Conflicting scrollbars are not applied by ScrollBehavior to CupertinoActionSheet', (

0 commit comments

Comments
 (0)