diff --git a/packages/cupertino_ui/temporarily_disabled_tests/dialog_test.dart b/packages/cupertino_ui/test/dialog_test.dart similarity index 95% rename from packages/cupertino_ui/temporarily_disabled_tests/dialog_test.dart rename to packages/cupertino_ui/test/dialog_test.dart index 9125825606e5..c43a5600d19a 100644 --- a/packages/cupertino_ui/temporarily_disabled_tests/dialog_test.dart +++ b/packages/cupertino_ui/test/dialog_test.dart @@ -2,14 +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.', -) // This file is run as part of a reduced test set in CI on Mac and Windows // machines. @Tags(['reduced-test-set']) library; +import 'dart:async' show unawaited; import 'dart:math'; import 'dart:ui'; @@ -19,8 +17,6 @@ import 'package:flutter/rendering.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; -import '../widgets/semantics_tester.dart'; - void main() { testWidgets('Overall appearance is correct for the light theme', (WidgetTester tester) async { await tester.pumpWidget( @@ -575,16 +571,18 @@ void main() { final BuildContext context = tester.element(find.text('Go')); - showCupertinoDialog( - context: context, - builder: (BuildContext context) { - return Container( - width: 100.0, - height: 100.0, - alignment: Alignment.center, - child: const Text('Dialog'), - ); - }, + unawaited( + showCupertinoDialog( + context: context, + builder: (BuildContext context) { + return Container( + width: 100.0, + height: 100.0, + alignment: Alignment.center, + child: const Text('Dialog'), + ); + }, + ), ); await tester.pumpAndSettle(const Duration(seconds: 1)); @@ -602,17 +600,19 @@ void main() { final BuildContext context = tester.element(find.text('Go')); - showCupertinoDialog( - context: context, - barrierDismissible: true, - builder: (BuildContext context) { - return Container( - width: 100.0, - height: 100.0, - alignment: Alignment.center, - child: const Text('Dialog'), - ); - }, + unawaited( + showCupertinoDialog( + context: context, + barrierDismissible: true, + builder: (BuildContext context) { + return Container( + width: 100.0, + height: 100.0, + alignment: Alignment.center, + child: const Text('Dialog'), + ); + }, + ), ); await tester.pumpAndSettle(const Duration(seconds: 1)); @@ -683,7 +683,6 @@ void main() { }); testWidgets('Has semantic annotations', (WidgetTester tester) async { - final semantics = SemanticsTester(tester); await tester.pumpWidget( const CupertinoApp( home: CupertinoAlertDialog( @@ -697,63 +696,31 @@ void main() { ), ); + final SemanticsNode dialog = tester.semantics.find(find.bySemanticsLabel('Alert')); + expect(dialog.role, SemanticsRole.alertDialog); expect( - semantics, - hasSemantics( - TestSemantics.root( - children: [ - TestSemantics( - children: [ - TestSemantics( - children: [ - TestSemantics( - flags: [SemanticsFlag.scopesRoute], - children: [ - TestSemantics( - flags: [ - SemanticsFlag.scopesRoute, - SemanticsFlag.namesRoute, - ], - role: SemanticsRole.alertDialog, - label: 'Alert', - children: [ - TestSemantics( - flags: [SemanticsFlag.hasImplicitScrolling], - children: [ - TestSemantics(label: 'The Title'), - TestSemantics(label: 'Content'), - ], - ), - TestSemantics( - flags: [SemanticsFlag.hasImplicitScrolling], - children: [ - TestSemantics( - flags: [SemanticsFlag.isButton], - label: 'Cancel', - ), - TestSemantics( - flags: [SemanticsFlag.isButton], - label: 'OK', - ), - ], - ), - ], - ), - ], - ), - ], - ), - ], - ), - ], - ), - ignoreId: true, - ignoreRect: true, - ignoreTransform: true, + dialog, + isSemantics( + namesRoute: true, + scopesRoute: true, + children: [ + isSemantics( + hasImplicitScrolling: true, + children: [ + isSemantics(label: 'The Title'), + isSemantics(label: 'Content'), + ], + ), + isSemantics( + hasImplicitScrolling: true, + children: [ + isSemantics(label: 'Cancel', isButton: true), + isSemantics(label: 'OK', isButton: true), + ], + ), + ], ), ); - - semantics.dispose(); }); testWidgets('Dialog default action style', (WidgetTester tester) async { @@ -1699,8 +1666,6 @@ void main() { }); testWidgets('showCupertinoDialog - custom barrierLabel', (WidgetTester tester) async { - final semantics = SemanticsTester(tester); - await tester.pumpWidget( CupertinoApp( home: Builder( @@ -1731,13 +1696,7 @@ void main() { ), ); - expect( - semantics, - isNot( - includesNodeWith(label: 'Custom label', flags: [SemanticsFlag.namesRoute]), - ), - ); - semantics.dispose(); + expect(find.semantics.byLabel('Custom label'), findsNothing); }); testWidgets('showCupertinoDialog - custom barrierColor', (WidgetTester tester) async { @@ -1913,12 +1872,14 @@ void main() { ); final BuildContext context = tester.element(find.text('Test')); - showCupertinoDialog( - context: context, - builder: (BuildContext context) { - return const Placeholder(); - }, - anchorPoint: const Offset(1000, 0), + unawaited( + showCupertinoDialog( + context: context, + builder: (BuildContext context) { + return const Placeholder(); + }, + anchorPoint: const Offset(1000, 0), + ), ); await tester.pumpAndSettle(); @@ -1951,11 +1912,13 @@ void main() { ); final BuildContext context = tester.element(find.text('Test')); - showCupertinoDialog( - context: context, - builder: (BuildContext context) { - return const Placeholder(); - }, + unawaited( + showCupertinoDialog( + context: context, + builder: (BuildContext context) { + return const Placeholder(); + }, + ), ); await tester.pumpAndSettle(); @@ -1988,11 +1951,13 @@ void main() { ); final BuildContext context = tester.element(find.text('Test')); - showCupertinoDialog( - context: context, - builder: (BuildContext context) { - return const Placeholder(); - }, + unawaited( + showCupertinoDialog( + context: context, + builder: (BuildContext context) { + return const Placeholder(); + }, + ), ); await tester.pumpAndSettle();