Unverified Commit e8b397ca authored by Polina Cherkasova's avatar Polina Cherkasova Committed by GitHub

Setup leak tracking regression for material. (#130169)

parent d4608046
......@@ -65,7 +65,7 @@ void checkChipMaterialClipBehavior(WidgetTester tester, Clip clipBehavior) {
}
void main() {
testWidgets('ActionChip defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ActionChip defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
const String label = 'action chip';
......@@ -136,7 +136,7 @@ void main() {
expect(decoration.color, null);
});
testWidgets('ActionChip.elevated defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ActionChip.elevated defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
const String label = 'action chip';
......@@ -207,7 +207,7 @@ void main() {
expect(decoration.color, theme.colorScheme.onSurface.withOpacity(0.12));
});
testWidgets('ActionChip.color resolves material states', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ActionChip.color resolves material states', (WidgetTester tester) async {
const Color disabledColor = Color(0xff00ff00);
const Color backgroundColor = Color(0xff0000ff);
final MaterialStateProperty<Color?> color = MaterialStateProperty.resolveWith((Set<MaterialState> states) {
......@@ -266,7 +266,7 @@ void main() {
);
});
testWidgets('ActionChip uses provided state color properties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ActionChip uses provided state color properties', (WidgetTester tester) async {
const Color disabledColor = Color(0xff00ff00);
const Color backgroundColor = Color(0xff0000ff);
Widget buildApp({ required bool enabled, required bool selected }) {
......
......@@ -15,7 +15,7 @@ void main() {
const ActionIconThemeData().copyWith().hashCode);
});
testWidgets('ActionIconThemeData copyWith overrides all properties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ActionIconThemeData copyWith overrides all properties', (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/126762.
Widget originalButtonBuilder(BuildContext context) {
return const SizedBox();
......
......@@ -10,6 +10,7 @@ import 'dart:math' as math show pi;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
import '../widgets/semantics_tester.dart';
class MockCanvas extends Fake implements Canvas {
......@@ -95,7 +96,7 @@ class RecordedScale extends RecordedCanvasCall {
}
void main() {
testWidgets('IconTheme color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('IconTheme color', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -116,7 +117,7 @@ void main() {
expect(canvas.capturedPaint, hasColor(0xFF666666));
});
testWidgets('IconTheme opacity', (WidgetTester tester) async {
testWidgetsWithLeakTracking('IconTheme opacity', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -138,7 +139,7 @@ void main() {
expect(canvas.capturedPaint, hasColor(0x80666666));
});
testWidgets('color overrides IconTheme color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('color overrides IconTheme color', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -160,7 +161,7 @@ void main() {
expect(canvas.capturedPaint, hasColor(0xFF0000FF));
});
testWidgets('IconTheme size', (WidgetTester tester) async {
testWidgetsWithLeakTracking('IconTheme size', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -184,7 +185,7 @@ void main() {
expect(canvas.capturedSy, 0.25);
});
testWidgets('size overridesIconTheme size', (WidgetTester tester) async {
testWidgetsWithLeakTracking('size overridesIconTheme size', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -209,7 +210,7 @@ void main() {
expect(canvas.capturedSy, 2);
});
testWidgets('Semantic label', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Semantic label', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
......@@ -229,7 +230,7 @@ void main() {
semantics.dispose();
});
testWidgets('Inherited text direction rtl', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Inherited text direction rtl', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.rtl,
......@@ -258,7 +259,7 @@ void main() {
matchesGoldenFile('animated_icons_test.icon.rtl.png'));
});
testWidgets('Inherited text direction ltr', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Inherited text direction ltr', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -285,7 +286,7 @@ void main() {
matchesGoldenFile('animated_icons_test.icon.ltr.png'));
});
testWidgets('Inherited text direction overridden', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Inherited text direction overridden', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -311,7 +312,7 @@ void main() {
]);
});
testWidgets('Direction has no effect on position of widget', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Direction has no effect on position of widget', (WidgetTester tester) async {
const AnimatedIcon icon = AnimatedIcon(
progress: AlwaysStoppedAnimation<double>(0.0),
icon: AnimatedIcons.arrow_menu,
......
......@@ -5,8 +5,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
void main() {
testWidgets("builder doesn't get called if app doesn't change", (WidgetTester tester) async {
testWidgetsWithLeakTracking("builder doesn't get called if app doesn't change", (WidgetTester tester) async {
final List<String> log = <String>[];
final Widget app = MaterialApp(
home: const Placeholder(),
......@@ -33,7 +35,7 @@ void main() {
expect(log, <String>['build']);
});
testWidgets("builder doesn't get called if app doesn't change", (WidgetTester tester) async {
testWidgetsWithLeakTracking("builder doesn't get called if app doesn't change", (WidgetTester tester) async {
final List<String> log = <String>[];
await tester.pumpWidget(
MaterialApp(
......
......@@ -6,6 +6,8 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
void main() {
testWidgets('BackButton control test', (WidgetTester tester) async {
await tester.pumpWidget(
......@@ -34,7 +36,7 @@ void main() {
expect(find.text('Home'), findsOneWidget);
});
testWidgets('BackButton onPressed overrides default pop behavior', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BackButton onPressed overrides default pop behavior', (WidgetTester tester) async {
bool customCallbackWasCalled = false;
await tester.pumpWidget(
MaterialApp(
......@@ -67,7 +69,7 @@ void main() {
expect(customCallbackWasCalled, true);
});
testWidgets('BackButton icon', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BackButton icon', (WidgetTester tester) async {
final Key androidKey = UniqueKey();
final Key iOSKey = UniqueKey();
final Key linuxKey = UniqueKey();
......@@ -115,7 +117,7 @@ void main() {
expect(windowsIcon.icon == androidIcon.icon, isTrue);
});
testWidgets('BackButton color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BackButton color', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Material(
......@@ -133,7 +135,7 @@ void main() {
expect(iconText.text.style!.color, Colors.red);
});
testWidgets('BackButton color with ButtonStyle', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BackButton color with ButtonStyle', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),
......@@ -154,7 +156,7 @@ void main() {
expect(iconText.text.style!.color, Colors.red);
});
testWidgets('BackButton.style.iconColor parameter overrides BackButton.color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BackButton.style.iconColor parameter overrides BackButton.color', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),
......@@ -177,7 +179,7 @@ void main() {
expect(iconText.text.style!.color, Colors.red);
});
testWidgets('BackButton semantics', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BackButton semantics', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
MaterialApp(
......@@ -220,7 +222,7 @@ void main() {
handle.dispose();
}, variant: TargetPlatformVariant.all());
testWidgets('CloseButton semantics', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CloseButton semantics', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
MaterialApp(
......@@ -263,7 +265,7 @@ void main() {
handle.dispose();
}, variant: TargetPlatformVariant.all());
testWidgets('CloseButton color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CloseButton color', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Material(
......@@ -281,7 +283,7 @@ void main() {
expect(iconText.text.style!.color, Colors.red);
});
testWidgets('CloseButton color with ButtonStyle', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CloseButton color with ButtonStyle', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),
......@@ -302,7 +304,7 @@ void main() {
expect(iconText.text.style!.color, Colors.red);
});
testWidgets('CloseButton.style.iconColor parameter overrides CloseButton.color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CloseButton.style.iconColor parameter overrides CloseButton.color', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),
......@@ -325,7 +327,7 @@ void main() {
expect(iconText.text.style!.color, Colors.red);
});
testWidgets('CloseButton onPressed overrides default pop behavior', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CloseButton onPressed overrides default pop behavior', (WidgetTester tester) async {
bool customCallbackWasCalled = false;
await tester.pumpWidget(
MaterialApp(
......
......@@ -8,11 +8,12 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
import '../rendering/mock_canvas.dart';
void main() {
testWidgets('Large Badge defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Large Badge defaults', (WidgetTester tester) async {
late final ThemeData theme;
await tester.pumpWidget(
......@@ -58,7 +59,7 @@ void main() {
expect(box, paints..rrect(rrect: rrect, color: theme.colorScheme.error));
});
testWidgets('Large Badge defaults with RTL', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Large Badge defaults with RTL', (WidgetTester tester) async {
late final ThemeData theme;
await tester.pumpWidget(
......@@ -101,7 +102,7 @@ void main() {
});
// Essentially the same as 'Large Badge defaults'
testWidgets('Badge.count', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Badge.count', (WidgetTester tester) async {
late final ThemeData theme;
Widget buildFrame(int count) {
......@@ -160,7 +161,7 @@ void main() {
expect(find.text('999+'), findsOneWidget);
});
testWidgets('Small Badge defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Small Badge defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData.light(useMaterial3: true);
await tester.pumpWidget(
......@@ -191,7 +192,7 @@ void main() {
expect(box, paints..rrect(rrect: RRect.fromLTRBR(18, 0, 24, 6, const Radius.circular(3)), color: theme.colorScheme.error));
});
testWidgets('Small Badge RTL defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Small Badge RTL defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData.light(useMaterial3: true);
await tester.pumpWidget(
......@@ -224,7 +225,7 @@ void main() {
expect(box, paints..rrect(rrect: RRect.fromLTRBR(0, 0, 6, 6, const Radius.circular(3)), color: theme.colorScheme.error));
});
testWidgets('Large Badge textStyle and colors', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Large Badge textStyle and colors', (WidgetTester tester) async {
final ThemeData theme = ThemeData.light(useMaterial3: true);
const Color green = Color(0xff00ff00);
const Color black = Color(0xff000000);
......@@ -251,7 +252,7 @@ void main() {
expect(tester.renderObject(find.byType(Badge)), paints..rrect(color: black));
});
testWidgets('isLabelVisible', (WidgetTester tester) async {
testWidgetsWithLeakTracking('isLabelVisible', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData.light(useMaterial3: true),
......@@ -275,7 +276,7 @@ void main() {
expect(box, isNot(paints..rrect()));
});
testWidgets('Large Badge alignment', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Large Badge alignment', (WidgetTester tester) async {
const Radius badgeRadius = Radius.circular(8);
Widget buildFrame(Alignment alignment, [Offset offset = Offset.zero]) {
......@@ -350,7 +351,7 @@ void main() {
expect(box, paints..rrect(rrect: RRect.fromLTRBR(200 - 16, 200 - 16, 200, 200, badgeRadius).shift(offset)));
});
testWidgets('Small Badge alignment', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Small Badge alignment', (WidgetTester tester) async {
const Radius badgeRadius = Radius.circular(3);
Widget buildFrame(Alignment alignment, [Offset offset = Offset.zero]) {
......
......@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
import '../rendering/mock_canvas.dart';
void main() {
......@@ -32,7 +33,7 @@ void main() {
expect(themeData.offset, null);
});
testWidgets('Default BadgeThemeData debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Default BadgeThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const BadgeThemeData().debugFillProperties(builder);
......@@ -44,7 +45,7 @@ void main() {
expect(description, <String>[]);
});
testWidgets('BadgeThemeData implements debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BadgeThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const BadgeThemeData(
backgroundColor: Color(0xfffffff0),
......@@ -74,7 +75,7 @@ void main() {
]);
});
testWidgets('Badge uses ThemeData badge theme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Badge uses ThemeData badge theme', (WidgetTester tester) async {
const Color green = Color(0xff00ff00);
const Color black = Color(0xff000000);
const BadgeThemeData badgeTheme = BadgeThemeData(
......@@ -123,7 +124,7 @@ void main() {
// This test is essentially the same as 'Badge uses ThemeData badge theme'. In
// this case the theme is introduced with the BadgeTheme widget instead of
// ThemeData.badgeTheme.
testWidgets('Badge uses BadgeTheme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Badge uses BadgeTheme', (WidgetTester tester) async {
const Color green = Color(0xff00ff00);
const Color black = Color(0xff000000);
const BadgeThemeData badgeTheme = BadgeThemeData(
......
......@@ -6,6 +6,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
void main() {
test('MaterialBannerThemeData copyWith, ==, hashCode basics', () {
expect(const MaterialBannerThemeData(), const MaterialBannerThemeData().copyWith());
......@@ -24,7 +26,7 @@ void main() {
expect(bannerTheme.leadingPadding, null);
});
testWidgets('Default MaterialBannerThemeData debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Default MaterialBannerThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const MaterialBannerThemeData().debugFillProperties(builder);
......@@ -36,7 +38,7 @@ void main() {
expect(description, <String>[]);
});
testWidgets('MaterialBannerThemeData implements debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('MaterialBannerThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const MaterialBannerThemeData(
backgroundColor: Color(0xfffffff0),
......@@ -66,7 +68,7 @@ void main() {
]);
});
testWidgets('Material3 - Passing no MaterialBannerThemeData returns defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material3 - Passing no MaterialBannerThemeData returns defaults', (WidgetTester tester) async {
const String contentText = 'Content';
final ThemeData theme = ThemeData(useMaterial3: true);
late final ThemeData localizedTheme;
......@@ -115,7 +117,7 @@ void main() {
expect(divider.color, theme.colorScheme.outlineVariant);
});
testWidgets('Material3 - Passing no MaterialBannerThemeData returns defaults when presented by ScaffoldMessenger', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material3 - Passing no MaterialBannerThemeData returns defaults when presented by ScaffoldMessenger', (WidgetTester tester) async {
const String contentText = 'Content';
const Key tapTarget = Key('tap-target');
final ThemeData theme = ThemeData(useMaterial3: true);
......@@ -178,7 +180,7 @@ void main() {
expect(divider.color, theme.colorScheme.outlineVariant);
});
testWidgets('MaterialBanner uses values from MaterialBannerThemeData', (WidgetTester tester) async {
testWidgetsWithLeakTracking('MaterialBanner uses values from MaterialBannerThemeData', (WidgetTester tester) async {
final MaterialBannerThemeData bannerTheme = _bannerTheme();
const String contentText = 'Content';
await tester.pumpWidget(MaterialApp(
......@@ -217,7 +219,7 @@ void main() {
expect(find.byType(Divider), findsNothing);
});
testWidgets('MaterialBanner uses values from MaterialBannerThemeData when presented by ScaffoldMessenger', (WidgetTester tester) async {
testWidgetsWithLeakTracking('MaterialBanner uses values from MaterialBannerThemeData when presented by ScaffoldMessenger', (WidgetTester tester) async {
final MaterialBannerThemeData bannerTheme = _bannerTheme();
const String contentText = 'Content';
const Key tapTarget = Key('tap-target');
......@@ -273,7 +275,7 @@ void main() {
expect(find.byType(Divider), findsNothing);
});
testWidgets('MaterialBanner widget properties take priority over theme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('MaterialBanner widget properties take priority over theme', (WidgetTester tester) async {
const Color backgroundColor = Colors.purple;
const Color surfaceTintColor = Colors.red;
const Color shadowColor = Colors.orange;
......@@ -324,7 +326,7 @@ void main() {
expect(find.byType(Divider), findsNothing);
});
testWidgets('MaterialBanner widget properties take priority over theme when presented by ScaffoldMessenger', (WidgetTester tester) async {
testWidgetsWithLeakTracking('MaterialBanner widget properties take priority over theme when presented by ScaffoldMessenger', (WidgetTester tester) async {
const Color backgroundColor = Colors.purple;
const double elevation = 6.0;
const TextStyle textStyle = TextStyle(color: Colors.green);
......@@ -387,7 +389,7 @@ void main() {
expect(find.byType(Divider), findsNothing);
});
testWidgets('MaterialBanner uses color scheme when necessary', (WidgetTester tester) async {
testWidgetsWithLeakTracking('MaterialBanner uses color scheme when necessary', (WidgetTester tester) async {
final ColorScheme colorScheme = const ColorScheme.light().copyWith(surface: Colors.purple);
const String contentText = 'Content';
await tester.pumpWidget(MaterialApp(
......@@ -409,7 +411,7 @@ void main() {
expect(material.color, colorScheme.surface);
});
testWidgets('MaterialBanner uses color scheme when necessary when presented by ScaffoldMessenger', (WidgetTester tester) async {
testWidgetsWithLeakTracking('MaterialBanner uses color scheme when necessary when presented by ScaffoldMessenger', (WidgetTester tester) async {
final ColorScheme colorScheme = const ColorScheme.light().copyWith(surface: Colors.purple);
const String contentText = 'Content';
const Key tapTarget = Key('tap-target');
......@@ -453,7 +455,7 @@ void main() {
// support is deprecated and the APIs are removed, these tests
// can be deleted.
testWidgets('Material2 - Passing no MaterialBannerThemeData returns defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material2 - Passing no MaterialBannerThemeData returns defaults', (WidgetTester tester) async {
const String contentText = 'Content';
await tester.pumpWidget(MaterialApp(
......@@ -499,7 +501,7 @@ void main() {
expect(divider.color, null);
});
testWidgets('Material2 - Passing no MaterialBannerThemeData returns defaults when presented by ScaffoldMessenger', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material2 - Passing no MaterialBannerThemeData returns defaults when presented by ScaffoldMessenger', (WidgetTester tester) async {
const String contentText = 'Content';
const Key tapTarget = Key('tap-target');
......
......@@ -11,10 +11,11 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
import '../rendering/mock_canvas.dart';
void main() {
testWidgets('shadow effect is not doubled', (WidgetTester tester) async {
testWidgetsWithLeakTracking('shadow effect is not doubled', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/123064
debugDisableShadows = false;
......@@ -40,7 +41,7 @@ void main() {
debugDisableShadows = true;
});
testWidgets('only one layer with `color` is painted', (WidgetTester tester) async {
testWidgetsWithLeakTracking('only one layer with `color` is painted', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/122667
const Color bottomAppBarColor = Colors.black45;
......@@ -79,7 +80,7 @@ void main() {
}
});
testWidgets('no overlap with floating action button', (WidgetTester tester) async {
testWidgetsWithLeakTracking('no overlap with floating action button', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
......@@ -110,7 +111,7 @@ void main() {
);
});
testWidgets('custom shape', (WidgetTester tester) async {
testWidgetsWithLeakTracking('custom shape', (WidgetTester tester) async {
final Key key = UniqueKey();
Future<void> pump(FloatingActionButtonLocation location) async {
await tester.pumpWidget(
......@@ -154,7 +155,7 @@ void main() {
);
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44572
testWidgets('Custom Padding', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Custom Padding', (WidgetTester tester) async {
const EdgeInsets customPadding = EdgeInsets.all(10);
await tester.pumpWidget(
MaterialApp(
......@@ -186,7 +187,7 @@ void main() {
expect(babRect, const Rect.fromLTRB(240, 520, 560, 600));
});
testWidgets('Custom Padding in Material 3', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Custom Padding in Material 3', (WidgetTester tester) async {
const EdgeInsets customPadding = EdgeInsets.all(10);
await tester.pumpWidget(
MaterialApp(
......@@ -218,7 +219,7 @@ void main() {
expect(babRect, const Rect.fromLTRB(240, 520, 560, 600));
});
testWidgets('color defaults to Theme.bottomAppBarColor in M2', (WidgetTester tester) async {
testWidgetsWithLeakTracking('color defaults to Theme.bottomAppBarColor in M2', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
......@@ -244,7 +245,7 @@ void main() {
expect(physicalShape.color, const Color(0xffffff00));
});
testWidgets('color overrides theme color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('color overrides theme color', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
......@@ -275,7 +276,7 @@ void main() {
});
testWidgets('color overrides theme color with Material 3', (WidgetTester tester) async {
testWidgetsWithLeakTracking('color overrides theme color with Material 3', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData.light(useMaterial3: true).copyWith(
......@@ -302,7 +303,7 @@ void main() {
expect(physicalShape.color, const Color(0xff0000ff));
});
testWidgets('Shadow color is transparent in Material 3', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Shadow color is transparent in Material 3', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true,
......@@ -324,7 +325,7 @@ void main() {
expect(physicalShape.shadowColor, Colors.transparent);
});
testWidgets('dark theme applies an elevation overlay color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('dark theme applies an elevation overlay color', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData.from(useMaterial3: false, colorScheme: const ColorScheme.dark()),
......@@ -345,7 +346,7 @@ void main() {
// This is a regression test for a bug we had where toggling the notch on/off
// would crash, as the shouldReclip method of ShapeBorderClipper or
// _BottomAppBarClipper would try an illegal downcast.
testWidgets('toggle shape to null', (WidgetTester tester) async {
testWidgetsWithLeakTracking('toggle shape to null', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
......@@ -375,7 +376,7 @@ void main() {
);
});
testWidgets('no notch when notch param is null', (WidgetTester tester) async {
testWidgetsWithLeakTracking('no notch when notch param is null', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
......@@ -405,7 +406,7 @@ void main() {
);
});
testWidgets('notch no margin', (WidgetTester tester) async {
testWidgetsWithLeakTracking('notch no margin', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
......@@ -457,7 +458,7 @@ void main() {
);
});
testWidgets('notch with margin', (WidgetTester tester) async {
testWidgetsWithLeakTracking('notch with margin', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
......@@ -509,7 +510,7 @@ void main() {
);
});
testWidgets('observes safe area', (WidgetTester tester) async {
testWidgetsWithLeakTracking('observes safe area', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: false),
......@@ -534,7 +535,7 @@ void main() {
);
});
testWidgets('clipBehavior is propagated', (WidgetTester tester) async {
testWidgetsWithLeakTracking('clipBehavior is propagated', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
......@@ -568,7 +569,7 @@ void main() {
expect(physicalShape.clipBehavior, Clip.antiAliasWithSaveLayer);
});
testWidgets('BottomAppBar with shape when Scaffold.bottomNavigationBar == null', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BottomAppBar with shape when Scaffold.bottomNavigationBar == null', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/80878
final ThemeData theme = ThemeData();
await tester.pumpWidget(
......@@ -604,7 +605,7 @@ void main() {
expect(tester.getSize(find.byType(BottomAppBar)), theme.useMaterial3 ? const Size(800, 80) : const Size(800, 50));
});
testWidgets('notch with margin and top padding, home safe area', (WidgetTester tester) async {
testWidgetsWithLeakTracking('notch with margin and top padding, home safe area', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/90024
await tester.pumpWidget(
const MediaQuery(
......@@ -665,7 +666,7 @@ void main() {
);
});
testWidgets('BottomAppBar does not apply custom clipper without FAB', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BottomAppBar does not apply custom clipper without FAB', (WidgetTester tester) async {
Widget buildWidget({Widget? fab}) {
return MaterialApp(
home: Scaffold(
......@@ -690,7 +691,7 @@ void main() {
expect(physicalShape.clipper.toString(), 'ShapeBorderClipper');
});
testWidgets('BottomAppBar adds bottom padding to height', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BottomAppBar adds bottom padding to height', (WidgetTester tester) async {
const double bottomPadding = 35.0;
await tester.pumpWidget(
......
......@@ -10,6 +10,8 @@ library;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
void main() {
test('BottomAppBarTheme lerp special cases', () {
expect(BottomAppBarTheme.lerp(null, null, 0), const BottomAppBarTheme());
......@@ -18,7 +20,7 @@ void main() {
});
group('Material 2 tests', () {
testWidgets('BAB theme overrides color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BAB theme overrides color', (WidgetTester tester) async {
const Color themedColor = Colors.black87;
const BottomAppBarTheme theme = BottomAppBarTheme(color: themedColor);
......@@ -28,7 +30,7 @@ void main() {
expect(widget.color, themedColor);
});
testWidgets('BAB color - Widget', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BAB color - Widget', (WidgetTester tester) async {
const Color themeColor = Colors.white10;
const Color babThemeColor = Colors.black87;
const Color babColor = Colors.pink;
......@@ -47,7 +49,7 @@ void main() {
expect(widget.color, babColor);
});
testWidgets('BAB color - BabTheme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BAB color - BabTheme', (WidgetTester tester) async {
const Color themeColor = Colors.white10;
const Color babThemeColor = Colors.black87;
const BottomAppBarTheme theme = BottomAppBarTheme(color: babThemeColor);
......@@ -65,7 +67,7 @@ void main() {
expect(widget.color, babThemeColor);
});
testWidgets('BAB color - Theme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BAB color - Theme', (WidgetTester tester) async {
const Color themeColor = Colors.white10;
await tester.pumpWidget(MaterialApp(
......@@ -77,7 +79,7 @@ void main() {
expect(widget.color, themeColor);
});
testWidgets('BAB color - Default', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BAB color - Default', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: const Scaffold(body: BottomAppBar()),
......@@ -88,7 +90,7 @@ void main() {
expect(widget.color, Colors.white);
});
testWidgets('BAB theme customizes shape', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BAB theme customizes shape', (WidgetTester tester) async {
const BottomAppBarTheme theme = BottomAppBarTheme(
color: Colors.white30,
shape: CircularNotchedRectangle(),
......@@ -103,7 +105,7 @@ void main() {
);
});
testWidgets('BAB theme does not affect defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BAB theme does not affect defaults', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: const Scaffold(body: BottomAppBar()),
......@@ -117,7 +119,7 @@ void main() {
});
group('Material 3 tests', () {
testWidgets('BAB theme overrides color - M3', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BAB theme overrides color - M3', (WidgetTester tester) async {
const Color themedColor = Colors.black87;
const BottomAppBarTheme theme = BottomAppBarTheme(
color: themedColor,
......@@ -129,7 +131,7 @@ void main() {
expect(widget.color, themedColor);
});
testWidgets('BAB color - Widget - M3', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BAB color - Widget - M3', (WidgetTester tester) async {
const Color themeColor = Colors.white10;
const Color babThemeColor = Colors.black87;
const Color babColor = Colors.pink;
......@@ -148,7 +150,7 @@ void main() {
expect(widget.color, babColor);
});
testWidgets('BAB color - BabTheme - M3', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BAB color - BabTheme - M3', (WidgetTester tester) async {
const Color themeColor = Colors.white10;
const Color babThemeColor = Colors.black87;
const BottomAppBarTheme theme = BottomAppBarTheme(color: babThemeColor);
......@@ -166,7 +168,7 @@ void main() {
expect(widget.color, babThemeColor);
});
testWidgets('BAB theme does not affect defaults - M3', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BAB theme does not affect defaults - M3', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(MaterialApp(
theme: theme,
......@@ -179,7 +181,7 @@ void main() {
expect(widget.elevation, equals(3.0));
});
testWidgets('BAB theme overrides surfaceTintColor - M3', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BAB theme overrides surfaceTintColor - M3', (WidgetTester tester) async {
const Color color = Colors.blue; // base color that the surface tint will be applied to
const Color babThemeSurfaceTintColor = Colors.black87;
const BottomAppBarTheme theme = BottomAppBarTheme(
......@@ -191,7 +193,7 @@ void main() {
expect(widget.color, ElevationOverlay.applySurfaceTint(color, babThemeSurfaceTintColor, 0));
});
testWidgets('BAB theme overrides shadowColor - M3', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BAB theme overrides shadowColor - M3', (WidgetTester tester) async {
const Color babThemeShadowColor = Colors.yellow;
const BottomAppBarTheme theme = BottomAppBarTheme(
shadowColor: babThemeShadowColor, elevation: 0
......@@ -202,7 +204,7 @@ void main() {
expect(widget.shadowColor, babThemeShadowColor);
});
testWidgets('BAB surfaceTintColor - Widget - M3', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BAB surfaceTintColor - Widget - M3', (WidgetTester tester) async {
const Color color = Colors.white10; // base color that the surface tint will be applied to
const Color themeSurfaceTintColor = Colors.white10;
const Color babThemeSurfaceTintColor = Colors.black87;
......@@ -225,7 +227,7 @@ void main() {
expect(widget.color, ElevationOverlay.applySurfaceTint(color, babSurfaceTintColor, 3.0));
});
testWidgets('BAB surfaceTintColor - BabTheme - M3', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BAB surfaceTintColor - BabTheme - M3', (WidgetTester tester) async {
const Color color = Colors.blue; // base color that the surface tint will be applied to
const Color themeColor = Colors.white10;
const Color babThemeColor = Colors.black87;
......
......@@ -8,6 +8,8 @@ import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:vector_math/vector_math_64.dart' show Vector3;
import '../foundation/leak_tracking.dart';
void main() {
test('BottomNavigationBarThemeData copyWith, ==, hashCode basics', () {
......@@ -52,7 +54,7 @@ void main() {
expect(themeData.mouseCursor, null);
});
testWidgets('Default BottomNavigationBarThemeData debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Default BottomNavigationBarThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const BottomNavigationBarThemeData().debugFillProperties(builder);
......@@ -64,7 +66,7 @@ void main() {
expect(description, <String>[]);
});
testWidgets('BottomNavigationBarThemeData implements debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BottomNavigationBarThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const BottomNavigationBarThemeData(
backgroundColor: Color(0xfffffff0),
......@@ -105,7 +107,7 @@ void main() {
expect(description[11], 'mouseCursor: MaterialStateMouseCursor(clickable)');
});
testWidgets('BottomNavigationBar is themeable', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BottomNavigationBar is themeable', (WidgetTester tester) async {
const Color backgroundColor = Color(0xFF000001);
const Color selectedItemColor = Color(0xFF000002);
const Color unselectedItemColor = Color(0xFF000003);
......@@ -209,7 +211,7 @@ void main() {
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.move);
});
testWidgets('BottomNavigationBar properties are taken over the theme values', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BottomNavigationBar properties are taken over the theme values', (WidgetTester tester) async {
const Color themeBackgroundColor = Color(0xFF000001);
const Color themeSelectedItemColor = Color(0xFF000002);
const Color themeUnselectedItemColor = Color(0xFF000003);
......@@ -336,7 +338,7 @@ void main() {
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
});
testWidgets('BottomNavigationBarTheme can be used to hide all labels', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BottomNavigationBarTheme can be used to hide all labels', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/66738.
await tester.pumpWidget(
MaterialApp(
......@@ -374,7 +376,7 @@ void main() {
expect(tester.widget<Visibility>(findVisibility.at(1)).visible, false);
});
testWidgets('BottomNavigationBarTheme can be used to hide selected labels', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BottomNavigationBarTheme can be used to hide selected labels', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/66738.
await tester.pumpWidget(
MaterialApp(
......@@ -412,7 +414,7 @@ void main() {
expect(tester.widget<FadeTransition>(findFadeTransition.at(1)).opacity.value, 1.0);
});
testWidgets('BottomNavigationBarTheme can be used to hide unselected labels', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BottomNavigationBarTheme can be used to hide unselected labels', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(
......
......@@ -6,6 +6,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
void main() {
test('BottomSheetThemeData copyWith, ==, hashCode basics', () {
expect(const BottomSheetThemeData(), const BottomSheetThemeData().copyWith());
......@@ -36,7 +38,7 @@ void main() {
expect(bottomSheetTheme.dragHandleSize, null);
});
testWidgets('Default BottomSheetThemeData debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Default BottomSheetThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const BottomSheetThemeData().debugFillProperties(builder);
......@@ -48,7 +50,7 @@ void main() {
expect(description, <String>[]);
});
testWidgets('BottomSheetThemeData implements debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BottomSheetThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const BottomSheetThemeData(
backgroundColor: Color(0xFFFFFFFF),
......@@ -78,7 +80,7 @@ void main() {
]);
});
testWidgets('Passing no BottomSheetThemeData returns defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Passing no BottomSheetThemeData returns defaults', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false),
home: Scaffold(
......@@ -103,7 +105,7 @@ void main() {
expect(material.clipBehavior, Clip.none);
});
testWidgets('BottomSheet uses values from BottomSheetThemeData', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BottomSheet uses values from BottomSheetThemeData', (WidgetTester tester) async {
final BottomSheetThemeData bottomSheetTheme = _bottomSheetTheme();
await tester.pumpWidget(MaterialApp(
......@@ -130,7 +132,7 @@ void main() {
expect(material.clipBehavior, bottomSheetTheme.clipBehavior);
});
testWidgets('BottomSheet widget properties take priority over theme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BottomSheet widget properties take priority over theme', (WidgetTester tester) async {
const Color backgroundColor = Colors.purple;
const Color shadowColor = Colors.blue;
const double elevation = 7.0;
......@@ -169,7 +171,7 @@ void main() {
expect(material.clipBehavior, clipBehavior);
});
testWidgets('Modal bottom sheet-specific parameters are used for modal bottom sheets', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Modal bottom sheet-specific parameters are used for modal bottom sheets', (WidgetTester tester) async {
const double modalElevation = 5.0;
const double persistentElevation = 7.0;
const Color modalBackgroundColor = Colors.yellow;
......@@ -200,7 +202,7 @@ void main() {
expect(modalBarrier.color, modalBarrierColor);
});
testWidgets('General bottom sheet parameters take priority over modal bottom sheet-specific parameters for persistent bottom sheets', (WidgetTester tester) async {
testWidgetsWithLeakTracking('General bottom sheet parameters take priority over modal bottom sheet-specific parameters for persistent bottom sheets', (WidgetTester tester) async {
const double modalElevation = 5.0;
const double persistentElevation = 7.0;
const Color modalBackgroundColor = Colors.yellow;
......@@ -226,7 +228,7 @@ void main() {
expect(material.color, persistentBackgroundColor);
});
testWidgets("Modal bottom sheet-specific parameters don't apply to persistent bottom sheets", (WidgetTester tester) async {
testWidgetsWithLeakTracking("Modal bottom sheet-specific parameters don't apply to persistent bottom sheets", (WidgetTester tester) async {
const double modalElevation = 5.0;
const Color modalBackgroundColor = Colors.yellow;
const BottomSheetThemeData bottomSheetTheme = BottomSheetThemeData(
......@@ -248,7 +250,7 @@ void main() {
expect(material.color, null);
});
testWidgets('Modal bottom sheets respond to theme changes', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Modal bottom sheets respond to theme changes', (WidgetTester tester) async {
const double lightElevation = 5.0;
const double darkElevation = 3.0;
const Color lightBackgroundColor = Colors.green;
......
......@@ -5,8 +5,10 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
void main() {
testWidgets('ButtonBar default control smoketest', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ButtonBar default control smoketest', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -17,7 +19,7 @@ void main() {
group('alignment', () {
testWidgets('default alignment is MainAxisAlignment.end', (WidgetTester tester) async {
testWidgetsWithLeakTracking('default alignment is MainAxisAlignment.end', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: ButtonBar(
......@@ -34,7 +36,7 @@ void main() {
expect(tester.getRect(child).right, 792.0); // bar width - default padding
});
testWidgets('ButtonBarTheme.alignment overrides default', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ButtonBarTheme.alignment overrides default', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: ButtonBarTheme(
......@@ -56,7 +58,7 @@ void main() {
expect(tester.getRect(child).right, 405.0); // (bar width - padding) / 2 - 10 / 2 + 10
});
testWidgets('ButtonBar.alignment overrides ButtonBarTheme.alignment and default', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ButtonBar.alignment overrides ButtonBarTheme.alignment and default', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: ButtonBarTheme(
......@@ -83,7 +85,7 @@ void main() {
group('mainAxisSize', () {
testWidgets('Default mainAxisSize is MainAxisSize.max', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Default mainAxisSize is MainAxisSize.max', (WidgetTester tester) async {
const Key buttonBarKey = Key('row');
const Key child0Key = Key('child0');
const Key child1Key = Key('child1');
......@@ -130,7 +132,7 @@ void main() {
expect(childRect.right, 800.0);
});
testWidgets('ButtonBarTheme.mainAxisSize overrides default', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ButtonBarTheme.mainAxisSize overrides default', (WidgetTester tester) async {
const Key buttonBarKey = Key('row');
const Key child0Key = Key('child0');
const Key child1Key = Key('child1');
......@@ -185,7 +187,7 @@ void main() {
expect(childRect.left, ((800.0 - buttonBarRect.width) / 2.0) + 200.0);
});
testWidgets('ButtonBar.mainAxisSize overrides ButtonBarTheme.mainAxisSize and default', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ButtonBar.mainAxisSize overrides ButtonBarTheme.mainAxisSize and default', (WidgetTester tester) async {
const Key buttonBarKey = Key('row');
const Key child0Key = Key('child0');
const Key child1Key = Key('child1');
......@@ -240,7 +242,7 @@ void main() {
group('button properties override ButtonTheme', () {
testWidgets('default button properties override ButtonTheme properties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('default button properties override ButtonTheme properties', (WidgetTester tester) async {
late BuildContext capturedContext;
await tester.pumpWidget(
MaterialApp(
......@@ -263,7 +265,7 @@ void main() {
expect(buttonTheme.layoutBehavior, equals(ButtonBarLayoutBehavior.padded));
});
testWidgets('ButtonBarTheme button properties override defaults and ButtonTheme properties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ButtonBarTheme button properties override defaults and ButtonTheme properties', (WidgetTester tester) async {
late BuildContext capturedContext;
await tester.pumpWidget(
MaterialApp(
......@@ -296,7 +298,7 @@ void main() {
expect(buttonTheme.layoutBehavior, equals(ButtonBarLayoutBehavior.constrained));
});
testWidgets('ButtonBar button properties override ButtonBarTheme, defaults and ButtonTheme properties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ButtonBar button properties override ButtonBarTheme, defaults and ButtonTheme properties', (WidgetTester tester) async {
late BuildContext capturedContext;
await tester.pumpWidget(
MaterialApp(
......@@ -339,7 +341,7 @@ void main() {
group('layoutBehavior', () {
testWidgets('ButtonBar has a min height of 52 when using ButtonBarLayoutBehavior.constrained', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ButtonBar has a min height of 52 when using ButtonBarLayoutBehavior.constrained', (WidgetTester tester) async {
await tester.pumpWidget(
const SingleChildScrollView(
child: ListBody(
......@@ -362,7 +364,7 @@ void main() {
expect(tester.getBottomRight(buttonBar).dy - tester.getTopRight(buttonBar).dy, 52.0);
});
testWidgets('ButtonBar has padding applied when using ButtonBarLayoutBehavior.padded', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ButtonBar has padding applied when using ButtonBarLayoutBehavior.padded', (WidgetTester tester) async {
await tester.pumpWidget(
const SingleChildScrollView(
child: ListBody(
......@@ -387,7 +389,7 @@ void main() {
});
group("ButtonBar's children wrap when they overflow horizontally", () {
testWidgets("ButtonBar's children wrap when buttons overflow", (WidgetTester tester) async {
testWidgetsWithLeakTracking("ButtonBar's children wrap when buttons overflow", (WidgetTester tester) async {
final Key keyOne = UniqueKey();
final Key keyTwo = UniqueKey();
await tester.pumpWidget(
......@@ -409,7 +411,7 @@ void main() {
expect(containerOneRect.left, containerTwoRect.left);
});
testWidgets(
testWidgetsWithLeakTracking(
"ButtonBar's children overflow defaults - MainAxisAlignment.end", (WidgetTester tester) async {
final Key keyOne = UniqueKey();
final Key keyTwo = UniqueKey();
......@@ -437,7 +439,7 @@ void main() {
},
);
testWidgets("ButtonBar's children overflow - MainAxisAlignment.start", (WidgetTester tester) async {
testWidgetsWithLeakTracking("ButtonBar's children overflow - MainAxisAlignment.start", (WidgetTester tester) async {
final Key keyOne = UniqueKey();
final Key keyTwo = UniqueKey();
await tester.pumpWidget(
......@@ -464,7 +466,7 @@ void main() {
expect(containerOneRect.left, buttonBarRect.left);
});
testWidgets("ButtonBar's children overflow - MainAxisAlignment.center", (WidgetTester tester) async {
testWidgetsWithLeakTracking("ButtonBar's children overflow - MainAxisAlignment.center", (WidgetTester tester) async {
final Key keyOne = UniqueKey();
final Key keyTwo = UniqueKey();
await tester.pumpWidget(
......@@ -491,7 +493,7 @@ void main() {
expect(containerOneRect.center.dx, buttonBarRect.center.dx);
});
testWidgets(
testWidgetsWithLeakTracking(
"ButtonBar's children default to MainAxisAlignment.start for horizontal "
'alignment when overflowing in spaceBetween, spaceAround and spaceEvenly '
'cases when overflowing.', (WidgetTester tester) async {
......@@ -545,7 +547,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
"ButtonBar's children respects verticalDirection when overflowing",
(WidgetTester tester) async {
final Key keyOne = UniqueKey();
......@@ -574,7 +576,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
'ButtonBar has no spacing by default when overflowing',
(WidgetTester tester) async {
final Key keyOne = UniqueKey();
......@@ -599,7 +601,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
"ButtonBar's children respects overflowButtonSpacing when overflowing",
(WidgetTester tester) async {
final Key keyOne = UniqueKey();
......@@ -628,7 +630,7 @@ void main() {
);
});
testWidgets('_RenderButtonBarRow.constraints does not work before layout', (WidgetTester tester) async {
testWidgetsWithLeakTracking('_RenderButtonBarRow.constraints does not work before layout', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(home: ButtonBar()),
Duration.zero,
......
......@@ -6,6 +6,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
void main() {
test('ButtonBarThemeData lerp special cases', () {
......@@ -36,7 +38,7 @@ void main() {
expect(const ButtonBarThemeData().hashCode, const ButtonBarThemeData().copyWith().hashCode);
});
testWidgets('ButtonBarThemeData lerps correctly', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ButtonBarThemeData lerps correctly', (WidgetTester tester) async {
const ButtonBarThemeData barThemePrimary = ButtonBarThemeData(
alignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min,
......@@ -72,7 +74,7 @@ void main() {
expect(lerp.overflowDirection, equals(VerticalDirection.up));
});
testWidgets('Default ButtonBarThemeData debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Default ButtonBarThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ButtonBarThemeData().debugFillProperties(builder);
......@@ -84,7 +86,7 @@ void main() {
expect(description, <String>[]);
});
testWidgets('ButtonBarThemeData implements debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ButtonBarThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ButtonBarThemeData(
alignment: MainAxisAlignment.center,
......@@ -116,7 +118,7 @@ void main() {
]);
});
testWidgets('ButtonBarTheme.of falls back to ThemeData.buttonBarTheme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ButtonBarTheme.of falls back to ThemeData.buttonBarTheme', (WidgetTester tester) async {
const ButtonBarThemeData buttonBarTheme = ButtonBarThemeData(buttonMinWidth: 42.0);
late BuildContext capturedContext;
await tester.pumpWidget(
......@@ -134,7 +136,7 @@ void main() {
expect(ButtonBarTheme.of(capturedContext).buttonMinWidth, equals(42.0));
});
testWidgets('ButtonBarTheme overrides ThemeData.buttonBarTheme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ButtonBarTheme overrides ThemeData.buttonBarTheme', (WidgetTester tester) async {
const ButtonBarThemeData defaultBarTheme = ButtonBarThemeData(buttonMinWidth: 42.0);
const ButtonBarThemeData buttonBarTheme = ButtonBarThemeData(buttonMinWidth: 84.0);
late BuildContext capturedContext;
......
......@@ -7,6 +7,8 @@ import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
void main() {
test('ButtonStyle copyWith, merge, ==, hashCode basics', () {
expect(const ButtonStyle(), const ButtonStyle().copyWith());
......@@ -44,7 +46,7 @@ void main() {
expect(style.enableFeedback, null);
});
testWidgets('Default ButtonStyle debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Default ButtonStyle debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ButtonStyle().debugFillProperties(builder);
......@@ -56,7 +58,7 @@ void main() {
expect(description, <String>[]);
});
testWidgets('ButtonStyle debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ButtonStyle debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ButtonStyle(
textStyle: MaterialStatePropertyAll<TextStyle>(TextStyle(fontSize: 10.0)),
......@@ -106,7 +108,7 @@ void main() {
]);
});
testWidgets('ButtonStyle copyWith, merge', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ButtonStyle copyWith, merge', (WidgetTester tester) async {
const MaterialStateProperty<TextStyle> textStyle = MaterialStatePropertyAll<TextStyle>(TextStyle(fontSize: 10));
const MaterialStateProperty<Color> backgroundColor = MaterialStatePropertyAll<Color>(Color(0xfffffff1));
const MaterialStateProperty<Color> foregroundColor = MaterialStatePropertyAll<Color>(Color(0xfffffff2));
......
......@@ -5,6 +5,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
test('ButtonThemeData defaults', () {
const ButtonThemeData theme = ButtonThemeData();
......
......@@ -6,10 +6,11 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
import '../widgets/semantics_tester.dart';
void main() {
testWidgets('Card can take semantic text from multiple children', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Card can take semantic text from multiple children', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
Directionality(
......@@ -77,7 +78,7 @@ void main() {
semantics.dispose();
});
testWidgets('Card merges children when it is a semanticContainer', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Card merges children when it is a semanticContainer', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
debugResetSemanticsIdCounter();
......@@ -116,7 +117,7 @@ void main() {
semantics.dispose();
});
testWidgets('Card margin', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Card margin', (WidgetTester tester) async {
const Key contentsKey = ValueKey<String>('contents');
await tester.pumpWidget(
......@@ -163,7 +164,7 @@ void main() {
expect(tester.getSize(find.byKey(contentsKey)), const Size(100.0, 100.0));
});
testWidgets('Card clipBehavior property passes through to the Material', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Card clipBehavior property passes through to the Material', (WidgetTester tester) async {
await tester.pumpWidget(const Card());
expect(tester.widget<Material>(find.byType(Material)).clipBehavior, Clip.none);
......@@ -171,7 +172,7 @@ void main() {
expect(tester.widget<Material>(find.byType(Material)).clipBehavior, Clip.antiAlias);
});
testWidgets('Card clipBehavior property defers to theme when null', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Card clipBehavior property defers to theme when null', (WidgetTester tester) async {
await tester.pumpWidget(Builder(builder: (BuildContext context) {
final ThemeData themeData = Theme.of(context);
return Theme(
......@@ -186,7 +187,7 @@ void main() {
expect(tester.widget<Material>(find.byType(Material)).clipBehavior, Clip.antiAliasWithSaveLayer);
});
testWidgets('Card shadowColor', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Card shadowColor', (WidgetTester tester) async {
Material getCardMaterial(WidgetTester tester) {
return tester.widget<Material>(
find.descendant(
......
......@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
import '../rendering/mock_canvas.dart';
void main() {
......@@ -41,7 +42,7 @@ void main() {
expect(theme.data.visualDensity, null);
});
testWidgets('Default CheckboxThemeData debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Default CheckboxThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const CheckboxThemeData().debugFillProperties(builder);
......@@ -53,7 +54,7 @@ void main() {
expect(description, <String>[]);
});
testWidgets('CheckboxThemeData implements debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CheckboxThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const CheckboxThemeData(
mouseCursor: MaterialStatePropertyAll<MouseCursor?>(SystemMouseCursors.click),
......@@ -84,7 +85,7 @@ void main() {
);
});
testWidgets('Checkbox is themeable', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Checkbox is themeable', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
const MouseCursor mouseCursor = SystemMouseCursors.text;
......@@ -166,7 +167,7 @@ void main() {
expect(_getCheckboxMaterial(tester), paints..path(color: selectedFillColor)..path(color: focusedCheckColor));
});
testWidgets('Checkbox properties are taken over the theme values', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Checkbox properties are taken over the theme values', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
const MouseCursor themeMouseCursor = SystemMouseCursors.click;
......@@ -264,7 +265,7 @@ void main() {
expect(_getCheckboxMaterial(tester), paints..circle(color: focusColor, radius: splashRadius));
});
testWidgets('Checkbox activeColor property is taken over the theme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Checkbox activeColor property is taken over the theme', (WidgetTester tester) async {
const Color themeSelectedFillColor = Color(0xfffffff1);
const Color themeDefaultFillColor = Color(0xfffffff0);
const Color selectedFillColor = Color(0xfffffff6);
......@@ -302,7 +303,7 @@ void main() {
expect(_getCheckboxMaterial(tester), paints..path(color: selectedFillColor));
});
testWidgets('Checkbox theme overlay color resolves in active/pressed states', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Checkbox theme overlay color resolves in active/pressed states', (WidgetTester tester) async {
const Color activePressedOverlayColor = Color(0xFF000001);
const Color inactivePressedOverlayColor = Color(0xFF000002);
......@@ -363,7 +364,7 @@ void main() {
);
});
testWidgets('Local CheckboxTheme can override global CheckboxTheme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Local CheckboxTheme can override global CheckboxTheme', (WidgetTester tester) async {
const Color globalThemeFillColor = Color(0xfffffff1);
const Color globalThemeCheckColor = Color(0xff000000);
const Color localThemeFillColor = Color(0xffff0000);
......
......@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
import '../rendering/mock_canvas.dart';
RenderBox getMaterialBox(WidgetTester tester) {
......@@ -72,7 +73,7 @@ void main() {
expect(themeData.pressElevation, null);
});
testWidgets('Default ChipThemeData debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Default ChipThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ChipThemeData().debugFillProperties(builder);
......@@ -84,7 +85,7 @@ void main() {
expect(description, <String>[]);
});
testWidgets('ChipThemeData implements debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ChipThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ChipThemeData(
color: MaterialStatePropertyAll<Color>(Color(0xfffffff0)),
......@@ -138,7 +139,7 @@ void main() {
]);
});
testWidgets('Chip uses ThemeData chip theme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip uses ThemeData chip theme', (WidgetTester tester) async {
const ChipThemeData chipTheme = ChipThemeData(
backgroundColor: Color(0xff112233),
elevation: 4,
......@@ -175,7 +176,7 @@ void main() {
expect(getLabelStyle(tester).style.fontSize, 32);
});
testWidgets('Chip uses ChipTheme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip uses ChipTheme', (WidgetTester tester) async {
const ChipThemeData chipTheme = ChipThemeData(
backgroundColor: Color(0xff112233),
elevation: 4,
......@@ -228,7 +229,7 @@ void main() {
expect(getLabelStyle(tester).style.fontSize, 32);
});
testWidgets('Chip uses constructor parameters', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip uses constructor parameters', (WidgetTester tester) async {
const ChipThemeData shadowedChipTheme = ChipThemeData(
backgroundColor: Color(0xff112233),
elevation: 4,
......@@ -281,7 +282,7 @@ void main() {
expect(getLabelStyle(tester).style.fontSize, 32);
});
testWidgets('ChipTheme.fromDefaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ChipTheme.fromDefaults', (WidgetTester tester) async {
const TextStyle labelStyle = TextStyle();
ChipThemeData chipTheme = ChipThemeData.fromDefaults(
brightness: Brightness.light,
......@@ -333,7 +334,7 @@ void main() {
expect(chipTheme.pressElevation, 8.0);
});
testWidgets('ChipThemeData generates correct opacities for defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ChipThemeData generates correct opacities for defaults', (WidgetTester tester) async {
const Color customColor1 = Color(0xcafefeed);
const Color customColor2 = Color(0xdeadbeef);
final TextStyle customStyle = ThemeData.fallback().textTheme.bodyLarge!.copyWith(color: customColor2);
......@@ -396,7 +397,7 @@ void main() {
expect(customTheme.brightness, equals(Brightness.light));
});
testWidgets('ChipThemeData lerps correctly', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ChipThemeData lerps correctly', (WidgetTester tester) async {
final ChipThemeData chipThemeBlack = ChipThemeData.fromDefaults(
secondaryColor: Colors.black,
brightness: Brightness.dark,
......@@ -544,7 +545,7 @@ void main() {
expect(lerp.iconTheme, isNull);
});
testWidgets('Chip uses stateful color from chip theme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip uses stateful color from chip theme', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode();
const Color pressedColor = Color(0x00000001);
......@@ -640,7 +641,7 @@ void main() {
expect(textColor(), disabledColor);
});
testWidgets('Chip uses stateful border side from resolveWith pattern', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip uses stateful border side from resolveWith pattern', (WidgetTester tester) async {
const Color selectedColor = Color(0x00000001);
const Color defaultColor = Color(0x00000002);
......@@ -681,7 +682,7 @@ void main() {
expect(find.byType(RawChip), paints..rrect()..rrect(color: selectedColor));
});
testWidgets('Chip uses stateful border side from chip theme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip uses stateful border side from chip theme', (WidgetTester tester) async {
const Color selectedColor = Color(0x00000001);
const Color defaultColor = Color(0x00000002);
......@@ -723,7 +724,7 @@ void main() {
expect(find.byType(RawChip), paints..rrect()..rrect(color: selectedColor));
});
testWidgets('Chip uses stateful shape from chip theme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Chip uses stateful shape from chip theme', (WidgetTester tester) async {
OutlinedBorder? getShape(Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) {
return const RoundedRectangleBorder();
......@@ -763,7 +764,7 @@ void main() {
expect(getMaterial(tester).shape, isA<RoundedRectangleBorder>());
});
testWidgets('RawChip uses material state color from ChipTheme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('RawChip uses material state color from ChipTheme', (WidgetTester tester) async {
const Color disabledSelectedColor = Color(0xffffff00);
const Color disabledColor = Color(0xff00ff00);
const Color backgroundColor = Color(0xff0000ff);
......@@ -827,7 +828,7 @@ void main() {
expect(getMaterialBox(tester), paints..rrect(color: disabledSelectedColor));
});
testWidgets('RawChip uses state colors from ChipTheme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('RawChip uses state colors from ChipTheme', (WidgetTester tester) async {
const ChipThemeData chipTheme = ChipThemeData(
disabledColor: Color(0xadfefafe),
backgroundColor: Color(0xcafefeed),
......
......@@ -5,6 +5,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
import '../rendering/mock_canvas.dart';
RenderBox getMaterialBox(WidgetTester tester, Finder type) {
......@@ -64,7 +65,7 @@ void checkChipMaterialClipBehavior(WidgetTester tester, Clip clipBehavior) {
}
void main() {
testWidgets('ChoiceChip defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ChoiceChip defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
const String label = 'choice chip';
......@@ -196,7 +197,7 @@ void main() {
expect(decoration.color, theme.colorScheme.onSurface.withOpacity(0.12));
});
testWidgets('ChoiceChip.elevated defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ChoiceChip.elevated defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
const String label = 'choice chip';
......@@ -328,7 +329,7 @@ void main() {
expect(decoration.color, theme.colorScheme.onSurface.withOpacity(0.12));
});
testWidgets('ChoiceChip.color resolves material states', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ChoiceChip.color resolves material states', (WidgetTester tester) async {
const Color disabledSelectedColor = Color(0xffffff00);
const Color disabledColor = Color(0xff00ff00);
const Color backgroundColor = Color(0xff0000ff);
......@@ -427,7 +428,7 @@ void main() {
);
});
testWidgets('ChoiceChip uses provided state color properties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ChoiceChip uses provided state color properties', (WidgetTester tester) async {
const Color disabledColor = Color(0xff00ff00);
const Color backgroundColor = Color(0xff0000ff);
const Color selectedColor = Color(0xffff0000);
......@@ -502,7 +503,7 @@ void main() {
);
});
testWidgets('ChoiceChip can be tapped', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ChoiceChip can be tapped', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Material(
......@@ -518,7 +519,7 @@ void main() {
expect(tester.takeException(), null);
});
testWidgets('ChoiceChip clipBehavior properly passes through to the Material', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ChoiceChip clipBehavior properly passes through to the Material', (WidgetTester tester) async {
const Text label = Text('label');
await tester.pumpWidget(wrapForChip(child: const ChoiceChip(label: label, selected: false)));
checkChipMaterialClipBehavior(tester, Clip.none);
......@@ -527,7 +528,7 @@ void main() {
checkChipMaterialClipBehavior(tester, Clip.antiAlias);
});
testWidgets('ChoiceChip passes iconTheme property to RawChip', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ChoiceChip passes iconTheme property to RawChip', (WidgetTester tester) async {
const IconThemeData iconTheme = IconThemeData(color: Colors.red);
await tester.pumpWidget(wrapForChip(
child: const ChoiceChip(
......@@ -539,7 +540,7 @@ void main() {
expect(rawChip.iconTheme, iconTheme);
});
testWidgets('ChoiceChip passes showCheckmark from ChipTheme to RawChip', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ChoiceChip passes showCheckmark from ChipTheme to RawChip', (WidgetTester tester) async {
const bool showCheckmark = false;
await tester.pumpWidget(wrapForChip(
child: const ChipTheme(
......@@ -555,7 +556,7 @@ void main() {
expect(rawChip.showCheckmark, showCheckmark);
});
testWidgets('ChoiceChip passes checkmark properties to RawChip', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ChoiceChip passes checkmark properties to RawChip', (WidgetTester tester) async {
const bool showCheckmark = false;
const Color checkmarkColor = Color(0xff0000ff);
await tester.pumpWidget(wrapForChip(
......@@ -575,7 +576,7 @@ void main() {
// support is deprecated and the APIs are removed, these tests
// can be deleted.
testWidgets('ChoiceChip defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ChoiceChip defaults', (WidgetTester tester) async {
Widget buildFrame(Brightness brightness) {
return MaterialApp(
theme: ThemeData(useMaterial3: false, brightness: brightness),
......
......@@ -13,11 +13,12 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
import '../image_data.dart';
import '../painting/mocks_for_image_cache.dart';
void main() {
testWidgets('CircleAvatar with dark background color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CircleAvatar with dark background color', (WidgetTester tester) async {
final Color backgroundColor = Colors.blue.shade900;
await tester.pumpWidget(
wrap(
......@@ -39,7 +40,7 @@ void main() {
expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorLight));
});
testWidgets('CircleAvatar with light background color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CircleAvatar with light background color', (WidgetTester tester) async {
final Color backgroundColor = Colors.blue.shade100;
await tester.pumpWidget(
wrap(
......@@ -61,7 +62,7 @@ void main() {
expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorDark));
});
testWidgets('CircleAvatar with image background', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CircleAvatar with image background', (WidgetTester tester) async {
await tester.pumpWidget(
wrap(
child: CircleAvatar(
......@@ -78,7 +79,7 @@ void main() {
expect(decoration.image!.fit, equals(BoxFit.cover));
});
testWidgets('CircleAvatar with image foreground', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CircleAvatar with image foreground', (WidgetTester tester) async {
await tester.pumpWidget(
wrap(
child: CircleAvatar(
......@@ -95,7 +96,7 @@ void main() {
expect(decoration.image!.fit, equals(BoxFit.cover));
});
testWidgets('CircleAvatar backgroundImage is used as a fallback for foregroundImage', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CircleAvatar backgroundImage is used as a fallback for foregroundImage', (WidgetTester tester) async {
final ErrorImageProvider errorImage = ErrorImageProvider();
bool caughtForegroundImageError = false;
await tester.pumpWidget(
......@@ -123,7 +124,7 @@ void main() {
);
});
testWidgets('CircleAvatar with foreground color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CircleAvatar with foreground color', (WidgetTester tester) async {
final Color foregroundColor = Colors.red.shade100;
await tester.pumpWidget(
wrap(
......@@ -146,7 +147,7 @@ void main() {
expect(paragraph.text.style!.color, equals(foregroundColor));
});
testWidgets('CircleAvatar default colors', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CircleAvatar default colors', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(
wrap(
......@@ -168,7 +169,7 @@ void main() {
expect(paragraph.text.style!.color, equals(theme.colorScheme.onPrimaryContainer));
});
testWidgets('CircleAvatar text does not expand with textScaleFactor', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CircleAvatar text does not expand with textScaleFactor', (WidgetTester tester) async {
final Color foregroundColor = Colors.red.shade100;
await tester.pumpWidget(
wrap(
......@@ -212,7 +213,7 @@ void main() {
expect(tester.getSize(find.text('Z')), equals(const Size(16.0, 16.0)));
});
testWidgets('CircleAvatar respects minRadius', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CircleAvatar respects minRadius', (WidgetTester tester) async {
final Color backgroundColor = Colors.blue.shade900;
await tester.pumpWidget(
wrap(
......@@ -236,7 +237,7 @@ void main() {
expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorLight));
});
testWidgets('CircleAvatar respects maxRadius', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CircleAvatar respects maxRadius', (WidgetTester tester) async {
final Color backgroundColor = Colors.blue.shade900;
await tester.pumpWidget(
wrap(
......@@ -258,7 +259,7 @@ void main() {
expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorLight));
});
testWidgets('CircleAvatar respects setting both minRadius and maxRadius', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CircleAvatar respects setting both minRadius and maxRadius', (WidgetTester tester) async {
final Color backgroundColor = Colors.blue.shade900;
await tester.pumpWidget(
wrap(
......@@ -286,7 +287,7 @@ void main() {
// support is deprecated and the APIs are removed, these tests
// can be deleted.
testWidgets('CircleAvatar default colors with light theme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CircleAvatar default colors with light theme', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: false, primaryColor: Colors.grey.shade100);
await tester.pumpWidget(
wrap(
......@@ -308,7 +309,7 @@ void main() {
expect(paragraph.text.style!.color, equals(theme.primaryTextTheme.titleLarge!.color));
});
testWidgets('CircleAvatar default colors with dark theme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CircleAvatar default colors with dark theme', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: false, primaryColor: Colors.grey.shade800);
await tester.pumpWidget(
wrap(
......
......@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
void main() {
test('DataTableThemeData copyWith, ==, hashCode basics', () {
expect(const DataTableThemeData(), const DataTableThemeData().copyWith());
......@@ -64,7 +66,7 @@ void main() {
expect(theme.data.dataRowCursor, null);
});
testWidgets('Default DataTableThemeData debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Default DataTableThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const DataTableThemeData().debugFillProperties(builder);
......@@ -76,7 +78,7 @@ void main() {
expect(description, <String>[]);
});
testWidgets('DataTableThemeData implements debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DataTableThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
DataTableThemeData(
decoration: const BoxDecoration(color: Color(0xfffffff0)),
......@@ -120,7 +122,7 @@ void main() {
expect(description[13], 'dataRowCursor: MaterialStatePropertyAll(SystemMouseCursor(forbidden))');
});
testWidgets('DataTable is themeable', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DataTable is themeable', (WidgetTester tester) async {
const BoxDecoration decoration = BoxDecoration(color: Color(0xfffffff0));
const MaterialStateProperty<Color> dataRowColor = MaterialStatePropertyAll<Color>(Color(0xfffffff1));
const double minMaxDataRowHeight = 41.0;
......@@ -207,7 +209,7 @@ void main() {
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.forbidden);
});
testWidgets('DataTable is themeable - separate test for deprecated dataRowHeight', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DataTable is themeable - separate test for deprecated dataRowHeight', (WidgetTester tester) async {
const double dataRowHeight = 51.0;
await tester.pumpWidget(
......@@ -241,7 +243,7 @@ void main() {
expect(tester.getSize(_findFirstContainerFor('Data')).height, dataRowHeight);
});
testWidgets('DataTable properties are taken over the theme values', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DataTable properties are taken over the theme values', (WidgetTester tester) async {
const BoxDecoration themeDecoration = BoxDecoration(color: Color(0xfffffff1));
const MaterialStateProperty<Color> themeDataRowColor = MaterialStatePropertyAll<Color>(Color(0xfffffff0));
const double minMaxThemeDataRowHeight = 50.0;
......@@ -354,7 +356,7 @@ void main() {
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), dataRowCursor.resolve(<MaterialState>{}));
});
testWidgets('DataTable properties are taken over the theme values - separate test for deprecated dataRowHeight', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DataTable properties are taken over the theme values - separate test for deprecated dataRowHeight', (WidgetTester tester) async {
const double themeDataRowHeight = 50.0;
const double dataRowHeight = 51.0;
......@@ -390,7 +392,7 @@ void main() {
expect(tester.getSize(_findFirstContainerFor('Data')).height, dataRowHeight);
});
testWidgets('Local DataTableTheme can override global DataTableTheme', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Local DataTableTheme can override global DataTableTheme', (WidgetTester tester) async {
const BoxDecoration globalThemeDecoration = BoxDecoration(color: Color(0xfffffff1));
const MaterialStateProperty<Color> globalThemeDataRowColor = MaterialStatePropertyAll<Color>(Color(0xfffffff0));
const double minMaxGlobalThemeDataRowHeight = 50.0;
......@@ -507,7 +509,7 @@ void main() {
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), localDataRowCursor.resolve(<MaterialState>{}));
});
testWidgets('Local DataTableTheme can override global DataTableTheme - separate test for deprecated dataRowHeight', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Local DataTableTheme can override global DataTableTheme - separate test for deprecated dataRowHeight', (WidgetTester tester) async {
const double globalThemeDataRowHeight = 50.0;
const double localThemeDataRowHeight = 51.0;
......
......@@ -6,8 +6,10 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
void main() {
testWidgets('debugCheckHasMaterial control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('debugCheckHasMaterial control test', (WidgetTester tester) async {
await tester.pumpWidget(const Center(child: Chip(label: Text('label'))));
final dynamic exception = tester.takeException();
expect(exception, isFlutterError);
......@@ -47,7 +49,7 @@ void main() {
));
});
testWidgets('debugCheckHasMaterialLocalizations control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('debugCheckHasMaterialLocalizations control test', (WidgetTester tester) async {
await tester.pumpWidget(const Center(child: BackButton()));
final dynamic exception = tester.takeException();
expect(exception, isFlutterError);
......@@ -84,7 +86,7 @@ void main() {
));
});
testWidgets('debugCheckHasScaffold control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('debugCheckHasScaffold control test', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(
......
......@@ -5,10 +5,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
testWidgets('can press', (WidgetTester tester) async {
testWidgetsWithLeakTracking('can press', (WidgetTester tester) async {
bool pressed = false;
await tester.pumpWidget(
MaterialApp(
......@@ -29,7 +31,7 @@ void main() {
expect(pressed, true);
});
testWidgets('passing null to onPressed disables the button', (WidgetTester tester) async {
testWidgetsWithLeakTracking('passing null to onPressed disables the button', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Center(
......
......@@ -5,10 +5,12 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
testWidgets('positions itself at the anchor', (WidgetTester tester) async {
testWidgetsWithLeakTracking('positions itself at the anchor', (WidgetTester tester) async {
// An arbitrary point on the screen to position at.
const Offset anchor = Offset(30.0, 40.0);
......
......@@ -6,8 +6,10 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
void main() {
testWidgets('DrawerButton control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DrawerButton control test', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
......@@ -28,7 +30,7 @@ void main() {
expect(find.byType(Drawer), findsOneWidget);
});
testWidgets('DrawerButton onPressed overrides default end drawer open behaviour',
testWidgetsWithLeakTracking('DrawerButton onPressed overrides default end drawer open behaviour',
(WidgetTester tester) async {
bool customCallbackWasCalled = false;
await tester.pumpWidget(
......@@ -57,7 +59,7 @@ void main() {
expect(customCallbackWasCalled, true);
});
testWidgets('DrawerButton icon', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DrawerButton icon', (WidgetTester tester) async {
final Key androidKey = UniqueKey();
final Key iOSKey = UniqueKey();
final Key linuxKey = UniqueKey();
......@@ -111,7 +113,7 @@ void main() {
expect(windowsIcon.icon == androidIcon.icon, isTrue);
});
testWidgets('DrawerButton color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DrawerButton color', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),
......@@ -132,7 +134,7 @@ void main() {
expect(iconText.text.style!.color, Colors.red);
});
testWidgets('DrawerButton semantics', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DrawerButton semantics', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
const MaterialApp(
......@@ -169,7 +171,7 @@ void main() {
handle.dispose();
}, variant: TargetPlatformVariant.all());
testWidgets('EndDrawerButton control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('EndDrawerButton control test', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Scaffold(
......@@ -190,7 +192,7 @@ void main() {
expect(find.byType(Drawer), findsOneWidget);
});
testWidgets('EndDrawerButton semantics', (WidgetTester tester) async {
testWidgetsWithLeakTracking('EndDrawerButton semantics', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(
const MaterialApp(
......@@ -226,7 +228,7 @@ void main() {
handle.dispose();
}, variant: TargetPlatformVariant.all());
testWidgets('EndDrawerButton color', (WidgetTester tester) async {
testWidgetsWithLeakTracking('EndDrawerButton color', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(useMaterial3: true),
......@@ -247,7 +249,7 @@ void main() {
expect(iconText.text.style!.color, Colors.red);
});
testWidgets('EndDrawerButton onPressed overrides default end drawer open behaviour',
testWidgetsWithLeakTracking('EndDrawerButton onPressed overrides default end drawer open behaviour',
(WidgetTester tester) async {
bool customCallbackWasCalled = false;
await tester.pumpWidget(
......
......@@ -7,6 +7,7 @@ import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
import '../rendering/mock_canvas.dart';
const List<String> menuItems = <String>['one', 'two', 'three', 'four'];
......@@ -200,7 +201,7 @@ void main() {
expect(hintEmptyLabel, oneValueLabel);
});
testWidgets('label position test - show disabledHint: disable', (WidgetTester tester) async {
testWidgetsWithLeakTracking('label position test - show disabledHint: disable', (WidgetTester tester) async {
int? value;
await tester.pumpWidget(
......@@ -238,7 +239,7 @@ void main() {
expect(hintEmptyLabel, const Offset(0.0, 12.0));
});
testWidgets('label position test - show disabledHint: enable + null item', (WidgetTester tester) async {
testWidgetsWithLeakTracking('label position test - show disabledHint: enable + null item', (WidgetTester tester) async {
int? value;
await tester.pumpWidget(
......@@ -263,7 +264,7 @@ void main() {
expect(hintEmptyLabel, const Offset(0.0, 12.0));
});
testWidgets('label position test - show disabledHint: enable + empty item', (WidgetTester tester) async {
testWidgetsWithLeakTracking('label position test - show disabledHint: enable + empty item', (WidgetTester tester) async {
int? value;
await tester.pumpWidget(
......@@ -313,7 +314,7 @@ void main() {
expect(hintEmptyLabel, const Offset(0.0, 12.0));
});
testWidgets('label position test - no hint shown: enable + no selected + disabledHint', (WidgetTester tester) async {
testWidgetsWithLeakTracking('label position test - no hint shown: enable + no selected + disabledHint', (WidgetTester tester) async {
int? value;
await tester.pumpWidget(
......@@ -351,7 +352,7 @@ void main() {
expect(hintEmptyLabel, const Offset(0.0, 24.0));
});
testWidgets('label position test - show selected item: disabled + hint + disabledHint', (WidgetTester tester) async {
testWidgetsWithLeakTracking('label position test - show selected item: disabled + hint + disabledHint', (WidgetTester tester) async {
const int value = 1;
await tester.pumpWidget(
......@@ -391,7 +392,7 @@ void main() {
});
// Regression test for https://github.com/flutter/flutter/issues/82910
testWidgets('null value test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('null value test', (WidgetTester tester) async {
int? value = 1;
await tester.pumpWidget(
......@@ -492,7 +493,7 @@ void main() {
expect(value, equals('three'));
});
testWidgets('DropdownButtonFormField arrow icon aligns with the edge of button when expanded', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownButtonFormField arrow icon aligns with the edge of button when expanded', (WidgetTester tester) async {
final Key buttonKey = UniqueKey();
// There shouldn't be overflow when expanded although list contains longer items.
......@@ -527,7 +528,7 @@ void main() {
);
});
testWidgets('DropdownButtonFormField with isDense:true aligns selected menu item', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownButtonFormField with isDense:true aligns selected menu item', (WidgetTester tester) async {
final Key buttonKey = UniqueKey();
await tester.pumpWidget(
......@@ -567,7 +568,7 @@ void main() {
}
});
testWidgets('DropdownButtonFormField with isDense:true does not clip large scale text',
testWidgetsWithLeakTracking('DropdownButtonFormField with isDense:true does not clip large scale text',
(WidgetTester tester) async {
final Key buttonKey = UniqueKey();
const String value = 'two';
......@@ -606,7 +607,7 @@ void main() {
expect(box.size.height, 72.0);
});
testWidgets('DropdownButtonFormField.isDense is true by default', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownButtonFormField.isDense is true by default', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/46844
final Key buttonKey = UniqueKey();
const String value = 'two';
......@@ -637,7 +638,7 @@ void main() {
expect(box.size.height, 48.0);
});
testWidgets('DropdownButtonFormField - custom text style', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownButtonFormField - custom text style', (WidgetTester tester) async {
const String value = 'foo';
final UniqueKey itemKey = UniqueKey();
......@@ -675,7 +676,7 @@ void main() {
expect(richText.text.style!.fontSize, 20.0);
});
testWidgets('DropdownButtonFormField - disabledHint displays when the items list is empty, when items is null', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownButtonFormField - disabledHint displays when the items list is empty, when items is null', (WidgetTester tester) async {
final Key buttonKey = UniqueKey();
Widget build({ List<String>? items }) {
......@@ -698,7 +699,7 @@ void main() {
expect(find.text('disabled'), findsOneWidget);
});
testWidgets(
testWidgetsWithLeakTracking(
'DropdownButtonFormField - hint displays when the items list is '
'empty, items is null, and disabledHint is null',
(WidgetTester tester) async {
......@@ -722,7 +723,7 @@ void main() {
},
);
testWidgets('DropdownButtonFormField - disabledHint is null by default', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownButtonFormField - disabledHint is null by default', (WidgetTester tester) async {
final Key buttonKey = UniqueKey();
Widget build({ List<String>? items }) {
......@@ -742,7 +743,7 @@ void main() {
expect(find.text('hint used when disabled'), findsOneWidget);
});
testWidgets('DropdownButtonFormField - disabledHint is null by default', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownButtonFormField - disabledHint is null by default', (WidgetTester tester) async {
final Key buttonKey = UniqueKey();
Widget build({ List<String>? items }) {
......@@ -762,7 +763,7 @@ void main() {
expect(find.text('hint used when disabled'), findsOneWidget);
});
testWidgets('DropdownButtonFormField - disabledHint displays when onChanged is null', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownButtonFormField - disabledHint displays when onChanged is null', (WidgetTester tester) async {
final Key buttonKey = UniqueKey();
Widget build({ List<String>? items, ValueChanged<String?>? onChanged }) {
......@@ -780,7 +781,7 @@ void main() {
expect(find.text('disabled'), findsOneWidget);
});
testWidgets('DropdownButtonFormField - disabled hint should be of same size as enabled hint', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownButtonFormField - disabled hint should be of same size as enabled hint', (WidgetTester tester) async {
final Key buttonKey = UniqueKey();
Widget build({ List<String>? items}) {
......@@ -805,7 +806,7 @@ void main() {
expect(enabledHintBox.size, equals(disabledHintBox.size));
});
testWidgets('DropdownButtonFormField - Custom icon size and colors', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownButtonFormField - Custom icon size and colors', (WidgetTester tester) async {
final Key iconKey = UniqueKey();
final Icon customIcon = Icon(Icons.assessment, key: iconKey);
......@@ -838,7 +839,7 @@ void main() {
expect(disabledRichText.text.style!.color, Colors.orange);
});
testWidgets('DropdownButtonFormField - default elevation', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownButtonFormField - default elevation', (WidgetTester tester) async {
final Key buttonKey = UniqueKey();
debugDisableShadows = false;
await tester.pumpWidget(buildFormFrame(
......@@ -895,7 +896,7 @@ void main() {
debugDisableShadows = true;
});
testWidgets('DropdownButtonFormField does not allow duplicate item values', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownButtonFormField does not allow duplicate item values', (WidgetTester tester) async {
final List<DropdownMenuItem<String>> itemsWithDuplicateValues = <String>['a', 'b', 'c', 'c']
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
......@@ -924,7 +925,7 @@ void main() {
);
});
testWidgets('DropdownButtonFormField value should only appear in one menu item', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownButtonFormField value should only appear in one menu item', (WidgetTester tester) async {
final List<DropdownMenuItem<String>> itemsWithDuplicateValues = <String>['a', 'b', 'c', 'd']
.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
......@@ -1089,7 +1090,7 @@ void main() {
expect(find.text(currentValue), findsOneWidget);
});
testWidgets('autovalidateMode is passed to super', (WidgetTester tester) async {
testWidgetsWithLeakTracking('autovalidateMode is passed to super', (WidgetTester tester) async {
int validateCalled = 0;
await tester.pumpWidget(
......@@ -1118,7 +1119,7 @@ void main() {
expect(validateCalled, 1);
});
testWidgets('DropdownButtonFormField - Custom button alignment', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownButtonFormField - Custom button alignment', (WidgetTester tester) async {
await tester.pumpWidget(buildFormFrame(
buttonAlignment: AlignmentDirectional.center,
items: <String>['one'],
......
......@@ -6,6 +6,8 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
void main() {
test('DropdownMenuThemeData copyWith, ==, hashCode basics', () {
expect(const DropdownMenuThemeData(), const DropdownMenuThemeData().copyWith());
......@@ -30,7 +32,7 @@ void main() {
expect(identical(DropdownMenuThemeData.lerp(data, data, 0.5), data), true);
});
testWidgets('Default DropdownMenuThemeData debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Default DropdownMenuThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const DropdownMenuThemeData().debugFillProperties(builder);
......@@ -42,7 +44,7 @@ void main() {
expect(description, <String>[]);
});
testWidgets('With no other configuration, defaults are used', (WidgetTester tester) async {
testWidgetsWithLeakTracking('With no other configuration, defaults are used', (WidgetTester tester) async {
final ThemeData themeData = ThemeData();
await tester.pumpWidget(
MaterialApp(
......@@ -99,7 +101,7 @@ void main() {
expect(material.textStyle?.color, themeData.colorScheme.onSurface);
});
testWidgets('ThemeData.dropdownMenuTheme overrides defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ThemeData.dropdownMenuTheme overrides defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(
dropdownMenuTheme: DropdownMenuThemeData(
textStyle: TextStyle(
......@@ -178,7 +180,7 @@ void main() {
expect(material.textStyle?.color, theme.colorScheme.onSurface);
});
testWidgets('DropdownMenuTheme overrides ThemeData and defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('DropdownMenuTheme overrides ThemeData and defaults', (WidgetTester tester) async {
final DropdownMenuThemeData global = DropdownMenuThemeData(
textStyle: TextStyle(
color: Colors.orange,
......@@ -281,7 +283,7 @@ void main() {
expect(material.textStyle?.color, theme.colorScheme.onSurface);
});
testWidgets('Widget parameters overrides DropdownMenuTheme, ThemeData and defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Widget parameters overrides DropdownMenuTheme, ThemeData and defaults', (WidgetTester tester) async {
final DropdownMenuThemeData global = DropdownMenuThemeData(
textStyle: TextStyle(
color: Colors.orange,
......
......@@ -5,6 +5,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
void main() {
test('ElevatedButtonThemeData lerp special cases', () {
expect(ElevatedButtonThemeData.lerp(null, null, 0), null);
......@@ -12,7 +14,7 @@ void main() {
expect(identical(ElevatedButtonThemeData.lerp(data, data, 0.5), data), true);
});
testWidgets('Material3: Passing no ElevatedButtonTheme returns defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material3: Passing no ElevatedButtonTheme returns defaults', (WidgetTester tester) async {
const ColorScheme colorScheme = ColorScheme.light();
await tester.pumpWidget(
MaterialApp(
......@@ -49,7 +51,7 @@ void main() {
expect(align.alignment, Alignment.center);
});
testWidgets('Material2: Passing no ElevatedButtonTheme returns defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material2: Passing no ElevatedButtonTheme returns defaults', (WidgetTester tester) async {
const ColorScheme colorScheme = ColorScheme.light();
await tester.pumpWidget(
MaterialApp(
......@@ -189,19 +191,19 @@ void main() {
expect(align.alignment, alignment);
}
testWidgets('Button style overrides defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Button style overrides defaults', (WidgetTester tester) async {
await tester.pumpWidget(buildFrame(buttonStyle: style));
await tester.pumpAndSettle(); // allow the animations to finish
checkButton(tester);
});
testWidgets('Button theme style overrides defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Button theme style overrides defaults', (WidgetTester tester) async {
await tester.pumpWidget(buildFrame(themeStyle: style));
await tester.pumpAndSettle();
checkButton(tester);
});
testWidgets('Overall Theme button theme style overrides defaults', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Overall Theme button theme style overrides defaults', (WidgetTester tester) async {
await tester.pumpWidget(buildFrame(overallStyle: style));
await tester.pumpAndSettle();
checkButton(tester);
......@@ -209,26 +211,26 @@ void main() {
// Same as the previous tests with empty ButtonStyle's instead of null.
testWidgets('Button style overrides defaults, empty theme and overall styles', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Button style overrides defaults, empty theme and overall styles', (WidgetTester tester) async {
await tester.pumpWidget(buildFrame(buttonStyle: style, themeStyle: const ButtonStyle(), overallStyle: const ButtonStyle()));
await tester.pumpAndSettle(); // allow the animations to finish
checkButton(tester);
});
testWidgets('Button theme style overrides defaults, empty button and overall styles', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Button theme style overrides defaults, empty button and overall styles', (WidgetTester tester) async {
await tester.pumpWidget(buildFrame(buttonStyle: const ButtonStyle(), themeStyle: style, overallStyle: const ButtonStyle()));
await tester.pumpAndSettle(); // allow the animations to finish
checkButton(tester);
});
testWidgets('Overall Theme button theme style overrides defaults, null theme and empty overall style', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Overall Theme button theme style overrides defaults, null theme and empty overall style', (WidgetTester tester) async {
await tester.pumpWidget(buildFrame(buttonStyle: const ButtonStyle(), overallStyle: style));
await tester.pumpAndSettle(); // allow the animations to finish
checkButton(tester);
});
});
testWidgets('Material 3: Theme shadowColor', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material 3: Theme shadowColor', (WidgetTester tester) async {
const ColorScheme colorScheme = ColorScheme.light();
const Color shadowColor = Color(0xff000001);
const Color overriddenColor = Color(0xff000002);
......@@ -299,7 +301,7 @@ void main() {
expect(material.shadowColor, shadowColor);
});
testWidgets('Material 2: Theme shadowColor', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Material 2: Theme shadowColor', (WidgetTester tester) async {
const ColorScheme colorScheme = ColorScheme.light();
const Color shadowColor = Color(0xff000001);
const Color overriddenColor = Color(0xff000002);
......
......@@ -6,6 +6,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
class TestIcon extends StatefulWidget {
const TestIcon({super.key});
......@@ -69,7 +71,7 @@ void main() {
expect(theme.clipBehavior, null);
});
testWidgets('Default ExpansionTileThemeData debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Default ExpansionTileThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const TooltipThemeData().debugFillProperties(builder);
......@@ -81,7 +83,7 @@ void main() {
expect(description, <String>[]);
});
testWidgets('ExpansionTileThemeData implements debugFillProperties', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ExpansionTileThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ExpansionTileThemeData(
backgroundColor: Color(0xff000000),
......@@ -119,7 +121,7 @@ void main() {
]);
});
testWidgets('ExpansionTileTheme - collapsed', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ExpansionTileTheme - collapsed', (WidgetTester tester) async {
final Key tileKey = UniqueKey();
final Key titleKey = UniqueKey();
final Key iconKey = UniqueKey();
......@@ -211,7 +213,7 @@ void main() {
expect(shapeDecoration.shape, collapsedShape);
});
testWidgets('ExpansionTileTheme - expanded', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ExpansionTileTheme - expanded', (WidgetTester tester) async {
final Key tileKey = UniqueKey();
final Key titleKey = UniqueKey();
final Key iconKey = UniqueKey();
......
......@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
import '../widgets/semantics_tester.dart';
import 'feedback_tester.dart';
......@@ -37,7 +38,7 @@ void main () {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, null);
});
testWidgets('forTap', (WidgetTester tester) async {
testWidgetsWithLeakTracking('forTap', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester);
await tester.pumpWidget(TestWidget(
......@@ -66,7 +67,7 @@ void main () {
semanticsTester.dispose();
});
testWidgets('forTap Wrapper', (WidgetTester tester) async {
testWidgetsWithLeakTracking('forTap Wrapper', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester);
int callbackCount = 0;
......@@ -101,7 +102,7 @@ void main () {
semanticsTester.dispose();
});
testWidgets('forLongPress', (WidgetTester tester) async {
testWidgetsWithLeakTracking('forLongPress', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester);
await tester.pumpWidget(TestWidget(
......@@ -129,7 +130,7 @@ void main () {
semanticsTester.dispose();
});
testWidgets('forLongPress Wrapper', (WidgetTester tester) async {
testWidgetsWithLeakTracking('forLongPress Wrapper', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester);
int callbackCount = 0;
void callback() {
......@@ -166,7 +167,7 @@ void main () {
});
group('Feedback on iOS', () {
testWidgets('forTap', (WidgetTester tester) async {
testWidgetsWithLeakTracking('forTap', (WidgetTester tester) async {
await tester.pumpWidget(Theme(
data: ThemeData(platform: TargetPlatform.iOS),
child: TestWidget(
......@@ -182,7 +183,7 @@ void main () {
expect(feedback.clickSoundCount, 0);
});
testWidgets('forLongPress', (WidgetTester tester) async {
testWidgetsWithLeakTracking('forLongPress', (WidgetTester tester) async {
await tester.pumpWidget(Theme(
data: ThemeData(platform: TargetPlatform.iOS),
child: TestWidget(
......
......@@ -6,12 +6,14 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import '../foundation/leak_tracking.dart';
final Key blockKey = UniqueKey();
const double expandedAppbarHeight = 250.0;
final Key appbarContainerKey = UniqueKey();
void main() {
testWidgets('FlexibleSpaceBar collapse mode none', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FlexibleSpaceBar collapse mode none', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: debugDefaultTargetPlatformOverride),
......@@ -49,7 +51,7 @@ void main() {
expect(topAfterScroll.dy, equals(0.0));
}, variant: TargetPlatformVariant.all(excluding: <TargetPlatform>{ TargetPlatform.fuchsia }));
testWidgets('FlexibleSpaceBar collapse mode pin', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FlexibleSpaceBar collapse mode pin', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: debugDefaultTargetPlatformOverride),
......@@ -87,7 +89,7 @@ void main() {
expect(topAfterScroll.dy, equals(-100.0));
}, variant: TargetPlatformVariant.all(excluding: <TargetPlatform>{ TargetPlatform.fuchsia }));
testWidgets('FlexibleSpaceBar collapse mode parallax', (WidgetTester tester) async {
testWidgetsWithLeakTracking('FlexibleSpaceBar collapse mode parallax', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
theme: ThemeData(platform: debugDefaultTargetPlatformOverride),
......
......@@ -440,7 +440,7 @@ void main() {
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_centerOffsetX, _dockedOffsetY));
});
testWidgetsWithLeakTracking('endDocked', (WidgetTester tester) async {
testWidgets('endDocked', (WidgetTester tester) async {
await tester.pumpWidget(_singleFabScaffold(FloatingActionButtonLocation.endDocked));
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_rightOffsetX, _dockedOffsetY));
......@@ -502,7 +502,7 @@ void main() {
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_leftOffsetX, _topOffsetY));
});
testWidgets('miniStartFloat, RTL', (WidgetTester tester) async {
testWidgetsWithLeakTracking('miniStartFloat, RTL', (WidgetTester tester) async {
await tester.pumpWidget(_singleFabScaffold(FloatingActionButtonLocation.miniStartFloat, textDirection: TextDirection.rtl));
expect(tester.getCenter(find.byType(FloatingActionButton)), const Offset(_miniRightOffsetX, _miniFloatOffsetY));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment