-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[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
Merged
+71
−106
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
c2bbd60
Re-enabled dialog_test.
justinmc cf7cc29
Unawaited
justinmc ab8a7ce
SemanticsHandle
justinmc b335d18
Simplify byPredicate to byLabel
justinmc d977332
No ensureSemantics needed.
justinmc fa16d3f
Merge branch 'main' into cross-imports-dialog
justinmc 4ee13ef
Test whole tree.
justinmc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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,31 @@ void main() { | |
| ), | ||
| ); | ||
|
|
||
| final SemanticsNode dialog = tester.semantics.find(find.bySemanticsLabel('Alert')); | ||
| expect(dialog.role, SemanticsRole.alertDialog); | ||
| 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, | ||
| dialog, | ||
| isSemantics( | ||
| namesRoute: true, | ||
| scopesRoute: true, | ||
| children: <Matcher>[ | ||
| isSemantics( | ||
| hasImplicitScrolling: true, | ||
| children: <Matcher>[ | ||
| isSemantics(label: 'The Title'), | ||
| isSemantics(label: 'Content'), | ||
| ], | ||
| ), | ||
| isSemantics( | ||
| hasImplicitScrolling: true, | ||
| children: <Matcher>[ | ||
| 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); | ||
|
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 +1696,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 +1872,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 +1912,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 +1951,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(); | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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