diff --git a/packages/cupertino_ui/temporarily_disabled_tests/picker_test.dart b/packages/cupertino_ui/test/picker_test.dart similarity index 95% rename from packages/cupertino_ui/temporarily_disabled_tests/picker_test.dart rename to packages/cupertino_ui/test/picker_test.dart index 9efd956e277c..a739f38b9d12 100644 --- a/packages/cupertino_ui/temporarily_disabled_tests/picker_test.dart +++ b/packages/cupertino_ui/test/picker_test.dart @@ -2,17 +2,12 @@ // 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.', -) import 'package:cupertino_ui/cupertino_ui.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import '../widgets/semantics_tester.dart'; - /// A [CustomPainter] that calls a callback when it paints. class TestCallbackPainter extends CustomPainter { /// Creates a [TestCallbackPainter] that calls [onPaint] when it paints. @@ -73,7 +68,7 @@ void main() { }); testWidgets('Picker semantics', (WidgetTester tester) async { - final semantics = SemanticsTester(tester); + final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget( CupertinoApp( @@ -90,11 +85,16 @@ void main() { ), ); expect( - semantics, - includesNodeWith( + tester.getSemantics( + find.byWidgetPredicate( + (Widget widget) => widget.runtimeType.toString() == '_CupertinoPickerSemantics', + ), + ), + isSemantics( value: '0', increasedValue: '1', - actions: [SemanticsAction.increase], + hasIncreaseAction: true, + hasDecreaseAction: false, ), ); @@ -105,15 +105,21 @@ void main() { hourListController.jumpToItem(11); await tester.pumpAndSettle(); expect( - semantics, - includesNodeWith( + tester.getSemantics( + find.byWidgetPredicate( + (Widget widget) => widget.runtimeType.toString() == '_CupertinoPickerSemantics', + ), + ), + isSemantics( value: '11', increasedValue: '12', decreasedValue: '10', - actions: [SemanticsAction.increase, SemanticsAction.decrease], + hasIncreaseAction: true, + hasDecreaseAction: true, ), ); - semantics.dispose(); + + handle.dispose(); }); testWidgets('Picker semantics excludes current item with empty label', ( @@ -121,7 +127,7 @@ void main() { ) async { // When the current item has an empty label (e.g., wrapped with ExcludeSemantics), // the picker should not set any value, increasedValue, decreasedValue, or actions. - final semantics = SemanticsTester(tester); + final SemanticsHandle handle = tester.ensureSemantics(); final controller = FixedExtentScrollController(initialItem: 1); addTearDown(controller.dispose); @@ -146,15 +152,13 @@ void main() { // When the current item (index 1) has an empty label due to ExcludeSemantics, // the picker should not have any value or actions set. - expect(semantics, isNot(includesNodeWith(value: '1'))); - // Also verify that no increase/decrease actions are set for this item. - expect( - semantics, - isNot(includesNodeWith(actions: [SemanticsAction.increase])), - ); expect( - semantics, - isNot(includesNodeWith(actions: [SemanticsAction.decrease])), + tester.getSemantics( + find.byWidgetPredicate( + (Widget widget) => widget.runtimeType.toString() == '_CupertinoPickerSemantics', + ), + ), + isSemantics(value: '', hasIncreaseAction: false, hasDecreaseAction: false), ); // Scroll to item 0 which has a valid label. @@ -163,10 +167,13 @@ void main() { // Now the picker should have value '0' but no increase action // because the next item (1) has an empty label. - expect(semantics, includesNodeWith(value: '0')); expect( - semantics, - isNot(includesNodeWith(value: '0', actions: [SemanticsAction.increase])), + tester.getSemantics( + find.byWidgetPredicate( + (Widget widget) => widget.runtimeType.toString() == '_CupertinoPickerSemantics', + ), + ), + isSemantics(value: '0', hasIncreaseAction: false, hasDecreaseAction: false), ); // Scroll to item 2 which has a valid label. @@ -175,13 +182,15 @@ void main() { // Now the picker should have value '2' but no decrease action // because the previous item (1) has an empty label. - expect(semantics, includesNodeWith(value: '2')); expect( - semantics, - isNot(includesNodeWith(value: '2', actions: [SemanticsAction.decrease])), + tester.getSemantics( + find.byWidgetPredicate( + (Widget widget) => widget.runtimeType.toString() == '_CupertinoPickerSemantics', + ), + ), + isSemantics(value: '2', hasDecreaseAction: false, hasIncreaseAction: false), ); - - semantics.dispose(); + handle.dispose(); }); group('layout', () {