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- )
85import 'package:cupertino_ui/cupertino_ui.dart' ;
96import 'package:flutter/foundation.dart' ;
107import 'package:flutter/rendering.dart' ;
118import 'package:flutter/services.dart' ;
129import 'package:flutter_test/flutter_test.dart' ;
1310
14- import '../widgets/semantics_tester.dart' ;
15-
1611/// A [CustomPainter] that calls a callback when it paints.
1712class TestCallbackPainter extends CustomPainter {
1813 /// Creates a [TestCallbackPainter] that calls [onPaint] when it paints.
@@ -73,7 +68,7 @@ void main() {
7368 });
7469
7570 testWidgets ('Picker semantics' , (WidgetTester tester) async {
76- final semantics = SemanticsTester ( tester);
71+ final SemanticsHandle handle = tester. ensureSemantics ( );
7772
7873 await tester.pumpWidget (
7974 CupertinoApp (
@@ -90,11 +85,16 @@ void main() {
9085 ),
9186 );
9287 expect (
93- semantics,
94- includesNodeWith (
88+ tester.getSemantics (
89+ find.byWidgetPredicate (
90+ (Widget widget) => widget.runtimeType.toString () == '_CupertinoPickerSemantics' ,
91+ ),
92+ ),
93+ isSemantics (
9594 value: '0' ,
9695 increasedValue: '1' ,
97- actions: < SemanticsAction > [SemanticsAction .increase],
96+ hasIncreaseAction: true ,
97+ hasDecreaseAction: false ,
9898 ),
9999 );
100100
@@ -105,23 +105,29 @@ void main() {
105105 hourListController.jumpToItem (11 );
106106 await tester.pumpAndSettle ();
107107 expect (
108- semantics,
109- includesNodeWith (
108+ tester.getSemantics (
109+ find.byWidgetPredicate (
110+ (Widget widget) => widget.runtimeType.toString () == '_CupertinoPickerSemantics' ,
111+ ),
112+ ),
113+ isSemantics (
110114 value: '11' ,
111115 increasedValue: '12' ,
112116 decreasedValue: '10' ,
113- actions: < SemanticsAction > [SemanticsAction .increase, SemanticsAction .decrease],
117+ hasIncreaseAction: true ,
118+ hasDecreaseAction: true ,
114119 ),
115120 );
116- semantics.dispose ();
121+
122+ handle.dispose ();
117123 });
118124
119125 testWidgets ('Picker semantics excludes current item with empty label' , (
120126 WidgetTester tester,
121127 ) async {
122128 // When the current item has an empty label (e.g., wrapped with ExcludeSemantics),
123129 // the picker should not set any value, increasedValue, decreasedValue, or actions.
124- final semantics = SemanticsTester ( tester);
130+ final SemanticsHandle handle = tester. ensureSemantics ( );
125131 final controller = FixedExtentScrollController (initialItem: 1 );
126132 addTearDown (controller.dispose);
127133
@@ -146,15 +152,13 @@ void main() {
146152
147153 // When the current item (index 1) has an empty label due to ExcludeSemantics,
148154 // the picker should not have any value or actions set.
149- expect (semantics, isNot (includesNodeWith (value: '1' )));
150- // Also verify that no increase/decrease actions are set for this item.
151- expect (
152- semantics,
153- isNot (includesNodeWith (actions: < SemanticsAction > [SemanticsAction .increase])),
154- );
155155 expect (
156- semantics,
157- isNot (includesNodeWith (actions: < SemanticsAction > [SemanticsAction .decrease])),
156+ tester.getSemantics (
157+ find.byWidgetPredicate (
158+ (Widget widget) => widget.runtimeType.toString () == '_CupertinoPickerSemantics' ,
159+ ),
160+ ),
161+ isSemantics (value: '' , hasIncreaseAction: false , hasDecreaseAction: false ),
158162 );
159163
160164 // Scroll to item 0 which has a valid label.
@@ -163,10 +167,13 @@ void main() {
163167
164168 // Now the picker should have value '0' but no increase action
165169 // because the next item (1) has an empty label.
166- expect (semantics, includesNodeWith (value: '0' ));
167170 expect (
168- semantics,
169- isNot (includesNodeWith (value: '0' , actions: < SemanticsAction > [SemanticsAction .increase])),
171+ tester.getSemantics (
172+ find.byWidgetPredicate (
173+ (Widget widget) => widget.runtimeType.toString () == '_CupertinoPickerSemantics' ,
174+ ),
175+ ),
176+ isSemantics (value: '0' , hasIncreaseAction: false , hasDecreaseAction: false ),
170177 );
171178
172179 // Scroll to item 2 which has a valid label.
@@ -175,13 +182,15 @@ void main() {
175182
176183 // Now the picker should have value '2' but no decrease action
177184 // because the previous item (1) has an empty label.
178- expect (semantics, includesNodeWith (value: '2' ));
179185 expect (
180- semantics,
181- isNot (includesNodeWith (value: '2' , actions: < SemanticsAction > [SemanticsAction .decrease])),
186+ tester.getSemantics (
187+ find.byWidgetPredicate (
188+ (Widget widget) => widget.runtimeType.toString () == '_CupertinoPickerSemantics' ,
189+ ),
190+ ),
191+ isSemantics (value: '2' , hasDecreaseAction: false , hasIncreaseAction: false ),
182192 );
183-
184- semantics.dispose ();
193+ handle.dispose ();
185194 });
186195
187196 group ('layout' , () {
0 commit comments