Skip to content

Commit

Permalink
Test cover more tests with leak tracking. (#133828)
Browse files Browse the repository at this point in the history
  • Loading branch information
polina-c authored Sep 1, 2023
1 parent 0f3bd90 commit 78ff122
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 74 deletions.
19 changes: 10 additions & 9 deletions packages/flutter/test/material/card_theme_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ library;

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';

void main() {
test('CardTheme copyWith, ==, hashCode basics', () {
Expand All @@ -22,7 +23,7 @@ void main() {
expect(identical(CardTheme.lerp(theme, theme, 0.5), theme), true);
});

testWidgets('Material3 - Passing no CardTheme returns defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material3 - Passing no CardTheme returns defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(MaterialApp(
theme: theme,
Expand All @@ -45,7 +46,7 @@ void main() {
));
});

testWidgets('Card uses values from CardTheme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Card uses values from CardTheme', (WidgetTester tester) async {
final CardTheme cardTheme = _cardTheme();

await tester.pumpWidget(MaterialApp(
Expand All @@ -67,7 +68,7 @@ void main() {
expect(material.shape, cardTheme.shape);
});

testWidgets('Card widget properties take priority over theme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Card widget properties take priority over theme', (WidgetTester tester) async {
const Clip clip = Clip.hardEdge;
const Color color = Colors.orange;
const Color shadowColor = Colors.pink;
Expand Down Expand Up @@ -102,7 +103,7 @@ void main() {
expect(material.shape, shape);
});

testWidgets('CardTheme properties take priority over ThemeData properties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CardTheme properties take priority over ThemeData properties', (WidgetTester tester) async {
final CardTheme cardTheme = _cardTheme();
final ThemeData themeData = _themeData().copyWith(cardTheme: cardTheme);

Expand All @@ -117,7 +118,7 @@ void main() {
expect(material.color, cardTheme.color);
});

testWidgets('Material3 - ThemeData properties are used when no CardTheme is set', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material3 - ThemeData properties are used when no CardTheme is set', (WidgetTester tester) async {
final ThemeData themeData = ThemeData(useMaterial3: true);

await tester.pumpWidget(MaterialApp(
Expand All @@ -131,7 +132,7 @@ void main() {
expect(material.color, themeData.colorScheme.surface);
});

testWidgets('Material3 - CardTheme customizes shape', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material3 - CardTheme customizes shape', (WidgetTester tester) async {
const CardTheme cardTheme = CardTheme(
color: Colors.white,
shape: BeveledRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(7))),
Expand Down Expand Up @@ -165,7 +166,7 @@ void main() {
// support is deprecated and the APIs are removed, these tests
// can be deleted.

testWidgets('Material2 - ThemeData properties are used when no CardTheme is set', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material2 - ThemeData properties are used when no CardTheme is set', (WidgetTester tester) async {
final ThemeData themeData = ThemeData(useMaterial3: false);

await tester.pumpWidget(MaterialApp(
Expand All @@ -179,7 +180,7 @@ void main() {
expect(material.color, themeData.cardColor);
});

testWidgets('Material2 - Passing no CardTheme returns defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material2 - Passing no CardTheme returns defaults', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: const Scaffold(
Expand All @@ -201,7 +202,7 @@ void main() {
));
});

testWidgets('Material2 - CardTheme customizes shape', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material2 - CardTheme customizes shape', (WidgetTester tester) async {
const CardTheme cardTheme = CardTheme(
color: Colors.white,
shape: BeveledRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(7))),
Expand Down
4 changes: 2 additions & 2 deletions packages/flutter/test/material/checkbox_list_tile_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ void main() {
);
});

testWidgets('Material2 - CheckboxListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material2 - CheckboxListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;

const Color fillColor = Color(0xFF000000);
Expand Down Expand Up @@ -859,7 +859,7 @@ void main() {
);
});

testWidgets('Material3 - CheckboxListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material3 - CheckboxListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;

const Color fillColor = Color(0xFF000000);
Expand Down
Loading

0 comments on commit 78ff122

Please sign in to comment.