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