Skip to content

Commit 87d3770

Browse files
[cupertino_ui] Migrate button_test.dart to SemanticsHandle (#11992)
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 9768d30 commit 87d3770

1 file changed

Lines changed: 10 additions & 21 deletions

File tree

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

Lines changed: 10 additions & 21 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
import 'package:cupertino_ui/cupertino_ui.dart';
96
import 'package:flutter/foundation.dart';
107
import 'package:flutter/gestures.dart';
@@ -13,8 +10,6 @@ import 'package:flutter/scheduler.dart';
1310
import 'package:flutter/services.dart';
1411
import 'package:flutter_test/flutter_test.dart';
1512

16-
import '../widgets/semantics_tester.dart';
17-
1813
const TextStyle testStyle = TextStyle(fontSize: 10.0, letterSpacing: 0.0);
1914

2015
void main() {
@@ -348,7 +343,8 @@ void main() {
348343
});
349344

350345
testWidgets('Cupertino button is semantically a button', (WidgetTester tester) async {
351-
final semantics = SemanticsTester(tester);
346+
final SemanticsHandle handle = tester.ensureSemantics();
347+
352348
await tester.pumpWidget(
353349
boilerplate(
354350
child: Center(
@@ -358,24 +354,17 @@ void main() {
358354
);
359355

360356
expect(
361-
semantics,
362-
hasSemantics(
363-
TestSemantics.root(
364-
children: <TestSemantics>[
365-
TestSemantics.rootChild(
366-
actions: SemanticsAction.tap.index | SemanticsAction.focus.index,
367-
label: 'ABC',
368-
flags: <SemanticsFlag>[SemanticsFlag.isButton, SemanticsFlag.isFocusable],
369-
),
370-
],
371-
),
372-
ignoreId: true,
373-
ignoreRect: true,
374-
ignoreTransform: true,
357+
tester.getSemantics(find.text('ABC')),
358+
isSemantics(
359+
label: 'ABC',
360+
isButton: true,
361+
isFocusable: true,
362+
hasTapAction: true,
363+
hasFocusAction: true,
375364
),
376365
);
377366

378-
semantics.dispose();
367+
handle.dispose();
379368
});
380369

381370
testWidgets('Can specify colors', (WidgetTester tester) async {

0 commit comments

Comments
 (0)