Unverified Commit beeb3ce9 authored by derdilla's avatar derdilla Committed by GitHub

Cover some cupertino tests with leak tracing (#135149)

parent 687f9c86
...@@ -68,7 +68,7 @@ void main() { ...@@ -68,7 +68,7 @@ void main() {
// TODO(LongCatIsLoong): Uncomment once https://github.com/flutter/flutter/issues/44115 // TODO(LongCatIsLoong): Uncomment once https://github.com/flutter/flutter/issues/44115
// is fixed. // is fixed.
/* /*
testWidgets( testWidgetsWithLeakTracking(
'CupertinoButton.filled default color contrast meets guideline', 'CupertinoButton.filled default color contrast meets guideline',
(WidgetTester tester) async { (WidgetTester tester) async {
// The native color combination systemBlue text over white background fails // The native color combination systemBlue text over white background fails
...@@ -185,7 +185,7 @@ void main() { ...@@ -185,7 +185,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(1)); expect(SchedulerBinding.instance.transientCallbackCount, equals(1));
}); });
testWidgets("Disabled button doesn't animate", (WidgetTester tester) async { testWidgetsWithLeakTracking("Disabled button doesn't animate", (WidgetTester tester) async {
await tester.pumpWidget(boilerplate(child: const CupertinoButton( await tester.pumpWidget(boilerplate(child: const CupertinoButton(
onPressed: null, onPressed: null,
child: Text('Tap me'), child: Text('Tap me'),
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.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 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class DependentWidget extends StatelessWidget { class DependentWidget extends StatelessWidget {
const DependentWidget({ const DependentWidget({
...@@ -200,7 +201,7 @@ void main() { ...@@ -200,7 +201,7 @@ void main() {
); );
}); });
testWidgets( testWidgetsWithLeakTracking(
'Dynamic colors that are not actually dynamic should not claim dependencies', 'Dynamic colors that are not actually dynamic should not claim dependencies',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget(const DependentWidget(color: notSoDynamicColor1)); await tester.pumpWidget(const DependentWidget(color: notSoDynamicColor1));
...@@ -210,7 +211,7 @@ void main() { ...@@ -210,7 +211,7 @@ void main() {
}, },
); );
testWidgets( testWidgetsWithLeakTracking(
'Dynamic colors that are only dependent on vibrancy should not claim unnecessary dependencies, ' 'Dynamic colors that are only dependent on vibrancy should not claim unnecessary dependencies, '
'and its resolved color should change when its dependency changes', 'and its resolved color should change when its dependency changes',
(WidgetTester tester) async { (WidgetTester tester) async {
...@@ -254,7 +255,7 @@ void main() { ...@@ -254,7 +255,7 @@ void main() {
}, },
); );
testWidgets( testWidgetsWithLeakTracking(
'Dynamic colors that are only dependent on accessibility contrast should not claim unnecessary dependencies, ' 'Dynamic colors that are only dependent on accessibility contrast should not claim unnecessary dependencies, '
'and its resolved color should change when its dependency changes', 'and its resolved color should change when its dependency changes',
(WidgetTester tester) async { (WidgetTester tester) async {
...@@ -283,7 +284,7 @@ void main() { ...@@ -283,7 +284,7 @@ void main() {
}, },
); );
testWidgets( testWidgetsWithLeakTracking(
'Dynamic colors that are only dependent on elevation level should not claim unnecessary dependencies, ' 'Dynamic colors that are only dependent on elevation level should not claim unnecessary dependencies, '
'and its resolved color should change when its dependency changes', 'and its resolved color should change when its dependency changes',
(WidgetTester tester) async { (WidgetTester tester) async {
...@@ -312,7 +313,7 @@ void main() { ...@@ -312,7 +313,7 @@ void main() {
}, },
); );
testWidgets('Dynamic color with all 3 dependencies works', (WidgetTester tester) async { testWidgetsWithLeakTracking('Dynamic color with all 3 dependencies works', (WidgetTester tester) async {
const Color dynamicRainbowColor1 = CupertinoDynamicColor( const Color dynamicRainbowColor1 = CupertinoDynamicColor(
color: color0, color: color0,
darkColor: color1, darkColor: color1,
...@@ -413,7 +414,7 @@ void main() { ...@@ -413,7 +414,7 @@ void main() {
expect(find.byType(DependentWidget), paints..rect(color: color7)); expect(find.byType(DependentWidget), paints..rect(color: color7));
}); });
testWidgets('CupertinoDynamicColor used in a CupertinoTheme', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoDynamicColor used in a CupertinoTheme', (WidgetTester tester) async {
late CupertinoDynamicColor color; late CupertinoDynamicColor color;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
...@@ -498,7 +499,7 @@ void main() { ...@@ -498,7 +499,7 @@ void main() {
Color? color; Color? color;
setUp(() { color = null; }); setUp(() { color = null; });
testWidgets('dynamic color works in cupertino override theme', (WidgetTester tester) async { testWidgetsWithLeakTracking('dynamic color works in cupertino override theme', (WidgetTester tester) async {
CupertinoDynamicColor typedColor() => color! as CupertinoDynamicColor; CupertinoDynamicColor typedColor() => color! as CupertinoDynamicColor;
await tester.pumpWidget( await tester.pumpWidget(
...@@ -555,7 +556,7 @@ void main() { ...@@ -555,7 +556,7 @@ void main() {
expect(typedColor().value, dynamicColor.darkHighContrastElevatedColor.value); expect(typedColor().value, dynamicColor.darkHighContrastElevatedColor.value);
}); });
testWidgets('dynamic color does not work in a material theme', (WidgetTester tester) async { testWidgetsWithLeakTracking('dynamic color does not work in a material theme', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
// This will create a MaterialBasedCupertinoThemeData with primaryColor set to `dynamicColor`. // This will create a MaterialBasedCupertinoThemeData with primaryColor set to `dynamicColor`.
......
...@@ -7,6 +7,7 @@ import 'package:flutter/foundation.dart'; ...@@ -7,6 +7,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.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 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
// Constants taken from _ContextMenuActionState. // Constants taken from _ContextMenuActionState.
...@@ -71,7 +72,7 @@ void main() { ...@@ -71,7 +72,7 @@ void main() {
return icon; return icon;
} }
testWidgets('responds to taps', (WidgetTester tester) async { testWidgetsWithLeakTracking('responds to taps', (WidgetTester tester) async {
bool wasPressed = false; bool wasPressed = false;
await tester.pumpWidget(getApp(onPressed: () { await tester.pumpWidget(getApp(onPressed: () {
wasPressed = true; wasPressed = true;
...@@ -82,7 +83,7 @@ void main() { ...@@ -82,7 +83,7 @@ void main() {
expect(wasPressed, true); expect(wasPressed, true);
}); });
testWidgets('turns grey when pressed and held', (WidgetTester tester) async { testWidgetsWithLeakTracking('turns grey when pressed and held', (WidgetTester tester) async {
await tester.pumpWidget(getApp()); await tester.pumpWidget(getApp());
expect(find.byType(CupertinoContextMenuAction), expect(find.byType(CupertinoContextMenuAction),
paints..rect(color: kBackgroundColor.color)); paints..rect(color: kBackgroundColor.color));
...@@ -117,27 +118,27 @@ void main() { ...@@ -117,27 +118,27 @@ void main() {
paints..rect(color: kBackgroundColor.darkColor)); paints..rect(color: kBackgroundColor.darkColor));
}); });
testWidgets('icon and textStyle colors are correct out of the box', testWidgetsWithLeakTracking('icon and textStyle colors are correct out of the box',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget(getApp()); await tester.pumpWidget(getApp());
expect(getTextStyle(tester).color, CupertinoColors.label); expect(getTextStyle(tester).color, CupertinoColors.label);
expect(getIcon(tester).color, CupertinoColors.label); expect(getIcon(tester).color, CupertinoColors.label);
}); });
testWidgets('icon and textStyle colors are correct for destructive actions', testWidgetsWithLeakTracking('icon and textStyle colors are correct for destructive actions',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget(getApp(isDestructiveAction: true)); await tester.pumpWidget(getApp(isDestructiveAction: true));
expect(getTextStyle(tester).color, kDestructiveActionColor); expect(getTextStyle(tester).color, kDestructiveActionColor);
expect(getIcon(tester).color, kDestructiveActionColor); expect(getIcon(tester).color, kDestructiveActionColor);
}); });
testWidgets('textStyle is correct for defaultAction', testWidgetsWithLeakTracking('textStyle is correct for defaultAction',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget(getApp(isDefaultAction: true)); await tester.pumpWidget(getApp(isDefaultAction: true));
expect(getTextStyle(tester).fontWeight, kDefaultActionWeight); expect(getTextStyle(tester).fontWeight, kDefaultActionWeight);
}); });
testWidgets( testWidgetsWithLeakTracking(
'Hovering over Cupertino context menu action updates cursor to clickable on Web', 'Hovering over Cupertino context menu action updates cursor to clickable on Web',
(WidgetTester tester) async { (WidgetTester tester) async {
/// Cupertino context menu action without "onPressed" callback. /// Cupertino context menu action without "onPressed" callback.
......
...@@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart'; ...@@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.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 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
...@@ -120,7 +121,7 @@ void main() { ...@@ -120,7 +121,7 @@ void main() {
} }
group('CupertinoContextMenu before and during opening', () { group('CupertinoContextMenu before and during opening', () {
testWidgets('An unopened CupertinoContextMenu renders child in the same place as without', (WidgetTester tester) async { testWidgetsWithLeakTracking('An unopened CupertinoContextMenu renders child in the same place as without', (WidgetTester tester) async {
// Measure the child in the scene with no CupertinoContextMenu. // Measure the child in the scene with no CupertinoContextMenu.
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -140,7 +141,7 @@ void main() { ...@@ -140,7 +141,7 @@ void main() {
expect(tester.getRect(find.byWidget(child)), childRect); expect(tester.getRect(find.byWidget(child)), childRect);
}); });
testWidgets('Can open CupertinoContextMenu by tap and hold', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can open CupertinoContextMenu by tap and hold', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu(child: child)); await tester.pumpWidget(getContextMenu(child: child));
expect(find.byWidget(child), findsOneWidget); expect(find.byWidget(child), findsOneWidget);
...@@ -176,7 +177,7 @@ void main() { ...@@ -176,7 +177,7 @@ void main() {
expect(findStatic(), findsOneWidget); expect(findStatic(), findsOneWidget);
}); });
testWidgets('CupertinoContextMenu is in the correct position when within a nested navigator', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoContextMenu is in the correct position when within a nested navigator', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
...@@ -241,7 +242,7 @@ void main() { ...@@ -241,7 +242,7 @@ void main() {
expect(findStatic(), findsOneWidget); expect(findStatic(), findsOneWidget);
}); });
testWidgets('CupertinoContextMenu with a basic builder opens and closes the same as when providing a child', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoContextMenu with a basic builder opens and closes the same as when providing a child', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getBuilderContextMenu(builder: (BuildContext context, Animation<double> animation) { await tester.pumpWidget(getBuilderContextMenu(builder: (BuildContext context, Animation<double> animation) {
return child; return child;
...@@ -279,7 +280,7 @@ void main() { ...@@ -279,7 +280,7 @@ void main() {
expect(findStatic(), findsOneWidget); expect(findStatic(), findsOneWidget);
}); });
testWidgets('CupertinoContextMenu with a builder can change the animation', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoContextMenu with a builder can change the animation', (WidgetTester tester) async {
await tester.pumpWidget(getBuilderContextMenu(builder: (BuildContext context, Animation<double> animation) { await tester.pumpWidget(getBuilderContextMenu(builder: (BuildContext context, Animation<double> animation) {
return Container( return Container(
width: 300.0, width: 300.0,
...@@ -319,7 +320,7 @@ void main() { ...@@ -319,7 +320,7 @@ void main() {
expect(decoyLaterDecoration?.borderRadius, isNot(equals(BorderRadius.circular(0)))); expect(decoyLaterDecoration?.borderRadius, isNot(equals(BorderRadius.circular(0))));
}); });
testWidgets('Hovering over Cupertino context menu updates cursor to clickable on Web', (WidgetTester tester) async { testWidgetsWithLeakTracking('Hovering over Cupertino context menu updates cursor to clickable on Web', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
...@@ -350,7 +351,7 @@ void main() { ...@@ -350,7 +351,7 @@ void main() {
); );
}); });
testWidgets('CupertinoContextMenu is in the correct position when within a Transform.scale', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoContextMenu is in the correct position when within a Transform.scale', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
...@@ -408,7 +409,7 @@ void main() { ...@@ -408,7 +409,7 @@ void main() {
}); });
group('CupertinoContextMenu when open', () { group('CupertinoContextMenu when open', () {
testWidgets('Last action does not have border', (WidgetTester tester) async { testWidgetsWithLeakTracking('Last action does not have border', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
...@@ -467,7 +468,7 @@ void main() { ...@@ -467,7 +468,7 @@ void main() {
expect(findStaticChildDecoration(tester), findsNWidgets(3)); expect(findStaticChildDecoration(tester), findsNWidgets(3));
}); });
testWidgets('Can close CupertinoContextMenu by background tap', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can close CupertinoContextMenu by background tap', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu(child: child)); await tester.pumpWidget(getContextMenu(child: child));
...@@ -485,7 +486,7 @@ void main() { ...@@ -485,7 +486,7 @@ void main() {
expect(findStatic(), findsNothing); expect(findStatic(), findsNothing);
}); });
testWidgets('Can close CupertinoContextMenu by dragging down', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can close CupertinoContextMenu by dragging down', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu(child: child)); await tester.pumpWidget(getContextMenu(child: child));
...@@ -527,7 +528,7 @@ void main() { ...@@ -527,7 +528,7 @@ void main() {
expect(findStatic(), findsNothing); expect(findStatic(), findsNothing);
}); });
testWidgets('Can close CupertinoContextMenu by flinging down', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can close CupertinoContextMenu by flinging down', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu(child: child)); await tester.pumpWidget(getContextMenu(child: child));
...@@ -552,7 +553,7 @@ void main() { ...@@ -552,7 +553,7 @@ void main() {
expect(findStatic(), findsNothing); expect(findStatic(), findsNothing);
}); });
testWidgets("Backdrop is added using ModalRoute's filter parameter", (WidgetTester tester) async { testWidgetsWithLeakTracking("Backdrop is added using ModalRoute's filter parameter", (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu(child: child)); await tester.pumpWidget(getContextMenu(child: child));
expect(find.byType(BackdropFilter), findsNothing); expect(find.byType(BackdropFilter), findsNothing);
...@@ -567,7 +568,7 @@ void main() { ...@@ -567,7 +568,7 @@ void main() {
expect(find.byType(BackdropFilter), findsOneWidget); expect(find.byType(BackdropFilter), findsOneWidget);
}); });
testWidgets('Preview widget should have the correct border radius', (WidgetTester tester) async { testWidgetsWithLeakTracking('Preview widget should have the correct border radius', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu(child: child)); await tester.pumpWidget(getContextMenu(child: child));
...@@ -585,7 +586,7 @@ void main() { ...@@ -585,7 +586,7 @@ void main() {
expect(previewWidget.borderRadius, equals(BorderRadius.circular(12.0))); expect(previewWidget.borderRadius, equals(BorderRadius.circular(12.0)));
}); });
testWidgets('CupertinoContextMenu width is correct', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoContextMenu width is correct', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu(child: child)); await tester.pumpWidget(getContextMenu(child: child));
expect(find.byWidget(child), findsOneWidget); expect(find.byWidget(child), findsOneWidget);
...@@ -628,7 +629,7 @@ void main() { ...@@ -628,7 +629,7 @@ void main() {
} }
}); });
testWidgets("ContextMenu route animation doesn't throw exception on dismiss", (WidgetTester tester) async { testWidgetsWithLeakTracking("ContextMenu route animation doesn't throw exception on dismiss", (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/124597. // This is a regression test for https://github.com/flutter/flutter/issues/124597.
final List<int> items = List<int>.generate(2, (int index) => index).toList(); final List<int> items = List<int>.generate(2, (int index) => index).toList();
...@@ -675,7 +676,7 @@ void main() { ...@@ -675,7 +676,7 @@ void main() {
}); });
group("Open layout differs depending on child's position on screen", () { group("Open layout differs depending on child's position on screen", () {
testWidgets('Portrait', (WidgetTester tester) async { testWidgetsWithLeakTracking('Portrait', (WidgetTester tester) async {
const Size portraitScreenSize = Size(600.0, 800.0); const Size portraitScreenSize = Size(600.0, 800.0);
await binding.setSurfaceSize(portraitScreenSize); await binding.setSurfaceSize(portraitScreenSize);
...@@ -747,7 +748,7 @@ void main() { ...@@ -747,7 +748,7 @@ void main() {
await binding.setSurfaceSize(const Size(800.0, 600.0)); await binding.setSurfaceSize(const Size(800.0, 600.0));
}); });
testWidgets('Landscape', (WidgetTester tester) async { testWidgetsWithLeakTracking('Landscape', (WidgetTester tester) async {
// Pump a CupertinoContextMenu in the center of the screen and open it. // Pump a CupertinoContextMenu in the center of the screen and open it.
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu( await tester.pumpWidget(getContextMenu(
...@@ -812,7 +813,7 @@ void main() { ...@@ -812,7 +813,7 @@ void main() {
}); });
}); });
testWidgets('Conflicting gesture detectors', (WidgetTester tester) async { testWidgetsWithLeakTracking('Conflicting gesture detectors', (WidgetTester tester) async {
int? onPointerDownTime; int? onPointerDownTime;
int? onPointerUpTime; int? onPointerUpTime;
bool insideTapTriggered = false; bool insideTapTriggered = false;
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('debugCheckHasCupertinoLocalizations throws', (WidgetTester tester) async { testWidgetsWithLeakTracking('debugCheckHasCupertinoLocalizations throws', (WidgetTester tester) async {
final GlobalKey noLocalizationsAvailable = GlobalKey(); final GlobalKey noLocalizationsAvailable = GlobalKey();
final GlobalKey localizationsAvailable = GlobalKey(); final GlobalKey localizationsAvailable = GlobalKey();
......
...@@ -5,11 +5,12 @@ ...@@ -5,11 +5,12 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.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(
CupertinoApp( CupertinoApp(
...@@ -30,7 +31,7 @@ void main() { ...@@ -30,7 +31,7 @@ void main() {
expect(pressed, true); expect(pressed, true);
}); });
testWidgets('keeps contrast with background on hover', testWidgetsWithLeakTracking('keeps contrast with background on hover',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
...@@ -70,7 +71,7 @@ void main() { ...@@ -70,7 +71,7 @@ void main() {
); );
}); });
testWidgets('pressedOpacity defaults to 0.1', (WidgetTester tester) async { testWidgetsWithLeakTracking('pressedOpacity defaults to 0.1', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -114,7 +115,7 @@ void main() { ...@@ -114,7 +115,7 @@ void main() {
expect(opacity.opacity.value, 1.0); expect(opacity.opacity.value, 1.0);
}); });
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 CupertinoApp( const CupertinoApp(
home: Center( home: Center(
......
...@@ -7,11 +7,12 @@ import 'dart:ui'; ...@@ -7,11 +7,12 @@ import 'dart:ui';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
testWidgets('has correct backdrop filters', (WidgetTester tester) async { testWidgetsWithLeakTracking('has correct backdrop filters', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -53,7 +54,7 @@ void main() { ...@@ -53,7 +54,7 @@ void main() {
); );
}); });
testWidgets('has shadow', (WidgetTester tester) async { testWidgetsWithLeakTracking('has shadow', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -83,7 +84,7 @@ void main() { ...@@ -83,7 +84,7 @@ void main() {
); );
}); });
testWidgets('is translucent', (WidgetTester tester) async { testWidgetsWithLeakTracking('is translucent', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -116,7 +117,7 @@ void main() { ...@@ -116,7 +117,7 @@ void main() {
); );
}); });
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,9 +6,10 @@ import 'package:flutter/cupertino.dart'; ...@@ -6,9 +6,10 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; 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 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('Shows prefix', (WidgetTester tester) async { testWidgetsWithLeakTracking('Shows prefix', (WidgetTester tester) async {
const Widget prefix = Text('Enter Value'); const Widget prefix = Text('Enter Value');
await tester.pumpWidget( await tester.pumpWidget(
...@@ -25,7 +26,7 @@ void main() { ...@@ -25,7 +26,7 @@ void main() {
expect(prefix, tester.widget(find.byType(Text))); expect(prefix, tester.widget(find.byType(Text)));
}); });
testWidgets('Shows child', (WidgetTester tester) async { testWidgetsWithLeakTracking('Shows child', (WidgetTester tester) async {
const Widget child = CupertinoTextField(); const Widget child = CupertinoTextField();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -41,7 +42,7 @@ void main() { ...@@ -41,7 +42,7 @@ void main() {
expect(child, tester.widget(find.byType(CupertinoTextField))); expect(child, tester.widget(find.byType(CupertinoTextField)));
}); });
testWidgets('RTL puts prefix after child', (WidgetTester tester) async { testWidgetsWithLeakTracking('RTL puts prefix after child', (WidgetTester tester) async {
const Widget prefix = Text('Enter Value'); const Widget prefix = Text('Enter Value');
const Widget child = CupertinoTextField(); const Widget child = CupertinoTextField();
...@@ -62,7 +63,7 @@ void main() { ...@@ -62,7 +63,7 @@ void main() {
expect(tester.getTopLeft(find.byType(Text)).dx > tester.getTopLeft(find.byType(CupertinoTextField)).dx, true); expect(tester.getTopLeft(find.byType(Text)).dx > tester.getTopLeft(find.byType(CupertinoTextField)).dx, true);
}); });
testWidgets('LTR puts child after prefix', (WidgetTester tester) async { testWidgetsWithLeakTracking('LTR puts child after prefix', (WidgetTester tester) async {
const Widget prefix = Text('Enter Value'); const Widget prefix = Text('Enter Value');
const Widget child = CupertinoTextField(); const Widget child = CupertinoTextField();
...@@ -83,7 +84,7 @@ void main() { ...@@ -83,7 +84,7 @@ void main() {
expect(tester.getTopLeft(find.byType(Text)).dx > tester.getTopLeft(find.byType(CupertinoTextField)).dx, false); expect(tester.getTopLeft(find.byType(Text)).dx > tester.getTopLeft(find.byType(CupertinoTextField)).dx, false);
}); });
testWidgets('Shows error widget', (WidgetTester tester) async { testWidgetsWithLeakTracking('Shows error widget', (WidgetTester tester) async {
const Widget error = Text('Error'); const Widget error = Text('Error');
await tester.pumpWidget( await tester.pumpWidget(
...@@ -100,7 +101,7 @@ void main() { ...@@ -100,7 +101,7 @@ void main() {
expect(error, tester.widget(find.byType(Text))); expect(error, tester.widget(find.byType(Text)));
}); });
testWidgets('Shows helper widget', (WidgetTester tester) async { testWidgetsWithLeakTracking('Shows helper widget', (WidgetTester tester) async {
const Widget helper = Text('Helper'); const Widget helper = Text('Helper');
await tester.pumpWidget( await tester.pumpWidget(
...@@ -117,7 +118,7 @@ void main() { ...@@ -117,7 +118,7 @@ void main() {
expect(helper, tester.widget(find.byType(Text))); expect(helper, tester.widget(find.byType(Text)));
}); });
testWidgets('Shows helper text above error text', (WidgetTester tester) async { testWidgetsWithLeakTracking('Shows helper text above error text', (WidgetTester tester) async {
const Widget helper = Text('Helper'); const Widget helper = Text('Helper');
const Widget error = CupertinoActivityIndicator(); const Widget error = CupertinoActivityIndicator();
...@@ -139,7 +140,7 @@ void main() { ...@@ -139,7 +140,7 @@ void main() {
); );
}); });
testWidgets('Shows helper in label color and error text in red color', (WidgetTester tester) async { testWidgetsWithLeakTracking('Shows helper in label color and error text in red color', (WidgetTester tester) async {
const Widget helper = Text('Helper'); const Widget helper = Text('Helper');
const Widget error = Text('Error'); const Widget error = Text('Error');
...@@ -166,7 +167,7 @@ void main() { ...@@ -166,7 +167,7 @@ void main() {
expect(errorTextStyle.style.color, CupertinoColors.destructiveRed); expect(errorTextStyle.style.color, CupertinoColors.destructiveRed);
}); });
testWidgets('CupertinoFormRow adapts to MaterialApp dark mode', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoFormRow adapts to MaterialApp dark mode', (WidgetTester tester) async {
const Widget prefix = Text('Prefix'); const Widget prefix = Text('Prefix');
const Widget helper = Text('Helper'); const Widget helper = Text('Helper');
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('IconTheme.of works', (WidgetTester tester) async { testWidgetsWithLeakTracking('IconTheme.of works', (WidgetTester tester) async {
const IconThemeData data = IconThemeData( const IconThemeData data = IconThemeData(
size: 16.0, size: 16.0,
fill: 0.0, fill: 0.0,
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('shows header', (WidgetTester tester) async { testWidgetsWithLeakTracking('shows header', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -23,7 +24,7 @@ void main() { ...@@ -23,7 +24,7 @@ void main() {
expect(find.text('Header'), findsOneWidget); expect(find.text('Header'), findsOneWidget);
}); });
testWidgets('shows footer', (WidgetTester tester) async { testWidgetsWithLeakTracking('shows footer', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -40,7 +41,7 @@ void main() { ...@@ -40,7 +41,7 @@ void main() {
expect(find.text('Footer'), findsOneWidget); expect(find.text('Footer'), findsOneWidget);
}); });
testWidgets('shows long dividers in edge-to-edge section part 1', (WidgetTester tester) async { testWidgetsWithLeakTracking('shows long dividers in edge-to-edge section part 1', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -59,7 +60,7 @@ void main() { ...@@ -59,7 +60,7 @@ void main() {
expect(childrenColumn.children.length, 3); expect(childrenColumn.children.length, 3);
}); });
testWidgets('shows long dividers in edge-to-edge section part 2', (WidgetTester tester) async { testWidgetsWithLeakTracking('shows long dividers in edge-to-edge section part 2', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -80,7 +81,7 @@ void main() { ...@@ -80,7 +81,7 @@ void main() {
expect(childrenColumn.children.length, 5); expect(childrenColumn.children.length, 5);
}); });
testWidgets('does not show long dividers in insetGrouped section part 1', (WidgetTester tester) async { testWidgetsWithLeakTracking('does not show long dividers in insetGrouped section part 1', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -100,7 +101,7 @@ void main() { ...@@ -100,7 +101,7 @@ void main() {
expect(childrenColumn.children.length, 1); expect(childrenColumn.children.length, 1);
}); });
testWidgets('does not show long dividers in insetGrouped section part 2', (WidgetTester tester) async { testWidgetsWithLeakTracking('does not show long dividers in insetGrouped section part 2', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -121,7 +122,7 @@ void main() { ...@@ -121,7 +122,7 @@ void main() {
expect(childrenColumn.children.length, 3); expect(childrenColumn.children.length, 3);
}); });
testWidgets('sets background color for section', (WidgetTester tester) async { testWidgetsWithLeakTracking('sets background color for section', (WidgetTester tester) async {
const Color backgroundColor = CupertinoColors.systemBlue; const Color backgroundColor = CupertinoColors.systemBlue;
await tester.pumpWidget( await tester.pumpWidget(
...@@ -144,7 +145,7 @@ void main() { ...@@ -144,7 +145,7 @@ void main() {
expect(boxDecoration.color, backgroundColor); expect(boxDecoration.color, backgroundColor);
}); });
testWidgets('setting clipBehavior clips children section', (WidgetTester tester) async { testWidgetsWithLeakTracking('setting clipBehavior clips children section', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -161,7 +162,7 @@ void main() { ...@@ -161,7 +162,7 @@ void main() {
expect(find.byType(ClipRRect), findsOneWidget); expect(find.byType(ClipRRect), findsOneWidget);
}); });
testWidgets('not setting clipBehavior does not clip children section', (WidgetTester tester) async { testWidgetsWithLeakTracking('not setting clipBehavior does not clip children section', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -177,7 +178,7 @@ void main() { ...@@ -177,7 +178,7 @@ void main() {
expect(find.byType(ClipRRect), findsNothing); expect(find.byType(ClipRRect), findsNothing);
}); });
testWidgets('CupertinoListSection respects separatorColor', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoListSection respects separatorColor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -200,7 +201,7 @@ void main() { ...@@ -200,7 +201,7 @@ void main() {
} }
}); });
testWidgets('CupertinoListSection.separatorColor defaults CupertinoColors.separator', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoListSection.separatorColor defaults CupertinoColors.separator', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('shows title', (WidgetTester tester) async { testWidgetsWithLeakTracking('shows title', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
await tester.pumpWidget( await tester.pumpWidget(
...@@ -23,7 +24,7 @@ void main() { ...@@ -23,7 +24,7 @@ void main() {
expect(find.text('CupertinoListTile'), findsOneWidget); expect(find.text('CupertinoListTile'), findsOneWidget);
}); });
testWidgets('shows subtitle', (WidgetTester tester) async { testWidgetsWithLeakTracking('shows subtitle', (WidgetTester tester) async {
const Widget subtitle = Text('CupertinoListTile subtitle'); const Widget subtitle = Text('CupertinoListTile subtitle');
await tester.pumpWidget( await tester.pumpWidget(
...@@ -41,7 +42,7 @@ void main() { ...@@ -41,7 +42,7 @@ void main() {
expect(find.text('CupertinoListTile subtitle'), findsOneWidget); expect(find.text('CupertinoListTile subtitle'), findsOneWidget);
}); });
testWidgets('shows additionalInfo', (WidgetTester tester) async { testWidgetsWithLeakTracking('shows additionalInfo', (WidgetTester tester) async {
const Widget additionalInfo = Text('Not Connected'); const Widget additionalInfo = Text('Not Connected');
await tester.pumpWidget( await tester.pumpWidget(
...@@ -59,7 +60,7 @@ void main() { ...@@ -59,7 +60,7 @@ void main() {
expect(find.text('Not Connected'), findsOneWidget); expect(find.text('Not Connected'), findsOneWidget);
}); });
testWidgets('shows trailing', (WidgetTester tester) async { testWidgetsWithLeakTracking('shows trailing', (WidgetTester tester) async {
const Widget trailing = CupertinoListTileChevron(); const Widget trailing = CupertinoListTileChevron();
await tester.pumpWidget( await tester.pumpWidget(
...@@ -76,7 +77,7 @@ void main() { ...@@ -76,7 +77,7 @@ void main() {
expect(tester.widget<CupertinoListTileChevron>(find.byType(CupertinoListTileChevron)), trailing); expect(tester.widget<CupertinoListTileChevron>(find.byType(CupertinoListTileChevron)), trailing);
}); });
testWidgets('shows leading', (WidgetTester tester) async { testWidgetsWithLeakTracking('shows leading', (WidgetTester tester) async {
const Widget leading = Icon(CupertinoIcons.add); const Widget leading = Icon(CupertinoIcons.add);
await tester.pumpWidget( await tester.pumpWidget(
...@@ -93,7 +94,7 @@ void main() { ...@@ -93,7 +94,7 @@ void main() {
expect(tester.widget<Icon>(find.byType(Icon)), leading); expect(tester.widget<Icon>(find.byType(Icon)), leading);
}); });
testWidgets('sets backgroundColor', (WidgetTester tester) async { testWidgetsWithLeakTracking('sets backgroundColor', (WidgetTester tester) async {
const Color backgroundColor = CupertinoColors.systemRed; const Color backgroundColor = CupertinoColors.systemRed;
await tester.pumpWidget( await tester.pumpWidget(
...@@ -118,7 +119,7 @@ void main() { ...@@ -118,7 +119,7 @@ void main() {
expect(container.color, backgroundColor); expect(container.color, backgroundColor);
}); });
testWidgets('does not change backgroundColor when tapped if onTap is not provided', (WidgetTester tester) async { testWidgetsWithLeakTracking('does not change backgroundColor when tapped if onTap is not provided', (WidgetTester tester) async {
const Color backgroundColor = CupertinoColors.systemBlue; const Color backgroundColor = CupertinoColors.systemBlue;
const Color backgroundColorActivated = CupertinoColors.systemRed; const Color backgroundColorActivated = CupertinoColors.systemRed;
...@@ -148,7 +149,7 @@ void main() { ...@@ -148,7 +149,7 @@ void main() {
expect(container.color, backgroundColor); expect(container.color, backgroundColor);
}); });
testWidgets('changes backgroundColor when tapped if onTap is provided', (WidgetTester tester) async { testWidgetsWithLeakTracking('changes backgroundColor when tapped if onTap is provided', (WidgetTester tester) async {
const Color backgroundColor = CupertinoColors.systemBlue; const Color backgroundColor = CupertinoColors.systemBlue;
const Color backgroundColorActivated = CupertinoColors.systemRed; const Color backgroundColorActivated = CupertinoColors.systemRed;
...@@ -187,7 +188,7 @@ void main() { ...@@ -187,7 +188,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgets('does not contain GestureDetector if onTap is not provided', (WidgetTester tester) async { testWidgetsWithLeakTracking('does not contain GestureDetector if onTap is not provided', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -208,7 +209,7 @@ void main() { ...@@ -208,7 +209,7 @@ void main() {
expect(find.byType(GestureDetector), findsNothing); expect(find.byType(GestureDetector), findsNothing);
}); });
testWidgets('contains GestureDetector if onTap is provided', (WidgetTester tester) async { testWidgetsWithLeakTracking('contains GestureDetector if onTap is provided', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -230,7 +231,7 @@ void main() { ...@@ -230,7 +231,7 @@ void main() {
expect(find.byType(GestureDetector), findsOneWidget); expect(find.byType(GestureDetector), findsOneWidget);
}); });
testWidgets('resets the background color when navigated back', (WidgetTester tester) async { testWidgetsWithLeakTracking('resets the background color when navigated back', (WidgetTester tester) async {
const Color backgroundColor = CupertinoColors.systemBlue; const Color backgroundColor = CupertinoColors.systemBlue;
const Color backgroundColorActivated = CupertinoColors.systemRed; const Color backgroundColorActivated = CupertinoColors.systemRed;
...@@ -279,7 +280,7 @@ void main() { ...@@ -279,7 +280,7 @@ void main() {
}); });
group('alignment of widgets for left-to-right', () { group('alignment of widgets for left-to-right', () {
testWidgets('leading is on the left of title', (WidgetTester tester) async { testWidgetsWithLeakTracking('leading is on the left of title', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
const Widget leading = Icon(CupertinoIcons.add); const Widget leading = Icon(CupertinoIcons.add);
...@@ -303,7 +304,7 @@ void main() { ...@@ -303,7 +304,7 @@ void main() {
expect(foundTitle.dx > foundLeading.dx, true); expect(foundTitle.dx > foundLeading.dx, true);
}); });
testWidgets('subtitle is placed below title and aligned on left', (WidgetTester tester) async { testWidgetsWithLeakTracking('subtitle is placed below title and aligned on left', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile title'); const Widget title = Text('CupertinoListTile title');
const Widget subtitle = Text('CupertinoListTile subtitle'); const Widget subtitle = Text('CupertinoListTile subtitle');
...@@ -328,7 +329,7 @@ void main() { ...@@ -328,7 +329,7 @@ void main() {
expect(foundTitle.dy < foundSubtitle.dy, isTrue); expect(foundTitle.dy < foundSubtitle.dy, isTrue);
}); });
testWidgets('additionalInfo is on the right of title', (WidgetTester tester) async { testWidgetsWithLeakTracking('additionalInfo is on the right of title', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
const Widget additionalInfo = Text('Not Connected'); const Widget additionalInfo = Text('Not Connected');
...@@ -352,7 +353,7 @@ void main() { ...@@ -352,7 +353,7 @@ void main() {
expect(foundTitle.dx < foundInfo.dx, isTrue); expect(foundTitle.dx < foundInfo.dx, isTrue);
}); });
testWidgets('trailing is on the right of additionalInfo', (WidgetTester tester) async { testWidgetsWithLeakTracking('trailing is on the right of additionalInfo', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
const Widget additionalInfo = Text('Not Connected'); const Widget additionalInfo = Text('Not Connected');
const Widget trailing = CupertinoListTileChevron(); const Widget trailing = CupertinoListTileChevron();
...@@ -380,7 +381,7 @@ void main() { ...@@ -380,7 +381,7 @@ void main() {
}); });
group('alignment of widgets for right-to-left', () { group('alignment of widgets for right-to-left', () {
testWidgets('leading is on the right of title', (WidgetTester tester) async { testWidgetsWithLeakTracking('leading is on the right of title', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
const Widget leading = Icon(CupertinoIcons.add); const Widget leading = Icon(CupertinoIcons.add);
...@@ -404,7 +405,7 @@ void main() { ...@@ -404,7 +405,7 @@ void main() {
expect(foundTitle.dx < foundLeading.dx, true); expect(foundTitle.dx < foundLeading.dx, true);
}); });
testWidgets('subtitle is placed below title and aligned on right', (WidgetTester tester) async { testWidgetsWithLeakTracking('subtitle is placed below title and aligned on right', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile title'); const Widget title = Text('CupertinoListTile title');
const Widget subtitle = Text('CupertinoListTile subtitle'); const Widget subtitle = Text('CupertinoListTile subtitle');
...@@ -429,7 +430,7 @@ void main() { ...@@ -429,7 +430,7 @@ void main() {
expect(foundTitle.dy < foundSubtitle.dy, isTrue); expect(foundTitle.dy < foundSubtitle.dy, isTrue);
}); });
testWidgets('additionalInfo is on the left of title', (WidgetTester tester) async { testWidgetsWithLeakTracking('additionalInfo is on the left of title', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
const Widget additionalInfo = Text('Not Connected'); const Widget additionalInfo = Text('Not Connected');
...@@ -453,7 +454,7 @@ void main() { ...@@ -453,7 +454,7 @@ void main() {
expect(foundTitle.dx > foundInfo.dx, isTrue); expect(foundTitle.dx > foundInfo.dx, isTrue);
}); });
testWidgets('trailing is on the left of additionalInfo', (WidgetTester tester) async { testWidgetsWithLeakTracking('trailing is on the left of additionalInfo', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
const Widget additionalInfo = Text('Not Connected'); const Widget additionalInfo = Text('Not Connected');
const Widget trailing = CupertinoListTileChevron(); const Widget trailing = CupertinoListTileChevron();
...@@ -480,7 +481,7 @@ void main() { ...@@ -480,7 +481,7 @@ void main() {
}); });
}); });
testWidgets('onTap with delay does not throw an exception', (WidgetTester tester) async { testWidgetsWithLeakTracking('onTap with delay does not throw an exception', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
bool showTile = true; bool showTile = true;
...@@ -520,7 +521,7 @@ void main() { ...@@ -520,7 +521,7 @@ void main() {
expect(tester.takeException(), null); expect(tester.takeException(), null);
}); });
testWidgets('title does not overflow', (WidgetTester tester) async { testWidgetsWithLeakTracking('title does not overflow', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
...@@ -534,7 +535,7 @@ void main() { ...@@ -534,7 +535,7 @@ void main() {
expect(tester.takeException(), null); expect(tester.takeException(), null);
}); });
testWidgets('subtitle does not overflow', (WidgetTester tester) async { testWidgetsWithLeakTracking('subtitle does not overflow', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('English translations exist for all CupertinoLocalization properties', (WidgetTester tester) async { testWidgetsWithLeakTracking('English translations exist for all CupertinoLocalization properties', (WidgetTester tester) async {
const CupertinoLocalizations localizations = DefaultCupertinoLocalizations(); const CupertinoLocalizations localizations = DefaultCupertinoLocalizations();
expect(localizations.datePickerYear(2018), isNotNull); expect(localizations.datePickerYear(2018), isNotNull);
...@@ -36,7 +37,7 @@ void main() { ...@@ -36,7 +37,7 @@ void main() {
expect(localizations.noSpellCheckReplacementsLabel, isNotNull); expect(localizations.noSpellCheckReplacementsLabel, isNotNull);
}); });
testWidgets('CupertinoLocalizations.of throws', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoLocalizations.of throws', (WidgetTester tester) async {
final GlobalKey noLocalizationsAvailable = GlobalKey(); final GlobalKey noLocalizationsAvailable = GlobalKey();
final GlobalKey localizationsAvailable = GlobalKey(); final GlobalKey localizationsAvailable = GlobalKey();
......
...@@ -7,6 +7,7 @@ import 'dart:typed_data'; ...@@ -7,6 +7,7 @@ import 'dart:typed_data';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.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 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../../image_data.dart'; import '../../image_data.dart';
...@@ -17,9 +18,14 @@ void main() { ...@@ -17,9 +18,14 @@ void main() {
selectedTabs = <int>[]; selectedTabs = <int>[];
}); });
testWidgets('Last tab gets focus', (WidgetTester tester) async { testWidgetsWithLeakTracking('Last tab gets focus', (WidgetTester tester) async {
// 2 nodes for 2 tabs // 2 nodes for 2 tabs
final List<FocusNode> focusNodes = <FocusNode>[FocusNode(), FocusNode()]; final List<FocusNode> focusNodes = <FocusNode>[];
for (int i = 0; i < 2; i++) {
final FocusNode focusNode = FocusNode();
focusNodes.add(focusNode);
addTearDown(focusNode.dispose);
}
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -52,10 +58,13 @@ void main() { ...@@ -52,10 +58,13 @@ void main() {
expect(focusNodes[1].hasFocus, isFalse); expect(focusNodes[1].hasFocus, isFalse);
}); });
testWidgets('Do not affect focus order in the route', (WidgetTester tester) async { testWidgetsWithLeakTracking('Do not affect focus order in the route', (WidgetTester tester) async {
final List<FocusNode> focusNodes = <FocusNode>[ final List<FocusNode> focusNodes = <FocusNode>[];
FocusNode(), FocusNode(), FocusNode(), FocusNode(), for (int i = 0; i < 4; i++) {
]; final FocusNode focusNode = FocusNode();
focusNodes.add(focusNode);
addTearDown(focusNode.dispose);
}
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
...@@ -118,7 +127,7 @@ void main() { ...@@ -118,7 +127,7 @@ void main() {
); );
}); });
testWidgets('Tab bar respects themes', (WidgetTester tester) async { testWidgetsWithLeakTracking('Tab bar respects themes', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTabScaffold( home: CupertinoTabScaffold(
...@@ -176,7 +185,7 @@ void main() { ...@@ -176,7 +185,7 @@ void main() {
expect(tab2.text.style!.color!.value, CupertinoColors.systemRed.darkColor.value); expect(tab2.text.style!.color!.value, CupertinoColors.systemRed.darkColor.value);
}); });
testWidgets('dark mode background color', (WidgetTester tester) async { testWidgetsWithLeakTracking('dark mode background color', (WidgetTester tester) async {
const CupertinoDynamicColor backgroundColor = CupertinoDynamicColor.withBrightness( const CupertinoDynamicColor backgroundColor = CupertinoDynamicColor.withBrightness(
color: Color(0xFF123456), color: Color(0xFF123456),
darkColor: Color(0xFF654321), darkColor: Color(0xFF654321),
...@@ -229,7 +238,7 @@ void main() { ...@@ -229,7 +238,7 @@ void main() {
expect(tabDecoration.color!.value, backgroundColor.darkColor.value); expect(tabDecoration.color!.value, backgroundColor.darkColor.value);
}); });
testWidgets('Does not lose state when focusing on text input', (WidgetTester tester) async { testWidgetsWithLeakTracking('Does not lose state when focusing on text input', (WidgetTester tester) async {
// Regression testing for https://github.com/flutter/flutter/issues/28457. // Regression testing for https://github.com/flutter/flutter/issues/28457.
await tester.pumpWidget( await tester.pumpWidget(
...@@ -275,7 +284,7 @@ void main() { ...@@ -275,7 +284,7 @@ void main() {
expect(find.text("don't lose me"), findsOneWidget); expect(find.text("don't lose me"), findsOneWidget);
}); });
testWidgets('textScaleFactor is set to 1.0', (WidgetTester tester) async { testWidgetsWithLeakTracking('textScaleFactor is set to 1.0', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Builder(builder: (BuildContext context) { home: Builder(builder: (BuildContext context) {
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
const Color _kScrollbarColor = Color(0x59000000); const Color _kScrollbarColor = Color(0x59000000);
...@@ -13,7 +14,7 @@ const Offset _kGestureOffset = Offset(0, -25); ...@@ -13,7 +14,7 @@ const Offset _kGestureOffset = Offset(0, -25);
const Radius _kScrollbarRadius = Radius.circular(1.5); const Radius _kScrollbarRadius = Radius.circular(1.5);
void main() { void main() {
testWidgets('Paints iOS spec', (WidgetTester tester) async { testWidgetsWithLeakTracking('Paints iOS spec', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -51,7 +52,7 @@ void main() { ...@@ -51,7 +52,7 @@ void main() {
)); ));
}); });
testWidgets('Paints iOS spec with nav bar', (WidgetTester tester) async { testWidgetsWithLeakTracking('Paints iOS spec with nav bar', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: MediaQuery( home: MediaQuery(
...@@ -96,7 +97,7 @@ void main() { ...@@ -96,7 +97,7 @@ void main() {
)); ));
}); });
testWidgets("should not paint when there isn't enough space", (WidgetTester tester) async { testWidgetsWithLeakTracking("should not paint when there isn't enough space", (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: MediaQuery( home: MediaQuery(
......
...@@ -9,6 +9,7 @@ import 'package:flutter/material.dart'; ...@@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
...@@ -32,7 +33,7 @@ void main() { ...@@ -32,7 +33,7 @@ void main() {
return tester.dragFrom(topLeft + const Offset(unit, unit), const Offset(delta, 0.0)); return tester.dragFrom(topLeft + const Offset(unit, unit), const Offset(delta, 0.0));
} }
testWidgets('Slider does not move when tapped (LTR)', (WidgetTester tester) async { testWidgetsWithLeakTracking('Slider does not move when tapped (LTR)', (WidgetTester tester) async {
final Key sliderKey = UniqueKey(); final Key sliderKey = UniqueKey();
double value = 0.0; double value = 0.0;
...@@ -68,7 +69,7 @@ void main() { ...@@ -68,7 +69,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
}); });
testWidgets('Slider does not move when tapped (RTL)', (WidgetTester tester) async { testWidgetsWithLeakTracking('Slider does not move when tapped (RTL)', (WidgetTester tester) async {
final Key sliderKey = UniqueKey(); final Key sliderKey = UniqueKey();
double value = 0.0; double value = 0.0;
...@@ -104,7 +105,7 @@ void main() { ...@@ -104,7 +105,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
}); });
testWidgets('Slider calls onChangeStart once when interaction begins', (WidgetTester tester) async { testWidgetsWithLeakTracking('Slider calls onChangeStart once when interaction begins', (WidgetTester tester) async {
final Key sliderKey = UniqueKey(); final Key sliderKey = UniqueKey();
double value = 0.0; double value = 0.0;
int numberOfTimesOnChangeStartIsCalled = 0; int numberOfTimesOnChangeStartIsCalled = 0;
...@@ -145,7 +146,7 @@ void main() { ...@@ -145,7 +146,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
}); });
testWidgets('Slider calls onChangeEnd once after interaction has ended', (WidgetTester tester) async { testWidgetsWithLeakTracking('Slider calls onChangeEnd once after interaction has ended', (WidgetTester tester) async {
final Key sliderKey = UniqueKey(); final Key sliderKey = UniqueKey();
double value = 0.0; double value = 0.0;
int numberOfTimesOnChangeEndIsCalled = 0; int numberOfTimesOnChangeEndIsCalled = 0;
...@@ -186,7 +187,7 @@ void main() { ...@@ -186,7 +187,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
}); });
testWidgets('Slider moves when dragged (LTR)', (WidgetTester tester) async { testWidgetsWithLeakTracking('Slider moves when dragged (LTR)', (WidgetTester tester) async {
final Key sliderKey = UniqueKey(); final Key sliderKey = UniqueKey();
double value = 0.0; double value = 0.0;
late double startValue; late double startValue;
...@@ -240,7 +241,7 @@ void main() { ...@@ -240,7 +241,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
}); });
testWidgets('Slider moves when dragged (RTL)', (WidgetTester tester) async { testWidgetsWithLeakTracking('Slider moves when dragged (RTL)', (WidgetTester tester) async {
final Key sliderKey = UniqueKey(); final Key sliderKey = UniqueKey();
double value = 0.0; double value = 0.0;
late double startValue; late double startValue;
...@@ -294,7 +295,7 @@ void main() { ...@@ -294,7 +295,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
}); });
testWidgets('Slider Semantics', (WidgetTester tester) async { testWidgetsWithLeakTracking('Slider Semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget( await tester.pumpWidget(
...@@ -358,7 +359,7 @@ void main() { ...@@ -358,7 +359,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgets('Slider Semantics can be updated', (WidgetTester tester) async { testWidgetsWithLeakTracking('Slider Semantics can be updated', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
double value = 0.5; double value = 0.5;
await tester.pumpWidget( await tester.pumpWidget(
...@@ -409,7 +410,7 @@ void main() { ...@@ -409,7 +410,7 @@ void main() {
handle.dispose(); handle.dispose();
}); });
testWidgets('Slider respects themes', (WidgetTester tester) async { testWidgetsWithLeakTracking('Slider respects themes', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -444,7 +445,7 @@ void main() { ...@@ -444,7 +445,7 @@ void main() {
); );
}); });
testWidgets('Themes can be overridden', (WidgetTester tester) async { testWidgetsWithLeakTracking('Themes can be overridden', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.dark), theme: const CupertinoThemeData(brightness: Brightness.dark),
...@@ -463,7 +464,7 @@ void main() { ...@@ -463,7 +464,7 @@ void main() {
); );
}); });
testWidgets('Themes can be overridden by dynamic colors', (WidgetTester tester) async { testWidgetsWithLeakTracking('Themes can be overridden by dynamic colors', (WidgetTester tester) async {
const CupertinoDynamicColor activeColor = CupertinoDynamicColor( const CupertinoDynamicColor activeColor = CupertinoDynamicColor(
color: Color(0x00000001), color: Color(0x00000001),
darkColor: Color(0x00000002), darkColor: Color(0x00000002),
...@@ -519,7 +520,7 @@ void main() { ...@@ -519,7 +520,7 @@ void main() {
expect(find.byType(CupertinoSlider), paints..rrect(color: activeColor.highContrastElevatedColor)); expect(find.byType(CupertinoSlider), paints..rrect(color: activeColor.highContrastElevatedColor));
}); });
testWidgets('track color is dynamic', (WidgetTester tester) async { testWidgetsWithLeakTracking('track color is dynamic', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.light), theme: const CupertinoThemeData(brightness: Brightness.light),
...@@ -567,7 +568,7 @@ void main() { ...@@ -567,7 +568,7 @@ void main() {
); );
}); });
testWidgets('Thumb color can be overridden', (WidgetTester tester) async { testWidgetsWithLeakTracking('Thumb color can be overridden', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -615,7 +616,7 @@ void main() { ...@@ -615,7 +616,7 @@ void main() {
); );
}); });
testWidgets('Hovering over Cupertino slider thumb updates cursor to clickable on Web', (WidgetTester tester) async { testWidgetsWithLeakTracking('Hovering over Cupertino slider thumb updates cursor to clickable on Web', (WidgetTester tester) async {
final Key sliderKey = UniqueKey(); final Key sliderKey = UniqueKey();
double value = 0.0; double value = 0.0;
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgets('Use home', (WidgetTester tester) async { testWidgetsWithLeakTracking('Use home', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTabView( home: CupertinoTabView(
...@@ -18,7 +19,7 @@ void main() { ...@@ -18,7 +19,7 @@ void main() {
expect(find.text('home'), findsOneWidget); expect(find.text('home'), findsOneWidget);
}); });
testWidgets('Use routes', (WidgetTester tester) async { testWidgetsWithLeakTracking('Use routes', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTabView( home: CupertinoTabView(
...@@ -32,7 +33,7 @@ void main() { ...@@ -32,7 +33,7 @@ void main() {
expect(find.text('first route'), findsOneWidget); expect(find.text('first route'), findsOneWidget);
}); });
testWidgets('Use home and named routes', (WidgetTester tester) async { testWidgetsWithLeakTracking('Use home and named routes', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTabView( home: CupertinoTabView(
...@@ -58,7 +59,7 @@ void main() { ...@@ -58,7 +59,7 @@ void main() {
expect(find.text('second named route'), findsOneWidget); expect(find.text('second named route'), findsOneWidget);
}); });
testWidgets('Use onGenerateRoute', (WidgetTester tester) async { testWidgetsWithLeakTracking('Use onGenerateRoute', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTabView( home: CupertinoTabView(
...@@ -80,7 +81,7 @@ void main() { ...@@ -80,7 +81,7 @@ void main() {
expect(find.text('generated home'), findsOneWidget); expect(find.text('generated home'), findsOneWidget);
}); });
testWidgets('Use onUnknownRoute', (WidgetTester tester) async { testWidgetsWithLeakTracking('Use onUnknownRoute', (WidgetTester tester) async {
late String unknownForRouteCalled; late String unknownForRouteCalled;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
...@@ -101,7 +102,7 @@ void main() { ...@@ -101,7 +102,7 @@ void main() {
expect(tester.takeException(), isAssertionError); expect(tester.takeException(), isAssertionError);
}); });
testWidgets('Can use navigatorKey to navigate', (WidgetTester tester) async { testWidgetsWithLeakTracking('Can use navigatorKey to navigate', (WidgetTester tester) async {
final GlobalKey<NavigatorState> key = GlobalKey(); final GlobalKey<NavigatorState> key = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
...@@ -122,7 +123,7 @@ void main() { ...@@ -122,7 +123,7 @@ void main() {
expect(find.text('second route'), findsOneWidget); expect(find.text('second route'), findsOneWidget);
}); });
testWidgets('Changing the key resets the navigator', (WidgetTester tester) async { testWidgetsWithLeakTracking('Changing the key resets the navigator', (WidgetTester tester) async {
final GlobalKey<NavigatorState> key = GlobalKey(); final GlobalKey<NavigatorState> key = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
...@@ -172,7 +173,7 @@ void main() { ...@@ -172,7 +173,7 @@ void main() {
expect(find.text('second route'), findsNothing); expect(find.text('second route'), findsNothing);
}); });
testWidgets('Throws FlutterError when onUnknownRoute is null', (WidgetTester tester) async { testWidgetsWithLeakTracking('Throws FlutterError when onUnknownRoute is null', (WidgetTester tester) async {
final GlobalKey<NavigatorState> key = GlobalKey(); final GlobalKey<NavigatorState> key = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
...@@ -209,7 +210,7 @@ void main() { ...@@ -209,7 +210,7 @@ void main() {
); );
}); });
testWidgets('Throws FlutterError when onUnknownRoute returns null', (WidgetTester tester) async { testWidgetsWithLeakTracking('Throws FlutterError when onUnknownRoute returns null', (WidgetTester tester) async {
final GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>();
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
...@@ -239,7 +240,7 @@ void main() { ...@@ -239,7 +240,7 @@ void main() {
); );
}); });
testWidgets('Navigator of CupertinoTabView restores state', (WidgetTester tester) async { testWidgetsWithLeakTracking('Navigator of CupertinoTabView restores state', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
restorationScopeId: 'app', restorationScopeId: 'app',
......
...@@ -5,12 +5,13 @@ ...@@ -5,12 +5,13 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.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 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
const String text = 'Hello World! How are you? Life is good!'; const String text = 'Hello World! How are you? Life is good!';
const String alternativeText = 'Everything is awesome!!'; const String alternativeText = 'Everything is awesome!!';
void main() { void main() {
testWidgets('CupertinoTextField restoration', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoTextField restoration', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
restorationScopeId: 'app', restorationScopeId: 'app',
...@@ -21,7 +22,7 @@ void main() { ...@@ -21,7 +22,7 @@ void main() {
await restoreAndVerify(tester); await restoreAndVerify(tester);
}); });
testWidgets('CupertinoTextField restoration with external controller', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoTextField restoration with external controller', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
restorationScopeId: 'app', restorationScopeId: 'app',
......
...@@ -4,11 +4,12 @@ ...@@ -4,11 +4,12 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.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(
CupertinoApp( CupertinoApp(
...@@ -29,7 +30,7 @@ void main() { ...@@ -29,7 +30,7 @@ void main() {
expect(pressed, true); expect(pressed, true);
}); });
testWidgets('background darkens when pressed', (WidgetTester tester) async { testWidgetsWithLeakTracking('background darkens when pressed', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
...@@ -75,7 +76,7 @@ void main() { ...@@ -75,7 +76,7 @@ void main() {
expect(boxDecoration.color, const Color(0x00000000)); expect(boxDecoration.color, const Color(0x00000000));
}); });
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 CupertinoApp( const CupertinoApp(
home: Center( home: Center(
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/editable_text_utils.dart' show textOffsetToPosition; import '../widgets/editable_text_utils.dart' show textOffsetToPosition;
...@@ -106,7 +107,7 @@ void main() { ...@@ -106,7 +107,7 @@ void main() {
); );
} }
testWidgets('chevrons point to the correct side', (WidgetTester tester) async { testWidgetsWithLeakTracking('chevrons point to the correct side', (WidgetTester tester) async {
// Add enough TestBoxes to need 3 pages. // Add enough TestBoxes to need 3 pages.
final List<Widget> children = List<Widget>.generate(15, (int i) => const TestBox()); final List<Widget> children = List<Widget>.generate(15, (int i) => const TestBox());
await tester.pumpWidget( await tester.pumpWidget(
...@@ -146,7 +147,7 @@ void main() { ...@@ -146,7 +147,7 @@ void main() {
expect(findOverflowBackButton(), overflowBackPaintPattern()); expect(findOverflowBackButton(), overflowBackPaintPattern());
}, skip: kIsWeb); // Path.combine is not implemented in the HTML backend https://github.com/flutter/flutter/issues/44572 }, skip: kIsWeb); // Path.combine is not implemented in the HTML backend https://github.com/flutter/flutter/issues/44572
testWidgets('paginates children if they overflow', (WidgetTester tester) async { testWidgetsWithLeakTracking('paginates children if they overflow', (WidgetTester tester) async {
late StateSetter setState; late StateSetter setState;
final List<Widget> children = List<Widget>.generate(7, (int i) => const TestBox()); final List<Widget> children = List<Widget>.generate(7, (int i) => const TestBox());
await tester.pumpWidget( await tester.pumpWidget(
...@@ -241,7 +242,7 @@ void main() { ...@@ -241,7 +242,7 @@ void main() {
expect(findOverflowBackButton(), findsNothing); expect(findOverflowBackButton(), findsNothing);
}, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web. }, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web.
testWidgets('does not paginate if children fit with zero margin', (WidgetTester tester) async { testWidgetsWithLeakTracking('does not paginate if children fit with zero margin', (WidgetTester tester) async {
final List<Widget> children = List<Widget>.generate(7, (int i) => const TestBox()); final List<Widget> children = List<Widget>.generate(7, (int i) => const TestBox());
final double spacerWidth = 1.0 / tester.view.devicePixelRatio; final double spacerWidth = 1.0 / tester.view.devicePixelRatio;
final double dividerWidth = 1.0 / tester.view.devicePixelRatio; final double dividerWidth = 1.0 / tester.view.devicePixelRatio;
...@@ -268,7 +269,7 @@ void main() { ...@@ -268,7 +269,7 @@ void main() {
expect(findOverflowBackButton(), findsNothing); expect(findOverflowBackButton(), findsNothing);
}, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web. }, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web.
testWidgets('positions itself at anchorAbove if it fits', (WidgetTester tester) async { testWidgetsWithLeakTracking('positions itself at anchorAbove if it fits', (WidgetTester tester) async {
late StateSetter setState; late StateSetter setState;
const double height = _kToolbarHeight; const double height = _kToolbarHeight;
const double anchorBelowY = 500.0; const double anchorBelowY = 500.0;
...@@ -334,7 +335,7 @@ void main() { ...@@ -334,7 +335,7 @@ void main() {
expect(toolbarY, equals(anchorAboveY - height - _kToolbarContentDistance)); expect(toolbarY, equals(anchorAboveY - height - _kToolbarContentDistance));
}, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web. }, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web.
testWidgets('can create and use a custom toolbar', (WidgetTester tester) async { testWidgetsWithLeakTracking('can create and use a custom toolbar', (WidgetTester tester) async {
final TextEditingController controller = TextEditingController( final TextEditingController controller = TextEditingController(
text: 'Select me custom menu', text: 'Select me custom menu',
); );
...@@ -369,7 +370,7 @@ void main() { ...@@ -369,7 +370,7 @@ void main() {
for (final Brightness? themeBrightness in <Brightness?>[...Brightness.values, null]) { for (final Brightness? themeBrightness in <Brightness?>[...Brightness.values, null]) {
for (final Brightness? mediaBrightness in <Brightness?>[...Brightness.values, null]) { for (final Brightness? mediaBrightness in <Brightness?>[...Brightness.values, null]) {
testWidgets('draws dark buttons in dark mode and light button in light mode when theme is $themeBrightness and MediaQuery is $mediaBrightness', (WidgetTester tester) async { testWidgetsWithLeakTracking('draws dark buttons in dark mode and light button in light mode when theme is $themeBrightness and MediaQuery is $mediaBrightness', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
theme: CupertinoThemeData( theme: CupertinoThemeData(
...@@ -426,7 +427,7 @@ void main() { ...@@ -426,7 +427,7 @@ void main() {
} }
} }
testWidgets('draws a shadow below the toolbar in light mode', (WidgetTester tester) async { testWidgetsWithLeakTracking('draws a shadow below the toolbar in light mode', (WidgetTester tester) async {
late StateSetter setState; late StateSetter setState;
const double height = _kToolbarHeight; const double height = _kToolbarHeight;
double anchorAboveY = 0.0; double anchorAboveY = 0.0;
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
int buildCount = 0; int buildCount = 0;
CupertinoThemeData? actualTheme; CupertinoThemeData? actualTheme;
...@@ -46,7 +47,7 @@ void main() { ...@@ -46,7 +47,7 @@ void main() {
actualIconTheme = null; actualIconTheme = null;
}); });
testWidgets('Default theme has defaults', (WidgetTester tester) async { testWidgetsWithLeakTracking('Default theme has defaults', (WidgetTester tester) async {
final CupertinoThemeData theme = await testTheme(tester, const CupertinoThemeData()); final CupertinoThemeData theme = await testTheme(tester, const CupertinoThemeData());
expect(theme.brightness, isNull); expect(theme.brightness, isNull);
...@@ -55,7 +56,7 @@ void main() { ...@@ -55,7 +56,7 @@ void main() {
expect(theme.applyThemeToAll, false); expect(theme.applyThemeToAll, false);
}); });
testWidgets('Theme attributes cascade', (WidgetTester tester) async { testWidgetsWithLeakTracking('Theme attributes cascade', (WidgetTester tester) async {
final CupertinoThemeData theme = await testTheme(tester, const CupertinoThemeData( final CupertinoThemeData theme = await testTheme(tester, const CupertinoThemeData(
primaryColor: CupertinoColors.systemRed, primaryColor: CupertinoColors.systemRed,
)); ));
...@@ -63,7 +64,7 @@ void main() { ...@@ -63,7 +64,7 @@ void main() {
expect(theme.textTheme.actionTextStyle.color, isSameColorAs(CupertinoColors.systemRed.color)); expect(theme.textTheme.actionTextStyle.color, isSameColorAs(CupertinoColors.systemRed.color));
}); });
testWidgets('Dependent attribute can be overridden from cascaded value', (WidgetTester tester) async { testWidgetsWithLeakTracking('Dependent attribute can be overridden from cascaded value', (WidgetTester tester) async {
final CupertinoThemeData theme = await testTheme(tester, const CupertinoThemeData( final CupertinoThemeData theme = await testTheme(tester, const CupertinoThemeData(
brightness: Brightness.dark, brightness: Brightness.dark,
textTheme: CupertinoTextThemeData( textTheme: CupertinoTextThemeData(
...@@ -77,7 +78,7 @@ void main() { ...@@ -77,7 +78,7 @@ void main() {
expect(theme.textTheme.textStyle.color, isSameColorAs(CupertinoColors.black)); expect(theme.textTheme.textStyle.color, isSameColorAs(CupertinoColors.black));
}); });
testWidgets( testWidgetsWithLeakTracking(
'Reading themes creates dependencies', 'Reading themes creates dependencies',
(WidgetTester tester) async { (WidgetTester tester) async {
// Reading the theme creates a dependency. // Reading the theme creates a dependency.
...@@ -118,7 +119,7 @@ void main() { ...@@ -118,7 +119,7 @@ void main() {
}, },
); );
testWidgets( testWidgetsWithLeakTracking(
'copyWith works', 'copyWith works',
(WidgetTester tester) async { (WidgetTester tester) async {
const CupertinoThemeData originalTheme = CupertinoThemeData( const CupertinoThemeData originalTheme = CupertinoThemeData(
...@@ -141,7 +142,7 @@ void main() { ...@@ -141,7 +142,7 @@ void main() {
}, },
); );
testWidgets("Theme has default IconThemeData, which is derived from the theme's primary color", (WidgetTester tester) async { testWidgetsWithLeakTracking("Theme has default IconThemeData, which is derived from the theme's primary color", (WidgetTester tester) async {
const CupertinoDynamicColor primaryColor = CupertinoColors.systemRed; const CupertinoDynamicColor primaryColor = CupertinoColors.systemRed;
const CupertinoThemeData themeData = CupertinoThemeData(primaryColor: primaryColor); const CupertinoThemeData themeData = CupertinoThemeData(primaryColor: primaryColor);
...@@ -158,7 +159,7 @@ void main() { ...@@ -158,7 +159,7 @@ void main() {
expect(darkColor, isSameColorAs(primaryColor.darkColor)); expect(darkColor, isSameColorAs(primaryColor.darkColor));
}); });
testWidgets('IconTheme.of creates a dependency on iconTheme', (WidgetTester tester) async { testWidgetsWithLeakTracking('IconTheme.of creates a dependency on iconTheme', (WidgetTester tester) async {
IconThemeData iconTheme = await testIconTheme(tester, const CupertinoThemeData(primaryColor: CupertinoColors.destructiveRed)); IconThemeData iconTheme = await testIconTheme(tester, const CupertinoThemeData(primaryColor: CupertinoColors.destructiveRed));
expect(buildCount, 1); expect(buildCount, 1);
...@@ -169,7 +170,7 @@ void main() { ...@@ -169,7 +170,7 @@ void main() {
expect(iconTheme.color, CupertinoColors.activeOrange); expect(iconTheme.color, CupertinoColors.activeOrange);
}); });
testWidgets('CupertinoTheme diagnostics', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoTheme diagnostics', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const CupertinoThemeData().debugFillProperties(builder); const CupertinoThemeData().debugFillProperties(builder);
...@@ -201,7 +202,7 @@ void main() { ...@@ -201,7 +202,7 @@ void main() {
); );
}); });
testWidgets('CupertinoTheme.toStringDeep uses single-line style', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoTheme.toStringDeep uses single-line style', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/47651. // Regression test for https://github.com/flutter/flutter/issues/47651.
expect( expect(
const CupertinoTheme( const CupertinoTheme(
...@@ -212,7 +213,7 @@ void main() { ...@@ -212,7 +213,7 @@ void main() {
); );
}); });
testWidgets('CupertinoThemeData equality', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoThemeData equality', (WidgetTester tester) async {
const CupertinoThemeData a = CupertinoThemeData(brightness: Brightness.dark); const CupertinoThemeData a = CupertinoThemeData(brightness: Brightness.dark);
final CupertinoThemeData b = a.copyWith(); final CupertinoThemeData b = a.copyWith();
final CupertinoThemeData c = a.copyWith(brightness: Brightness.light); final CupertinoThemeData c = a.copyWith(brightness: Brightness.light);
...@@ -235,7 +236,7 @@ void main() { ...@@ -235,7 +236,7 @@ void main() {
} }
void dynamicColorsTestGroup() { void dynamicColorsTestGroup() {
testWidgets('CupertinoTheme.of resolves colors', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoTheme.of resolves colors', (WidgetTester tester) async {
final CupertinoThemeData data = CupertinoThemeData(brightness: currentBrightness, primaryColor: CupertinoColors.systemRed); final CupertinoThemeData data = CupertinoThemeData(brightness: currentBrightness, primaryColor: CupertinoColors.systemRed);
final CupertinoThemeData theme = await testTheme(tester, data); final CupertinoThemeData theme = await testTheme(tester, data);
...@@ -243,7 +244,7 @@ void main() { ...@@ -243,7 +244,7 @@ void main() {
colorMatches(theme.primaryColor, CupertinoColors.systemRed); colorMatches(theme.primaryColor, CupertinoColors.systemRed);
}); });
testWidgets('CupertinoTheme.of resolves default values', (WidgetTester tester) async { testWidgetsWithLeakTracking('CupertinoTheme.of resolves default values', (WidgetTester tester) async {
const CupertinoDynamicColor primaryColor = CupertinoColors.systemRed; const CupertinoDynamicColor primaryColor = CupertinoColors.systemRed;
final CupertinoThemeData data = CupertinoThemeData(brightness: currentBrightness, primaryColor: primaryColor); final CupertinoThemeData data = CupertinoThemeData(brightness: currentBrightness, primaryColor: primaryColor);
......
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