Skip to content
66 changes: 20 additions & 46 deletions packages/material_ui/temporarily_disabled_tests/card_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
'This file is skipped due to a cross-import that needs to be fixed. Tracked in https://github.com/flutter/flutter/issues/177028.',
)
import 'package:material_ui/material_ui.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import '../widgets/semantics_tester.dart';

void main() {
testWidgets('Material3 - Card defaults (Elevated card)', (WidgetTester tester) async {
Expand Down Expand Up @@ -93,7 +91,6 @@ void main() {
});

testWidgets('Card can take semantic text from multiple children', (WidgetTester tester) async {
final semantics = SemanticsTester(tester);
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
Expand All @@ -115,38 +112,29 @@ void main() {
);

expect(
semantics,
hasSemantics(
TestSemantics.root(
children: <TestSemantics>[
TestSemantics(id: 1, label: 'I am text!', textDirection: TextDirection.ltr),
TestSemantics(id: 2, label: 'Moar text!!1', textDirection: TextDirection.ltr),
TestSemantics(
id: 3,
label: 'Button',
textDirection: TextDirection.ltr,
actions: <SemanticsAction>[SemanticsAction.tap, SemanticsAction.focus],
flags: <SemanticsFlag>[
SemanticsFlag.hasEnabledState,
SemanticsFlag.isButton,
SemanticsFlag.isEnabled,
SemanticsFlag.isFocusable,
],
),
],
),
ignoreTransform: true,
ignoreRect: true,
tester.getSemantics(find.text('I am text!')),
matchesSemantics(label: 'I am text!', textDirection: TextDirection.ltr),
);
expect(
tester.getSemantics(find.text('Moar text!!1')),
matchesSemantics(label: 'Moar text!!1', textDirection: TextDirection.ltr),
);
expect(
tester.getSemantics(find.widgetWithText(ElevatedButton, 'Button')),
matchesSemantics(
label: 'Button',
textDirection: TextDirection.ltr,
hasTapAction: true,
hasFocusAction: true,
hasEnabledState: true,
isButton: true,
isEnabled: true,
isFocusable: true,
),
);

semantics.dispose();
});

testWidgets('Card merges children when it is a semanticContainer', (WidgetTester tester) async {
final semantics = SemanticsTester(tester);
debugResetSemanticsIdCounter();

await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
Expand All @@ -161,23 +149,9 @@ void main() {
);

expect(
semantics,
hasSemantics(
TestSemantics.root(
children: <TestSemantics>[
TestSemantics(
id: 1,
label: 'First child\nSecond child',
textDirection: TextDirection.ltr,
),
],
),
ignoreTransform: true,
ignoreRect: true,
),
tester.getSemantics(find.byType(Card)),
matchesSemantics(label: 'First child\nSecond child', textDirection: TextDirection.ltr),
);

semantics.dispose();
});

testWidgets('Card margin', (WidgetTester tester) async {
Expand Down
Loading