Cover some cupertino tests with leak tracing (#135149)
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -10,6 +10,7 @@ import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
|
||||
|
||||
void main() {
|
||||
late FakeBuilder mockHelper;
|
||||
@@ -34,7 +35,7 @@ void main() {
|
||||
}
|
||||
|
||||
void uiTestGroup() {
|
||||
testWidgets("doesn't invoke anything without user interaction", (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking("doesn't invoke anything without user interaction", (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CustomScrollView(
|
||||
@@ -56,7 +57,7 @@ void main() {
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
|
||||
testWidgets('calls the indicator builder when starting to overscroll', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('calls the indicator builder when starting to overscroll', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CustomScrollView(
|
||||
@@ -90,7 +91,7 @@ void main() {
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
"don't call the builder if overscroll doesn't move slivers like on Android",
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
@@ -124,7 +125,7 @@ void main() {
|
||||
variant: TargetPlatformVariant.only(TargetPlatform.android),
|
||||
);
|
||||
|
||||
testWidgets('let the builder update as canceled drag scrolls away', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('let the builder update as canceled drag scrolls away', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CustomScrollView(
|
||||
@@ -186,7 +187,7 @@ void main() {
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
|
||||
testWidgets('drag past threshold triggers refresh task', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('drag past threshold triggers refresh task', (WidgetTester tester) async {
|
||||
final List<MethodCall> platformCallLog = <MethodCall>[];
|
||||
|
||||
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
|
||||
@@ -268,7 +269,7 @@ void main() {
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'refreshing task keeps the sliver expanded forever until done',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
@@ -343,7 +344,7 @@ void main() {
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'refreshing task keeps the sliver expanded forever until completes with error',
|
||||
(WidgetTester tester) async {
|
||||
final FlutterError error = FlutterError('Oops');
|
||||
@@ -431,7 +432,7 @@ void main() {
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets('expanded refreshing sliver scrolls normally', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('expanded refreshing sliver scrolls normally', (WidgetTester tester) async {
|
||||
mockHelper.refreshIndicator = const Center(child: Text('-1'));
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -520,7 +521,7 @@ void main() {
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
|
||||
testWidgets('expanded refreshing sliver goes away when done', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('expanded refreshing sliver goes away when done', (WidgetTester tester) async {
|
||||
mockHelper.refreshIndicator = const Center(child: Text('-1'));
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -588,7 +589,7 @@ void main() {
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
|
||||
testWidgets('builder still called when sliver snapped back more than 90%', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('builder still called when sliver snapped back more than 90%', (WidgetTester tester) async {
|
||||
mockHelper.refreshIndicator = const Center(child: Text('-1'));
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -686,7 +687,7 @@ void main() {
|
||||
expect(find.text('-1'), findsOneWidget);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'retracting sliver during done cannot be pulled to refresh again until fully retracted',
|
||||
(WidgetTester tester) async {
|
||||
mockHelper.refreshIndicator = const Center(child: Text('-1'));
|
||||
@@ -791,7 +792,7 @@ void main() {
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'sliver held in overscroll when task finishes completes normally',
|
||||
(WidgetTester tester) async {
|
||||
mockHelper.refreshIndicator = const Center(child: Text('-1'));
|
||||
@@ -843,7 +844,7 @@ void main() {
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'sliver scrolled away when task completes properly removes itself',
|
||||
(WidgetTester tester) async {
|
||||
if (testListLength < 4) {
|
||||
@@ -929,7 +930,7 @@ void main() {
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
"don't do anything unless it can be overscrolled at the start of the list",
|
||||
(WidgetTester tester) async {
|
||||
mockHelper.refreshIndicator = const Center(child: Text('-1'));
|
||||
@@ -957,7 +958,7 @@ void main() {
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'without an onRefresh, builder is called with arm for one frame then sliver goes away',
|
||||
(WidgetTester tester) async {
|
||||
mockHelper.refreshIndicator = const Center(child: Text('-1'));
|
||||
@@ -1014,7 +1015,7 @@ void main() {
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets('Should not crash when dragged', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Should not crash when dragged', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CustomScrollView(
|
||||
@@ -1039,7 +1040,7 @@ void main() {
|
||||
|
||||
// Test to make sure the refresh sliver's overscroll isn't eaten by the
|
||||
// nav bar sliver https://github.com/flutter/flutter/issues/74516.
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'properly displays when the refresh sliver is behind the large title nav bar sliver',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
@@ -1082,7 +1083,7 @@ void main() {
|
||||
}
|
||||
|
||||
void stateMachineTestGroup() {
|
||||
testWidgets('starts in inactive state', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('starts in inactive state', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CustomScrollView(
|
||||
@@ -1102,7 +1103,7 @@ void main() {
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
|
||||
testWidgets('goes to drag and returns to inactive in a small drag', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('goes to drag and returns to inactive in a small drag', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CustomScrollView(
|
||||
@@ -1132,7 +1133,7 @@ void main() {
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
|
||||
testWidgets('goes to armed the frame it passes the threshold', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('goes to armed the frame it passes the threshold', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: CustomScrollView(
|
||||
@@ -1167,7 +1168,7 @@ void main() {
|
||||
);
|
||||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'goes to refresh the frame it crossed back the refresh threshold',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
@@ -1216,7 +1217,7 @@ void main() {
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'goes to done internally as soon as the task finishes',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
@@ -1264,7 +1265,7 @@ void main() {
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'goes back to inactive when retracting back past 10% of arming distance',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
@@ -1349,7 +1350,7 @@ void main() {
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'goes back to inactive if already scrolled away when task completes',
|
||||
(WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
@@ -1413,7 +1414,7 @@ void main() {
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
"don't have to build any indicators or occupy space during refresh",
|
||||
(WidgetTester tester) async {
|
||||
mockHelper.refreshIndicator = const Center(child: Text('-1'));
|
||||
@@ -1463,7 +1464,7 @@ void main() {
|
||||
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
|
||||
);
|
||||
|
||||
testWidgets('buildRefreshIndicator progress', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('buildRefreshIndicator progress', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Builder(
|
||||
@@ -1510,7 +1511,7 @@ void main() {
|
||||
expect(tester.widget<CupertinoActivityIndicator>(find.byType(CupertinoActivityIndicator)).progress, 100.0 / 100.0);
|
||||
});
|
||||
|
||||
testWidgets('indicator should not become larger when overscrolled', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('indicator should not become larger when overscrolled', (WidgetTester tester) async {
|
||||
// test for https://github.com/flutter/flutter/issues/79841
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
@@ -1546,7 +1547,7 @@ void main() {
|
||||
// correct by coincidence.
|
||||
group('state machine test short list', stateMachineTestGroup);
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'Does not crash when paintExtent > remainingPaintExtent',
|
||||
(WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/46871.
|
||||
|
||||
@@ -12,6 +12,7 @@ import 'package:flutter/foundation.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';
|
||||
|
||||
import '../widgets/semantics_tester.dart';
|
||||
|
||||
@@ -22,7 +23,7 @@ void main() {
|
||||
navigatorObserver = MockNavigatorObserver();
|
||||
});
|
||||
|
||||
testWidgets('Middle auto-populates with title', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Middle auto-populates with title', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const CupertinoApp(
|
||||
home: Placeholder(),
|
||||
@@ -52,7 +53,7 @@ void main() {
|
||||
expect(tester.getCenter(find.text('An iPod')).dx, 400.0);
|
||||
});
|
||||
|
||||
testWidgets('Large title auto-populates with title', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Large title auto-populates with title', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const CupertinoApp(
|
||||
home: Placeholder(),
|
||||
@@ -117,7 +118,7 @@ void main() {
|
||||
expect(tester.getCenter(find.byWidget(titles[0].widget)).dx, 400.0);
|
||||
});
|
||||
|
||||
testWidgets('Leading auto-populates with back button with previous title', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Leading auto-populates with back button with previous title', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const CupertinoApp(
|
||||
home: Placeholder(),
|
||||
@@ -164,7 +165,7 @@ void main() {
|
||||
expect(tester.getTopLeft(find.text('An iPod')).dx, moreOrLessEquals(8.0 + 4.0 + 34.0 + 6.0, epsilon: 0.5));
|
||||
});
|
||||
|
||||
testWidgets('Previous title is correct on first transition frame', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Previous title is correct on first transition frame', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const CupertinoApp(
|
||||
home: Placeholder(),
|
||||
@@ -207,7 +208,7 @@ void main() {
|
||||
expect(find.widgetWithText(CupertinoButton, 'An iPod'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Previous title stays up to date with changing routes', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Previous title stays up to date with changing routes', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const CupertinoApp(
|
||||
home: Placeholder(),
|
||||
@@ -271,7 +272,7 @@ void main() {
|
||||
expect(tester.getTopLeft(find.text('Back')).dx, moreOrLessEquals(8.0 + 4.0 + 34.0 + 6.0, epsilon: 0.5));
|
||||
});
|
||||
|
||||
testWidgets('Back swipe dismiss interrupted by route push', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Back swipe dismiss interrupted by route push', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/28728
|
||||
final GlobalKey scaffoldKey = GlobalKey();
|
||||
|
||||
@@ -377,7 +378,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Fullscreen route animates correct transform values over time', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Fullscreen route animates correct transform values over time', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
home: Builder(
|
||||
@@ -562,11 +563,11 @@ void main() {
|
||||
expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(-0.0, epsilon: 1.0));
|
||||
}
|
||||
|
||||
testWidgets('CupertinoPageRoute has parallax when non fullscreenDialog route is pushed on top', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('CupertinoPageRoute has parallax when non fullscreenDialog route is pushed on top', (WidgetTester tester) async {
|
||||
await testParallax(tester, fromFullscreenDialog: false);
|
||||
});
|
||||
|
||||
testWidgets('FullscreenDialog CupertinoPageRoute has parallax when non fullscreenDialog route is pushed on top', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('FullscreenDialog CupertinoPageRoute has parallax when non fullscreenDialog route is pushed on top', (WidgetTester tester) async {
|
||||
await testParallax(tester, fromFullscreenDialog: true);
|
||||
});
|
||||
|
||||
@@ -651,15 +652,15 @@ void main() {
|
||||
expect(tester.getTopLeft(find.byType(Placeholder)).dx, 0.0);
|
||||
}
|
||||
|
||||
testWidgets('CupertinoPageRoute has no parallax when fullscreenDialog route is pushed on top', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('CupertinoPageRoute has no parallax when fullscreenDialog route is pushed on top', (WidgetTester tester) async {
|
||||
await testNoParallax(tester, fromFullscreenDialog: false);
|
||||
});
|
||||
|
||||
testWidgets('FullscreenDialog CupertinoPageRoute has no parallax when fullscreenDialog route is pushed on top', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('FullscreenDialog CupertinoPageRoute has no parallax when fullscreenDialog route is pushed on top', (WidgetTester tester) async {
|
||||
await testNoParallax(tester, fromFullscreenDialog: true);
|
||||
});
|
||||
|
||||
testWidgets('Animated push/pop is not linear', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Animated push/pop is not linear', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const CupertinoApp(
|
||||
home: Text('1'),
|
||||
@@ -711,7 +712,7 @@ void main() {
|
||||
expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(607, epsilon: 1));
|
||||
});
|
||||
|
||||
testWidgets('Dragged pop gesture is linear', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Dragged pop gesture is linear', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const CupertinoApp(
|
||||
home: Text('1'),
|
||||
@@ -757,7 +758,7 @@ void main() {
|
||||
expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(300));
|
||||
});
|
||||
|
||||
testWidgets('Pop gesture snapping is not linear', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Pop gesture snapping is not linear', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const CupertinoApp(
|
||||
home: Text('1'),
|
||||
@@ -804,7 +805,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Snapped drags forwards and backwards should signal didStart/StopUserGesture', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Snapped drags forwards and backwards should signal didStart/StopUserGesture', (WidgetTester tester) async {
|
||||
final GlobalKey<NavigatorState> navigatorKey = GlobalKey();
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
@@ -858,7 +859,7 @@ void main() {
|
||||
});
|
||||
|
||||
/// Regression test for https://github.com/flutter/flutter/issues/29596.
|
||||
testWidgets('test edge swipe then drop back at ending point works', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('test edge swipe then drop back at ending point works', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
navigatorObservers: <NavigatorObserver>[navigatorObserver],
|
||||
@@ -895,7 +896,7 @@ void main() {
|
||||
expect(navigatorObserver.invocations.removeLast(), NavigatorInvocation.didPop);
|
||||
});
|
||||
|
||||
testWidgets('test edge swipe then drop back at starting point works', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('test edge swipe then drop back at starting point works', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
navigatorObservers: <NavigatorObserver>[navigatorObserver],
|
||||
@@ -952,7 +953,7 @@ void main() {
|
||||
);
|
||||
}
|
||||
|
||||
testWidgets('when route is not fullscreenDialog, it has a barrierColor', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('when route is not fullscreenDialog, it has a barrierColor', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: SizedBox.expand(),
|
||||
@@ -967,7 +968,7 @@ void main() {
|
||||
expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, const Color(0x18000000));
|
||||
});
|
||||
|
||||
testWidgets('when route is a fullscreenDialog, it has no barrierColor', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('when route is a fullscreenDialog, it has no barrierColor', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const MaterialApp(
|
||||
home: SizedBox.expand(),
|
||||
@@ -982,7 +983,7 @@ void main() {
|
||||
expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, isNull);
|
||||
});
|
||||
|
||||
testWidgets('when route is not fullscreenDialog, it has a _CupertinoEdgeShadowDecoration', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('when route is not fullscreenDialog, it has a _CupertinoEdgeShadowDecoration', (WidgetTester tester) async {
|
||||
PaintPattern paintsShadowRect({required double dx, required Color color}) {
|
||||
return paints..everything((Symbol methodName, List<dynamic> arguments) {
|
||||
if (methodName != #drawRect) {
|
||||
@@ -1072,7 +1073,7 @@ void main() {
|
||||
expect(box, paintsShadowRect(dx: 754, color: const Color(0x00000000)));
|
||||
});
|
||||
|
||||
testWidgets('when route is fullscreenDialog, it has no visible _CupertinoEdgeShadowDecoration', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('when route is fullscreenDialog, it has no visible _CupertinoEdgeShadowDecoration', (WidgetTester tester) async {
|
||||
PaintPattern paintsNoShadows() {
|
||||
return paints..everything((Symbol methodName, List<dynamic> arguments) {
|
||||
if (methodName != #drawRect) {
|
||||
@@ -1114,7 +1115,7 @@ void main() {
|
||||
});
|
||||
});
|
||||
|
||||
testWidgets('ModalPopup overlay dark mode', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('ModalPopup overlay dark mode', (WidgetTester tester) async {
|
||||
late StateSetter stateSetter;
|
||||
Brightness brightness = Brightness.light;
|
||||
|
||||
@@ -1187,7 +1188,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('During back swipe the route ignores input', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('During back swipe the route ignores input', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/39989
|
||||
|
||||
final GlobalKey homeScaffoldKey = GlobalKey();
|
||||
@@ -1250,7 +1251,7 @@ void main() {
|
||||
expect(pageTapCount, 1);
|
||||
});
|
||||
|
||||
testWidgets('showCupertinoModalPopup uses root navigator by default', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('showCupertinoModalPopup uses root navigator by default', (WidgetTester tester) async {
|
||||
final PopupObserver rootObserver = PopupObserver();
|
||||
final PopupObserver nestedObserver = PopupObserver();
|
||||
|
||||
@@ -1283,7 +1284,7 @@ void main() {
|
||||
expect(nestedObserver.popupCount, 0);
|
||||
});
|
||||
|
||||
testWidgets('back swipe to screen edges does not dismiss the hero animation', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('back swipe to screen edges does not dismiss the hero animation', (WidgetTester tester) async {
|
||||
final GlobalKey<NavigatorState> navigator = GlobalKey<NavigatorState>();
|
||||
final UniqueKey container = UniqueKey();
|
||||
await tester.pumpWidget(CupertinoApp(
|
||||
@@ -1353,7 +1354,7 @@ void main() {
|
||||
expect(firstPosition, greaterThan(thirdPosition));
|
||||
});
|
||||
|
||||
testWidgets('showCupertinoModalPopup uses nested navigator if useRootNavigator is false', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('showCupertinoModalPopup uses nested navigator if useRootNavigator is false', (WidgetTester tester) async {
|
||||
final PopupObserver rootObserver = PopupObserver();
|
||||
final PopupObserver nestedObserver = PopupObserver();
|
||||
|
||||
@@ -1387,7 +1388,7 @@ void main() {
|
||||
expect(nestedObserver.popupCount, 1);
|
||||
});
|
||||
|
||||
testWidgets('showCupertinoDialog uses root navigator by default', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('showCupertinoDialog uses root navigator by default', (WidgetTester tester) async {
|
||||
final DialogObserver rootObserver = DialogObserver();
|
||||
final DialogObserver nestedObserver = DialogObserver();
|
||||
|
||||
@@ -1420,7 +1421,7 @@ void main() {
|
||||
expect(nestedObserver.dialogCount, 0);
|
||||
});
|
||||
|
||||
testWidgets('showCupertinoDialog uses nested navigator if useRootNavigator is false', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('showCupertinoDialog uses nested navigator if useRootNavigator is false', (WidgetTester tester) async {
|
||||
final DialogObserver rootObserver = DialogObserver();
|
||||
final DialogObserver nestedObserver = DialogObserver();
|
||||
|
||||
@@ -1454,7 +1455,7 @@ void main() {
|
||||
expect(nestedObserver.dialogCount, 1);
|
||||
});
|
||||
|
||||
testWidgets('showCupertinoModalPopup does not allow for semantics dismiss by default', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('showCupertinoModalPopup does not allow for semantics dismiss by default', (WidgetTester tester) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
await tester.pumpWidget(CupertinoApp(
|
||||
@@ -1489,7 +1490,7 @@ void main() {
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
testWidgets('showCupertinoModalPopup allows for semantics dismiss when set', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('showCupertinoModalPopup allows for semantics dismiss when set', (WidgetTester tester) async {
|
||||
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
await tester.pumpWidget(CupertinoApp(
|
||||
@@ -1525,7 +1526,7 @@ void main() {
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
testWidgets('showCupertinoModalPopup passes RouteSettings to PopupRoute', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('showCupertinoModalPopup passes RouteSettings to PopupRoute', (WidgetTester tester) async {
|
||||
final RouteSettingsObserver routeSettingsObserver = RouteSettingsObserver();
|
||||
|
||||
await tester.pumpWidget(CupertinoApp(
|
||||
@@ -1556,7 +1557,7 @@ void main() {
|
||||
expect(routeSettingsObserver.routeName, '/modal');
|
||||
});
|
||||
|
||||
testWidgets('showCupertinoModalPopup transparent barrier color is transparent', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('showCupertinoModalPopup transparent barrier color is transparent', (WidgetTester tester) async {
|
||||
const Color kTransparentColor = Color(0x00000000);
|
||||
|
||||
await tester.pumpWidget(CupertinoApp(
|
||||
@@ -1582,7 +1583,7 @@ void main() {
|
||||
expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, null);
|
||||
});
|
||||
|
||||
testWidgets('showCupertinoModalPopup null barrier color must be default gray barrier color', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('showCupertinoModalPopup null barrier color must be default gray barrier color', (WidgetTester tester) async {
|
||||
// Barrier color for a Cupertino modal barrier.
|
||||
// Extracted from https://developer.apple.com/design/resources/.
|
||||
const Color kModalBarrierColor = CupertinoDynamicColor.withBrightness(
|
||||
@@ -1612,7 +1613,7 @@ void main() {
|
||||
expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, kModalBarrierColor);
|
||||
});
|
||||
|
||||
testWidgets('showCupertinoModalPopup custom barrier color', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('showCupertinoModalPopup custom barrier color', (WidgetTester tester) async {
|
||||
const Color customColor = Color(0x11223344);
|
||||
|
||||
await tester.pumpWidget(CupertinoApp(
|
||||
@@ -1638,7 +1639,7 @@ void main() {
|
||||
expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, customColor);
|
||||
});
|
||||
|
||||
testWidgets('showCupertinoModalPopup barrier dismissible', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('showCupertinoModalPopup barrier dismissible', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(CupertinoApp(
|
||||
home: CupertinoPageScaffold(
|
||||
child: Builder(builder: (BuildContext context) {
|
||||
@@ -1663,7 +1664,7 @@ void main() {
|
||||
expect(find.text('Visible'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('showCupertinoModalPopup barrier not dismissible', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('showCupertinoModalPopup barrier not dismissible', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(CupertinoApp(
|
||||
home: CupertinoPageScaffold(
|
||||
child: Builder(builder: (BuildContext context) {
|
||||
@@ -1689,7 +1690,7 @@ void main() {
|
||||
expect(find.text('Visible'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('CupertinoPage works', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('CupertinoPage works', (WidgetTester tester) async {
|
||||
final LocalKey pageKey = UniqueKey();
|
||||
final TransitionDetector detector = TransitionDetector();
|
||||
List<Page<void>> myPages = <Page<void>>[
|
||||
@@ -1750,7 +1751,7 @@ void main() {
|
||||
expect(find.widgetWithText(CupertinoNavigationBar, 'title two'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('CupertinoPage can toggle MaintainState', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('CupertinoPage can toggle MaintainState', (WidgetTester tester) async {
|
||||
final LocalKey pageKeyOne = UniqueKey();
|
||||
final LocalKey pageKeyTwo = UniqueKey();
|
||||
final TransitionDetector detector = TransitionDetector();
|
||||
@@ -1799,7 +1800,7 @@ void main() {
|
||||
expect(find.text('second'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Popping routes should cancel down events', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Popping routes should cancel down events', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(const _TestPostRouteCancel());
|
||||
|
||||
final TestGesture gesture = await tester.createGesture();
|
||||
@@ -1818,7 +1819,7 @@ void main() {
|
||||
expect(find.text('PointerCancelEvents: 1'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Popping routes during back swipe should not crash', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Popping routes during back swipe should not crash', (WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/63984#issuecomment-675679939
|
||||
|
||||
final CupertinoPageRoute<void> r = CupertinoPageRoute<void>(builder: (BuildContext context) {
|
||||
@@ -1868,7 +1869,7 @@ void main() {
|
||||
await tester.pump();
|
||||
});
|
||||
|
||||
testWidgets('CupertinoModalPopupRoute is state restorable', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('CupertinoModalPopupRoute is state restorable', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const CupertinoApp(
|
||||
restorationScopeId: 'app',
|
||||
@@ -1899,7 +1900,7 @@ void main() {
|
||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/33615
|
||||
|
||||
group('showCupertinoDialog avoids overlapping display features', () {
|
||||
testWidgets('positioning with anchorPoint', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('positioning with anchorPoint', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
@@ -1937,7 +1938,7 @@ void main() {
|
||||
expect(tester.getBottomRight(find.byType(Placeholder)), const Offset(800.0, 600.0));
|
||||
});
|
||||
|
||||
testWidgets('positioning with Directionality', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('positioning with Directionality', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
@@ -1977,7 +1978,7 @@ void main() {
|
||||
expect(tester.getBottomRight(find.byType(Placeholder)), const Offset(800.0, 600.0));
|
||||
});
|
||||
|
||||
testWidgets('positioning by default', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('positioning by default', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
@@ -2016,7 +2017,7 @@ void main() {
|
||||
});
|
||||
|
||||
group('showCupertinoModalPopup avoids overlapping display features', () {
|
||||
testWidgets('positioning using anchorPoint', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('positioning using anchorPoint', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
@@ -2054,7 +2055,7 @@ void main() {
|
||||
expect(tester.getBottomRight(find.byType(Placeholder)).dx, 800);
|
||||
});
|
||||
|
||||
testWidgets('positioning using Directionality', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('positioning using Directionality', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
@@ -2094,7 +2095,7 @@ void main() {
|
||||
expect(tester.getBottomRight(find.byType(Placeholder)).dx, 800);
|
||||
});
|
||||
|
||||
testWidgets('default positioning', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('default positioning', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
CupertinoApp(
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -14,6 +14,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';
|
||||
|
||||
import '../widgets/semantics_tester.dart';
|
||||
|
||||
@@ -93,7 +94,7 @@ Color getBackgroundColor(WidgetTester tester, int childIndex) {
|
||||
}
|
||||
|
||||
void main() {
|
||||
testWidgets('Tap changes toggle state', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Tap changes toggle state', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('Child 1');
|
||||
children[1] = const Text('Child 2');
|
||||
@@ -127,7 +128,7 @@ void main() {
|
||||
expect(sharedValue, 1);
|
||||
});
|
||||
|
||||
testWidgets('Need at least 2 children', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Need at least 2 children', (WidgetTester tester) async {
|
||||
await expectLater(
|
||||
() => tester.pumpWidget(
|
||||
boilerplate(
|
||||
@@ -161,7 +162,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Padding works', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Padding works', (WidgetTester tester) async {
|
||||
const Key key = Key('Container');
|
||||
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
@@ -248,7 +249,7 @@ void main() {
|
||||
await verifyPadding(padding: const EdgeInsets.fromLTRB(1, 3, 5, 7));
|
||||
});
|
||||
|
||||
testWidgets('Value attribute must be the key of one of the children widgets', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Value attribute must be the key of one of the children widgets', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('Child 1');
|
||||
children[1] = const Text('Child 2');
|
||||
@@ -271,7 +272,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Widgets have correct default text/icon styles, change correctly on selection', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Widgets have correct default text/icon styles, change correctly on selection', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('Child 1');
|
||||
children[1] = const Icon(IconData(1));
|
||||
@@ -314,7 +315,7 @@ void main() {
|
||||
expect(iconTheme.data.color, isSameColorAs(CupertinoColors.white));
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'Segmented controls respects themes',
|
||||
(WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
@@ -360,7 +361,7 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('SegmentedControl is correct when user provides custom colors', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('SegmentedControl is correct when user provides custom colors', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('Child 1');
|
||||
children[1] = const Icon(IconData(1));
|
||||
@@ -417,7 +418,7 @@ void main() {
|
||||
expect(getBackgroundColor(tester, 1), CupertinoColors.activeGreen.color);
|
||||
});
|
||||
|
||||
testWidgets('Widgets are centered within segments', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Widgets are centered within segments', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('Child 1');
|
||||
children[1] = const Text('Child 2');
|
||||
@@ -444,7 +445,7 @@ void main() {
|
||||
expect(tester.getCenter(find.text('Child 2')), const Offset(142.0, 100.0));
|
||||
});
|
||||
|
||||
testWidgets('Tap calls onValueChanged', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Tap calls onValueChanged', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('Child 1');
|
||||
children[1] = const Text('Child 2');
|
||||
@@ -473,7 +474,7 @@ void main() {
|
||||
expect(value, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('State does not change if onValueChanged does not call setState()', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('State does not change if onValueChanged does not call setState()', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('Child 1');
|
||||
children[1] = const Text('Child 2');
|
||||
@@ -504,7 +505,7 @@ void main() {
|
||||
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white));
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'Background color of child should change on selection, '
|
||||
'and should not change when tapped again',
|
||||
(WidgetTester tester) async {
|
||||
@@ -524,7 +525,7 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'Children can be non-Text or Icon widgets (in this case, '
|
||||
'a Container or Placeholder widget)',
|
||||
(WidgetTester tester) async {
|
||||
@@ -557,7 +558,7 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Passed in value is child initially selected', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Passed in value is child initially selected', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(setupSimpleSegmentedControl());
|
||||
|
||||
expect(getSelectedIndex(tester), 0);
|
||||
@@ -566,7 +567,7 @@ void main() {
|
||||
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white));
|
||||
});
|
||||
|
||||
testWidgets('Null input for value results in no child initially selected', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Null input for value results in no child initially selected', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('Child 1');
|
||||
children[1] = const Text('Child 2');
|
||||
@@ -597,7 +598,7 @@ void main() {
|
||||
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white));
|
||||
});
|
||||
|
||||
testWidgets('Long press changes background color of not-selected child', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Long press changes background color of not-selected child', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(setupSimpleSegmentedControl());
|
||||
|
||||
expect(getBackgroundColor(tester, 0), CupertinoColors.activeBlue);
|
||||
@@ -611,7 +612,7 @@ void main() {
|
||||
expect(getBackgroundColor(tester, 1), const Color(0x33007aff));
|
||||
});
|
||||
|
||||
testWidgets('Long press does not change background color of currently-selected child', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Long press does not change background color of currently-selected child', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(setupSimpleSegmentedControl());
|
||||
|
||||
expect(getBackgroundColor(tester, 0), CupertinoColors.activeBlue);
|
||||
@@ -625,7 +626,7 @@ void main() {
|
||||
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white));
|
||||
});
|
||||
|
||||
testWidgets('Height of segmented control is determined by tallest widget', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Height of segmented control is determined by tallest widget', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = Container(
|
||||
constraints: const BoxConstraints.tightFor(height: 100.0),
|
||||
@@ -656,7 +657,7 @@ void main() {
|
||||
expect(buttonBox.size.height, 400.0);
|
||||
});
|
||||
|
||||
testWidgets('Width of each segmented control segment is determined by widest widget', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Width of each segmented control segment is determined by widest widget', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = Container(
|
||||
constraints: const BoxConstraints.tightFor(width: 50.0),
|
||||
@@ -695,7 +696,7 @@ void main() {
|
||||
expect(childWidth, getSurroundingRect(tester, child: 2).width);
|
||||
});
|
||||
|
||||
testWidgets('Width is finite in unbounded space', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Width is finite in unbounded space', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('Child 1');
|
||||
children[1] = const Text('Child 2');
|
||||
@@ -723,7 +724,7 @@ void main() {
|
||||
expect(segmentedControl.size.width.isFinite, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Directionality test - RTL should reverse order of widgets', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Directionality test - RTL should reverse order of widgets', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('Child 1');
|
||||
children[1] = const Text('Child 2');
|
||||
@@ -743,7 +744,7 @@ void main() {
|
||||
expect(tester.getTopRight(find.text('Child 1')).dx > tester.getTopRight(find.text('Child 2')).dx, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('Correct initial selection and toggling behavior - RTL', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Correct initial selection and toggling behavior - RTL', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('Child 1');
|
||||
children[1] = const Text('Child 2');
|
||||
@@ -786,7 +787,7 @@ void main() {
|
||||
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
|
||||
});
|
||||
|
||||
testWidgets('Segmented control semantics', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Segmented control semantics', (WidgetTester tester) async {
|
||||
final SemanticsTester semantics = SemanticsTester(tester);
|
||||
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
@@ -889,7 +890,7 @@ void main() {
|
||||
semantics.dispose();
|
||||
});
|
||||
|
||||
testWidgets('Non-centered taps work on smaller widgets', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Non-centered taps work on smaller widgets', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('Child 1');
|
||||
children[1] = const Text('Child 2');
|
||||
@@ -931,7 +932,7 @@ void main() {
|
||||
expect(sharedValue, 0);
|
||||
});
|
||||
|
||||
testWidgets('Hit-tests report accurate local position in segments', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Hit-tests report accurate local position in segments', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
late TapDownDetails tapDownDetails;
|
||||
children[0] = GestureDetector(
|
||||
@@ -971,7 +972,7 @@ void main() {
|
||||
expect(tapDownDetails.globalPosition, segment0GlobalOffset + const Offset(7, 11));
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
testWidgetsWithLeakTracking(
|
||||
'Segment still hittable with a child that has no hitbox',
|
||||
(WidgetTester tester) async {
|
||||
// Regression test for https://github.com/flutter/flutter/issues/57326.
|
||||
@@ -1010,7 +1011,7 @@ void main() {
|
||||
},
|
||||
);
|
||||
|
||||
testWidgets('Animation is correct when the selected segment changes', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Animation is correct when the selected segment changes', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(setupSimpleSegmentedControl());
|
||||
|
||||
await tester.tap(find.text('Child 2'));
|
||||
@@ -1040,7 +1041,7 @@ void main() {
|
||||
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
|
||||
});
|
||||
|
||||
testWidgets('Animation is correct when widget is rebuilt', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Animation is correct when widget is rebuilt', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('Child 1');
|
||||
children[1] = const Text('Child 2');
|
||||
@@ -1192,7 +1193,7 @@ void main() {
|
||||
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
|
||||
});
|
||||
|
||||
testWidgets('Multiple segments are pressed', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Multiple segments are pressed', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('A');
|
||||
children[1] = const Text('B');
|
||||
@@ -1234,7 +1235,7 @@ void main() {
|
||||
expect(getBackgroundColor(tester, 2), isSameColorAs(CupertinoColors.white));
|
||||
});
|
||||
|
||||
testWidgets('Transition is triggered while a transition is already occurring', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Transition is triggered while a transition is already occurring', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('A');
|
||||
children[1] = const Text('B');
|
||||
@@ -1296,7 +1297,7 @@ void main() {
|
||||
expect(getBackgroundColor(tester, 2), CupertinoColors.activeBlue);
|
||||
});
|
||||
|
||||
testWidgets('Segment is selected while it is transitioning to unselected state', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Segment is selected while it is transitioning to unselected state', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(setupSimpleSegmentedControl());
|
||||
|
||||
await tester.tap(find.text('Child 2'));
|
||||
@@ -1324,7 +1325,7 @@ void main() {
|
||||
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white));
|
||||
});
|
||||
|
||||
testWidgets('Add segment while animation is running', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Add segment while animation is running', (WidgetTester tester) async {
|
||||
Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('A');
|
||||
children[1] = const Text('B');
|
||||
@@ -1372,7 +1373,7 @@ void main() {
|
||||
expect(getBackgroundColor(tester, 3), isSameColorAs(CupertinoColors.white));
|
||||
});
|
||||
|
||||
testWidgets('Remove segment while animation is running', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Remove segment while animation is running', (WidgetTester tester) async {
|
||||
Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('A');
|
||||
children[1] = const Text('B');
|
||||
@@ -1417,7 +1418,7 @@ void main() {
|
||||
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
|
||||
});
|
||||
|
||||
testWidgets('Remove currently animating segment', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Remove currently animating segment', (WidgetTester tester) async {
|
||||
Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('A');
|
||||
children[1] = const Text('B');
|
||||
@@ -1469,7 +1470,7 @@ void main() {
|
||||
});
|
||||
|
||||
// Regression test: https://github.com/flutter/flutter/issues/43414.
|
||||
testWidgets("Quick double tap doesn't break the internal state", (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking("Quick double tap doesn't break the internal state", (WidgetTester tester) async {
|
||||
const Map<int, Widget> children = <int, Widget>{
|
||||
0: Text('A'),
|
||||
1: Text('B'),
|
||||
@@ -1509,7 +1510,7 @@ void main() {
|
||||
expect(sharedValue, 2);
|
||||
});
|
||||
|
||||
testWidgets('Golden Test Placeholder Widget', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Golden Test Placeholder Widget', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = Container();
|
||||
children[1] = const Placeholder();
|
||||
@@ -1543,7 +1544,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Golden Test Pressed State', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Golden Test Pressed State', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('A');
|
||||
children[1] = const Text('B');
|
||||
@@ -1581,7 +1582,7 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Hovering over Cupertino segmented control updates cursor to clickable on Web', (WidgetTester tester) async {
|
||||
testWidgetsWithLeakTracking('Hovering over Cupertino segmented control updates cursor to clickable on Web', (WidgetTester tester) async {
|
||||
final Map<int, Widget> children = <int, Widget>{};
|
||||
children[0] = const Text('A');
|
||||
children[1] = const Text('B');
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user