Repository navigation
[cupertino_ui] Re-enable dialog_test.dart #12057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
c2bbd60
cf7cc29
ab8a7ce
b335d18
d977332
fa16d3f
4ee13ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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(<String>['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<void>( | ||
| context: context, | ||
| builder: (BuildContext context) { | ||
| return Container( | ||
| width: 100.0, | ||
| height: 100.0, | ||
| alignment: Alignment.center, | ||
| child: const Text('Dialog'), | ||
| ); | ||
| }, | ||
| unawaited( | ||
| showCupertinoDialog<void>( | ||
| 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<void>( | ||
| context: context, | ||
| barrierDismissible: true, | ||
| builder: (BuildContext context) { | ||
| return Container( | ||
| width: 100.0, | ||
| height: 100.0, | ||
| alignment: Alignment.center, | ||
| child: const Text('Dialog'), | ||
| ); | ||
| }, | ||
| unawaited( | ||
| showCupertinoDialog<void>( | ||
| 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,26 @@ void main() { | |
| ), | ||
| ); | ||
|
|
||
| final Finder dialogFinder = find.bySemanticsLabel('Alert'); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this can use the isSemantics(children:) to assert the subtree
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done in 4ee13ef I was hoping to use your new isSemantics |
||
| final SemanticsNode dialog = tester.semantics.find(find.bySemanticsLabel('Alert')); | ||
| expect(dialog.role, SemanticsRole.alertDialog); | ||
| expect(dialog, isSemantics(namesRoute: true, scopesRoute: true)); | ||
| expect( | ||
| semantics, | ||
| hasSemantics( | ||
| TestSemantics.root( | ||
| children: <TestSemantics>[ | ||
| TestSemantics( | ||
| children: <TestSemantics>[ | ||
| TestSemantics( | ||
| children: <TestSemantics>[ | ||
| TestSemantics( | ||
| flags: <SemanticsFlag>[SemanticsFlag.scopesRoute], | ||
| children: <TestSemantics>[ | ||
| TestSemantics( | ||
| flags: <SemanticsFlag>[ | ||
| SemanticsFlag.scopesRoute, | ||
| SemanticsFlag.namesRoute, | ||
| ], | ||
| role: SemanticsRole.alertDialog, | ||
| label: 'Alert', | ||
| children: <TestSemantics>[ | ||
| TestSemantics( | ||
| flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling], | ||
| children: <TestSemantics>[ | ||
| TestSemantics(label: 'The Title'), | ||
| TestSemantics(label: 'Content'), | ||
| ], | ||
| ), | ||
| TestSemantics( | ||
| flags: <SemanticsFlag>[SemanticsFlag.hasImplicitScrolling], | ||
| children: <TestSemantics>[ | ||
| TestSemantics( | ||
| flags: <SemanticsFlag>[SemanticsFlag.isButton], | ||
| label: 'Cancel', | ||
| ), | ||
| TestSemantics( | ||
| flags: <SemanticsFlag>[SemanticsFlag.isButton], | ||
| label: 'OK', | ||
| ), | ||
| ], | ||
| ), | ||
| ], | ||
| ), | ||
| ], | ||
| ), | ||
| ], | ||
| ), | ||
| ], | ||
| ), | ||
| ], | ||
| ), | ||
| ignoreId: true, | ||
| ignoreRect: true, | ||
| ignoreTransform: true, | ||
| ), | ||
| find.descendant(of: dialogFinder, matching: find.bySemanticsLabel('The Title')), | ||
| findsOneWidget, | ||
| ); | ||
|
|
||
| semantics.dispose(); | ||
| expect( | ||
| find.descendant(of: dialogFinder, matching: find.bySemanticsLabel('Content')), | ||
| findsOneWidget, | ||
| ); | ||
| final SemanticsNode buttonOK = tester.semantics.find( | ||
| find.descendant(of: dialogFinder, matching: find.bySemanticsLabel('OK')), | ||
| ); | ||
| expect(buttonOK, isSemantics(isButton: true)); | ||
| final SemanticsNode buttonCancel = tester.semantics.find( | ||
| find.descendant(of: dialogFinder, matching: find.bySemanticsLabel('Cancel')), | ||
| ); | ||
| expect(buttonCancel, isSemantics(isButton: true)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. During the migration from final Finder dialogFinder = find.bySemanticsLabel('Alert');\n final SemanticsNode dialog = tester.semantics.find(dialogFinder);\n expect(dialog.role, SemanticsRole.alertDialog);\n expect(dialog, isSemantics(namesRoute: true, scopesRoute: true));\n\n final Finder titleFinder = find.descendant(of: dialogFinder, matching: find.bySemanticsLabel('The Title'));\n expect(titleFinder, findsOneWidget);\n final SemanticsNode titleNode = tester.semantics.find(titleFinder);\n expect(titleNode.parent, isSemantics(hasImplicitScrolling: true));\n\n expect(\n find.descendant(of: dialogFinder, matching: find.bySemanticsLabel('Content')),\n findsOneWidget,\n );\n\n final Finder okFinder = find.descendant(of: dialogFinder, matching: find.bySemanticsLabel('OK'));\n final SemanticsNode buttonOK = tester.semantics.find(okFinder);\n expect(buttonOK, isSemantics(isButton: true));\n expect(buttonOK.parent, isSemantics(hasImplicitScrolling: true));\n\n final Finder cancelFinder = find.descendant(of: dialogFinder, matching: find.bySemanticsLabel('Cancel'));\n final SemanticsNode buttonCancel = tester.semantics.find(cancelFinder);\n expect(buttonCancel, isSemantics(isButton: true)); |
||
| }); | ||
|
|
||
| testWidgets('Dialog default action style', (WidgetTester tester) async { | ||
|
|
@@ -1699,8 +1661,6 @@ void main() { | |
| }); | ||
|
|
||
| testWidgets('showCupertinoDialog - custom barrierLabel', (WidgetTester tester) async { | ||
| final semantics = SemanticsTester(tester); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| await tester.pumpWidget( | ||
| CupertinoApp( | ||
| home: Builder( | ||
|
|
@@ -1731,13 +1691,7 @@ void main() { | |
| ), | ||
| ); | ||
|
|
||
| expect( | ||
| semantics, | ||
| isNot( | ||
| includesNodeWith(label: 'Custom label', flags: <SemanticsFlag>[SemanticsFlag.namesRoute]), | ||
| ), | ||
| ); | ||
| semantics.dispose(); | ||
| expect(find.semantics.byLabel('Custom label'), findsNothing); | ||
| }); | ||
|
|
||
| testWidgets('showCupertinoDialog - custom barrierColor', (WidgetTester tester) async { | ||
|
|
@@ -1913,12 +1867,14 @@ void main() { | |
| ); | ||
|
|
||
| final BuildContext context = tester.element(find.text('Test')); | ||
| showCupertinoDialog<void>( | ||
| context: context, | ||
| builder: (BuildContext context) { | ||
| return const Placeholder(); | ||
| }, | ||
| anchorPoint: const Offset(1000, 0), | ||
| unawaited( | ||
| showCupertinoDialog<void>( | ||
| context: context, | ||
| builder: (BuildContext context) { | ||
| return const Placeholder(); | ||
| }, | ||
| anchorPoint: const Offset(1000, 0), | ||
| ), | ||
| ); | ||
| await tester.pumpAndSettle(); | ||
|
|
||
|
|
@@ -1951,11 +1907,13 @@ void main() { | |
| ); | ||
|
|
||
| final BuildContext context = tester.element(find.text('Test')); | ||
| showCupertinoDialog<void>( | ||
| context: context, | ||
| builder: (BuildContext context) { | ||
| return const Placeholder(); | ||
| }, | ||
| unawaited( | ||
| showCupertinoDialog<void>( | ||
| context: context, | ||
| builder: (BuildContext context) { | ||
| return const Placeholder(); | ||
| }, | ||
| ), | ||
| ); | ||
| await tester.pumpAndSettle(); | ||
|
|
||
|
|
@@ -1988,11 +1946,13 @@ void main() { | |
| ); | ||
|
|
||
| final BuildContext context = tester.element(find.text('Test')); | ||
| showCupertinoDialog<void>( | ||
| context: context, | ||
| builder: (BuildContext context) { | ||
| return const Placeholder(); | ||
| }, | ||
| unawaited( | ||
| showCupertinoDialog<void>( | ||
| context: context, | ||
| builder: (BuildContext context) { | ||
| return const Placeholder(); | ||
| }, | ||
| ), | ||
| ); | ||
| await tester.pumpAndSettle(); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Should we use
SemanticsHandleto ensure semantics is initialized like below (plus dispose at the end of the test)? I'm not sure how necessary this is but I've been doing it in the migrations I've done.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in ab8a7ce.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
semantics is enabled by default, I think this is not needed