Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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(
Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand Down Expand Up @@ -683,7 +683,6 @@ void main() {
});

testWidgets('Has semantic annotations', (WidgetTester tester) async {
final semantics = SemanticsTester(tester);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Should we use SemanticsHandle to 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.

final SemanticsHandle handle = tester.ensureSemantics();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in ab8a7ce.

Copy link
Copy Markdown
Contributor

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

await tester.pumpWidget(
const CupertinoApp(
home: CupertinoAlertDialog(
Expand All @@ -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 {
Expand Down Expand Up @@ -1699,8 +1666,6 @@ void main() {
});

testWidgets('showCupertinoDialog - custom barrierLabel', (WidgetTester tester) async {
final semantics = SemanticsTester(tester);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


await tester.pumpWidget(
CupertinoApp(
home: Builder(
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
Loading