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() {
// TODO(LongCatIsLoong): Uncomment once https://github.com/flutter/flutter/issues/44115
// is fixed.
/*
testWidgets(
testWidgetsWithLeakTracking(
'CupertinoButton.filled default color contrast meets guideline',
(WidgetTester tester) async {
// The native color combination systemBlue text over white background fails
......@@ -185,7 +185,7 @@ void main() {
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(
onPressed: null,
child: Text('Tap me'),
......
......@@ -5,6 +5,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class DependentWidget extends StatelessWidget {
const DependentWidget({
......@@ -200,7 +201,7 @@ void main() {
);
});
testWidgets(
testWidgetsWithLeakTracking(
'Dynamic colors that are not actually dynamic should not claim dependencies',
(WidgetTester tester) async {
await tester.pumpWidget(const DependentWidget(color: notSoDynamicColor1));
......@@ -210,7 +211,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
'Dynamic colors that are only dependent on vibrancy should not claim unnecessary dependencies, '
'and its resolved color should change when its dependency changes',
(WidgetTester tester) async {
......@@ -254,7 +255,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
'Dynamic colors that are only dependent on accessibility contrast should not claim unnecessary dependencies, '
'and its resolved color should change when its dependency changes',
(WidgetTester tester) async {
......@@ -283,7 +284,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
'Dynamic colors that are only dependent on elevation level should not claim unnecessary dependencies, '
'and its resolved color should change when its dependency changes',
(WidgetTester tester) async {
......@@ -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(
color: color0,
darkColor: color1,
......@@ -413,7 +414,7 @@ void main() {
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;
await tester.pumpWidget(
CupertinoApp(
......@@ -498,7 +499,7 @@ void main() {
Color? color;
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;
await tester.pumpWidget(
......@@ -555,7 +556,7 @@ void main() {
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(
MaterialApp(
// This will create a MaterialBasedCupertinoThemeData with primaryColor set to `dynamicColor`.
......
......@@ -7,6 +7,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
// Constants taken from _ContextMenuActionState.
......@@ -71,7 +72,7 @@ void main() {
return icon;
}
testWidgets('responds to taps', (WidgetTester tester) async {
testWidgetsWithLeakTracking('responds to taps', (WidgetTester tester) async {
bool wasPressed = false;
await tester.pumpWidget(getApp(onPressed: () {
wasPressed = true;
......@@ -82,7 +83,7 @@ void main() {
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());
expect(find.byType(CupertinoContextMenuAction),
paints..rect(color: kBackgroundColor.color));
......@@ -117,27 +118,27 @@ void main() {
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 {
await tester.pumpWidget(getApp());
expect(getTextStyle(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 {
await tester.pumpWidget(getApp(isDestructiveAction: true));
expect(getTextStyle(tester).color, kDestructiveActionColor);
expect(getIcon(tester).color, kDestructiveActionColor);
});
testWidgets('textStyle is correct for defaultAction',
testWidgetsWithLeakTracking('textStyle is correct for defaultAction',
(WidgetTester tester) async {
await tester.pumpWidget(getApp(isDefaultAction: true));
expect(getTextStyle(tester).fontWeight, kDefaultActionWeight);
});
testWidgets(
testWidgetsWithLeakTracking(
'Hovering over Cupertino context menu action updates cursor to clickable on Web',
(WidgetTester tester) async {
/// Cupertino context menu action without "onPressed" callback.
......
......@@ -8,6 +8,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
......@@ -120,7 +121,7 @@ void main() {
}
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.
final Widget child = getChild();
await tester.pumpWidget(
......@@ -140,7 +141,7 @@ void main() {
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();
await tester.pumpWidget(getContextMenu(child: child));
expect(find.byWidget(child), findsOneWidget);
......@@ -176,7 +177,7 @@ void main() {
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();
await tester.pumpWidget(CupertinoApp(
home: CupertinoPageScaffold(
......@@ -241,7 +242,7 @@ void main() {
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();
await tester.pumpWidget(getBuilderContextMenu(builder: (BuildContext context, Animation<double> animation) {
return child;
......@@ -279,7 +280,7 @@ void main() {
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) {
return Container(
width: 300.0,
......@@ -319,7 +320,7 @@ void main() {
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();
await tester.pumpWidget(CupertinoApp(
home: CupertinoPageScaffold(
......@@ -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();
await tester.pumpWidget(CupertinoApp(
home: CupertinoPageScaffold(
......@@ -408,7 +409,7 @@ void main() {
});
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();
await tester.pumpWidget(CupertinoApp(
home: CupertinoPageScaffold(
......@@ -467,7 +468,7 @@ void main() {
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();
await tester.pumpWidget(getContextMenu(child: child));
......@@ -485,7 +486,7 @@ void main() {
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();
await tester.pumpWidget(getContextMenu(child: child));
......@@ -527,7 +528,7 @@ void main() {
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();
await tester.pumpWidget(getContextMenu(child: child));
......@@ -552,7 +553,7 @@ void main() {
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();
await tester.pumpWidget(getContextMenu(child: child));
expect(find.byType(BackdropFilter), findsNothing);
......@@ -567,7 +568,7 @@ void main() {
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();
await tester.pumpWidget(getContextMenu(child: child));
......@@ -585,7 +586,7 @@ void main() {
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();
await tester.pumpWidget(getContextMenu(child: child));
expect(find.byWidget(child), findsOneWidget);
......@@ -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.
final List<int> items = List<int>.generate(2, (int index) => index).toList();
......@@ -675,7 +676,7 @@ void main() {
});
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);
await binding.setSurfaceSize(portraitScreenSize);
......@@ -747,7 +748,7 @@ void main() {
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.
final Widget child = getChild();
await tester.pumpWidget(getContextMenu(
......@@ -812,7 +813,7 @@ void main() {
});
});
testWidgets('Conflicting gesture detectors', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Conflicting gesture detectors', (WidgetTester tester) async {
int? onPointerDownTime;
int? onPointerUpTime;
bool insideTapTriggered = false;
......
......@@ -4,9 +4,10 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('debugCheckHasCupertinoLocalizations throws', (WidgetTester tester) async {
testWidgetsWithLeakTracking('debugCheckHasCupertinoLocalizations throws', (WidgetTester tester) async {
final GlobalKey noLocalizationsAvailable = GlobalKey();
final GlobalKey localizationsAvailable = GlobalKey();
......
......@@ -5,11 +5,12 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
testWidgets('can press', (WidgetTester tester) async {
testWidgetsWithLeakTracking('can press', (WidgetTester tester) async {
bool pressed = false;
await tester.pumpWidget(
CupertinoApp(
......@@ -30,7 +31,7 @@ void main() {
expect(pressed, true);
});
testWidgets('keeps contrast with background on hover',
testWidgetsWithLeakTracking('keeps contrast with background on hover',
(WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
......@@ -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(
CupertinoApp(
home: Center(
......@@ -114,7 +115,7 @@ void main() {
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(
const CupertinoApp(
home: Center(
......
......@@ -7,11 +7,12 @@ import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
testWidgets('has correct backdrop filters', (WidgetTester tester) async {
testWidgetsWithLeakTracking('has correct backdrop filters', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: Center(
......@@ -53,7 +54,7 @@ void main() {
);
});
testWidgets('has shadow', (WidgetTester tester) async {
testWidgetsWithLeakTracking('has shadow', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: Center(
......@@ -83,7 +84,7 @@ void main() {
);
});
testWidgets('is translucent', (WidgetTester tester) async {
testWidgetsWithLeakTracking('is translucent', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: Center(
......@@ -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.
const Offset anchor = Offset(30.0, 40.0);
......
......@@ -6,9 +6,10 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('Shows prefix', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Shows prefix', (WidgetTester tester) async {
const Widget prefix = Text('Enter Value');
await tester.pumpWidget(
......@@ -25,7 +26,7 @@ void main() {
expect(prefix, tester.widget(find.byType(Text)));
});
testWidgets('Shows child', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Shows child', (WidgetTester tester) async {
const Widget child = CupertinoTextField();
await tester.pumpWidget(
......@@ -41,7 +42,7 @@ void main() {
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 child = CupertinoTextField();
......@@ -62,7 +63,7 @@ void main() {
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 child = CupertinoTextField();
......@@ -83,7 +84,7 @@ void main() {
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');
await tester.pumpWidget(
......@@ -100,7 +101,7 @@ void main() {
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');
await tester.pumpWidget(
......@@ -117,7 +118,7 @@ void main() {
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 error = CupertinoActivityIndicator();
......@@ -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 error = Text('Error');
......@@ -166,7 +167,7 @@ void main() {
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 helper = Text('Helper');
......
......@@ -4,9 +4,10 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('IconTheme.of works', (WidgetTester tester) async {
testWidgetsWithLeakTracking('IconTheme.of works', (WidgetTester tester) async {
const IconThemeData data = IconThemeData(
size: 16.0,
fill: 0.0,
......
......@@ -4,9 +4,10 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('shows header', (WidgetTester tester) async {
testWidgetsWithLeakTracking('shows header', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: Center(
......@@ -23,7 +24,7 @@ void main() {
expect(find.text('Header'), findsOneWidget);
});
testWidgets('shows footer', (WidgetTester tester) async {
testWidgetsWithLeakTracking('shows footer', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: Center(
......@@ -40,7 +41,7 @@ void main() {
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(
CupertinoApp(
home: Center(
......@@ -59,7 +60,7 @@ void main() {
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(
CupertinoApp(
home: Center(
......@@ -80,7 +81,7 @@ void main() {
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(
CupertinoApp(
home: Center(
......@@ -100,7 +101,7 @@ void main() {
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(
CupertinoApp(
home: Center(
......@@ -121,7 +122,7 @@ void main() {
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;
await tester.pumpWidget(
......@@ -144,7 +145,7 @@ void main() {
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(
CupertinoApp(
home: Center(
......@@ -161,7 +162,7 @@ void main() {
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(
CupertinoApp(
home: Center(
......@@ -177,7 +178,7 @@ void main() {
expect(find.byType(ClipRRect), findsNothing);
});
testWidgets('CupertinoListSection respects separatorColor', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CupertinoListSection respects separatorColor', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: Center(
......@@ -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(
CupertinoApp(
home: Center(
......
......@@ -4,9 +4,10 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('shows title', (WidgetTester tester) async {
testWidgetsWithLeakTracking('shows title', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile');
await tester.pumpWidget(
......@@ -23,7 +24,7 @@ void main() {
expect(find.text('CupertinoListTile'), findsOneWidget);
});
testWidgets('shows subtitle', (WidgetTester tester) async {
testWidgetsWithLeakTracking('shows subtitle', (WidgetTester tester) async {
const Widget subtitle = Text('CupertinoListTile subtitle');
await tester.pumpWidget(
......@@ -41,7 +42,7 @@ void main() {
expect(find.text('CupertinoListTile subtitle'), findsOneWidget);
});
testWidgets('shows additionalInfo', (WidgetTester tester) async {
testWidgetsWithLeakTracking('shows additionalInfo', (WidgetTester tester) async {
const Widget additionalInfo = Text('Not Connected');
await tester.pumpWidget(
......@@ -59,7 +60,7 @@ void main() {
expect(find.text('Not Connected'), findsOneWidget);
});
testWidgets('shows trailing', (WidgetTester tester) async {
testWidgetsWithLeakTracking('shows trailing', (WidgetTester tester) async {
const Widget trailing = CupertinoListTileChevron();
await tester.pumpWidget(
......@@ -76,7 +77,7 @@ void main() {
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);
await tester.pumpWidget(
......@@ -93,7 +94,7 @@ void main() {
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;
await tester.pumpWidget(
......@@ -118,7 +119,7 @@ void main() {
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 backgroundColorActivated = CupertinoColors.systemRed;
......@@ -148,7 +149,7 @@ void main() {
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 backgroundColorActivated = CupertinoColors.systemRed;
......@@ -187,7 +188,7 @@ void main() {
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(
Directionality(
textDirection: TextDirection.ltr,
......@@ -208,7 +209,7 @@ void main() {
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(
Directionality(
textDirection: TextDirection.ltr,
......@@ -230,7 +231,7 @@ void main() {
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 backgroundColorActivated = CupertinoColors.systemRed;
......@@ -279,7 +280,7 @@ void main() {
});
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 leading = Icon(CupertinoIcons.add);
......@@ -303,7 +304,7 @@ void main() {
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 subtitle = Text('CupertinoListTile subtitle');
......@@ -328,7 +329,7 @@ void main() {
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 additionalInfo = Text('Not Connected');
......@@ -352,7 +353,7 @@ void main() {
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 additionalInfo = Text('Not Connected');
const Widget trailing = CupertinoListTileChevron();
......@@ -380,7 +381,7 @@ void main() {
});
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 leading = Icon(CupertinoIcons.add);
......@@ -404,7 +405,7 @@ void main() {
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 subtitle = Text('CupertinoListTile subtitle');
......@@ -429,7 +430,7 @@ void main() {
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 additionalInfo = Text('Not Connected');
......@@ -453,7 +454,7 @@ void main() {
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 additionalInfo = Text('Not Connected');
const Widget trailing = CupertinoListTileChevron();
......@@ -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');
bool showTile = true;
......@@ -520,7 +521,7 @@ void main() {
expect(tester.takeException(), null);
});
testWidgets('title does not overflow', (WidgetTester tester) async {
testWidgetsWithLeakTracking('title does not overflow', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: CupertinoPageScaffold(
......@@ -534,7 +535,7 @@ void main() {
expect(tester.takeException(), null);
});
testWidgets('subtitle does not overflow', (WidgetTester tester) async {
testWidgetsWithLeakTracking('subtitle does not overflow', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: CupertinoPageScaffold(
......
......@@ -4,9 +4,10 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
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();
expect(localizations.datePickerYear(2018), isNotNull);
......@@ -36,7 +37,7 @@ void main() {
expect(localizations.noSpellCheckReplacementsLabel, isNotNull);
});
testWidgets('CupertinoLocalizations.of throws', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CupertinoLocalizations.of throws', (WidgetTester tester) async {
final GlobalKey noLocalizationsAvailable = GlobalKey();
final GlobalKey localizationsAvailable = GlobalKey();
......
......@@ -7,6 +7,7 @@ import 'dart:typed_data';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../../image_data.dart';
......@@ -17,9 +18,14 @@ void main() {
selectedTabs = <int>[];
});
testWidgets('Last tab gets focus', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Last tab gets focus', (WidgetTester tester) async {
// 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(
MaterialApp(
......@@ -52,10 +58,13 @@ void main() {
expect(focusNodes[1].hasFocus, isFalse);
});
testWidgets('Do not affect focus order in the route', (WidgetTester tester) async {
final List<FocusNode> focusNodes = <FocusNode>[
FocusNode(), FocusNode(), FocusNode(), FocusNode(),
];
testWidgetsWithLeakTracking('Do not affect focus order in the route', (WidgetTester tester) async {
final List<FocusNode> focusNodes = <FocusNode>[];
for (int i = 0; i < 4; i++) {
final FocusNode focusNode = FocusNode();
focusNodes.add(focusNode);
addTearDown(focusNode.dispose);
}
await tester.pumpWidget(
MaterialApp(
......@@ -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(
CupertinoApp(
home: CupertinoTabScaffold(
......@@ -176,7 +185,7 @@ void main() {
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(
color: Color(0xFF123456),
darkColor: Color(0xFF654321),
......@@ -229,7 +238,7 @@ void main() {
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.
await tester.pumpWidget(
......@@ -275,7 +284,7 @@ void main() {
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(
MaterialApp(
home: Builder(builder: (BuildContext context) {
......
......@@ -4,6 +4,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
const Color _kScrollbarColor = Color(0x59000000);
......@@ -13,7 +14,7 @@ const Offset _kGestureOffset = Offset(0, -25);
const Radius _kScrollbarRadius = Radius.circular(1.5);
void main() {
testWidgets('Paints iOS spec', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Paints iOS spec', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
......@@ -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(
CupertinoApp(
home: MediaQuery(
......@@ -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(
CupertinoApp(
home: MediaQuery(
......
......@@ -9,6 +9,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart';
......@@ -32,7 +33,7 @@ void main() {
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();
double value = 0.0;
......@@ -68,7 +69,7 @@ void main() {
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();
double value = 0.0;
......@@ -104,7 +105,7 @@ void main() {
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();
double value = 0.0;
int numberOfTimesOnChangeStartIsCalled = 0;
......@@ -145,7 +146,7 @@ void main() {
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();
double value = 0.0;
int numberOfTimesOnChangeEndIsCalled = 0;
......@@ -186,7 +187,7 @@ void main() {
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();
double value = 0.0;
late double startValue;
......@@ -240,7 +241,7 @@ void main() {
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();
double value = 0.0;
late double startValue;
......@@ -294,7 +295,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
});
testWidgets('Slider Semantics', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Slider Semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(
......@@ -358,7 +359,7 @@ void main() {
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();
double value = 0.5;
await tester.pumpWidget(
......@@ -409,7 +410,7 @@ void main() {
handle.dispose();
});
testWidgets('Slider respects themes', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Slider respects themes', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: Center(
......@@ -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(
CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.dark),
......@@ -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(
color: Color(0x00000001),
darkColor: Color(0x00000002),
......@@ -519,7 +520,7 @@ void main() {
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(
CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.light),
......@@ -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(
CupertinoApp(
home: Center(
......@@ -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();
double value = 0.0;
......
......@@ -4,9 +4,10 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('Use home', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Use home', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: CupertinoTabView(
......@@ -18,7 +19,7 @@ void main() {
expect(find.text('home'), findsOneWidget);
});
testWidgets('Use routes', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Use routes', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: CupertinoTabView(
......@@ -32,7 +33,7 @@ void main() {
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(
CupertinoApp(
home: CupertinoTabView(
......@@ -58,7 +59,7 @@ void main() {
expect(find.text('second named route'), findsOneWidget);
});
testWidgets('Use onGenerateRoute', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Use onGenerateRoute', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: CupertinoTabView(
......@@ -80,7 +81,7 @@ void main() {
expect(find.text('generated home'), findsOneWidget);
});
testWidgets('Use onUnknownRoute', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Use onUnknownRoute', (WidgetTester tester) async {
late String unknownForRouteCalled;
await tester.pumpWidget(
CupertinoApp(
......@@ -101,7 +102,7 @@ void main() {
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();
await tester.pumpWidget(
CupertinoApp(
......@@ -122,7 +123,7 @@ void main() {
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();
await tester.pumpWidget(
CupertinoApp(
......@@ -172,7 +173,7 @@ void main() {
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();
await tester.pumpWidget(
CupertinoApp(
......@@ -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>();
await tester.pumpWidget(
CupertinoApp(
......@@ -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(
CupertinoApp(
restorationScopeId: 'app',
......
......@@ -5,12 +5,13 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.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 alternativeText = 'Everything is awesome!!';
void main() {
testWidgets('CupertinoTextField restoration', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CupertinoTextField restoration', (WidgetTester tester) async {
await tester.pumpWidget(
const CupertinoApp(
restorationScopeId: 'app',
......@@ -21,7 +22,7 @@ void main() {
await restoreAndVerify(tester);
});
testWidgets('CupertinoTextField restoration with external controller', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CupertinoTextField restoration with external controller', (WidgetTester tester) async {
await tester.pumpWidget(
const CupertinoApp(
restorationScopeId: 'app',
......
......@@ -4,11 +4,12 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
testWidgets('can press', (WidgetTester tester) async {
testWidgetsWithLeakTracking('can press', (WidgetTester tester) async {
bool pressed = false;
await tester.pumpWidget(
CupertinoApp(
......@@ -29,7 +30,7 @@ void main() {
expect(pressed, true);
});
testWidgets('background darkens when pressed', (WidgetTester tester) async {
testWidgetsWithLeakTracking('background darkens when pressed', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: Center(
......@@ -75,7 +76,7 @@ void main() {
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(
const CupertinoApp(
home: Center(
......
......@@ -5,6 +5,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.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;
......@@ -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.
final List<Widget> children = List<Widget>.generate(15, (int i) => const TestBox());
await tester.pumpWidget(
......@@ -146,7 +147,7 @@ void main() {
expect(findOverflowBackButton(), overflowBackPaintPattern());
}, 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;
final List<Widget> children = List<Widget>.generate(7, (int i) => const TestBox());
await tester.pumpWidget(
......@@ -241,7 +242,7 @@ void main() {
expect(findOverflowBackButton(), findsNothing);
}, 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 double spacerWidth = 1.0 / tester.view.devicePixelRatio;
final double dividerWidth = 1.0 / tester.view.devicePixelRatio;
......@@ -268,7 +269,7 @@ void main() {
expect(findOverflowBackButton(), findsNothing);
}, 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;
const double height = _kToolbarHeight;
const double anchorBelowY = 500.0;
......@@ -334,7 +335,7 @@ void main() {
expect(toolbarY, equals(anchorAboveY - height - _kToolbarContentDistance));
}, 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(
text: 'Select me custom menu',
);
......@@ -369,7 +370,7 @@ void main() {
for (final Brightness? themeBrightness 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(
CupertinoApp(
theme: CupertinoThemeData(
......@@ -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;
const double height = _kToolbarHeight;
double anchorAboveY = 0.0;
......
......@@ -5,6 +5,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
int buildCount = 0;
CupertinoThemeData? actualTheme;
......@@ -46,7 +47,7 @@ void main() {
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());
expect(theme.brightness, isNull);
......@@ -55,7 +56,7 @@ void main() {
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(
primaryColor: CupertinoColors.systemRed,
));
......@@ -63,7 +64,7 @@ void main() {
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(
brightness: Brightness.dark,
textTheme: CupertinoTextThemeData(
......@@ -77,7 +78,7 @@ void main() {
expect(theme.textTheme.textStyle.color, isSameColorAs(CupertinoColors.black));
});
testWidgets(
testWidgetsWithLeakTracking(
'Reading themes creates dependencies',
(WidgetTester tester) async {
// Reading the theme creates a dependency.
......@@ -118,7 +119,7 @@ void main() {
},
);
testWidgets(
testWidgetsWithLeakTracking(
'copyWith works',
(WidgetTester tester) async {
const CupertinoThemeData originalTheme = CupertinoThemeData(
......@@ -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 CupertinoThemeData themeData = CupertinoThemeData(primaryColor: primaryColor);
......@@ -158,7 +159,7 @@ void main() {
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));
expect(buildCount, 1);
......@@ -169,7 +170,7 @@ void main() {
expect(iconTheme.color, CupertinoColors.activeOrange);
});
testWidgets('CupertinoTheme diagnostics', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CupertinoTheme diagnostics', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const CupertinoThemeData().debugFillProperties(builder);
......@@ -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.
expect(
const CupertinoTheme(
......@@ -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);
final CupertinoThemeData b = a.copyWith();
final CupertinoThemeData c = a.copyWith(brightness: Brightness.light);
......@@ -235,7 +236,7 @@ void main() {
}
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 theme = await testTheme(tester, data);
......@@ -243,7 +244,7 @@ void main() {
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;
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