Skip to content

Commit 9768d30

Browse files
[cupertino_ui] Migrate radio_test.dart to SemanticsHandle (#11981)
Part of flutter/flutter#182636 and flutter/flutter#188395 This PR: * Removed the cross-import of `widgets/semantics_tester.dart`. Replaced `SemanticsTester` with `SemanticsHandle`. * Removed `@Skip` annotation, all tests in this file has passed. `semantics_tester.dart` has existed in `cupertino_ui`, so we can directly import `semantics_tester.dart`; * Moved the file to `test/` folder. ## Pre-Review Checklist
1 parent 66d9941 commit 9768d30

1 file changed

Lines changed: 22 additions & 29 deletions

File tree

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

Lines changed: 22 additions & 29 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
// reduced-test-set:
96
// This file is run as part of a reduced test set in CI on Mac and Windows
107
// machines.
@@ -18,8 +15,6 @@ import 'package:flutter/rendering.dart';
1815
import 'package:flutter/services.dart';
1916
import 'package:flutter_test/flutter_test.dart';
2017

21-
import '../widgets/semantics_tester.dart';
22-
2318
void main() {
2419
testWidgets('Radio control test', (WidgetTester tester) async {
2520
final Key key = UniqueKey();
@@ -146,7 +141,7 @@ void main() {
146141
});
147142

148143
testWidgets('Radio selected semantics - platform adaptive', (WidgetTester tester) async {
149-
final semantics = SemanticsTester(tester);
144+
final SemanticsHandle handle = tester.ensureSemantics();
150145

151146
await tester.pumpWidget(
152147
CupertinoApp(
@@ -158,29 +153,26 @@ void main() {
158153
defaultTargetPlatform == TargetPlatform.iOS ||
159154
defaultTargetPlatform == TargetPlatform.macOS;
160155
expect(
161-
semantics,
162-
includesNodeWith(
163-
flags: <SemanticsFlag>[
164-
SemanticsFlag.isInMutuallyExclusiveGroup,
165-
SemanticsFlag.hasCheckedState,
166-
SemanticsFlag.hasEnabledState,
167-
SemanticsFlag.isEnabled,
168-
SemanticsFlag.isFocusable,
169-
SemanticsFlag.isChecked,
170-
if (isApple) SemanticsFlag.hasSelectedState,
171-
if (isApple) SemanticsFlag.isSelected,
172-
],
173-
actions: <SemanticsAction>[
174-
SemanticsAction.tap,
175-
if (defaultTargetPlatform != TargetPlatform.iOS) SemanticsAction.focus,
176-
],
177-
),
178-
);
179-
semantics.dispose();
156+
tester.getSemantics(find.byType(CupertinoRadio<int>)),
157+
isSemantics(
158+
isInMutuallyExclusiveGroup: true,
159+
hasCheckedState: true,
160+
hasEnabledState: true,
161+
isEnabled: true,
162+
isFocusable: true,
163+
isChecked: true,
164+
hasSelectedState: isApple ? true : null,
165+
isSelected: isApple ? true : null,
166+
hasTapAction: true,
167+
hasFocusAction: defaultTargetPlatform != TargetPlatform.iOS ? true : null,
168+
),
169+
);
170+
171+
handle.dispose();
180172
}, variant: TargetPlatformVariant.all());
181173

182174
testWidgets('Radio semantics', (WidgetTester tester) async {
183-
final semantics = SemanticsTester(tester);
175+
final SemanticsHandle handle = tester.ensureSemantics();
184176

185177
await tester.pumpWidget(
186178
CupertinoApp(
@@ -262,11 +254,12 @@ void main() {
262254
),
263255
);
264256

265-
semantics.dispose();
257+
handle.dispose();
266258
});
267259

268260
testWidgets('has semantic events', (WidgetTester tester) async {
269-
final semantics = SemanticsTester(tester);
261+
final SemanticsHandle handle = tester.ensureSemantics();
262+
270263
final Key key = UniqueKey();
271264
dynamic semanticEvent;
272265
int? radioValue = 2;
@@ -303,7 +296,7 @@ void main() {
303296
});
304297
expect(object.debugSemantics!.getSemanticsData().hasAction(SemanticsAction.tap), true);
305298

306-
semantics.dispose();
299+
handle.dispose();
307300
tester.binding.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(
308301
SystemChannels.accessibility,
309302
null,

0 commit comments

Comments
 (0)