Skip to content

Commit 62f3d4d

Browse files
Remove semantics_tester import from cupertino/slider_test.dart (#184805)
Part of #182636 ## Summary Remove the `semantics_tester.dart` cross-import from `cupertino/slider_test.dart`. ## What changed * Replaced the deprecated `SemanticsTester`/`TestSemantics` assertion in the slider semantics test with `tester.getSemantics(...)` and `matchesSemantics(...)` * Removed the `../widgets/semantics_tester.dart` import ## Testing * `../../bin/flutter analyze test/cupertino/slider_test.dart` * `../../bin/flutter test test/cupertino/slider_test.dart` --------- Co-authored-by: Victor Sanni <victorsanniay@gmail.com>
1 parent 7b9f28c commit 62f3d4d

1 file changed

Lines changed: 12 additions & 33 deletions

File tree

packages/flutter/test/cupertino/slider_test.dart

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import 'package:flutter/scheduler.dart';
1010
import 'package:flutter/services.dart';
1111
import 'package:flutter_test/flutter_test.dart';
1212

13-
import '../widgets/semantics_tester.dart';
14-
1513
const CupertinoDynamicColor _kSystemFill = CupertinoDynamicColor(
1614
color: Color.fromARGB(51, 120, 120, 128),
1715
darkColor: Color.fromARGB(91, 120, 120, 128),
@@ -434,7 +432,7 @@ void main() {
434432
});
435433

436434
testWidgets('Slider Semantics', (WidgetTester tester) async {
437-
final semantics = SemanticsTester(tester);
435+
final SemanticsHandle handle = tester.ensureSemantics();
438436

439437
await tester.pumpWidget(
440438
MediaQuery(
@@ -447,23 +445,15 @@ void main() {
447445
);
448446

449447
expect(
450-
semantics,
451-
hasSemantics(
452-
TestSemantics.root(
453-
children: <TestSemantics>[
454-
TestSemantics.rootChild(
455-
id: 1,
456-
value: '50%',
457-
increasedValue: '60%',
458-
decreasedValue: '40%',
459-
textDirection: TextDirection.ltr,
460-
flags: <SemanticsFlag>[SemanticsFlag.isSlider],
461-
actions: SemanticsAction.decrease.index | SemanticsAction.increase.index,
462-
),
463-
],
464-
),
465-
ignoreRect: true,
466-
ignoreTransform: true,
448+
tester.getSemantics(find.byType(CupertinoSlider)),
449+
matchesSemantics(
450+
isSlider: true,
451+
hasIncreaseAction: true,
452+
hasDecreaseAction: true,
453+
value: '50%',
454+
increasedValue: '60%',
455+
decreasedValue: '40%',
456+
textDirection: TextDirection.ltr,
467457
),
468458
);
469459

@@ -478,20 +468,9 @@ void main() {
478468
),
479469
);
480470

481-
expect(
482-
semantics,
483-
hasSemantics(
484-
TestSemantics.root(
485-
children: <TestSemantics>[
486-
TestSemantics(id: 1, flags: <SemanticsFlag>[SemanticsFlag.isSlider]),
487-
],
488-
),
489-
ignoreRect: true,
490-
ignoreTransform: true,
491-
),
492-
);
471+
expect(tester.getSemantics(find.byType(CupertinoSlider)), matchesSemantics(isSlider: true));
493472

494-
semantics.dispose();
473+
handle.dispose();
495474
});
496475

497476
testWidgets('Slider Semantics can be updated', (WidgetTester tester) async {

0 commit comments

Comments
 (0)