Remove usage of testWidgetsWithLeakTracking. (#140239)

This commit is contained in:
Polina Cherkasova 2023-12-15 14:13:31 -08:00 committed by GitHub
parent 70145886e5
commit baf739c8e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
594 changed files with 9948 additions and 10520 deletions

View File

@ -9,7 +9,6 @@ library;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
@ -18,7 +17,7 @@ void main() {
* because [matchesGoldenFile] does not use Skia Gold in its native package. * because [matchesGoldenFile] does not use Skia Gold in its native package.
*/ */
testWidgetsWithLeakTracking('recording disposes images', testWidgets('recording disposes images',
(WidgetTester tester) async { (WidgetTester tester) async {
final AnimationSheetBuilder builder = AnimationSheetBuilder(frameSize: _DecuplePixels.size); final AnimationSheetBuilder builder = AnimationSheetBuilder(frameSize: _DecuplePixels.size);
addTearDown(builder.dispose); addTearDown(builder.dispose);
@ -34,7 +33,7 @@ void main() {
skip: isBrowser, // [intended] https://github.com/flutter/flutter/issues/56001 skip: isBrowser, // [intended] https://github.com/flutter/flutter/issues/56001
); );
testWidgetsWithLeakTracking('correctly records frames using collate', testWidgets('correctly records frames using collate',
(WidgetTester tester) async { (WidgetTester tester) async {
final AnimationSheetBuilder builder = AnimationSheetBuilder(frameSize: _DecuplePixels.size); final AnimationSheetBuilder builder = AnimationSheetBuilder(frameSize: _DecuplePixels.size);
addTearDown(builder.dispose); addTearDown(builder.dispose);
@ -72,7 +71,7 @@ void main() {
skip: isBrowser, // [intended] https://github.com/flutter/flutter/issues/56001 skip: isBrowser, // [intended] https://github.com/flutter/flutter/issues/56001
); // https://github.com/flutter/flutter/issues/56001 ); // https://github.com/flutter/flutter/issues/56001
testWidgetsWithLeakTracking('use allLayers to record out-of-subtree contents', (WidgetTester tester) async { testWidgets('use allLayers to record out-of-subtree contents', (WidgetTester tester) async {
final AnimationSheetBuilder builder = AnimationSheetBuilder( final AnimationSheetBuilder builder = AnimationSheetBuilder(
frameSize: const Size(8, 2), frameSize: const Size(8, 2),
allLayers: true, allLayers: true,

View File

@ -5,7 +5,6 @@
import 'package:flutter/animation.dart'; import 'package:flutter/animation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
test('copyWith, ==, hashCode basics', () { test('copyWith, ==, hashCode basics', () {
@ -13,7 +12,7 @@ void main() {
expect(AnimationStyle().hashCode, AnimationStyle().copyWith().hashCode); expect(AnimationStyle().hashCode, AnimationStyle().copyWith().hashCode);
}); });
testWidgetsWithLeakTracking('AnimationStyle.copyWith() overrides all properties', (WidgetTester tester) async { testWidgets('AnimationStyle.copyWith() overrides all properties', (WidgetTester tester) async {
final AnimationStyle original = AnimationStyle( final AnimationStyle original = AnimationStyle(
curve: Curves.ease, curve: Curves.ease,
duration: const Duration(seconds: 1), duration: const Duration(seconds: 1),
@ -38,7 +37,7 @@ void main() {
expect(identical(AnimationStyle.lerp(data, data, 0.5), data), true); expect(identical(AnimationStyle.lerp(data, data, 0.5), data), true);
}); });
testWidgetsWithLeakTracking('default AnimationStyle debugFillProperties', (WidgetTester tester) async { testWidgets('default AnimationStyle debugFillProperties', (WidgetTester tester) async {
final AnimationStyle a = AnimationStyle( final AnimationStyle a = AnimationStyle(
curve: Curves.ease, curve: Curves.ease,
duration: const Duration(seconds: 1), duration: const Duration(seconds: 1),
@ -57,7 +56,7 @@ void main() {
expect(AnimationStyle.lerp(a, b, 1.0), b); expect(AnimationStyle.lerp(a, b, 1.0), b);
}); });
testWidgetsWithLeakTracking('default AnimationStyle debugFillProperties', (WidgetTester tester) async { testWidgets('default AnimationStyle debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
AnimationStyle().debugFillProperties(builder); AnimationStyle().debugFillProperties(builder);
@ -69,7 +68,7 @@ void main() {
expect(description, <String>[]); expect(description, <String>[]);
}); });
testWidgetsWithLeakTracking('AnimationStyle implements debugFillProperties', (WidgetTester tester) async { testWidgets('AnimationStyle implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
AnimationStyle( AnimationStyle(

View File

@ -5,10 +5,9 @@
import 'package:flutter/animation.dart'; import 'package:flutter/animation.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('awaiting animation controllers - using direct future', (WidgetTester tester) async { testWidgets('awaiting animation controllers - using direct future', (WidgetTester tester) async {
final AnimationController controller1 = AnimationController( final AnimationController controller1 = AnimationController(
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
vsync: const TestVSync(), vsync: const TestVSync(),
@ -60,7 +59,7 @@ void main() {
expect(log, <String>['start', 'a', 'b', 'c', 'd', 'end']); expect(log, <String>['start', 'a', 'b', 'c', 'd', 'end']);
}); });
testWidgetsWithLeakTracking('awaiting animation controllers - using orCancel', (WidgetTester tester) async { testWidgets('awaiting animation controllers - using orCancel', (WidgetTester tester) async {
final AnimationController controller1 = AnimationController( final AnimationController controller1 = AnimationController(
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
vsync: const TestVSync(), vsync: const TestVSync(),
@ -112,7 +111,7 @@ void main() {
expect(log, <String>['start', 'a', 'b', 'c', 'd', 'end']); expect(log, <String>['start', 'a', 'b', 'c', 'd', 'end']);
}); });
testWidgetsWithLeakTracking('awaiting animation controllers and failing', (WidgetTester tester) async { testWidgets('awaiting animation controllers and failing', (WidgetTester tester) async {
final AnimationController controller1 = AnimationController( final AnimationController controller1 = AnimationController(
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
vsync: const TestVSync(), vsync: const TestVSync(),
@ -140,7 +139,7 @@ void main() {
expect(log, <String>['start', 'caught', 'end']); expect(log, <String>['start', 'caught', 'end']);
}); });
testWidgetsWithLeakTracking('creating orCancel future later', (WidgetTester tester) async { testWidgets('creating orCancel future later', (WidgetTester tester) async {
final AnimationController controller1 = AnimationController( final AnimationController controller1 = AnimationController(
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
vsync: const TestVSync(), vsync: const TestVSync(),
@ -154,7 +153,7 @@ void main() {
expect(true, isTrue); // should reach here expect(true, isTrue); // should reach here
}); });
testWidgetsWithLeakTracking('creating orCancel future later', (WidgetTester tester) async { testWidgets('creating orCancel future later', (WidgetTester tester) async {
final AnimationController controller1 = AnimationController( final AnimationController controller1 = AnimationController(
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
vsync: const TestVSync(), vsync: const TestVSync(),
@ -172,7 +171,7 @@ void main() {
expect(ok, isTrue); // should reach here expect(ok, isTrue); // should reach here
}); });
testWidgetsWithLeakTracking('TickerFuture is a Future', (WidgetTester tester) async { testWidgets('TickerFuture is a Future', (WidgetTester tester) async {
final AnimationController controller1 = AnimationController( final AnimationController controller1 = AnimationController(
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
vsync: const TestVSync(), vsync: const TestVSync(),

View File

@ -4,7 +4,6 @@
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
setUp(() { setUp(() {
@ -80,7 +79,7 @@ void main() {
controller.dispose(); controller.dispose();
}); });
testWidgetsWithLeakTracking('AnimationController with throwing listener', (WidgetTester tester) async { testWidgets('AnimationController with throwing listener', (WidgetTester tester) async {
final AnimationController controller = AnimationController( final AnimationController controller = AnimationController(
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
vsync: const TestVSync(), vsync: const TestVSync(),
@ -104,7 +103,7 @@ void main() {
log.clear(); log.clear();
}); });
testWidgetsWithLeakTracking('AnimationController with throwing status listener', (WidgetTester tester) async { testWidgets('AnimationController with throwing status listener', (WidgetTester tester) async {
final AnimationController controller = AnimationController( final AnimationController controller = AnimationController(
duration: const Duration(milliseconds: 100), duration: const Duration(milliseconds: 100),
vsync: const TestVSync(), vsync: const TestVSync(),

View File

@ -9,7 +9,6 @@ library;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
/* /*
@ -19,7 +18,7 @@ void main() {
LiveTestWidgetsFlutterBinding().framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.onlyPumps; LiveTestWidgetsFlutterBinding().framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.onlyPumps;
testWidgetsWithLeakTracking('Should show event indicator for pointer events', (WidgetTester tester) async { testWidgets('Should show event indicator for pointer events', (WidgetTester tester) async {
final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(200, 200), allLayers: true); final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(200, 200), allLayers: true);
addTearDown(animationSheet.dispose); addTearDown(animationSheet.dispose);
final List<Offset> taps = <Offset>[]; final List<Offset> taps = <Offset>[];
@ -78,7 +77,7 @@ void main() {
// Currently skipped due to daily flake: https://github.com/flutter/flutter/issues/87588 // Currently skipped due to daily flake: https://github.com/flutter/flutter/issues/87588
}, skip: true); // Typically skip: isBrowser https://github.com/flutter/flutter/issues/42767 }, skip: true); // Typically skip: isBrowser https://github.com/flutter/flutter/issues/42767
testWidgetsWithLeakTracking('Should show event indicator for pointer events with setSurfaceSize', (WidgetTester tester) async { testWidgets('Should show event indicator for pointer events with setSurfaceSize', (WidgetTester tester) async {
final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(200, 200), allLayers: true); final AnimationSheetBuilder animationSheet = AnimationSheetBuilder(frameSize: const Size(200, 200), allLayers: true);
addTearDown(animationSheet.dispose); addTearDown(animationSheet.dispose);
final List<Offset> taps = <Offset>[]; final List<Offset> taps = <Offset>[];

View File

@ -9,12 +9,11 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
void main() { void main() {
testWidgetsWithLeakTracking('Verify that a tap on modal barrier dismisses an action sheet', (WidgetTester tester) async { testWidgets('Verify that a tap on modal barrier dismisses an action sheet', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
const CupertinoActionSheet( const CupertinoActionSheet(
@ -33,7 +32,7 @@ void main() {
expect(find.text('Action Sheet'), findsNothing); expect(find.text('Action Sheet'), findsNothing);
}); });
testWidgetsWithLeakTracking('Verify that a tap on title section (not buttons) does not dismiss an action sheet', (WidgetTester tester) async { testWidgets('Verify that a tap on title section (not buttons) does not dismiss an action sheet', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
const CupertinoActionSheet( const CupertinoActionSheet(
@ -53,7 +52,7 @@ void main() {
expect(find.text('Action Sheet'), findsOneWidget); expect(find.text('Action Sheet'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Action sheet destructive text style', (WidgetTester tester) async { testWidgets('Action sheet destructive text style', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
CupertinoActionSheetAction( CupertinoActionSheetAction(
@ -74,7 +73,7 @@ void main() {
)); ));
}); });
testWidgetsWithLeakTracking('Action sheet dark mode', (WidgetTester tester) async { testWidgets('Action sheet dark mode', (WidgetTester tester) async {
final Widget action = CupertinoActionSheetAction( final Widget action = CupertinoActionSheetAction(
child: const Text('action'), child: const Text('action'),
onPressed: () {}, onPressed: () {},
@ -131,7 +130,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Action sheet default text style', (WidgetTester tester) async { testWidgets('Action sheet default text style', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
CupertinoActionSheetAction( CupertinoActionSheetAction(
@ -147,7 +146,7 @@ void main() {
expect(widget.style.fontWeight, equals(FontWeight.w600)); expect(widget.style.fontWeight, equals(FontWeight.w600));
}); });
testWidgetsWithLeakTracking('Action sheet text styles are correct when both title and message are included', (WidgetTester tester) async { testWidgets('Action sheet text styles are correct when both title and message are included', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
const CupertinoActionSheet( const CupertinoActionSheet(
@ -167,7 +166,7 @@ void main() {
expect(messageStyle.style.fontWeight, FontWeight.w400); expect(messageStyle.style.fontWeight, FontWeight.w400);
}); });
testWidgetsWithLeakTracking('Action sheet text styles are correct when title but no message is included', (WidgetTester tester) async { testWidgets('Action sheet text styles are correct when title but no message is included', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
const CupertinoActionSheet( const CupertinoActionSheet(
@ -184,7 +183,7 @@ void main() {
expect(titleStyle.style.fontWeight, FontWeight.w400); expect(titleStyle.style.fontWeight, FontWeight.w400);
}); });
testWidgetsWithLeakTracking('Action sheet text styles are correct when message but no title is included', (WidgetTester tester) async { testWidgets('Action sheet text styles are correct when message but no title is included', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
const CupertinoActionSheet( const CupertinoActionSheet(
@ -201,7 +200,7 @@ void main() {
expect(messageStyle.style.fontWeight, FontWeight.w600); expect(messageStyle.style.fontWeight, FontWeight.w600);
}); });
testWidgetsWithLeakTracking('Content section but no actions', (WidgetTester tester) async { testWidgets('Content section but no actions', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -239,7 +238,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Actions but no content section', (WidgetTester tester) async { testWidgets('Actions but no content section', (WidgetTester tester) async {
final ScrollController actionScrollController = ScrollController(); final ScrollController actionScrollController = ScrollController();
addTearDown(actionScrollController.dispose); addTearDown(actionScrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -288,7 +287,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Action section is scrollable', (WidgetTester tester) async { testWidgets('Action section is scrollable', (WidgetTester tester) async {
final ScrollController actionScrollController = ScrollController(); final ScrollController actionScrollController = ScrollController();
addTearDown(actionScrollController.dispose); addTearDown(actionScrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -354,7 +353,7 @@ void main() {
expect(tester.getSize(find.widgetWithText(CupertinoActionSheetAction, 'Five')).height, equals(83.0)); expect(tester.getSize(find.widgetWithText(CupertinoActionSheetAction, 'Five')).height, equals(83.0));
}); });
testWidgetsWithLeakTracking('Content section is scrollable', (WidgetTester tester) async { testWidgets('Content section is scrollable', (WidgetTester tester) async {
final ScrollController messageScrollController = ScrollController(); final ScrollController messageScrollController = ScrollController();
addTearDown(messageScrollController.dispose); addTearDown(messageScrollController.dispose);
late double screenHeight; late double screenHeight;
@ -397,7 +396,7 @@ void main() {
expect(tester.getSize(find.byType(CupertinoActionSheet)).height, screenHeight); expect(tester.getSize(find.byType(CupertinoActionSheet)).height, screenHeight);
}); });
testWidgetsWithLeakTracking('CupertinoActionSheet scrollbars controllers should be different', (WidgetTester tester) async { testWidgets('CupertinoActionSheet scrollbars controllers should be different', (WidgetTester tester) async {
// https://github.com/flutter/flutter/pull/81278 // https://github.com/flutter/flutter/pull/81278
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
@ -427,7 +426,7 @@ void main() {
expect(scrollbars[0].controller != scrollbars[1].controller, isTrue); expect(scrollbars[0].controller != scrollbars[1].controller, isTrue);
}); });
testWidgetsWithLeakTracking('Tap on button calls onPressed', (WidgetTester tester) async { testWidgets('Tap on button calls onPressed', (WidgetTester tester) async {
bool wasPressed = false; bool wasPressed = false;
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
@ -464,7 +463,7 @@ void main() {
expect(find.text('One'), findsNothing); expect(find.text('One'), findsNothing);
}); });
testWidgetsWithLeakTracking('Action sheet width is correct when given infinite horizontal space', (WidgetTester tester) async { testWidgets('Action sheet width is correct when given infinite horizontal space', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
Row( Row(
@ -492,7 +491,7 @@ void main() {
expect(tester.getSize(find.byType(CupertinoActionSheet)).width, 600.0); expect(tester.getSize(find.byType(CupertinoActionSheet)).width, 600.0);
}); });
testWidgetsWithLeakTracking('Action sheet height is correct when given infinite vertical space', (WidgetTester tester) async { testWidgets('Action sheet height is correct when given infinite vertical space', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
Column( Column(
@ -520,7 +519,7 @@ void main() {
expect(tester.getSize(find.byType(CupertinoActionSheet)).height, moreOrLessEquals(132.3)); expect(tester.getSize(find.byType(CupertinoActionSheet)).height, moreOrLessEquals(132.3));
}); });
testWidgetsWithLeakTracking('1 action button with cancel button', (WidgetTester tester) async { testWidgets('1 action button with cancel button', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
CupertinoActionSheet( CupertinoActionSheet(
@ -547,7 +546,7 @@ void main() {
expect(findScrollableActionsSectionRenderBox(tester).size.height, 56.0); expect(findScrollableActionsSectionRenderBox(tester).size.height, 56.0);
}); });
testWidgetsWithLeakTracking('2 action buttons with cancel button', (WidgetTester tester) async { testWidgets('2 action buttons with cancel button', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
CupertinoActionSheet( CupertinoActionSheet(
@ -577,7 +576,7 @@ void main() {
expect(findScrollableActionsSectionRenderBox(tester).size.height, moreOrLessEquals(112.3)); expect(findScrollableActionsSectionRenderBox(tester).size.height, moreOrLessEquals(112.3));
}); });
testWidgetsWithLeakTracking('3 action buttons with cancel button', (WidgetTester tester) async { testWidgets('3 action buttons with cancel button', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
CupertinoActionSheet( CupertinoActionSheet(
@ -611,7 +610,7 @@ void main() {
expect(findScrollableActionsSectionRenderBox(tester).size.height, moreOrLessEquals(168.6)); expect(findScrollableActionsSectionRenderBox(tester).size.height, moreOrLessEquals(168.6));
}); });
testWidgetsWithLeakTracking('4+ action buttons with cancel button', (WidgetTester tester) async { testWidgets('4+ action buttons with cancel button', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
CupertinoActionSheet( CupertinoActionSheet(
@ -649,7 +648,7 @@ void main() {
expect(findScrollableActionsSectionRenderBox(tester).size.height, moreOrLessEquals(84.3)); expect(findScrollableActionsSectionRenderBox(tester).size.height, moreOrLessEquals(84.3));
}); });
testWidgetsWithLeakTracking('1 action button without cancel button', (WidgetTester tester) async { testWidgets('1 action button without cancel button', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
CupertinoActionSheet( CupertinoActionSheet(
@ -671,7 +670,7 @@ void main() {
expect(findScrollableActionsSectionRenderBox(tester).size.height, 56.0); expect(findScrollableActionsSectionRenderBox(tester).size.height, 56.0);
}); });
testWidgetsWithLeakTracking('2+ action buttons without cancel button', (WidgetTester tester) async { testWidgets('2+ action buttons without cancel button', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
CupertinoActionSheet( CupertinoActionSheet(
@ -697,7 +696,7 @@ void main() {
expect(findScrollableActionsSectionRenderBox(tester).size.height, moreOrLessEquals(84.3)); expect(findScrollableActionsSectionRenderBox(tester).size.height, moreOrLessEquals(84.3));
}); });
testWidgetsWithLeakTracking('Action sheet with just cancel button is correct', (WidgetTester tester) async { testWidgets('Action sheet with just cancel button is correct', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
CupertinoActionSheet( CupertinoActionSheet(
@ -717,7 +716,7 @@ void main() {
expect(tester.getSize(find.byType(CupertinoActionSheet)).width, 600.0); expect(tester.getSize(find.byType(CupertinoActionSheet)).width, 600.0);
}); });
testWidgetsWithLeakTracking('Cancel button tap calls onPressed', (WidgetTester tester) async { testWidgets('Cancel button tap calls onPressed', (WidgetTester tester) async {
bool wasPressed = false; bool wasPressed = false;
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
@ -752,7 +751,7 @@ void main() {
expect(find.text('Cancel'), findsNothing); expect(find.text('Cancel'), findsNothing);
}); });
testWidgetsWithLeakTracking('Layout is correct when cancel button is present', (WidgetTester tester) async { testWidgets('Layout is correct when cancel button is present', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
CupertinoActionSheet( CupertinoActionSheet(
@ -789,7 +788,7 @@ void main() {
expect(tester.getBottomLeft(find.widgetWithText(CupertinoActionSheetAction, 'Two')).dy, 526.0); expect(tester.getBottomLeft(find.widgetWithText(CupertinoActionSheetAction, 'Two')).dy, 526.0);
}); });
testWidgetsWithLeakTracking('Enter/exit animation is correct', (WidgetTester tester) async { testWidgets('Enter/exit animation is correct', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
CupertinoActionSheet( CupertinoActionSheet(
@ -866,7 +865,7 @@ void main() {
expect(find.byType(CupertinoActionSheet), findsNothing); expect(find.byType(CupertinoActionSheet), findsNothing);
}); });
testWidgetsWithLeakTracking('Modal barrier is pressed during transition', (WidgetTester tester) async { testWidgets('Modal barrier is pressed during transition', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
CupertinoActionSheet( CupertinoActionSheet(
@ -924,7 +923,7 @@ void main() {
}); });
testWidgetsWithLeakTracking('Action sheet semantics', (WidgetTester tester) async { testWidgets('Action sheet semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget( await tester.pumpWidget(
@ -1033,7 +1032,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Conflicting scrollbars are not applied by ScrollBehavior to CupertinoActionSheet', (WidgetTester tester) async { testWidgets('Conflicting scrollbars are not applied by ScrollBehavior to CupertinoActionSheet', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/83819 // Regression test for https://github.com/flutter/flutter/issues/83819
final ScrollController actionScrollController = ScrollController(); final ScrollController actionScrollController = ScrollController();
addTearDown(actionScrollController.dispose); addTearDown(actionScrollController.dispose);
@ -1074,7 +1073,7 @@ void main() {
expect(find.byType(CupertinoScrollbar), findsNWidgets(2)); expect(find.byType(CupertinoScrollbar), findsNWidgets(2));
}, variant: TargetPlatformVariant.all()); }, variant: TargetPlatformVariant.all());
testWidgetsWithLeakTracking('Hovering over Cupertino action sheet action updates cursor to clickable on Web', (WidgetTester tester) async { testWidgets('Hovering over Cupertino action sheet action updates cursor to clickable on Web', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesActionSheet( createAppWithButtonThatLaunchesActionSheet(
CupertinoActionSheet( CupertinoActionSheet(

View File

@ -10,10 +10,9 @@ library;
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('Activity indicator animate property works', (WidgetTester tester) async { testWidgets('Activity indicator animate property works', (WidgetTester tester) async {
await tester.pumpWidget(buildCupertinoActivityIndicator()); await tester.pumpWidget(buildCupertinoActivityIndicator());
expect(SchedulerBinding.instance.transientCallbackCount, equals(1)); expect(SchedulerBinding.instance.transientCallbackCount, equals(1));
@ -29,7 +28,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(1)); expect(SchedulerBinding.instance.transientCallbackCount, equals(1));
}); });
testWidgetsWithLeakTracking('Activity indicator dark mode', (WidgetTester tester) async { testWidgets('Activity indicator dark mode', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
Center( Center(
@ -78,7 +77,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Activity indicator 0% in progress', (WidgetTester tester) async { testWidgets('Activity indicator 0% in progress', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
Center( Center(
@ -100,7 +99,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Activity indicator 30% in progress', (WidgetTester tester) async { testWidgets('Activity indicator 30% in progress', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
Center( Center(
@ -122,7 +121,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Activity indicator 100% in progress', (WidgetTester tester) async { testWidgets('Activity indicator 100% in progress', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
Center( Center(
@ -143,7 +142,7 @@ void main() {
}); });
// Regression test for https://github.com/flutter/flutter/issues/41345. // Regression test for https://github.com/flutter/flutter/issues/41345.
testWidgetsWithLeakTracking('has the correct corner radius', (WidgetTester tester) async { testWidgets('has the correct corner radius', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoActivityIndicator(animating: false, radius: 100), const CupertinoActivityIndicator(animating: false, radius: 100),
); );
@ -159,7 +158,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Can specify color', (WidgetTester tester) async { testWidgets('Can specify color', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
Center( Center(

View File

@ -6,7 +6,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/clipboard_utils.dart'; import '../widgets/clipboard_utils.dart';
import '../widgets/live_text_utils.dart'; import '../widgets/live_text_utils.dart';
@ -32,7 +31,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Builds the right toolbar on each platform, including web, and shows buttonItems', (WidgetTester tester) async { testWidgets('Builds the right toolbar on each platform, including web, and shows buttonItems', (WidgetTester tester) async {
const String buttonText = 'Click me'; const String buttonText = 'Click me';
await tester.pumpWidget( await tester.pumpWidget(
@ -73,7 +72,7 @@ void main() {
skip: isBrowser, // [intended] see https://github.com/flutter/flutter/issues/108382 skip: isBrowser, // [intended] see https://github.com/flutter/flutter/issues/108382
); );
testWidgetsWithLeakTracking('Can build children directly as well', (WidgetTester tester) async { testWidgets('Can build children directly as well', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
@ -96,7 +95,7 @@ void main() {
skip: isBrowser, // [intended] see https://github.com/flutter/flutter/issues/108382 skip: isBrowser, // [intended] see https://github.com/flutter/flutter/issues/108382
); );
testWidgetsWithLeakTracking('Can build from EditableTextState', (WidgetTester tester) async { testWidgets('Can build from EditableTextState', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
@ -159,7 +158,7 @@ void main() {
variant: TargetPlatformVariant.all(), variant: TargetPlatformVariant.all(),
); );
testWidgetsWithLeakTracking('Can build for editable text from raw parameters', (WidgetTester tester) async { testWidgets('Can build for editable text from raw parameters', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: Center( home: Center(
@ -237,7 +236,7 @@ void main() {
variant: TargetPlatformVariant.all(), variant: TargetPlatformVariant.all(),
); );
testWidgetsWithLeakTracking('Builds the correct button per-platform', (WidgetTester tester) async { testWidgets('Builds the correct button per-platform', (WidgetTester tester) async {
const String buttonText = 'Click me'; const String buttonText = 'Click me';
await tester.pumpWidget( await tester.pumpWidget(

View File

@ -7,10 +7,9 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('Heroes work', (WidgetTester tester) async { testWidgets('Heroes work', (WidgetTester tester) async {
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: ListView(children: <Widget>[ home: ListView(children: <Widget>[
const Hero(tag: 'a', child: Text('foo')), const Hero(tag: 'a', child: Text('foo')),
@ -40,7 +39,7 @@ void main() {
expect(find.widgetWithText(Navigator, 'foo'), findsOneWidget); expect(find.widgetWithText(Navigator, 'foo'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Has default cupertino localizations', (WidgetTester tester) async { testWidgets('Has default cupertino localizations', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Builder( home: Builder(
@ -62,7 +61,7 @@ void main() {
expect(find.text('Thu Oct 4 '), findsOneWidget); expect(find.text('Thu Oct 4 '), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Can use dynamic color', (WidgetTester tester) async { testWidgets('Can use dynamic color', (WidgetTester tester) async {
const CupertinoDynamicColor dynamicColor = CupertinoDynamicColor.withBrightness( const CupertinoDynamicColor dynamicColor = CupertinoDynamicColor.withBrightness(
color: Color(0xFF000000), color: Color(0xFF000000),
darkColor: Color(0xFF000001), darkColor: Color(0xFF000001),
@ -84,7 +83,7 @@ void main() {
expect(tester.widget<Title>(find.byType(Title)).color.value, 0xFF000001); expect(tester.widget<Title>(find.byType(Title)).color.value, 0xFF000001);
}); });
testWidgetsWithLeakTracking('Can customize initial routes', (WidgetTester tester) async { testWidgets('Can customize initial routes', (WidgetTester tester) async {
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -131,7 +130,7 @@ void main() {
expect(find.text('regular page two'), findsNothing); expect(find.text('regular page two'), findsNothing);
}); });
testWidgetsWithLeakTracking('CupertinoApp.navigatorKey can be updated', (WidgetTester tester) async { testWidgets('CupertinoApp.navigatorKey can be updated', (WidgetTester tester) async {
final GlobalKey<NavigatorState> key1 = GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> key1 = GlobalKey<NavigatorState>();
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
navigatorKey: key1, navigatorKey: key1,
@ -147,7 +146,7 @@ void main() {
expect(key1.currentState, isNull); expect(key1.currentState, isNull);
}); });
testWidgetsWithLeakTracking('CupertinoApp.router works', (WidgetTester tester) async { testWidgets('CupertinoApp.router works', (WidgetTester tester) async {
final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider( final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation( initialRouteInformation: RouteInformation(
uri: Uri.parse('initial'), uri: Uri.parse('initial'),
@ -180,7 +179,7 @@ void main() {
expect(find.text('popped'), findsOneWidget); expect(find.text('popped'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('CupertinoApp.router route information parser is optional', (WidgetTester tester) async { testWidgets('CupertinoApp.router route information parser is optional', (WidgetTester tester) async {
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate( final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate(
builder: (BuildContext context, RouteInformation information) { builder: (BuildContext context, RouteInformation information) {
return Text(information.uri.toString()); return Text(information.uri.toString());
@ -206,7 +205,7 @@ void main() {
expect(find.text('popped'), findsOneWidget); expect(find.text('popped'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('CupertinoApp.router throw if route information provider is provided but no route information parser', (WidgetTester tester) async { testWidgets('CupertinoApp.router throw if route information provider is provided but no route information parser', (WidgetTester tester) async {
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate( final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate(
builder: (BuildContext context, RouteInformation information) { builder: (BuildContext context, RouteInformation information) {
return Text(information.uri.toString()); return Text(information.uri.toString());
@ -233,7 +232,7 @@ void main() {
expect(tester.takeException(), isAssertionError); expect(tester.takeException(), isAssertionError);
}); });
testWidgetsWithLeakTracking('CupertinoApp.router throw if route configuration is provided along with other delegate', (WidgetTester tester) async { testWidgets('CupertinoApp.router throw if route configuration is provided along with other delegate', (WidgetTester tester) async {
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate( final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate(
builder: (BuildContext context, RouteInformation information) { builder: (BuildContext context, RouteInformation information) {
return Text(information.uri.toString()); return Text(information.uri.toString());
@ -255,7 +254,7 @@ void main() {
expect(tester.takeException(), isAssertionError); expect(tester.takeException(), isAssertionError);
}); });
testWidgetsWithLeakTracking('CupertinoApp.router router config works', (WidgetTester tester) async { testWidgets('CupertinoApp.router router config works', (WidgetTester tester) async {
late SimpleNavigatorRouterDelegate delegate; late SimpleNavigatorRouterDelegate delegate;
addTearDown(() => delegate.dispose()); addTearDown(() => delegate.dispose());
final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider( final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider(
@ -292,7 +291,7 @@ void main() {
expect(find.text('popped'), findsOneWidget); expect(find.text('popped'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('CupertinoApp has correct default ScrollBehavior', (WidgetTester tester) async { testWidgets('CupertinoApp has correct default ScrollBehavior', (WidgetTester tester) async {
late BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -307,7 +306,7 @@ void main() {
expect(ScrollConfiguration.of(capturedContext).runtimeType, CupertinoScrollBehavior); expect(ScrollConfiguration.of(capturedContext).runtimeType, CupertinoScrollBehavior);
}); });
testWidgetsWithLeakTracking('A ScrollBehavior can be set for CupertinoApp', (WidgetTester tester) async { testWidgets('A ScrollBehavior can be set for CupertinoApp', (WidgetTester tester) async {
late BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -325,7 +324,7 @@ void main() {
expect(scrollBehavior.getScrollPhysics(capturedContext).runtimeType, NeverScrollableScrollPhysics); expect(scrollBehavior.getScrollPhysics(capturedContext).runtimeType, NeverScrollableScrollPhysics);
}); });
testWidgetsWithLeakTracking('When `useInheritedMediaQuery` is true an existing MediaQuery is used if one is available', (WidgetTester tester) async { testWidgets('When `useInheritedMediaQuery` is true an existing MediaQuery is used if one is available', (WidgetTester tester) async {
late BuildContext capturedContext; late BuildContext capturedContext;
final UniqueKey uniqueKey = UniqueKey(); final UniqueKey uniqueKey = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
@ -345,7 +344,7 @@ void main() {
expect(capturedContext.dependOnInheritedWidgetOfExactType<MediaQuery>()?.key, uniqueKey); expect(capturedContext.dependOnInheritedWidgetOfExactType<MediaQuery>()?.key, uniqueKey);
}); });
testWidgetsWithLeakTracking('Text color is correctly resolved when CupertinoThemeData.brightness is null', (WidgetTester tester) async { testWidgets('Text color is correctly resolved when CupertinoThemeData.brightness is null', (WidgetTester tester) async {
debugBrightnessOverride = Brightness.dark; debugBrightnessOverride = Brightness.dark;
await tester.pumpWidget( await tester.pumpWidget(
@ -384,7 +383,7 @@ void main() {
debugBrightnessOverride = null; debugBrightnessOverride = null;
}); });
testWidgetsWithLeakTracking('Cursor color is resolved when CupertinoThemeData.brightness is null', (WidgetTester tester) async { testWidgets('Cursor color is resolved when CupertinoThemeData.brightness is null', (WidgetTester tester) async {
debugBrightnessOverride = Brightness.dark; debugBrightnessOverride = Brightness.dark;
RenderEditable findRenderEditable(WidgetTester tester) { RenderEditable findRenderEditable(WidgetTester tester) {
@ -441,7 +440,7 @@ void main() {
debugBrightnessOverride = null; debugBrightnessOverride = null;
}); });
testWidgetsWithLeakTracking('Assert in buildScrollbar that controller != null when using it', (WidgetTester tester) async { testWidgets('Assert in buildScrollbar that controller != null when using it', (WidgetTester tester) async {
const ScrollBehavior defaultBehavior = CupertinoScrollBehavior(); const ScrollBehavior defaultBehavior = CupertinoScrollBehavior();
late BuildContext capturedContext; late BuildContext capturedContext;

View File

@ -7,7 +7,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../image_data.dart'; import '../image_data.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
@ -30,7 +29,7 @@ Future<void> pumpWidgetWithBoilerplate(WidgetTester tester, Widget widget) async
Future<void> main() async { Future<void> main() async {
testWidgetsWithLeakTracking('Need at least 2 tabs', (WidgetTester tester) async { testWidgets('Need at least 2 tabs', (WidgetTester tester) async {
await expectLater( await expectLater(
() => pumpWidgetWithBoilerplate(tester, CupertinoTabBar( () => pumpWidgetWithBoilerplate(tester, CupertinoTabBar(
items: <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
@ -48,7 +47,7 @@ Future<void> main() async {
); );
}); });
testWidgetsWithLeakTracking('Active and inactive colors', (WidgetTester tester) async { testWidgets('Active and inactive colors', (WidgetTester tester) async {
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: CupertinoTabBar( child: CupertinoTabBar(
@ -82,7 +81,7 @@ Future<void> main() async {
}); });
testWidgetsWithLeakTracking('BottomNavigationBar.label will create a text widget', (WidgetTester tester) async { testWidgets('BottomNavigationBar.label will create a text widget', (WidgetTester tester) async {
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: CupertinoTabBar( child: CupertinoTabBar(
@ -104,7 +103,7 @@ Future<void> main() async {
expect(find.text('Tab 2'), findsOneWidget); expect(find.text('Tab 2'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Active and inactive colors dark mode', (WidgetTester tester) async { testWidgets('Active and inactive colors dark mode', (WidgetTester tester) async {
const CupertinoDynamicColor dynamicActiveColor = CupertinoDynamicColor.withBrightness( const CupertinoDynamicColor dynamicActiveColor = CupertinoDynamicColor.withBrightness(
color: Color(0xFF000000), color: Color(0xFF000000),
darkColor: Color(0xFF000001), darkColor: Color(0xFF000001),
@ -192,7 +191,7 @@ Future<void> main() async {
expect(decoration2.border!.top.color.value, 0x29000000); expect(decoration2.border!.top.color.value, 0x29000000);
}); });
testWidgetsWithLeakTracking('Tabs respects themes', (WidgetTester tester) async { testWidgets('Tabs respects themes', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTabBar( home: CupertinoTabBar(
@ -256,7 +255,7 @@ Future<void> main() async {
expect(actualActive.text.style!.color, isSameColorAs(CupertinoColors.activeBlue.darkColor)); expect(actualActive.text.style!.color, isSameColorAs(CupertinoColors.activeBlue.darkColor));
}); });
testWidgetsWithLeakTracking('Use active icon', (WidgetTester tester) async { testWidgets('Use active icon', (WidgetTester tester) async {
final MemoryImage activeIcon = MemoryImage(Uint8List.fromList(kBlueSquarePng)); final MemoryImage activeIcon = MemoryImage(Uint8List.fromList(kBlueSquarePng));
final MemoryImage inactiveIcon = MemoryImage(Uint8List.fromList(kTransparentImage)); final MemoryImage inactiveIcon = MemoryImage(Uint8List.fromList(kTransparentImage));
@ -289,7 +288,7 @@ Future<void> main() async {
expect(image.image, activeIcon); expect(image.image, activeIcon);
}); });
testWidgetsWithLeakTracking('Adjusts height to account for bottom padding', (WidgetTester tester) async { testWidgets('Adjusts height to account for bottom padding', (WidgetTester tester) async {
final CupertinoTabBar tabBar = CupertinoTabBar( final CupertinoTabBar tabBar = CupertinoTabBar(
items: <BottomNavigationBarItem>[ items: <BottomNavigationBarItem>[
BottomNavigationBarItem( BottomNavigationBarItem(
@ -328,7 +327,7 @@ Future<void> main() async {
expect(tester.getSize(find.byType(CupertinoTabBar)).height, 90.0); expect(tester.getSize(find.byType(CupertinoTabBar)).height, 90.0);
}); });
testWidgetsWithLeakTracking('Set custom height', (WidgetTester tester) async { testWidgets('Set custom height', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/51704 // Regression test for https://github.com/flutter/flutter/issues/51704
const double tabBarHeight = 56.0; const double tabBarHeight = 56.0;
final CupertinoTabBar tabBar = CupertinoTabBar( final CupertinoTabBar tabBar = CupertinoTabBar(
@ -371,7 +370,7 @@ Future<void> main() async {
expect(tester.getSize(find.byType(CupertinoTabBar)).height, tabBarHeight + bottomPadding); expect(tester.getSize(find.byType(CupertinoTabBar)).height, tabBarHeight + bottomPadding);
}); });
testWidgetsWithLeakTracking('Ensure bar height will not change when toggle keyboard', (WidgetTester tester) async { testWidgets('Ensure bar height will not change when toggle keyboard', (WidgetTester tester) async {
const double tabBarHeight = 56.0; const double tabBarHeight = 56.0;
final CupertinoTabBar tabBar = CupertinoTabBar( final CupertinoTabBar tabBar = CupertinoTabBar(
height: tabBarHeight, height: tabBarHeight,
@ -425,7 +424,7 @@ Future<void> main() async {
expect(tester.getSize(find.byType(CupertinoTabBar)).height, tabBarHeight + bottomPadding); expect(tester.getSize(find.byType(CupertinoTabBar)).height, tabBarHeight + bottomPadding);
}); });
testWidgetsWithLeakTracking('Opaque background does not add blur effects', (WidgetTester tester) async { testWidgets('Opaque background does not add blur effects', (WidgetTester tester) async {
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
data: const MediaQueryData(), data: const MediaQueryData(),
child: CupertinoTabBar( child: CupertinoTabBar(
@ -464,7 +463,7 @@ Future<void> main() async {
expect(find.byType(BackdropFilter), findsNothing); expect(find.byType(BackdropFilter), findsNothing);
}); });
testWidgetsWithLeakTracking('Tap callback', (WidgetTester tester) async { testWidgets('Tap callback', (WidgetTester tester) async {
late int callbackTab; late int callbackTab;
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
@ -492,7 +491,7 @@ Future<void> main() async {
expect(callbackTab, 1); expect(callbackTab, 1);
}); });
testWidgetsWithLeakTracking('tabs announce semantics', (WidgetTester tester) async { testWidgets('tabs announce semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await pumpWidgetWithBoilerplate(tester, MediaQuery( await pumpWidgetWithBoilerplate(tester, MediaQuery(
@ -527,7 +526,7 @@ Future<void> main() async {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Label of items should be nullable', (WidgetTester tester) async { testWidgets('Label of items should be nullable', (WidgetTester tester) async {
final MemoryImage iconProvider = MemoryImage(Uint8List.fromList(kTransparentImage)); final MemoryImage iconProvider = MemoryImage(Uint8List.fromList(kTransparentImage));
final List<int> itemsTapped = <int>[]; final List<int> itemsTapped = <int>[];
@ -564,7 +563,7 @@ Future<void> main() async {
expect(itemsTapped, <int>[1]); expect(itemsTapped, <int>[1]);
}); });
testWidgetsWithLeakTracking('Hide border hides the top border of the tabBar', (WidgetTester tester) async { testWidgets('Hide border hides the top border of the tabBar', (WidgetTester tester) async {
await pumpWidgetWithBoilerplate( await pumpWidgetWithBoilerplate(
tester, tester,
MediaQuery( MediaQuery(
@ -624,7 +623,7 @@ Future<void> main() async {
expect(boxDecorationHiddenBorder.border, isNull); expect(boxDecorationHiddenBorder.border, isNull);
}); });
testWidgetsWithLeakTracking('Hovering over tab bar item updates cursor to clickable on Web', (WidgetTester tester) async { testWidgets('Hovering over tab bar item updates cursor to clickable on Web', (WidgetTester tester) async {
await pumpWidgetWithBoilerplate( await pumpWidgetWithBoilerplate(
tester, tester,
MediaQuery( MediaQuery(

View File

@ -8,7 +8,6 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
@ -18,7 +17,7 @@ const TextStyle testStyle = TextStyle(
); );
void main() { void main() {
testWidgetsWithLeakTracking('Default layout minimum size', (WidgetTester tester) async { testWidgets('Default layout minimum size', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate(child: const CupertinoButton( boilerplate(child: const CupertinoButton(
onPressed: null, onPressed: null,
@ -33,7 +32,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Minimum size parameter', (WidgetTester tester) async { testWidgets('Minimum size parameter', (WidgetTester tester) async {
const double minSize = 60.0; const double minSize = 60.0;
await tester.pumpWidget( await tester.pumpWidget(
boilerplate(child: const CupertinoButton( boilerplate(child: const CupertinoButton(
@ -50,7 +49,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Size grows with text', (WidgetTester tester) async { testWidgets('Size grows with text', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate(child: const CupertinoButton( boilerplate(child: const CupertinoButton(
onPressed: null, onPressed: null,
@ -68,7 +67,7 @@ void main() {
// TODO(LongCatIsLoong): Uncomment once https://github.com/flutter/flutter/issues/44115 // TODO(LongCatIsLoong): Uncomment once https://github.com/flutter/flutter/issues/44115
// is fixed. // is fixed.
/* /*
testWidgetsWithLeakTracking( testWidgets(
'CupertinoButton.filled default color contrast meets guideline', 'CupertinoButton.filled default color contrast meets guideline',
(WidgetTester tester) async { (WidgetTester tester) async {
// The native color combination systemBlue text over white background fails // The native color combination systemBlue text over white background fails
@ -103,7 +102,7 @@ void main() {
}); });
*/ */
testWidgetsWithLeakTracking('Button child alignment', (WidgetTester tester) async { testWidgets('Button child alignment', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoButton( home: CupertinoButton(
@ -130,7 +129,7 @@ void main() {
expect(align.alignment, Alignment.centerLeft); expect(align.alignment, Alignment.centerLeft);
}); });
testWidgetsWithLeakTracking('Button with background is wider', (WidgetTester tester) async { testWidgets('Button with background is wider', (WidgetTester tester) async {
await tester.pumpWidget(boilerplate(child: const CupertinoButton( await tester.pumpWidget(boilerplate(child: const CupertinoButton(
onPressed: null, onPressed: null,
color: Color(0xFFFFFFFF), color: Color(0xFFFFFFFF),
@ -144,7 +143,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Custom padding', (WidgetTester tester) async { testWidgets('Custom padding', (WidgetTester tester) async {
await tester.pumpWidget(boilerplate(child: const CupertinoButton( await tester.pumpWidget(boilerplate(child: const CupertinoButton(
onPressed: null, onPressed: null,
padding: EdgeInsets.all(100.0), padding: EdgeInsets.all(100.0),
@ -157,7 +156,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Button takes taps', (WidgetTester tester) async { testWidgets('Button takes taps', (WidgetTester tester) async {
bool value = false; bool value = false;
await tester.pumpWidget( await tester.pumpWidget(
StatefulBuilder( StatefulBuilder(
@ -185,7 +184,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(1)); expect(SchedulerBinding.instance.transientCallbackCount, equals(1));
}); });
testWidgetsWithLeakTracking("Disabled button doesn't animate", (WidgetTester tester) async { testWidgets("Disabled button doesn't animate", (WidgetTester tester) async {
await tester.pumpWidget(boilerplate(child: const CupertinoButton( await tester.pumpWidget(boilerplate(child: const CupertinoButton(
onPressed: null, onPressed: null,
child: Text('Tap me'), child: Text('Tap me'),
@ -196,7 +195,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
}); });
testWidgetsWithLeakTracking('Enabled button animates', (WidgetTester tester) async { testWidgets('Enabled button animates', (WidgetTester tester) async {
await tester.pumpWidget(boilerplate(child: CupertinoButton( await tester.pumpWidget(boilerplate(child: CupertinoButton(
child: const Text('Tap me'), child: const Text('Tap me'),
onPressed: () { }, onPressed: () { },
@ -232,7 +231,7 @@ void main() {
expect(transition.opacity.value, moreOrLessEquals(1.0, epsilon: 0.001)); expect(transition.opacity.value, moreOrLessEquals(1.0, epsilon: 0.001));
}); });
testWidgetsWithLeakTracking('pressedOpacity defaults to 0.1', (WidgetTester tester) async { testWidgets('pressedOpacity defaults to 0.1', (WidgetTester tester) async {
await tester.pumpWidget(boilerplate(child: CupertinoButton( await tester.pumpWidget(boilerplate(child: CupertinoButton(
child: const Text('Tap me'), child: const Text('Tap me'),
onPressed: () { }, onPressed: () { },
@ -255,7 +254,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('pressedOpacity parameter', (WidgetTester tester) async { testWidgets('pressedOpacity parameter', (WidgetTester tester) async {
const double pressedOpacity = 0.5; const double pressedOpacity = 0.5;
await tester.pumpWidget(boilerplate(child: CupertinoButton( await tester.pumpWidget(boilerplate(child: CupertinoButton(
pressedOpacity: pressedOpacity, pressedOpacity: pressedOpacity,
@ -280,7 +279,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Cupertino button is semantically a button', (WidgetTester tester) async { testWidgets('Cupertino button is semantically a button', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
@ -311,7 +310,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Can specify colors', (WidgetTester tester) async { testWidgets('Can specify colors', (WidgetTester tester) async {
await tester.pumpWidget(boilerplate(child: CupertinoButton( await tester.pumpWidget(boilerplate(child: CupertinoButton(
color: const Color(0x000000FF), color: const Color(0x000000FF),
disabledColor: const Color(0x0000FF00), disabledColor: const Color(0x0000FF00),
@ -339,7 +338,7 @@ void main() {
expect(boxDecoration.color, const Color(0x0000FF00)); expect(boxDecoration.color, const Color(0x0000FF00));
}); });
testWidgetsWithLeakTracking('Can specify dynamic colors', (WidgetTester tester) async { testWidgets('Can specify dynamic colors', (WidgetTester tester) async {
const Color bgColor = CupertinoDynamicColor.withBrightness( const Color bgColor = CupertinoDynamicColor.withBrightness(
color: Color(0xFF123456), color: Color(0xFF123456),
darkColor: Color(0xFF654321), darkColor: Color(0xFF654321),
@ -388,7 +387,7 @@ void main() {
expect(boxDecoration.color!.value, 0xFF111111); expect(boxDecoration.color!.value, 0xFF111111);
}); });
testWidgetsWithLeakTracking('Button respects themes', (WidgetTester tester) async { testWidgets('Button respects themes', (WidgetTester tester) async {
late TextStyle textStyle; late TextStyle textStyle;
await tester.pumpWidget( await tester.pumpWidget(
@ -462,7 +461,7 @@ void main() {
expect(decoration.color, isSameColorAs(CupertinoColors.systemBlue.darkColor)); expect(decoration.color, isSameColorAs(CupertinoColors.systemBlue.darkColor));
}); });
testWidgetsWithLeakTracking('Hovering over Cupertino button updates cursor to clickable on Web', (WidgetTester tester) async { testWidgets('Hovering over Cupertino button updates cursor to clickable on Web', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(

View File

@ -7,7 +7,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
@ -16,7 +15,7 @@ void main() {
debugResetSemanticsIdCounter(); debugResetSemanticsIdCounter();
}); });
testWidgetsWithLeakTracking('CupertinoCheckbox semantics', (WidgetTester tester) async { testWidgets('CupertinoCheckbox semantics', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget( await tester.pumpWidget(
@ -156,7 +155,7 @@ void main() {
handle.dispose(); handle.dispose();
}); });
testWidgetsWithLeakTracking('Can wrap CupertinoCheckbox with Semantics', (WidgetTester tester) async { testWidgets('Can wrap CupertinoCheckbox with Semantics', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget( await tester.pumpWidget(
@ -184,7 +183,7 @@ void main() {
handle.dispose(); handle.dispose();
}); });
testWidgetsWithLeakTracking('CupertinoCheckbox tristate: true', (WidgetTester tester) async { testWidgets('CupertinoCheckbox tristate: true', (WidgetTester tester) async {
bool? checkBoxValue; bool? checkBoxValue;
await tester.pumpWidget( await tester.pumpWidget(
@ -228,7 +227,7 @@ void main() {
expect(checkBoxValue, null); expect(checkBoxValue, null);
}); });
testWidgetsWithLeakTracking('has semantics for tristate', (WidgetTester tester) async { testWidgets('has semantics for tristate', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -295,7 +294,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('has semantic events', (WidgetTester tester) async { testWidgets('has semantic events', (WidgetTester tester) async {
dynamic semanticEvent; dynamic semanticEvent;
bool? checkboxValue = false; bool? checkboxValue = false;
tester.binding.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, (dynamic message) async { tester.binding.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, (dynamic message) async {
@ -335,7 +334,7 @@ void main() {
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgetsWithLeakTracking('Checkbox can be toggled by keyboard shortcuts', (WidgetTester tester) async { testWidgets('Checkbox can be toggled by keyboard shortcuts', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
bool? value = true; bool? value = true;
Widget buildApp({bool enabled = true}) { Widget buildApp({bool enabled = true}) {
@ -372,7 +371,7 @@ void main() {
expect(value, isTrue); expect(value, isTrue);
}); });
testWidgetsWithLeakTracking('Checkbox respects shape and side', (WidgetTester tester) async { testWidgets('Checkbox respects shape and side', (WidgetTester tester) async {
const RoundedRectangleBorder roundedRectangleBorder = const RoundedRectangleBorder roundedRectangleBorder =
RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(5))); RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(5)));

View File

@ -5,7 +5,6 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class DependentWidget extends StatelessWidget { class DependentWidget extends StatelessWidget {
const DependentWidget({ const DependentWidget({
@ -201,7 +200,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking( testWidgets(
'Dynamic colors that are not actually dynamic should not claim dependencies', 'Dynamic colors that are not actually dynamic should not claim dependencies',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget(const DependentWidget(color: notSoDynamicColor1)); await tester.pumpWidget(const DependentWidget(color: notSoDynamicColor1));
@ -211,7 +210,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'Dynamic colors that are only dependent on vibrancy should not claim unnecessary dependencies, ' 'Dynamic colors that are only dependent on vibrancy should not claim unnecessary dependencies, '
'and its resolved color should change when its dependency changes', 'and its resolved color should change when its dependency changes',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -255,7 +254,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'Dynamic colors that are only dependent on accessibility contrast should not claim unnecessary dependencies, ' 'Dynamic colors that are only dependent on accessibility contrast should not claim unnecessary dependencies, '
'and its resolved color should change when its dependency changes', 'and its resolved color should change when its dependency changes',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -284,7 +283,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'Dynamic colors that are only dependent on elevation level should not claim unnecessary dependencies, ' 'Dynamic colors that are only dependent on elevation level should not claim unnecessary dependencies, '
'and its resolved color should change when its dependency changes', 'and its resolved color should change when its dependency changes',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -313,7 +312,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('Dynamic color with all 3 dependencies works', (WidgetTester tester) async { testWidgets('Dynamic color with all 3 dependencies works', (WidgetTester tester) async {
const Color dynamicRainbowColor1 = CupertinoDynamicColor( const Color dynamicRainbowColor1 = CupertinoDynamicColor(
color: color0, color: color0,
darkColor: color1, darkColor: color1,
@ -414,7 +413,7 @@ void main() {
expect(find.byType(DependentWidget), paints..rect(color: color7)); expect(find.byType(DependentWidget), paints..rect(color: color7));
}); });
testWidgetsWithLeakTracking('CupertinoDynamicColor used in a CupertinoTheme', (WidgetTester tester) async { testWidgets('CupertinoDynamicColor used in a CupertinoTheme', (WidgetTester tester) async {
late CupertinoDynamicColor color; late CupertinoDynamicColor color;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -499,7 +498,7 @@ void main() {
Color? color; Color? color;
setUp(() { color = null; }); setUp(() { color = null; });
testWidgetsWithLeakTracking('dynamic color works in cupertino override theme', (WidgetTester tester) async { testWidgets('dynamic color works in cupertino override theme', (WidgetTester tester) async {
CupertinoDynamicColor typedColor() => color! as CupertinoDynamicColor; CupertinoDynamicColor typedColor() => color! as CupertinoDynamicColor;
await tester.pumpWidget( await tester.pumpWidget(
@ -556,7 +555,7 @@ void main() {
expect(typedColor().value, dynamicColor.darkHighContrastElevatedColor.value); expect(typedColor().value, dynamicColor.darkHighContrastElevatedColor.value);
}); });
testWidgetsWithLeakTracking('dynamic color does not work in a material theme', (WidgetTester tester) async { testWidgets('dynamic color does not work in a material theme', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
// This will create a MaterialBasedCupertinoThemeData with primaryColor set to `dynamicColor`. // This will create a MaterialBasedCupertinoThemeData with primaryColor set to `dynamicColor`.

View File

@ -7,7 +7,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
// Constants taken from _ContextMenuActionState. // Constants taken from _ContextMenuActionState.
@ -72,7 +71,7 @@ void main() {
return icon; return icon;
} }
testWidgetsWithLeakTracking('responds to taps', (WidgetTester tester) async { testWidgets('responds to taps', (WidgetTester tester) async {
bool wasPressed = false; bool wasPressed = false;
await tester.pumpWidget(getApp(onPressed: () { await tester.pumpWidget(getApp(onPressed: () {
wasPressed = true; wasPressed = true;
@ -83,7 +82,7 @@ void main() {
expect(wasPressed, true); expect(wasPressed, true);
}); });
testWidgetsWithLeakTracking('turns grey when pressed and held', (WidgetTester tester) async { testWidgets('turns grey when pressed and held', (WidgetTester tester) async {
await tester.pumpWidget(getApp()); await tester.pumpWidget(getApp());
expect(find.byType(CupertinoContextMenuAction), expect(find.byType(CupertinoContextMenuAction),
paints..rect(color: kBackgroundColor.color)); paints..rect(color: kBackgroundColor.color));
@ -118,27 +117,27 @@ void main() {
paints..rect(color: kBackgroundColor.darkColor)); paints..rect(color: kBackgroundColor.darkColor));
}); });
testWidgetsWithLeakTracking('icon and textStyle colors are correct out of the box', testWidgets('icon and textStyle colors are correct out of the box',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget(getApp()); await tester.pumpWidget(getApp());
expect(getTextStyle(tester).color, CupertinoColors.label); expect(getTextStyle(tester).color, CupertinoColors.label);
expect(getIcon(tester).color, CupertinoColors.label); expect(getIcon(tester).color, CupertinoColors.label);
}); });
testWidgetsWithLeakTracking('icon and textStyle colors are correct for destructive actions', testWidgets('icon and textStyle colors are correct for destructive actions',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget(getApp(isDestructiveAction: true)); await tester.pumpWidget(getApp(isDestructiveAction: true));
expect(getTextStyle(tester).color, kDestructiveActionColor); expect(getTextStyle(tester).color, kDestructiveActionColor);
expect(getIcon(tester).color, kDestructiveActionColor); expect(getIcon(tester).color, kDestructiveActionColor);
}); });
testWidgetsWithLeakTracking('textStyle is correct for defaultAction', testWidgets('textStyle is correct for defaultAction',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget(getApp(isDefaultAction: true)); await tester.pumpWidget(getApp(isDefaultAction: true));
expect(getTextStyle(tester).fontWeight, kDefaultActionWeight); expect(getTextStyle(tester).fontWeight, kDefaultActionWeight);
}); });
testWidgetsWithLeakTracking( testWidgets(
'Hovering over Cupertino context menu action updates cursor to clickable on Web', 'Hovering over Cupertino context menu action updates cursor to clickable on Web',
(WidgetTester tester) async { (WidgetTester tester) async {
/// Cupertino context menu action without "onPressed" callback. /// Cupertino context menu action without "onPressed" callback.

View File

@ -8,7 +8,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized();
@ -121,7 +120,7 @@ void main() {
} }
group('CupertinoContextMenu before and during opening', () { group('CupertinoContextMenu before and during opening', () {
testWidgetsWithLeakTracking('An unopened CupertinoContextMenu renders child in the same place as without', (WidgetTester tester) async { testWidgets('An unopened CupertinoContextMenu renders child in the same place as without', (WidgetTester tester) async {
// Measure the child in the scene with no CupertinoContextMenu. // Measure the child in the scene with no CupertinoContextMenu.
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget( await tester.pumpWidget(
@ -141,7 +140,7 @@ void main() {
expect(tester.getRect(find.byWidget(child)), childRect); expect(tester.getRect(find.byWidget(child)), childRect);
}); });
testWidgetsWithLeakTracking('Can open CupertinoContextMenu by tap and hold', (WidgetTester tester) async { testWidgets('Can open CupertinoContextMenu by tap and hold', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu(child: child)); await tester.pumpWidget(getContextMenu(child: child));
expect(find.byWidget(child), findsOneWidget); expect(find.byWidget(child), findsOneWidget);
@ -177,7 +176,7 @@ void main() {
expect(findStatic(), findsOneWidget); expect(findStatic(), findsOneWidget);
}); });
testWidgetsWithLeakTracking('CupertinoContextMenu is in the correct position when within a nested navigator', (WidgetTester tester) async { testWidgets('CupertinoContextMenu is in the correct position when within a nested navigator', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
@ -242,7 +241,7 @@ void main() {
expect(findStatic(), findsOneWidget); expect(findStatic(), findsOneWidget);
}); });
testWidgetsWithLeakTracking('CupertinoContextMenu with a basic builder opens and closes the same as when providing a child', (WidgetTester tester) async { testWidgets('CupertinoContextMenu with a basic builder opens and closes the same as when providing a child', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getBuilderContextMenu(builder: (BuildContext context, Animation<double> animation) { await tester.pumpWidget(getBuilderContextMenu(builder: (BuildContext context, Animation<double> animation) {
return child; return child;
@ -280,7 +279,7 @@ void main() {
expect(findStatic(), findsOneWidget); expect(findStatic(), findsOneWidget);
}); });
testWidgetsWithLeakTracking('CupertinoContextMenu with a builder can change the animation', (WidgetTester tester) async { testWidgets('CupertinoContextMenu with a builder can change the animation', (WidgetTester tester) async {
await tester.pumpWidget(getBuilderContextMenu(builder: (BuildContext context, Animation<double> animation) { await tester.pumpWidget(getBuilderContextMenu(builder: (BuildContext context, Animation<double> animation) {
return Container( return Container(
width: 300.0, width: 300.0,
@ -325,7 +324,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Hovering over Cupertino context menu updates cursor to clickable on Web', (WidgetTester tester) async { testWidgets('Hovering over Cupertino context menu updates cursor to clickable on Web', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
@ -356,7 +355,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('CupertinoContextMenu is in the correct position when within a Transform.scale', (WidgetTester tester) async { testWidgets('CupertinoContextMenu is in the correct position when within a Transform.scale', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
@ -414,7 +413,7 @@ void main() {
}); });
group('CupertinoContextMenu when open', () { group('CupertinoContextMenu when open', () {
testWidgetsWithLeakTracking('Last action does not have border', (WidgetTester tester) async { testWidgets('Last action does not have border', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
@ -473,7 +472,7 @@ void main() {
expect(findStaticChildDecoration(tester), findsNWidgets(3)); expect(findStaticChildDecoration(tester), findsNWidgets(3));
}); });
testWidgetsWithLeakTracking('Can close CupertinoContextMenu by background tap', (WidgetTester tester) async { testWidgets('Can close CupertinoContextMenu by background tap', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu(child: child)); await tester.pumpWidget(getContextMenu(child: child));
@ -491,7 +490,7 @@ void main() {
expect(findStatic(), findsNothing); expect(findStatic(), findsNothing);
}); });
testWidgetsWithLeakTracking('Can close CupertinoContextMenu by dragging down', (WidgetTester tester) async { testWidgets('Can close CupertinoContextMenu by dragging down', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu(child: child)); await tester.pumpWidget(getContextMenu(child: child));
@ -533,7 +532,7 @@ void main() {
expect(findStatic(), findsNothing); expect(findStatic(), findsNothing);
}); });
testWidgetsWithLeakTracking('Can close CupertinoContextMenu by flinging down', (WidgetTester tester) async { testWidgets('Can close CupertinoContextMenu by flinging down', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu(child: child)); await tester.pumpWidget(getContextMenu(child: child));
@ -558,7 +557,7 @@ void main() {
expect(findStatic(), findsNothing); expect(findStatic(), findsNothing);
}); });
testWidgetsWithLeakTracking("Backdrop is added using ModalRoute's filter parameter", (WidgetTester tester) async { testWidgets("Backdrop is added using ModalRoute's filter parameter", (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu(child: child)); await tester.pumpWidget(getContextMenu(child: child));
expect(find.byType(BackdropFilter), findsNothing); expect(find.byType(BackdropFilter), findsNothing);
@ -573,7 +572,7 @@ void main() {
expect(find.byType(BackdropFilter), findsOneWidget); expect(find.byType(BackdropFilter), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Preview widget should have the correct border radius', (WidgetTester tester) async { testWidgets('Preview widget should have the correct border radius', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu(child: child)); await tester.pumpWidget(getContextMenu(child: child));
@ -591,7 +590,7 @@ void main() {
expect(previewWidget.borderRadius, equals(BorderRadius.circular(12.0))); expect(previewWidget.borderRadius, equals(BorderRadius.circular(12.0)));
}); });
testWidgetsWithLeakTracking('CupertinoContextMenu width is correct', (WidgetTester tester) async { testWidgets('CupertinoContextMenu width is correct', (WidgetTester tester) async {
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu(child: child)); await tester.pumpWidget(getContextMenu(child: child));
expect(find.byWidget(child), findsOneWidget); expect(find.byWidget(child), findsOneWidget);
@ -634,7 +633,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking("ContextMenu route animation doesn't throw exception on dismiss", (WidgetTester tester) async { testWidgets("ContextMenu route animation doesn't throw exception on dismiss", (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/124597. // This is a regression test for https://github.com/flutter/flutter/issues/124597.
final List<int> items = List<int>.generate(2, (int index) => index).toList(); final List<int> items = List<int>.generate(2, (int index) => index).toList();
@ -681,7 +680,7 @@ void main() {
}); });
group("Open layout differs depending on child's position on screen", () { group("Open layout differs depending on child's position on screen", () {
testWidgetsWithLeakTracking('Portrait', (WidgetTester tester) async { testWidgets('Portrait', (WidgetTester tester) async {
const Size portraitScreenSize = Size(600.0, 800.0); const Size portraitScreenSize = Size(600.0, 800.0);
await binding.setSurfaceSize(portraitScreenSize); await binding.setSurfaceSize(portraitScreenSize);
@ -753,7 +752,7 @@ void main() {
await binding.setSurfaceSize(const Size(800.0, 600.0)); await binding.setSurfaceSize(const Size(800.0, 600.0));
}); });
testWidgetsWithLeakTracking('Landscape', (WidgetTester tester) async { testWidgets('Landscape', (WidgetTester tester) async {
// Pump a CupertinoContextMenu in the center of the screen and open it. // Pump a CupertinoContextMenu in the center of the screen and open it.
final Widget child = getChild(); final Widget child = getChild();
await tester.pumpWidget(getContextMenu( await tester.pumpWidget(getContextMenu(
@ -818,7 +817,7 @@ void main() {
}); });
}); });
testWidgetsWithLeakTracking('Conflicting gesture detectors', (WidgetTester tester) async { testWidgets('Conflicting gesture detectors', (WidgetTester tester) async {
int? onPointerDownTime; int? onPointerDownTime;
int? onPointerUpTime; int? onPointerUpTime;
bool insideTapTriggered = false; bool insideTapTriggered = false;

View File

@ -14,7 +14,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
// TODO(yjbanov): on the web text rendered with perspective produces flaky goldens: https://github.com/flutter/flutter/issues/110785 // TODO(yjbanov): on the web text rendered with perspective produces flaky goldens: https://github.com/flutter/flutter/issues/110785
const bool skipPerspectiveTextGoldens = isBrowser; const bool skipPerspectiveTextGoldens = isBrowser;
@ -28,7 +27,7 @@ const Offset _kRowOffset = Offset(0.0, -50.0);
void main() { void main() {
group('Countdown timer picker', () { group('Countdown timer picker', () {
testWidgetsWithLeakTracking('initialTimerDuration falls within limit', (WidgetTester tester) async { testWidgets('initialTimerDuration falls within limit', (WidgetTester tester) async {
expect( expect(
() { () {
CupertinoTimerPicker( CupertinoTimerPicker(
@ -50,7 +49,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('minuteInterval is positive and is a factor of 60', (WidgetTester tester) async { testWidgets('minuteInterval is positive and is a factor of 60', (WidgetTester tester) async {
expect( expect(
() { () {
CupertinoTimerPicker( CupertinoTimerPicker(
@ -80,7 +79,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('secondInterval is positive and is a factor of 60', (WidgetTester tester) async { testWidgets('secondInterval is positive and is a factor of 60', (WidgetTester tester) async {
expect( expect(
() { () {
CupertinoTimerPicker( CupertinoTimerPicker(
@ -110,7 +109,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('background color default value', (WidgetTester tester) async { testWidgets('background color default value', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTimerPicker( home: CupertinoTimerPicker(
@ -123,7 +122,7 @@ void main() {
expect(pickers.any((CupertinoPicker picker) => picker.backgroundColor != null), false); expect(pickers.any((CupertinoPicker picker) => picker.backgroundColor != null), false);
}); });
testWidgetsWithLeakTracking('background color can be null', (WidgetTester tester) async { testWidgets('background color can be null', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTimerPicker( home: CupertinoTimerPicker(
@ -135,7 +134,7 @@ void main() {
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
}); });
testWidgetsWithLeakTracking('specified background color is applied', (WidgetTester tester) async { testWidgets('specified background color is applied', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTimerPicker( home: CupertinoTimerPicker(
@ -149,7 +148,7 @@ void main() {
expect(pickers.any((CupertinoPicker picker) => picker.backgroundColor != CupertinoColors.black), false); expect(pickers.any((CupertinoPicker picker) => picker.backgroundColor != CupertinoColors.black), false);
}); });
testWidgetsWithLeakTracking('specified item extent value is applied', (WidgetTester tester) async { testWidgets('specified item extent value is applied', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTimerPicker( home: CupertinoTimerPicker(
@ -163,7 +162,7 @@ void main() {
expect(pickers.any((CupertinoPicker picker) => picker.itemExtent != 42), false); expect(pickers.any((CupertinoPicker picker) => picker.itemExtent != 42), false);
}); });
testWidgetsWithLeakTracking('columns are ordered correctly when text direction is ltr', (WidgetTester tester) async { testWidgets('columns are ordered correctly when text direction is ltr', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTimerPicker( home: CupertinoTimerPicker(
@ -190,7 +189,7 @@ void main() {
expect(tester.getTopLeft(find.text('sec.')).dx > lastOffset.dx, true); expect(tester.getTopLeft(find.text('sec.')).dx > lastOffset.dx, true);
}); });
testWidgetsWithLeakTracking('columns are ordered correctly when text direction is rtl', (WidgetTester tester) async { testWidgets('columns are ordered correctly when text direction is rtl', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Directionality( home: Directionality(
@ -220,7 +219,7 @@ void main() {
expect(tester.getTopLeft(find.text('sec.')).dx > lastOffset.dx, false); expect(tester.getTopLeft(find.text('sec.')).dx > lastOffset.dx, false);
}); });
testWidgetsWithLeakTracking('width of picker is consistent', (WidgetTester tester) async { testWidgets('width of picker is consistent', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: SizedBox( home: SizedBox(
@ -258,7 +257,7 @@ void main() {
}); });
}); });
testWidgetsWithLeakTracking('picker honors minuteInterval and secondInterval', (WidgetTester tester) async { testWidgets('picker honors minuteInterval and secondInterval', (WidgetTester tester) async {
late Duration duration; late Duration duration;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -289,14 +288,14 @@ void main() {
}); });
group('Date picker', () { group('Date picker', () {
testWidgetsWithLeakTracking('initial date is set to default value', (WidgetTester tester) async { testWidgets('initial date is set to default value', (WidgetTester tester) async {
final CupertinoDatePicker picker = CupertinoDatePicker( final CupertinoDatePicker picker = CupertinoDatePicker(
onDateTimeChanged: (_) { }, onDateTimeChanged: (_) { },
); );
expect(picker.initialDateTime, isNotNull); expect(picker.initialDateTime, isNotNull);
}); });
testWidgetsWithLeakTracking('background color default value', (WidgetTester tester) async { testWidgets('background color default value', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoDatePicker( home: CupertinoDatePicker(
@ -309,7 +308,7 @@ void main() {
expect(pickers.any((CupertinoPicker picker) => picker.backgroundColor != null), false); expect(pickers.any((CupertinoPicker picker) => picker.backgroundColor != null), false);
}); });
testWidgetsWithLeakTracking('background color can be null', (WidgetTester tester) async { testWidgets('background color can be null', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoDatePicker( home: CupertinoDatePicker(
@ -321,7 +320,7 @@ void main() {
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
}); });
testWidgetsWithLeakTracking('specified background color is applied', (WidgetTester tester) async { testWidgets('specified background color is applied', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoDatePicker( home: CupertinoDatePicker(
@ -335,7 +334,7 @@ void main() {
expect(pickers.any((CupertinoPicker picker) => picker.backgroundColor != CupertinoColors.black), false); expect(pickers.any((CupertinoPicker picker) => picker.backgroundColor != CupertinoColors.black), false);
}); });
testWidgetsWithLeakTracking('specified item extent value is applied', (WidgetTester tester) async { testWidgets('specified item extent value is applied', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoDatePicker( home: CupertinoDatePicker(
@ -349,7 +348,7 @@ void main() {
expect(pickers.any((CupertinoPicker picker) => picker.itemExtent != 55), false); expect(pickers.any((CupertinoPicker picker) => picker.itemExtent != 55), false);
}); });
testWidgetsWithLeakTracking('initial date honors minuteInterval', (WidgetTester tester) async { testWidgets('initial date honors minuteInterval', (WidgetTester tester) async {
late DateTime newDateTime; late DateTime newDateTime;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -398,7 +397,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('changing initialDateTime after first build does not do anything', (WidgetTester tester) async { testWidgets('changing initialDateTime after first build does not do anything', (WidgetTester tester) async {
late DateTime selectedDateTime; late DateTime selectedDateTime;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -445,7 +444,7 @@ void main() {
expect(selectedDateTime, DateTime(2018, 1, 1, 8, 30)); expect(selectedDateTime, DateTime(2018, 1, 1, 8, 30));
}); });
testWidgetsWithLeakTracking('date picker has expected string', (WidgetTester tester) async { testWidgets('date picker has expected string', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -467,7 +466,7 @@ void main() {
expect(find.text('2018'), findsOneWidget); expect(find.text('2018'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('datetime picker has expected string', (WidgetTester tester) async { testWidgets('datetime picker has expected string', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -489,7 +488,7 @@ void main() {
expect(find.text('AM'), findsOneWidget); expect(find.text('AM'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('monthYear picker has expected string', (WidgetTester tester) async { testWidgets('monthYear picker has expected string', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -510,7 +509,7 @@ void main() {
expect(find.text('2018'), findsOneWidget); expect(find.text('2018'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('width of picker in date and time mode is consistent', (WidgetTester tester) async { testWidgets('width of picker in date and time mode is consistent', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Directionality( home: Directionality(
@ -549,7 +548,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('width of picker in date mode is consistent', (WidgetTester tester) async { testWidgets('width of picker in date mode is consistent', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -593,7 +592,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('width of picker in time mode is consistent', (WidgetTester tester) async { testWidgets('width of picker in time mode is consistent', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -637,7 +636,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('width of picker in monthYear mode is consistent', (WidgetTester tester) async { testWidgets('width of picker in monthYear mode is consistent', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -681,7 +680,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('wheel does not bend outwards', (WidgetTester tester) async { testWidgets('wheel does not bend outwards', (WidgetTester tester) async {
final Widget dateWidget = CupertinoDatePicker( final Widget dateWidget = CupertinoDatePicker(
mode: CupertinoDatePickerMode.date, mode: CupertinoDatePickerMode.date,
@ -746,7 +745,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('picker automatically scrolls away from invalid date on month change', (WidgetTester tester) async { testWidgets('picker automatically scrolls away from invalid date on month change', (WidgetTester tester) async {
late DateTime date; late DateTime date;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -787,7 +786,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking( testWidgets(
'date picker automatically scrolls away from invalid date, ' 'date picker automatically scrolls away from invalid date, '
"and onDateTimeChanged doesn't report these dates", "and onDateTimeChanged doesn't report these dates",
(WidgetTester tester) async { (WidgetTester tester) async {
@ -855,7 +854,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'dateTime picker automatically scrolls away from invalid date, ' 'dateTime picker automatically scrolls away from invalid date, '
"and onDateTimeChanged doesn't report these dates", "and onDateTimeChanged doesn't report these dates",
(WidgetTester tester) async { (WidgetTester tester) async {
@ -932,7 +931,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'time picker automatically scrolls away from invalid date, ' 'time picker automatically scrolls away from invalid date, '
"and onDateTimeChanged doesn't report these dates", "and onDateTimeChanged doesn't report these dates",
(WidgetTester tester) async { (WidgetTester tester) async {
@ -1010,7 +1009,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'monthYear picker automatically scrolls away from invalid date, ' 'monthYear picker automatically scrolls away from invalid date, '
"and onDateTimeChanged doesn't report these dates", "and onDateTimeChanged doesn't report these dates",
(WidgetTester tester) async { (WidgetTester tester) async {
@ -1069,7 +1068,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('picker automatically scrolls away from invalid date on day change', (WidgetTester tester) async { testWidgets('picker automatically scrolls away from invalid date on day change', (WidgetTester tester) async {
late DateTime date; late DateTime date;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -1123,7 +1122,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking( testWidgets(
'date picker should only take into account the date part of minimumDate and maximumDate', 'date picker should only take into account the date part of minimumDate and maximumDate',
(WidgetTester tester) async { (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/49606. // Regression test for https://github.com/flutter/flutter/issues/49606.
@ -1156,7 +1155,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('date picker does not display previous day of minimumDate if it is set at midnight', (WidgetTester tester) async { testWidgets('date picker does not display previous day of minimumDate if it is set at midnight', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/72932 // Regression test for https://github.com/flutter/flutter/issues/72932
final DateTime minDate = DateTime(2019, 12, 31); final DateTime minDate = DateTime(2019, 12, 31);
await tester.pumpWidget( await tester.pumpWidget(
@ -1180,7 +1179,7 @@ void main() {
group('Picker handles initial noon/midnight times', () { group('Picker handles initial noon/midnight times', () {
testWidgetsWithLeakTracking('midnight', (WidgetTester tester) async { testWidgets('midnight', (WidgetTester tester) async {
late DateTime date; late DateTime date;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -1208,7 +1207,7 @@ void main() {
expect(date, DateTime(2019, 1, 1, 0, 16)); expect(date, DateTime(2019, 1, 1, 0, 16));
}); });
testWidgetsWithLeakTracking('noon', (WidgetTester tester) async { testWidgets('noon', (WidgetTester tester) async {
late DateTime date; late DateTime date;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -1236,7 +1235,7 @@ void main() {
expect(date, DateTime(2019, 1, 1, 12, 16)); expect(date, DateTime(2019, 1, 1, 12, 16));
}); });
testWidgetsWithLeakTracking('noon in 24 hour time', (WidgetTester tester) async { testWidgets('noon in 24 hour time', (WidgetTester tester) async {
late DateTime date; late DateTime date;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -1266,7 +1265,7 @@ void main() {
}); });
}); });
testWidgetsWithLeakTracking('picker persists am/pm value when scrolling hours', (WidgetTester tester) async { testWidgets('picker persists am/pm value when scrolling hours', (WidgetTester tester) async {
late DateTime date; late DateTime date;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -1315,7 +1314,7 @@ void main() {
expect(date, DateTime(2019, 1, 1, 3)); expect(date, DateTime(2019, 1, 1, 3));
}); });
testWidgetsWithLeakTracking('picker automatically scrolls the am/pm column when the hour column changes enough', (WidgetTester tester) async { testWidgets('picker automatically scrolls the am/pm column when the hour column changes enough', (WidgetTester tester) async {
late DateTime date; late DateTime date;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -1366,7 +1365,7 @@ void main() {
expect(date, DateTime(2018, 1, 1, 15, 59)); expect(date, DateTime(2018, 1, 1, 15, 59));
}); });
testWidgetsWithLeakTracking('date picker given too narrow space horizontally shows message', (WidgetTester tester) async { testWidgets('date picker given too narrow space horizontally shows message', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -1390,7 +1389,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('DatePicker golden tests', (WidgetTester tester) async { testWidgets('DatePicker golden tests', (WidgetTester tester) async {
Widget buildApp(CupertinoDatePickerMode mode) { Widget buildApp(CupertinoDatePickerMode mode) {
return CupertinoApp( return CupertinoApp(
home: Center( home: Center(
@ -1454,7 +1453,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('DatePicker displays the date in correct order', (WidgetTester tester) async { testWidgets('DatePicker displays the date in correct order', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -1483,7 +1482,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('monthYear DatePicker displays the date in correct order', (WidgetTester tester) async { testWidgets('monthYear DatePicker displays the date in correct order', (WidgetTester tester) async {
Widget buildApp(DatePickerDateOrder order) { Widget buildApp(DatePickerDateOrder order) {
return CupertinoApp( return CupertinoApp(
home: Center( home: Center(
@ -1527,7 +1526,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('DatePicker displays hours and minutes correctly in RTL', (WidgetTester tester) async { testWidgets('DatePicker displays hours and minutes correctly in RTL', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Directionality( home: Directionality(
@ -1552,7 +1551,7 @@ void main() {
}); });
}); });
testWidgetsWithLeakTracking('TimerPicker golden tests', (WidgetTester tester) async { testWidgets('TimerPicker golden tests', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
// Also check if the picker respects the theme. // Also check if the picker respects the theme.
@ -1599,7 +1598,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('TimerPicker only changes hour label after scrolling stops', (WidgetTester tester) async { testWidgets('TimerPicker only changes hour label after scrolling stops', (WidgetTester tester) async {
Duration? duration; Duration? duration;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -1634,7 +1633,7 @@ void main() {
expect(find.text('hour'), findsOneWidget); expect(find.text('hour'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('TimerPicker has intrinsic width and height', (WidgetTester tester) async { testWidgets('TimerPicker has intrinsic width and height', (WidgetTester tester) async {
const Key key = Key('key'); const Key key = Key('key');
await tester.pumpWidget( await tester.pumpWidget(
@ -1680,7 +1679,7 @@ void main() {
expect(tester.getSize(find.descendant(of: find.byKey(key), matching: find.byType(Row))), const Size(342, 216)); expect(tester.getSize(find.descendant(of: find.byKey(key), matching: find.byType(Row))), const Size(342, 216));
}); });
testWidgetsWithLeakTracking('scrollController can be removed or added', (WidgetTester tester) async { testWidgets('scrollController can be removed or added', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
late int lastSelectedItem; late int lastSelectedItem;
void onSelectedItemChanged(int index) { void onSelectedItemChanged(int index) {
@ -1719,7 +1718,7 @@ void main() {
handle.dispose(); handle.dispose();
}); });
testWidgetsWithLeakTracking('CupertinoDataPicker does not provide invalid MediaQuery', (WidgetTester tester) async { testWidgets('CupertinoDataPicker does not provide invalid MediaQuery', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/47989. // Regression test for https://github.com/flutter/flutter/issues/47989.
Brightness brightness = Brightness.light; Brightness brightness = Brightness.light;
late StateSetter setState; late StateSetter setState;
@ -1764,7 +1763,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('picker exports semantics', (WidgetTester tester) async { testWidgets('picker exports semantics', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
debugResetSemanticsIdCounter(); debugResetSemanticsIdCounter();
int? lastSelectedItem; int? lastSelectedItem;
@ -1803,7 +1802,7 @@ void main() {
}); });
// Regression test for https://github.com/flutter/flutter/issues/98567 // Regression test for https://github.com/flutter/flutter/issues/98567
testWidgetsWithLeakTracking('picker semantics action test', (WidgetTester tester) async { testWidgets('picker semantics action test', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
debugResetSemanticsIdCounter(); debugResetSemanticsIdCounter();
final DateTime initialDate = DateTime(2018, 6, 8); final DateTime initialDate = DateTime(2018, 6, 8);
@ -1833,7 +1832,7 @@ void main() {
handle.dispose(); handle.dispose();
}); });
testWidgetsWithLeakTracking('DatePicker adapts to MaterialApp dark mode', (WidgetTester tester) async { testWidgets('DatePicker adapts to MaterialApp dark mode', (WidgetTester tester) async {
Widget buildDatePicker(Brightness brightness) { Widget buildDatePicker(Brightness brightness) {
return MaterialApp( return MaterialApp(
theme: ThemeData(brightness: brightness), theme: ThemeData(brightness: brightness),
@ -1860,7 +1859,7 @@ void main() {
expect(paragraph.text.style!.color.toString().contains('UNRESOLVED'), isFalse); expect(paragraph.text.style!.color.toString().contains('UNRESOLVED'), isFalse);
}); });
testWidgetsWithLeakTracking('TimerPicker adapts to MaterialApp dark mode', (WidgetTester tester) async { testWidgets('TimerPicker adapts to MaterialApp dark mode', (WidgetTester tester) async {
Widget buildTimerPicker(Brightness brightness) { Widget buildTimerPicker(Brightness brightness) {
return MaterialApp( return MaterialApp(
theme: ThemeData(brightness: brightness), theme: ThemeData(brightness: brightness),
@ -1887,7 +1886,7 @@ void main() {
expect(paragraph.text.style!.color.toString().contains('UNRESOLVED'), isFalse); expect(paragraph.text.style!.color.toString().contains('UNRESOLVED'), isFalse);
}); });
testWidgetsWithLeakTracking('TimerPicker minDate - maxDate with minuteInterval', (WidgetTester tester) async { testWidgets('TimerPicker minDate - maxDate with minuteInterval', (WidgetTester tester) async {
late DateTime date; late DateTime date;
final DateTime minimum = DateTime(2022, 6, 14, 3, 31); final DateTime minimum = DateTime(2022, 6, 14, 3, 31);
final DateTime initial = DateTime(2022, 6, 14, 3, 40); final DateTime initial = DateTime(2022, 6, 14, 3, 40);
@ -1934,7 +1933,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('date picker has expected day of week', (WidgetTester tester) async { testWidgets('date picker has expected day of week', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(

View File

@ -4,10 +4,9 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('debugCheckHasCupertinoLocalizations throws', (WidgetTester tester) async { testWidgets('debugCheckHasCupertinoLocalizations throws', (WidgetTester tester) async {
final GlobalKey noLocalizationsAvailable = GlobalKey(); final GlobalKey noLocalizationsAvailable = GlobalKey();
final GlobalKey localizationsAvailable = GlobalKey(); final GlobalKey localizationsAvailable = GlobalKey();

View File

@ -5,12 +5,11 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
testWidgetsWithLeakTracking('can press', (WidgetTester tester) async { testWidgets('can press', (WidgetTester tester) async {
bool pressed = false; bool pressed = false;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -31,7 +30,7 @@ void main() {
expect(pressed, true); expect(pressed, true);
}); });
testWidgetsWithLeakTracking('keeps contrast with background on hover', testWidgets('keeps contrast with background on hover',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -71,7 +70,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('pressedOpacity defaults to 0.1', (WidgetTester tester) async { testWidgets('pressedOpacity defaults to 0.1', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -115,7 +114,7 @@ void main() {
expect(opacity.opacity.value, 1.0); expect(opacity.opacity.value, 1.0);
}); });
testWidgetsWithLeakTracking('passing null to onPressed disables the button', (WidgetTester tester) async { testWidgets('passing null to onPressed disables the button', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Center( home: Center(

View File

@ -7,12 +7,11 @@ import 'dart:ui';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
testWidgetsWithLeakTracking('has correct backdrop filters', (WidgetTester tester) async { testWidgets('has correct backdrop filters', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -54,7 +53,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('has shadow', (WidgetTester tester) async { testWidgets('has shadow', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -84,7 +83,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('is translucent', (WidgetTester tester) async { testWidgets('is translucent', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -117,7 +116,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('positions itself at the anchor', (WidgetTester tester) async { testWidgets('positions itself at the anchor', (WidgetTester tester) async {
// An arbitrary point on the screen to position at. // An arbitrary point on the screen to position at.
const Offset anchor = Offset(30.0, 40.0); const Offset anchor = Offset(30.0, 40.0);

View File

@ -15,12 +15,11 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
void main() { void main() {
testWidgetsWithLeakTracking('Alert dialog control test', (WidgetTester tester) async { testWidgets('Alert dialog control test', (WidgetTester tester) async {
bool didDelete = false; bool didDelete = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -59,7 +58,7 @@ void main() {
expect(find.text('Delete'), findsNothing); expect(find.text('Delete'), findsNothing);
}); });
testWidgetsWithLeakTracking('Dialog not barrier dismissible by default', (WidgetTester tester) async { testWidgets('Dialog not barrier dismissible by default', (WidgetTester tester) async {
await tester.pumpWidget(createAppWithCenteredButton(const Text('Go'))); await tester.pumpWidget(createAppWithCenteredButton(const Text('Go')));
final BuildContext context = tester.element(find.text('Go')); final BuildContext context = tester.element(find.text('Go'));
@ -87,7 +86,7 @@ void main() {
}); });
testWidgetsWithLeakTracking('Dialog configurable to be barrier dismissible', (WidgetTester tester) async { testWidgets('Dialog configurable to be barrier dismissible', (WidgetTester tester) async {
await tester.pumpWidget(createAppWithCenteredButton(const Text('Go'))); await tester.pumpWidget(createAppWithCenteredButton(const Text('Go')));
final BuildContext context = tester.element(find.text('Go')); final BuildContext context = tester.element(find.text('Go'));
@ -115,7 +114,7 @@ void main() {
expect(find.text('Dialog'), findsNothing); expect(find.text('Dialog'), findsNothing);
}); });
testWidgetsWithLeakTracking('Dialog destructive action style', (WidgetTester tester) async { testWidgets('Dialog destructive action style', (WidgetTester tester) async {
await tester.pumpWidget(boilerplate(const CupertinoDialogAction( await tester.pumpWidget(boilerplate(const CupertinoDialogAction(
isDestructiveAction: true, isDestructiveAction: true,
child: Text('Ok'), child: Text('Ok'),
@ -126,7 +125,7 @@ void main() {
expect(widget.style.color!.withAlpha(255), CupertinoColors.systemRed.color); expect(widget.style.color!.withAlpha(255), CupertinoColors.systemRed.color);
}); });
testWidgetsWithLeakTracking('Dialog default action style', (WidgetTester tester) async { testWidgets('Dialog default action style', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoTheme( CupertinoTheme(
data: const CupertinoThemeData( data: const CupertinoThemeData(
@ -143,7 +142,7 @@ void main() {
expect(widget.style.color!.withAlpha(255), CupertinoColors.systemGreen.color); expect(widget.style.color!.withAlpha(255), CupertinoColors.systemGreen.color);
}); });
testWidgetsWithLeakTracking('Dialog dark theme', (WidgetTester tester) async { testWidgets('Dialog dark theme', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: MediaQuery( home: MediaQuery(
@ -179,7 +178,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Has semantic annotations', (WidgetTester tester) async { testWidgets('Has semantic annotations', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(const MaterialApp(home: Material( await tester.pumpWidget(const MaterialApp(home: Material(
child: CupertinoAlertDialog( child: CupertinoAlertDialog(
@ -251,7 +250,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Dialog default action style', (WidgetTester tester) async { testWidgets('Dialog default action style', (WidgetTester tester) async {
await tester.pumpWidget(boilerplate(const CupertinoDialogAction( await tester.pumpWidget(boilerplate(const CupertinoDialogAction(
isDefaultAction: true, isDefaultAction: true,
child: Text('Ok'), child: Text('Ok'),
@ -262,7 +261,7 @@ void main() {
expect(widget.style.fontWeight, equals(FontWeight.w600)); expect(widget.style.fontWeight, equals(FontWeight.w600));
}); });
testWidgetsWithLeakTracking('Dialog default and destructive action styles', (WidgetTester tester) async { testWidgets('Dialog default and destructive action styles', (WidgetTester tester) async {
await tester.pumpWidget(boilerplate(const CupertinoDialogAction( await tester.pumpWidget(boilerplate(const CupertinoDialogAction(
isDefaultAction: true, isDefaultAction: true,
isDestructiveAction: true, isDestructiveAction: true,
@ -275,7 +274,7 @@ void main() {
expect(widget.style.fontWeight, equals(FontWeight.w600)); expect(widget.style.fontWeight, equals(FontWeight.w600));
}); });
testWidgetsWithLeakTracking('Dialog disabled action style', (WidgetTester tester) async { testWidgets('Dialog disabled action style', (WidgetTester tester) async {
await tester.pumpWidget(boilerplate(const CupertinoDialogAction( await tester.pumpWidget(boilerplate(const CupertinoDialogAction(
child: Text('Ok'), child: Text('Ok'),
))); )));
@ -286,7 +285,7 @@ void main() {
expect(widget.style.color!.opacity, lessThanOrEqualTo(128 / 255)); expect(widget.style.color!.opacity, lessThanOrEqualTo(128 / 255));
}); });
testWidgetsWithLeakTracking('Dialog enabled action style', (WidgetTester tester) async { testWidgets('Dialog enabled action style', (WidgetTester tester) async {
await tester.pumpWidget(boilerplate(CupertinoDialogAction( await tester.pumpWidget(boilerplate(CupertinoDialogAction(
child: const Text('Ok'), child: const Text('Ok'),
onPressed: () {}, onPressed: () {},
@ -297,7 +296,7 @@ void main() {
expect(widget.style.color!.opacity, equals(1.0)); expect(widget.style.color!.opacity, equals(1.0));
}); });
testWidgetsWithLeakTracking('Message is scrollable, has correct padding with large text sizes', (WidgetTester tester) async { testWidgets('Message is scrollable, has correct padding with large text sizes', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -354,7 +353,7 @@ void main() {
expect(tester.getSize(find.widgetWithText(CupertinoDialogAction, 'OK')), equals(const Size(310.0, 98.0))); expect(tester.getSize(find.widgetWithText(CupertinoDialogAction, 'OK')), equals(const Size(310.0, 98.0)));
}); });
testWidgetsWithLeakTracking('Dialog respects small constraints.', (WidgetTester tester) async { testWidgets('Dialog respects small constraints.', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -400,7 +399,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Button list is scrollable, has correct position with large text sizes.', (WidgetTester tester) async { testWidgets('Button list is scrollable, has correct position with large text sizes.', (WidgetTester tester) async {
final ScrollController actionScrollController = ScrollController(); final ScrollController actionScrollController = ScrollController();
addTearDown(actionScrollController.dispose); addTearDown(actionScrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -461,7 +460,7 @@ void main() {
expect(tester.getSize(find.widgetWithText(CupertinoDialogAction, 'Cancel')).height, equals(148.0)); expect(tester.getSize(find.widgetWithText(CupertinoDialogAction, 'Cancel')).height, equals(148.0));
}); });
testWidgetsWithLeakTracking('Title Section is empty, Button section is not empty.', (WidgetTester tester) async { testWidgets('Title Section is empty, Button section is not empty.', (WidgetTester tester) async {
const double textScaleFactor = 1.0; const double textScaleFactor = 1.0;
final ScrollController actionScrollController = ScrollController(); final ScrollController actionScrollController = ScrollController();
addTearDown(actionScrollController.dispose); addTearDown(actionScrollController.dispose);
@ -515,7 +514,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Button section is empty, Title section is not empty.', (WidgetTester tester) async { testWidgets('Button section is empty, Title section is not empty.', (WidgetTester tester) async {
const double textScaleFactor = 1.0; const double textScaleFactor = 1.0;
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
@ -557,7 +556,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Actions section height for 1 button is height of button.', (WidgetTester tester) async { testWidgets('Actions section height for 1 button is height of button.', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -587,7 +586,7 @@ void main() {
expect(okButtonBox.size.height, actionsSectionBox.size.height); expect(okButtonBox.size.height, actionsSectionBox.size.height);
}); });
testWidgetsWithLeakTracking('Actions section height for 2 side-by-side buttons is height of tallest button.', (WidgetTester tester) async { testWidgets('Actions section height for 2 side-by-side buttons is height of tallest button.', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
late double dividerWidth; // Will be set when the dialog builder runs. Needs a BuildContext. late double dividerWidth; // Will be set when the dialog builder runs. Needs a BuildContext.
@ -633,7 +632,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Actions section height for 2 stacked buttons with enough room is height of both buttons.', (WidgetTester tester) async { testWidgets('Actions section height for 2 stacked buttons with enough room is height of both buttons.', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
const double dividerThickness = 0.3; const double dividerThickness = 0.3;
@ -675,7 +674,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Actions section height for 2 stacked buttons without enough room and regular font is 1.5 buttons tall.', (WidgetTester tester) async { testWidgets('Actions section height for 2 stacked buttons without enough room and regular font is 1.5 buttons tall.', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -710,7 +709,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Actions section height for 2 stacked buttons without enough room and large accessibility font is 50% of dialog height.', (WidgetTester tester) async { testWidgets('Actions section height for 2 stacked buttons without enough room and large accessibility font is 50% of dialog height.', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -751,7 +750,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Actions section height for 3 buttons without enough room is 1.5 buttons tall.', (WidgetTester tester) async { testWidgets('Actions section height for 3 buttons without enough room is 1.5 buttons tall.', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -796,7 +795,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Actions section overscroll is painted white.', (WidgetTester tester) async { testWidgets('Actions section overscroll is painted white.', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -845,7 +844,7 @@ void main() {
)); ));
}); });
testWidgetsWithLeakTracking('Pressed button changes appearance and dividers disappear.', (WidgetTester tester) async { testWidgets('Pressed button changes appearance and dividers disappear.', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
const double dividerThickness = 0.3; const double dividerThickness = 0.3;
@ -958,7 +957,7 @@ void main() {
await gesture.up(); await gesture.up();
}); });
testWidgetsWithLeakTracking('ScaleTransition animation for showCupertinoDialog()', (WidgetTester tester) async { testWidgets('ScaleTransition animation for showCupertinoDialog()', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -1036,7 +1035,7 @@ void main() {
expect(find.byType(Transform), findsNothing); expect(find.byType(Transform), findsNothing);
}); });
testWidgetsWithLeakTracking('FadeTransition animation for showCupertinoDialog()', (WidgetTester tester) async { testWidgets('FadeTransition animation for showCupertinoDialog()', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -1129,7 +1128,7 @@ void main() {
expect(transition.opacity.value, moreOrLessEquals(0.0, epsilon: 0.001)); expect(transition.opacity.value, moreOrLessEquals(0.0, epsilon: 0.001));
}); });
testWidgetsWithLeakTracking('Actions are accessible by key', (WidgetTester tester) async { testWidgets('Actions are accessible by key', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesDialog( createAppWithButtonThatLaunchesDialog(
dialogBuilder: (BuildContext context) { dialogBuilder: (BuildContext context) {
@ -1159,7 +1158,7 @@ void main() {
expect(find.byKey(const Key('option_3')), findsNothing); expect(find.byKey(const Key('option_3')), findsNothing);
}); });
testWidgetsWithLeakTracking('Dialog widget insets by MediaQuery viewInsets', (WidgetTester tester) async { testWidgets('Dialog widget insets by MediaQuery viewInsets', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: MediaQuery( home: MediaQuery(
@ -1189,7 +1188,7 @@ void main() {
expect(tester.getRect(find.byType(Placeholder)), placeholderRectWithoutInsets.translate(10, 10)); expect(tester.getRect(find.byType(Placeholder)), placeholderRectWithoutInsets.translate(10, 10));
}); });
testWidgetsWithLeakTracking('Material2 - Default cupertino dialog golden', (WidgetTester tester) async { testWidgets('Material2 - Default cupertino dialog golden', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesDialog( createAppWithButtonThatLaunchesDialog(
useMaterial3: false, useMaterial3: false,
@ -1220,7 +1219,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material3 - Default cupertino dialog golden', (WidgetTester tester) async { testWidgets('Material3 - Default cupertino dialog golden', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesDialog( createAppWithButtonThatLaunchesDialog(
useMaterial3: true, useMaterial3: true,
@ -1251,7 +1250,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('showCupertinoDialog - custom barrierLabel', (WidgetTester tester) async { testWidgets('showCupertinoDialog - custom barrierLabel', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget( await tester.pumpWidget(
@ -1291,7 +1290,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('CupertinoDialogRoute is state restorable', (WidgetTester tester) async { testWidgets('CupertinoDialogRoute is state restorable', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
restorationScopeId: 'app', restorationScopeId: 'app',
@ -1321,7 +1320,7 @@ void main() {
expect(find.byType(CupertinoAlertDialog), findsOneWidget); expect(find.byType(CupertinoAlertDialog), findsOneWidget);
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/33615 }, skip: isBrowser); // https://github.com/flutter/flutter/issues/33615
testWidgetsWithLeakTracking('Conflicting scrollbars are not applied by ScrollBehavior to CupertinoAlertDialog', (WidgetTester tester) async { testWidgets('Conflicting scrollbars are not applied by ScrollBehavior to CupertinoAlertDialog', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/83819 // Regression test for https://github.com/flutter/flutter/issues/83819
const double textScaleFactor = 1.0; const double textScaleFactor = 1.0;
final ScrollController actionScrollController = ScrollController(); final ScrollController actionScrollController = ScrollController();
@ -1361,7 +1360,7 @@ void main() {
expect(find.byType(CupertinoScrollbar), findsNWidgets(2)); expect(find.byType(CupertinoScrollbar), findsNWidgets(2));
}, variant: TargetPlatformVariant.all()); }, variant: TargetPlatformVariant.all());
testWidgetsWithLeakTracking('CupertinoAlertDialog scrollbars controllers should be different', (WidgetTester tester) async { testWidgets('CupertinoAlertDialog scrollbars controllers should be different', (WidgetTester tester) async {
// https://github.com/flutter/flutter/pull/81278 // https://github.com/flutter/flutter/pull/81278
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
@ -1388,7 +1387,7 @@ void main() {
}); });
group('showCupertinoDialog avoids overlapping display features', () { group('showCupertinoDialog avoids overlapping display features', () {
testWidgetsWithLeakTracking('positioning using anchorPoint', (WidgetTester tester) async { testWidgets('positioning using anchorPoint', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
@ -1426,7 +1425,7 @@ void main() {
expect(tester.getBottomRight(find.byType(Placeholder)), const Offset(800.0, 600.0)); expect(tester.getBottomRight(find.byType(Placeholder)), const Offset(800.0, 600.0));
}); });
testWidgetsWithLeakTracking('positioning using Directionality', (WidgetTester tester) async { testWidgets('positioning using Directionality', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
@ -1466,7 +1465,7 @@ void main() {
expect(tester.getBottomRight(find.byType(Placeholder)), const Offset(800.0, 600.0)); expect(tester.getBottomRight(find.byType(Placeholder)), const Offset(800.0, 600.0));
}); });
testWidgetsWithLeakTracking('default positioning', (WidgetTester tester) async { testWidgets('default positioning', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
@ -1504,7 +1503,7 @@ void main() {
}); });
}); });
testWidgetsWithLeakTracking('Hovering over Cupertino alert dialog action updates cursor to clickable on Web', (WidgetTester tester) async { testWidgets('Hovering over Cupertino alert dialog action updates cursor to clickable on Web', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
createAppWithButtonThatLaunchesDialog( createAppWithButtonThatLaunchesDialog(
dialogBuilder: (BuildContext context) { dialogBuilder: (BuildContext context) {

View File

@ -6,10 +6,9 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('Shows prefix', (WidgetTester tester) async { testWidgets('Shows prefix', (WidgetTester tester) async {
const Widget prefix = Text('Enter Value'); const Widget prefix = Text('Enter Value');
await tester.pumpWidget( await tester.pumpWidget(
@ -26,7 +25,7 @@ void main() {
expect(prefix, tester.widget(find.byType(Text))); expect(prefix, tester.widget(find.byType(Text)));
}); });
testWidgetsWithLeakTracking('Shows child', (WidgetTester tester) async { testWidgets('Shows child', (WidgetTester tester) async {
const Widget child = CupertinoTextField(); const Widget child = CupertinoTextField();
await tester.pumpWidget( await tester.pumpWidget(
@ -42,7 +41,7 @@ void main() {
expect(child, tester.widget(find.byType(CupertinoTextField))); expect(child, tester.widget(find.byType(CupertinoTextField)));
}); });
testWidgetsWithLeakTracking('RTL puts prefix after child', (WidgetTester tester) async { testWidgets('RTL puts prefix after child', (WidgetTester tester) async {
const Widget prefix = Text('Enter Value'); const Widget prefix = Text('Enter Value');
const Widget child = CupertinoTextField(); const Widget child = CupertinoTextField();
@ -63,7 +62,7 @@ void main() {
expect(tester.getTopLeft(find.byType(Text)).dx > tester.getTopLeft(find.byType(CupertinoTextField)).dx, true); expect(tester.getTopLeft(find.byType(Text)).dx > tester.getTopLeft(find.byType(CupertinoTextField)).dx, true);
}); });
testWidgetsWithLeakTracking('LTR puts child after prefix', (WidgetTester tester) async { testWidgets('LTR puts child after prefix', (WidgetTester tester) async {
const Widget prefix = Text('Enter Value'); const Widget prefix = Text('Enter Value');
const Widget child = CupertinoTextField(); const Widget child = CupertinoTextField();
@ -84,7 +83,7 @@ void main() {
expect(tester.getTopLeft(find.byType(Text)).dx > tester.getTopLeft(find.byType(CupertinoTextField)).dx, false); expect(tester.getTopLeft(find.byType(Text)).dx > tester.getTopLeft(find.byType(CupertinoTextField)).dx, false);
}); });
testWidgetsWithLeakTracking('Shows error widget', (WidgetTester tester) async { testWidgets('Shows error widget', (WidgetTester tester) async {
const Widget error = Text('Error'); const Widget error = Text('Error');
await tester.pumpWidget( await tester.pumpWidget(
@ -101,7 +100,7 @@ void main() {
expect(error, tester.widget(find.byType(Text))); expect(error, tester.widget(find.byType(Text)));
}); });
testWidgetsWithLeakTracking('Shows helper widget', (WidgetTester tester) async { testWidgets('Shows helper widget', (WidgetTester tester) async {
const Widget helper = Text('Helper'); const Widget helper = Text('Helper');
await tester.pumpWidget( await tester.pumpWidget(
@ -118,7 +117,7 @@ void main() {
expect(helper, tester.widget(find.byType(Text))); expect(helper, tester.widget(find.byType(Text)));
}); });
testWidgetsWithLeakTracking('Shows helper text above error text', (WidgetTester tester) async { testWidgets('Shows helper text above error text', (WidgetTester tester) async {
const Widget helper = Text('Helper'); const Widget helper = Text('Helper');
const Widget error = CupertinoActivityIndicator(); const Widget error = CupertinoActivityIndicator();
@ -140,7 +139,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Shows helper in label color and error text in red color', (WidgetTester tester) async { testWidgets('Shows helper in label color and error text in red color', (WidgetTester tester) async {
const Widget helper = Text('Helper'); const Widget helper = Text('Helper');
const Widget error = Text('Error'); const Widget error = Text('Error');
@ -167,7 +166,7 @@ void main() {
expect(errorTextStyle.style.color, CupertinoColors.destructiveRed); expect(errorTextStyle.style.color, CupertinoColors.destructiveRed);
}); });
testWidgetsWithLeakTracking('CupertinoFormRow adapts to MaterialApp dark mode', (WidgetTester tester) async { testWidgets('CupertinoFormRow adapts to MaterialApp dark mode', (WidgetTester tester) async {
const Widget prefix = Text('Prefix'); const Widget prefix = Text('Prefix');
const Widget helper = Text('Helper'); const Widget helper = Text('Helper');

View File

@ -5,10 +5,9 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('Shows header', (WidgetTester tester) async { testWidgets('Shows header', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -23,7 +22,7 @@ void main() {
expect(find.text('Header'), findsOneWidget); expect(find.text('Header'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Shows footer', (WidgetTester tester) async { testWidgets('Shows footer', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -38,7 +37,7 @@ void main() {
expect(find.text('Footer'), findsOneWidget); expect(find.text('Footer'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Shows long dividers in edge-to-edge section part 1', (WidgetTester tester) async { testWidgets('Shows long dividers in edge-to-edge section part 1', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -55,7 +54,7 @@ void main() {
expect(childrenColumn.children.length, 3); expect(childrenColumn.children.length, 3);
}); });
testWidgetsWithLeakTracking('Shows long dividers in edge-to-edge section part 2', (WidgetTester tester) async { testWidgets('Shows long dividers in edge-to-edge section part 2', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -76,7 +75,7 @@ void main() {
expect(childrenColumn.children.length, 5); expect(childrenColumn.children.length, 5);
}); });
testWidgetsWithLeakTracking('Does not show long dividers in insetGrouped section part 1', (WidgetTester tester) async { testWidgets('Does not show long dividers in insetGrouped section part 1', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -94,7 +93,7 @@ void main() {
expect(childrenColumn.children.length, 1); expect(childrenColumn.children.length, 1);
}); });
testWidgetsWithLeakTracking('Does not show long dividers in insetGrouped section part 2', (WidgetTester tester) async { testWidgets('Does not show long dividers in insetGrouped section part 2', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
restorationScopeId: 'App', restorationScopeId: 'App',
@ -116,7 +115,7 @@ void main() {
expect(childrenColumn.children.length, 3); expect(childrenColumn.children.length, 3);
}); });
testWidgetsWithLeakTracking('Sets background color for section', (WidgetTester tester) async { testWidgets('Sets background color for section', (WidgetTester tester) async {
const Color backgroundColor = CupertinoColors.systemBlue; const Color backgroundColor = CupertinoColors.systemBlue;
await tester.pumpWidget( await tester.pumpWidget(
@ -139,7 +138,7 @@ void main() {
expect(boxDecoration.color, backgroundColor); expect(boxDecoration.color, backgroundColor);
}); });
testWidgetsWithLeakTracking('Setting clipBehavior clips children section', (WidgetTester tester) async { testWidgets('Setting clipBehavior clips children section', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -154,7 +153,7 @@ void main() {
expect(find.byType(ClipRRect), findsOneWidget); expect(find.byType(ClipRRect), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Not setting clipBehavior does not produce a RenderClipRRect object', (WidgetTester tester) async { testWidgets('Not setting clipBehavior does not produce a RenderClipRRect object', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -169,7 +168,7 @@ void main() {
expect(renderClips, isEmpty); expect(renderClips, isEmpty);
}); });
testWidgetsWithLeakTracking('Does not double up padding on header', (WidgetTester tester) async { testWidgets('Does not double up padding on header', (WidgetTester tester) async {
const Widget header = Text('Header'); const Widget header = Text('Header');
await tester.pumpWidget( await tester.pumpWidget(
@ -186,7 +185,7 @@ void main() {
expect(tester.getTopLeft(find.byWidget(header)), const Offset(20, 22)); expect(tester.getTopLeft(find.byWidget(header)), const Offset(20, 22));
}); });
testWidgetsWithLeakTracking('Does not double up padding on footer', (WidgetTester tester) async { testWidgets('Does not double up padding on footer', (WidgetTester tester) async {
const Widget footer = Text('Footer'); const Widget footer = Text('Footer');
await tester.pumpWidget( await tester.pumpWidget(
@ -203,7 +202,7 @@ void main() {
expect(tester.getTopLeft(find.byWidget(footer)), offsetMoreOrLessEquals(const Offset(20, 65), epsilon: 1)); expect(tester.getTopLeft(find.byWidget(footer)), offsetMoreOrLessEquals(const Offset(20, 65), epsilon: 1));
}); });
testWidgetsWithLeakTracking('Sets custom margin', (WidgetTester tester) async { testWidgets('Sets custom margin', (WidgetTester tester) async {
final Widget child = CupertinoTextFormFieldRow(); final Widget child = CupertinoTextFormFieldRow();
const double margin = 35; const double margin = 35;

View File

@ -4,10 +4,9 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('IconTheme.of works', (WidgetTester tester) async { testWidgets('IconTheme.of works', (WidgetTester tester) async {
const IconThemeData data = IconThemeData( const IconThemeData data = IconThemeData(
size: 16.0, size: 16.0,
fill: 0.0, fill: 0.0,

View File

@ -4,10 +4,9 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('shows header', (WidgetTester tester) async { testWidgets('shows header', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -24,7 +23,7 @@ void main() {
expect(find.text('Header'), findsOneWidget); expect(find.text('Header'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('shows footer', (WidgetTester tester) async { testWidgets('shows footer', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -41,7 +40,7 @@ void main() {
expect(find.text('Footer'), findsOneWidget); expect(find.text('Footer'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('shows long dividers in edge-to-edge section part 1', (WidgetTester tester) async { testWidgets('shows long dividers in edge-to-edge section part 1', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -60,7 +59,7 @@ void main() {
expect(childrenColumn.children.length, 3); expect(childrenColumn.children.length, 3);
}); });
testWidgetsWithLeakTracking('shows long dividers in edge-to-edge section part 2', (WidgetTester tester) async { testWidgets('shows long dividers in edge-to-edge section part 2', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -81,7 +80,7 @@ void main() {
expect(childrenColumn.children.length, 5); expect(childrenColumn.children.length, 5);
}); });
testWidgetsWithLeakTracking('does not show long dividers in insetGrouped section part 1', (WidgetTester tester) async { testWidgets('does not show long dividers in insetGrouped section part 1', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -101,7 +100,7 @@ void main() {
expect(childrenColumn.children.length, 1); expect(childrenColumn.children.length, 1);
}); });
testWidgetsWithLeakTracking('does not show long dividers in insetGrouped section part 2', (WidgetTester tester) async { testWidgets('does not show long dividers in insetGrouped section part 2', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -122,7 +121,7 @@ void main() {
expect(childrenColumn.children.length, 3); expect(childrenColumn.children.length, 3);
}); });
testWidgetsWithLeakTracking('sets background color for section', (WidgetTester tester) async { testWidgets('sets background color for section', (WidgetTester tester) async {
const Color backgroundColor = CupertinoColors.systemBlue; const Color backgroundColor = CupertinoColors.systemBlue;
await tester.pumpWidget( await tester.pumpWidget(
@ -145,7 +144,7 @@ void main() {
expect(boxDecoration.color, backgroundColor); expect(boxDecoration.color, backgroundColor);
}); });
testWidgetsWithLeakTracking('setting clipBehavior clips children section', (WidgetTester tester) async { testWidgets('setting clipBehavior clips children section', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -162,7 +161,7 @@ void main() {
expect(find.byType(ClipRRect), findsOneWidget); expect(find.byType(ClipRRect), findsOneWidget);
}); });
testWidgetsWithLeakTracking('not setting clipBehavior does not clip children section', (WidgetTester tester) async { testWidgets('not setting clipBehavior does not clip children section', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -178,7 +177,7 @@ void main() {
expect(find.byType(ClipRRect), findsNothing); expect(find.byType(ClipRRect), findsNothing);
}); });
testWidgetsWithLeakTracking('CupertinoListSection respects separatorColor', (WidgetTester tester) async { testWidgets('CupertinoListSection respects separatorColor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -201,7 +200,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('CupertinoListSection.separatorColor defaults CupertinoColors.separator', (WidgetTester tester) async { testWidgets('CupertinoListSection.separatorColor defaults CupertinoColors.separator', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -224,7 +223,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('does not show margin by default', (WidgetTester tester) async { testWidgets('does not show margin by default', (WidgetTester tester) async {
const Widget child = CupertinoListTile(title: Text('CupertinoListTile')); const Widget child = CupertinoListTile(title: Text('CupertinoListTile'));
await tester.pumpWidget( await tester.pumpWidget(
@ -243,7 +242,7 @@ void main() {
expect(tester.getTopLeft(find.byWidget(child)), offsetMoreOrLessEquals(const Offset(0, 41), epsilon: 1)); expect(tester.getTopLeft(find.byWidget(child)), offsetMoreOrLessEquals(const Offset(0, 41), epsilon: 1));
}); });
testWidgetsWithLeakTracking('shows custom margin', (WidgetTester tester) async { testWidgets('shows custom margin', (WidgetTester tester) async {
const Widget child = CupertinoListTile(title: Text('CupertinoListTile')); const Widget child = CupertinoListTile(title: Text('CupertinoListTile'));
const double margin = 10; const double margin = 10;

View File

@ -4,10 +4,9 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('shows title', (WidgetTester tester) async { testWidgets('shows title', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
await tester.pumpWidget( await tester.pumpWidget(
@ -24,7 +23,7 @@ void main() {
expect(find.text('CupertinoListTile'), findsOneWidget); expect(find.text('CupertinoListTile'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('shows subtitle', (WidgetTester tester) async { testWidgets('shows subtitle', (WidgetTester tester) async {
const Widget subtitle = Text('CupertinoListTile subtitle'); const Widget subtitle = Text('CupertinoListTile subtitle');
await tester.pumpWidget( await tester.pumpWidget(
@ -42,7 +41,7 @@ void main() {
expect(find.text('CupertinoListTile subtitle'), findsOneWidget); expect(find.text('CupertinoListTile subtitle'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('shows additionalInfo', (WidgetTester tester) async { testWidgets('shows additionalInfo', (WidgetTester tester) async {
const Widget additionalInfo = Text('Not Connected'); const Widget additionalInfo = Text('Not Connected');
await tester.pumpWidget( await tester.pumpWidget(
@ -60,7 +59,7 @@ void main() {
expect(find.text('Not Connected'), findsOneWidget); expect(find.text('Not Connected'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('shows trailing', (WidgetTester tester) async { testWidgets('shows trailing', (WidgetTester tester) async {
const Widget trailing = CupertinoListTileChevron(); const Widget trailing = CupertinoListTileChevron();
await tester.pumpWidget( await tester.pumpWidget(
@ -77,7 +76,7 @@ void main() {
expect(tester.widget<CupertinoListTileChevron>(find.byType(CupertinoListTileChevron)), trailing); expect(tester.widget<CupertinoListTileChevron>(find.byType(CupertinoListTileChevron)), trailing);
}); });
testWidgetsWithLeakTracking('shows leading', (WidgetTester tester) async { testWidgets('shows leading', (WidgetTester tester) async {
const Widget leading = Icon(CupertinoIcons.add); const Widget leading = Icon(CupertinoIcons.add);
await tester.pumpWidget( await tester.pumpWidget(
@ -94,7 +93,7 @@ void main() {
expect(tester.widget<Icon>(find.byType(Icon)), leading); expect(tester.widget<Icon>(find.byType(Icon)), leading);
}); });
testWidgetsWithLeakTracking('sets backgroundColor', (WidgetTester tester) async { testWidgets('sets backgroundColor', (WidgetTester tester) async {
const Color backgroundColor = CupertinoColors.systemRed; const Color backgroundColor = CupertinoColors.systemRed;
await tester.pumpWidget( await tester.pumpWidget(
@ -119,7 +118,7 @@ void main() {
expect(container.color, backgroundColor); expect(container.color, backgroundColor);
}); });
testWidgetsWithLeakTracking('does not change backgroundColor when tapped if onTap is not provided', (WidgetTester tester) async { testWidgets('does not change backgroundColor when tapped if onTap is not provided', (WidgetTester tester) async {
const Color backgroundColor = CupertinoColors.systemBlue; const Color backgroundColor = CupertinoColors.systemBlue;
const Color backgroundColorActivated = CupertinoColors.systemRed; const Color backgroundColorActivated = CupertinoColors.systemRed;
@ -149,7 +148,7 @@ void main() {
expect(container.color, backgroundColor); expect(container.color, backgroundColor);
}); });
testWidgetsWithLeakTracking('changes backgroundColor when tapped if onTap is provided', (WidgetTester tester) async { testWidgets('changes backgroundColor when tapped if onTap is provided', (WidgetTester tester) async {
const Color backgroundColor = CupertinoColors.systemBlue; const Color backgroundColor = CupertinoColors.systemBlue;
const Color backgroundColorActivated = CupertinoColors.systemRed; const Color backgroundColorActivated = CupertinoColors.systemRed;
@ -188,7 +187,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('does not contain GestureDetector if onTap is not provided', (WidgetTester tester) async { testWidgets('does not contain GestureDetector if onTap is not provided', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -209,7 +208,7 @@ void main() {
expect(find.byType(GestureDetector), findsNothing); expect(find.byType(GestureDetector), findsNothing);
}); });
testWidgetsWithLeakTracking('contains GestureDetector if onTap is provided', (WidgetTester tester) async { testWidgets('contains GestureDetector if onTap is provided', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -231,7 +230,7 @@ void main() {
expect(find.byType(GestureDetector), findsOneWidget); expect(find.byType(GestureDetector), findsOneWidget);
}); });
testWidgetsWithLeakTracking('resets the background color when navigated back', (WidgetTester tester) async { testWidgets('resets the background color when navigated back', (WidgetTester tester) async {
const Color backgroundColor = CupertinoColors.systemBlue; const Color backgroundColor = CupertinoColors.systemBlue;
const Color backgroundColorActivated = CupertinoColors.systemRed; const Color backgroundColorActivated = CupertinoColors.systemRed;
@ -280,7 +279,7 @@ void main() {
}); });
group('alignment of widgets for left-to-right', () { group('alignment of widgets for left-to-right', () {
testWidgetsWithLeakTracking('leading is on the left of title', (WidgetTester tester) async { testWidgets('leading is on the left of title', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
const Widget leading = Icon(CupertinoIcons.add); const Widget leading = Icon(CupertinoIcons.add);
@ -304,7 +303,7 @@ void main() {
expect(foundTitle.dx > foundLeading.dx, true); expect(foundTitle.dx > foundLeading.dx, true);
}); });
testWidgetsWithLeakTracking('subtitle is placed below title and aligned on left', (WidgetTester tester) async { testWidgets('subtitle is placed below title and aligned on left', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile title'); const Widget title = Text('CupertinoListTile title');
const Widget subtitle = Text('CupertinoListTile subtitle'); const Widget subtitle = Text('CupertinoListTile subtitle');
@ -329,7 +328,7 @@ void main() {
expect(foundTitle.dy < foundSubtitle.dy, isTrue); expect(foundTitle.dy < foundSubtitle.dy, isTrue);
}); });
testWidgetsWithLeakTracking('additionalInfo is on the right of title', (WidgetTester tester) async { testWidgets('additionalInfo is on the right of title', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
const Widget additionalInfo = Text('Not Connected'); const Widget additionalInfo = Text('Not Connected');
@ -353,7 +352,7 @@ void main() {
expect(foundTitle.dx < foundInfo.dx, isTrue); expect(foundTitle.dx < foundInfo.dx, isTrue);
}); });
testWidgetsWithLeakTracking('trailing is on the right of additionalInfo', (WidgetTester tester) async { testWidgets('trailing is on the right of additionalInfo', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
const Widget additionalInfo = Text('Not Connected'); const Widget additionalInfo = Text('Not Connected');
const Widget trailing = CupertinoListTileChevron(); const Widget trailing = CupertinoListTileChevron();
@ -381,7 +380,7 @@ void main() {
}); });
group('alignment of widgets for right-to-left', () { group('alignment of widgets for right-to-left', () {
testWidgetsWithLeakTracking('leading is on the right of title', (WidgetTester tester) async { testWidgets('leading is on the right of title', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
const Widget leading = Icon(CupertinoIcons.add); const Widget leading = Icon(CupertinoIcons.add);
@ -405,7 +404,7 @@ void main() {
expect(foundTitle.dx < foundLeading.dx, true); expect(foundTitle.dx < foundLeading.dx, true);
}); });
testWidgetsWithLeakTracking('subtitle is placed below title and aligned on right', (WidgetTester tester) async { testWidgets('subtitle is placed below title and aligned on right', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile title'); const Widget title = Text('CupertinoListTile title');
const Widget subtitle = Text('CupertinoListTile subtitle'); const Widget subtitle = Text('CupertinoListTile subtitle');
@ -430,7 +429,7 @@ void main() {
expect(foundTitle.dy < foundSubtitle.dy, isTrue); expect(foundTitle.dy < foundSubtitle.dy, isTrue);
}); });
testWidgetsWithLeakTracking('additionalInfo is on the left of title', (WidgetTester tester) async { testWidgets('additionalInfo is on the left of title', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
const Widget additionalInfo = Text('Not Connected'); const Widget additionalInfo = Text('Not Connected');
@ -454,7 +453,7 @@ void main() {
expect(foundTitle.dx > foundInfo.dx, isTrue); expect(foundTitle.dx > foundInfo.dx, isTrue);
}); });
testWidgetsWithLeakTracking('trailing is on the left of additionalInfo', (WidgetTester tester) async { testWidgets('trailing is on the left of additionalInfo', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
const Widget additionalInfo = Text('Not Connected'); const Widget additionalInfo = Text('Not Connected');
const Widget trailing = CupertinoListTileChevron(); const Widget trailing = CupertinoListTileChevron();
@ -481,7 +480,7 @@ void main() {
}); });
}); });
testWidgetsWithLeakTracking('onTap with delay does not throw an exception', (WidgetTester tester) async { testWidgets('onTap with delay does not throw an exception', (WidgetTester tester) async {
const Widget title = Text('CupertinoListTile'); const Widget title = Text('CupertinoListTile');
bool showTile = true; bool showTile = true;
@ -521,7 +520,7 @@ void main() {
expect(tester.takeException(), null); expect(tester.takeException(), null);
}); });
testWidgetsWithLeakTracking('title does not overflow', (WidgetTester tester) async { testWidgets('title does not overflow', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
@ -535,7 +534,7 @@ void main() {
expect(tester.takeException(), null); expect(tester.takeException(), null);
}); });
testWidgetsWithLeakTracking('subtitle does not overflow', (WidgetTester tester) async { testWidgets('subtitle does not overflow', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(

View File

@ -4,10 +4,9 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('English translations exist for all CupertinoLocalization properties', (WidgetTester tester) async { testWidgets('English translations exist for all CupertinoLocalization properties', (WidgetTester tester) async {
const CupertinoLocalizations localizations = DefaultCupertinoLocalizations(); const CupertinoLocalizations localizations = DefaultCupertinoLocalizations();
expect(localizations.datePickerYear(2018), isNotNull); expect(localizations.datePickerYear(2018), isNotNull);
@ -38,7 +37,7 @@ void main() {
expect(localizations.clearButtonLabel, isNotNull); expect(localizations.clearButtonLabel, isNotNull);
}); });
testWidgetsWithLeakTracking('CupertinoLocalizations.of throws', (WidgetTester tester) async { testWidgets('CupertinoLocalizations.of throws', (WidgetTester tester) async {
final GlobalKey noLocalizationsAvailable = GlobalKey(); final GlobalKey noLocalizationsAvailable = GlobalKey();
final GlobalKey localizationsAvailable = GlobalKey(); final GlobalKey localizationsAvailable = GlobalKey();

View File

@ -8,7 +8,6 @@ library;
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
final Offset basicOffset = Offset(CupertinoMagnifier.kDefaultSize.width / 2, final Offset basicOffset = Offset(CupertinoMagnifier.kDefaultSize.width / 2,
@ -49,7 +48,7 @@ void main() {
animatedPositioned.left ?? 0, animatedPositioned.top ?? 0); animatedPositioned.left ?? 0, animatedPositioned.top ?? 0);
} }
testWidgetsWithLeakTracking('should be at gesture position if does not violate any positioning rules', (WidgetTester tester) async { testWidgets('should be at gesture position if does not violate any positioning rules', (WidgetTester tester) async {
final Key fakeTextFieldKey = UniqueKey(); final Key fakeTextFieldKey = UniqueKey();
final Key outerKey = UniqueKey(); final Key outerKey = UniqueKey();
@ -100,7 +99,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('should never horizontally be outside of Screen Padding', (WidgetTester tester) async { testWidgets('should never horizontally be outside of Screen Padding', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
color: Color.fromARGB(7, 0, 129, 90), color: Color.fromARGB(7, 0, 129, 90),
@ -132,7 +131,7 @@ void main() {
lessThan(MediaQuery.sizeOf(context).width)); lessThan(MediaQuery.sizeOf(context).width));
}); });
testWidgetsWithLeakTracking('should have some vertical drag', (WidgetTester tester) async { testWidgets('should have some vertical drag', (WidgetTester tester) async {
final double dragPositionBelowTextField = reasonableTextField.center.dy + 30; final double dragPositionBelowTextField = reasonableTextField.center.dy + 30;
await tester.pumpWidget( await tester.pumpWidget(
@ -173,7 +172,7 @@ void main() {
}); });
group('status', () { group('status', () {
testWidgetsWithLeakTracking('should hide if gesture is far below the text field', (WidgetTester tester) async { testWidgets('should hide if gesture is far below the text field', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
color: Color.fromARGB(7, 0, 129, 90), color: Color.fromARGB(7, 0, 129, 90),
@ -213,7 +212,7 @@ void main() {
expect(magnifierController.overlayEntry, isNotNull); expect(magnifierController.overlayEntry, isNotNull);
}); });
testWidgetsWithLeakTracking('should re-show if gesture moves back up', testWidgets('should re-show if gesture moves back up',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(

View File

@ -7,7 +7,6 @@ import 'dart:typed_data';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../../image_data.dart'; import '../../image_data.dart';
@ -18,7 +17,7 @@ void main() {
selectedTabs = <int>[]; selectedTabs = <int>[];
}); });
testWidgetsWithLeakTracking('Last tab gets focus', (WidgetTester tester) async { testWidgets('Last tab gets focus', (WidgetTester tester) async {
// 2 nodes for 2 tabs // 2 nodes for 2 tabs
final List<FocusNode> focusNodes = <FocusNode>[]; final List<FocusNode> focusNodes = <FocusNode>[];
for (int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
@ -58,7 +57,7 @@ void main() {
expect(focusNodes[1].hasFocus, isFalse); expect(focusNodes[1].hasFocus, isFalse);
}); });
testWidgetsWithLeakTracking('Do not affect focus order in the route', (WidgetTester tester) async { testWidgets('Do not affect focus order in the route', (WidgetTester tester) async {
final List<FocusNode> focusNodes = <FocusNode>[]; final List<FocusNode> focusNodes = <FocusNode>[];
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
@ -127,7 +126,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Tab bar respects themes', (WidgetTester tester) async { testWidgets('Tab bar respects themes', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTabScaffold( home: CupertinoTabScaffold(
@ -185,7 +184,7 @@ void main() {
expect(tab2.text.style!.color!.value, CupertinoColors.systemRed.darkColor.value); expect(tab2.text.style!.color!.value, CupertinoColors.systemRed.darkColor.value);
}); });
testWidgetsWithLeakTracking('dark mode background color', (WidgetTester tester) async { testWidgets('dark mode background color', (WidgetTester tester) async {
const CupertinoDynamicColor backgroundColor = CupertinoDynamicColor.withBrightness( const CupertinoDynamicColor backgroundColor = CupertinoDynamicColor.withBrightness(
color: Color(0xFF123456), color: Color(0xFF123456),
darkColor: Color(0xFF654321), darkColor: Color(0xFF654321),
@ -238,7 +237,7 @@ void main() {
expect(tabDecoration.color!.value, backgroundColor.darkColor.value); expect(tabDecoration.color!.value, backgroundColor.darkColor.value);
}); });
testWidgetsWithLeakTracking('Does not lose state when focusing on text input', (WidgetTester tester) async { testWidgets('Does not lose state when focusing on text input', (WidgetTester tester) async {
// Regression testing for https://github.com/flutter/flutter/issues/28457. // Regression testing for https://github.com/flutter/flutter/issues/28457.
await tester.pumpWidget( await tester.pumpWidget(
@ -284,7 +283,7 @@ void main() {
expect(find.text("don't lose me"), findsOneWidget); expect(find.text("don't lose me"), findsOneWidget);
}); });
testWidgetsWithLeakTracking('textScaleFactor is set to 1.0', (WidgetTester tester) async { testWidgets('textScaleFactor is set to 1.0', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Builder(builder: (BuildContext context) { home: Builder(builder: (BuildContext context) {

View File

@ -11,14 +11,13 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
int count = 0; int count = 0;
void main() { void main() {
testWidgetsWithLeakTracking('Middle still in center with asymmetrical actions', (WidgetTester tester) async { testWidgets('Middle still in center with asymmetrical actions', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoNavigationBar( home: CupertinoNavigationBar(
@ -35,7 +34,7 @@ void main() {
expect(tester.getCenter(find.text('Title')).dx, 400.0); expect(tester.getCenter(find.text('Title')).dx, 400.0);
}); });
testWidgetsWithLeakTracking('Middle still in center with back button', (WidgetTester tester) async { testWidgets('Middle still in center with back button', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoNavigationBar( home: CupertinoNavigationBar(
@ -59,7 +58,7 @@ void main() {
expect(tester.getCenter(find.text('Page 2')).dx, 400.0); expect(tester.getCenter(find.text('Page 2')).dx, 400.0);
}); });
testWidgetsWithLeakTracking('Opaque background does not add blur effects, non-opaque background adds blur effects', (WidgetTester tester) async { testWidgets('Opaque background does not add blur effects, non-opaque background adds blur effects', (WidgetTester tester) async {
const CupertinoDynamicColor background = CupertinoDynamicColor.withBrightness( const CupertinoDynamicColor background = CupertinoDynamicColor.withBrightness(
color: Color(0xFFE5E5E5), color: Color(0xFFE5E5E5),
darkColor: Color(0xF3E5E5E5), darkColor: Color(0xF3E5E5E5),
@ -90,7 +89,7 @@ void main() {
expect(find.byType(CupertinoNavigationBar), paints..rect(color: background.darkColor)); expect(find.byType(CupertinoNavigationBar), paints..rect(color: background.darkColor));
}); });
testWidgetsWithLeakTracking('Non-opaque background adds blur effects', (WidgetTester tester) async { testWidgets('Non-opaque background adds blur effects', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoNavigationBar( home: CupertinoNavigationBar(
@ -101,7 +100,7 @@ void main() {
expect(find.byType(BackdropFilter), findsOneWidget); expect(find.byType(BackdropFilter), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Nav bar displays correctly', (WidgetTester tester) async { testWidgets('Nav bar displays correctly', (WidgetTester tester) async {
final GlobalKey<NavigatorState> navigator = GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> navigator = GlobalKey<NavigatorState>();
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -131,7 +130,7 @@ void main() {
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
}); });
testWidgetsWithLeakTracking('Can specify custom padding', (WidgetTester tester) async { testWidgets('Can specify custom padding', (WidgetTester tester) async {
final Key middleBox = GlobalKey(); final Key middleBox = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -188,7 +187,7 @@ void main() {
} }
// Regression test for https://github.com/flutter/flutter/issues/119270 // Regression test for https://github.com/flutter/flutter/issues/119270
testWidgetsWithLeakTracking('System navigation bar properties are not overridden', (WidgetTester tester) async { testWidgets('System navigation bar properties are not overridden', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoNavigationBar( home: CupertinoNavigationBar(
@ -199,7 +198,7 @@ void main() {
expectSameStatusBarStyle(SystemChrome.latestStyle!, SystemUiOverlayStyle.dark); expectSameStatusBarStyle(SystemChrome.latestStyle!, SystemUiOverlayStyle.dark);
}); });
testWidgetsWithLeakTracking('Can specify custom brightness', (WidgetTester tester) async { testWidgets('Can specify custom brightness', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoNavigationBar( home: CupertinoNavigationBar(
@ -251,7 +250,7 @@ void main() {
expectSameStatusBarStyle(SystemChrome.latestStyle!, SystemUiOverlayStyle.dark); expectSameStatusBarStyle(SystemChrome.latestStyle!, SystemUiOverlayStyle.dark);
}); });
testWidgetsWithLeakTracking('Padding works in RTL', (WidgetTester tester) async { testWidgets('Padding works in RTL', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Directionality( home: Directionality(
@ -281,7 +280,7 @@ void main() {
expect(tester.getCenter(find.text('Title')).dx, 400.0); expect(tester.getCenter(find.text('Title')).dx, 400.0);
}); });
testWidgetsWithLeakTracking('Nav bar uses theme defaults', (WidgetTester tester) async { testWidgets('Nav bar uses theme defaults', (WidgetTester tester) async {
count = 0x000000; count = 0x000000;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -301,7 +300,7 @@ void main() {
expect(count, 0x010101); expect(count, 0x010101);
}); });
testWidgetsWithLeakTracking('Nav bar respects themes', (WidgetTester tester) async { testWidgets('Nav bar respects themes', (WidgetTester tester) async {
count = 0x000000; count = 0x000000;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -322,7 +321,7 @@ void main() {
expect(count, 0x010101); expect(count, 0x010101);
}); });
testWidgetsWithLeakTracking('Theme active color can be overridden', (WidgetTester tester) async { testWidgets('Theme active color can be overridden', (WidgetTester tester) async {
count = 0x000000; count = 0x000000;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -343,7 +342,7 @@ void main() {
expect(count, 0x010101); expect(count, 0x010101);
}); });
testWidgetsWithLeakTracking('No slivers with no large titles', (WidgetTester tester) async { testWidgets('No slivers with no large titles', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
@ -358,7 +357,7 @@ void main() {
expect(find.byType(SliverPersistentHeader), findsNothing); expect(find.byType(SliverPersistentHeader), findsNothing);
}); });
testWidgetsWithLeakTracking('Media padding is applied to CupertinoSliverNavigationBar', (WidgetTester tester) async { testWidgets('Media padding is applied to CupertinoSliverNavigationBar', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
final Key leadingKey = GlobalKey(); final Key leadingKey = GlobalKey();
@ -407,7 +406,7 @@ void main() {
expect(tester.getTopLeft(find.byKey(titleKey)), const Offset(16.0 + 20.0, 54.0 + 10.0)); expect(tester.getTopLeft(find.byKey(titleKey)), const Offset(16.0 + 20.0, 54.0 + 10.0));
}); });
testWidgetsWithLeakTracking('Large title nav bar scrolls', (WidgetTester tester) async { testWidgets('Large title nav bar scrolls', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -488,7 +487,7 @@ void main() {
expect(tester.getSize(find.widgetWithText(ClipRect, 'Title').first).height, 0.0); expect(tester.getSize(find.widgetWithText(ClipRect, 'Title').first).height, 0.0);
}); });
testWidgetsWithLeakTracking('User specified middle is always visible in sliver', (WidgetTester tester) async { testWidgets('User specified middle is always visible in sliver', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
final Key segmentedControlsKey = UniqueKey(); final Key segmentedControlsKey = UniqueKey();
@ -546,7 +545,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('User specified middle is only visible when sliver is collapsed if alwaysShowMiddle is false', (WidgetTester tester) async { testWidgets('User specified middle is only visible when sliver is collapsed if alwaysShowMiddle is false', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -593,7 +592,7 @@ void main() {
expect(middleOpacity.opacity.value, 0.0); expect(middleOpacity.opacity.value, 0.0);
}); });
testWidgetsWithLeakTracking('Small title can be overridden', (WidgetTester tester) async { testWidgets('Small title can be overridden', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -658,7 +657,7 @@ void main() {
expect(tester.getBottomLeft(find.text('Title')).dy, 44.0); // Extension gone. expect(tester.getBottomLeft(find.text('Title')).dy, 44.0); // Extension gone.
}); });
testWidgetsWithLeakTracking('Auto back/close button', (WidgetTester tester) async { testWidgets('Auto back/close button', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoNavigationBar( home: CupertinoNavigationBar(
@ -713,7 +712,7 @@ void main() {
expect(find.text('Home page'), findsOneWidget); expect(find.text('Home page'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Long back label turns into "back"', (WidgetTester tester) async { testWidgets('Long back label turns into "back"', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Placeholder(), home: Placeholder(),
@ -756,7 +755,7 @@ void main() {
expect(find.widgetWithText(CupertinoButton, 'Back'), findsOneWidget); expect(find.widgetWithText(CupertinoButton, 'Back'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Border should be displayed by default', (WidgetTester tester) async { testWidgets('Border should be displayed by default', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoNavigationBar( home: CupertinoNavigationBar(
@ -778,7 +777,7 @@ void main() {
expect(side, isNotNull); expect(side, isNotNull);
}); });
testWidgetsWithLeakTracking('Overrides border color', (WidgetTester tester) async { testWidgets('Overrides border color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoNavigationBar( home: CupertinoNavigationBar(
@ -807,7 +806,7 @@ void main() {
expect(side.color, const Color(0xFFAABBCC)); expect(side.color, const Color(0xFFAABBCC));
}); });
testWidgetsWithLeakTracking('Border should not be displayed when null', (WidgetTester tester) async { testWidgets('Border should not be displayed when null', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoNavigationBar( home: CupertinoNavigationBar(
@ -827,7 +826,7 @@ void main() {
expect(decoration.border, isNull); expect(decoration.border, isNull);
}); });
testWidgetsWithLeakTracking('Border is displayed by default in sliver nav bar', (WidgetTester tester) async { testWidgets('Border is displayed by default in sliver nav bar', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
@ -855,7 +854,7 @@ void main() {
expect(bottom, isNotNull); expect(bottom, isNotNull);
}); });
testWidgetsWithLeakTracking('Border is not displayed when null in sliver nav bar', (WidgetTester tester) async { testWidgets('Border is not displayed when null in sliver nav bar', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
@ -881,7 +880,7 @@ void main() {
expect(decoration.border, isNull); expect(decoration.border, isNull);
}); });
testWidgetsWithLeakTracking('CupertinoSliverNavigationBar has semantics', (WidgetTester tester) async { testWidgets('CupertinoSliverNavigationBar has semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(const CupertinoApp( await tester.pumpWidget(const CupertinoApp(
@ -906,7 +905,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('CupertinoNavigationBar has semantics', (WidgetTester tester) async { testWidgets('CupertinoNavigationBar has semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
@ -927,7 +926,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Border can be overridden in sliver nav bar', (WidgetTester tester) async { testWidgets('Border can be overridden in sliver nav bar', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
@ -965,7 +964,7 @@ void main() {
expect(bottom.color, const Color(0xFFAABBCC)); expect(bottom.color, const Color(0xFFAABBCC));
}); });
testWidgetsWithLeakTracking( testWidgets(
'Standard title golden', 'Standard title golden',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -988,7 +987,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'Large title golden', 'Large title golden',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -1019,7 +1018,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('NavBar draws a light system bar for a dark background', (WidgetTester tester) async { testWidgets('NavBar draws a light system bar for a dark background', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
WidgetsApp( WidgetsApp(
color: const Color(0xFFFFFFFF), color: const Color(0xFFFFFFFF),
@ -1039,7 +1038,7 @@ void main() {
expectSameStatusBarStyle(SystemChrome.latestStyle!, SystemUiOverlayStyle.light); expectSameStatusBarStyle(SystemChrome.latestStyle!, SystemUiOverlayStyle.light);
}); });
testWidgetsWithLeakTracking('NavBar draws a dark system bar for a light background', (WidgetTester tester) async { testWidgets('NavBar draws a dark system bar for a light background', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
WidgetsApp( WidgetsApp(
color: const Color(0xFFFFFFFF), color: const Color(0xFFFFFFFF),
@ -1059,7 +1058,7 @@ void main() {
expectSameStatusBarStyle(SystemChrome.latestStyle!, SystemUiOverlayStyle.dark); expectSameStatusBarStyle(SystemChrome.latestStyle!, SystemUiOverlayStyle.dark);
}); });
testWidgetsWithLeakTracking('CupertinoNavigationBarBackButton shows an error when manually added outside a route', (WidgetTester tester) async { testWidgets('CupertinoNavigationBarBackButton shows an error when manually added outside a route', (WidgetTester tester) async {
await tester.pumpWidget(const CupertinoNavigationBarBackButton()); await tester.pumpWidget(const CupertinoNavigationBarBackButton());
final dynamic exception = tester.takeException(); final dynamic exception = tester.takeException();
@ -1067,7 +1066,7 @@ void main() {
expect(exception.toString(), contains('CupertinoNavigationBarBackButton should only be used in routes that can be popped')); expect(exception.toString(), contains('CupertinoNavigationBarBackButton should only be used in routes that can be popped'));
}); });
testWidgetsWithLeakTracking('CupertinoNavigationBarBackButton shows an error when placed in a route that cannot be popped', (WidgetTester tester) async { testWidgets('CupertinoNavigationBarBackButton shows an error when placed in a route that cannot be popped', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoNavigationBarBackButton(), home: CupertinoNavigationBarBackButton(),
@ -1079,7 +1078,7 @@ void main() {
expect(exception.toString(), contains('CupertinoNavigationBarBackButton should only be used in routes that can be popped')); expect(exception.toString(), contains('CupertinoNavigationBarBackButton should only be used in routes that can be popped'));
}); });
testWidgetsWithLeakTracking('CupertinoNavigationBarBackButton with a custom onPressed callback can be placed anywhere', (WidgetTester tester) async { testWidgets('CupertinoNavigationBarBackButton with a custom onPressed callback can be placed anywhere', (WidgetTester tester) async {
bool backPressed = false; bool backPressed = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -1098,7 +1097,7 @@ void main() {
expect(backPressed, true); expect(backPressed, true);
}); });
testWidgetsWithLeakTracking( testWidgets(
'Manually inserted CupertinoNavigationBarBackButton still automatically ' 'Manually inserted CupertinoNavigationBarBackButton still automatically '
'show previous page title when possible', 'show previous page title when possible',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -1139,7 +1138,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'CupertinoNavigationBarBackButton onPressed overrides default pop behavior', 'CupertinoNavigationBarBackButton onPressed overrides default pop behavior',
(WidgetTester tester) async { (WidgetTester tester) async {
bool backPressed = false; bool backPressed = false;
@ -1194,7 +1193,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('textScaleFactor is set to 1.0', (WidgetTester tester) async { testWidgets('textScaleFactor is set to 1.0', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Builder(builder: (BuildContext context) { home: Builder(builder: (BuildContext context) {
@ -1273,7 +1272,7 @@ void main() {
expect(barItems2.any((RichText t) => t.textScaleFactor != 1), isFalse); expect(barItems2.any((RichText t) => t.textScaleFactor != 1), isFalse);
}); });
testWidgetsWithLeakTracking( testWidgets(
'CupertinoSliverNavigationBar stretches upon over-scroll and bounces back once over-scroll ends', 'CupertinoSliverNavigationBar stretches upon over-scroll and bounces back once over-scroll ends',
(WidgetTester tester) async { (WidgetTester tester) async {
const Text trailingText = Text('Bar Button'); const Text trailingText = Text('Bar Button');
@ -1328,7 +1327,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'CupertinoSliverNavigationBar does not stretch upon over-scroll if stretch parameter is false', 'CupertinoSliverNavigationBar does not stretch upon over-scroll if stretch parameter is false',
(WidgetTester tester) async { (WidgetTester tester) async {
const Text trailingText = Text('Bar Button'); const Text trailingText = Text('Bar Button');
@ -1382,7 +1381,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('Null NavigationBar border transition', (WidgetTester tester) async { testWidgets('Null NavigationBar border transition', (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/71389 // This is a regression test for https://github.com/flutter/flutter/issues/71389
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
@ -1422,7 +1421,7 @@ void main() {
expect(find.text('Page 2'), findsNothing); expect(find.text('Page 2'), findsNothing);
}); });
testWidgetsWithLeakTracking( testWidgets(
'CupertinoSliverNavigationBar magnifies upon over-scroll and shrinks back once over-scroll ends', 'CupertinoSliverNavigationBar magnifies upon over-scroll and shrinks back once over-scroll ends',
(WidgetTester tester) async { (WidgetTester tester) async {
const Text titleText = Text('Large Title'); const Text titleText = Text('Large Title');
@ -1480,7 +1479,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'CupertinoSliverNavigationBar large title text does not get clipped when magnified', 'CupertinoSliverNavigationBar large title text does not get clipped when magnified',
(WidgetTester tester) async { (WidgetTester tester) async {
const Text titleText = Text('Very very very long large title'); const Text titleText = Text('Very very very long large title');
@ -1527,7 +1526,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'CupertinoSliverNavigationBar large title can be hit tested when magnified', 'CupertinoSliverNavigationBar large title can be hit tested when magnified',
(WidgetTester tester) async { (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();

View File

@ -11,7 +11,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
Future<void> startTransitionBetween( Future<void> startTransitionBetween(
WidgetTester tester, { WidgetTester tester, {
@ -132,7 +131,7 @@ void checkOpacity(WidgetTester tester, Finder finder, double opacity) {
} }
void main() { void main() {
testWidgetsWithLeakTracking('Bottom middle moves between middle and back label', (WidgetTester tester) async { testWidgets('Bottom middle moves between middle and back label', (WidgetTester tester) async {
await startTransitionBetween(tester, fromTitle: 'Page 1'); await startTransitionBetween(tester, fromTitle: 'Page 1');
// Be mid-transition. // Be mid-transition.
@ -160,7 +159,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Bottom middle moves between middle and back label RTL', (WidgetTester tester) async { testWidgets('Bottom middle moves between middle and back label RTL', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
fromTitle: 'Page 1', fromTitle: 'Page 1',
@ -187,7 +186,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Bottom middle never changes size during the animation', (WidgetTester tester) async { testWidgets('Bottom middle never changes size during the animation', (WidgetTester tester) async {
await tester.binding.setSurfaceSize(const Size(1080.0 / 2.75, 600)); await tester.binding.setSurfaceSize(const Size(1080.0 / 2.75, 600));
addTearDown(() async { addTearDown(() async {
await tester.binding.setSurfaceSize(const Size(800.0, 600.0)); await tester.binding.setSurfaceSize(const Size(800.0, 600.0));
@ -208,7 +207,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('Bottom middle and top back label transitions their font', (WidgetTester tester) async { testWidgets('Bottom middle and top back label transitions their font', (WidgetTester tester) async {
await startTransitionBetween(tester, fromTitle: 'Page 1'); await startTransitionBetween(tester, fromTitle: 'Page 1');
// Be mid-transition. // Be mid-transition.
@ -252,7 +251,7 @@ void main() {
checkOpacity(tester, flying(tester, find.text('Page 1')).last, 0.5292819738388062); checkOpacity(tester, flying(tester, find.text('Page 1')).last, 0.5292819738388062);
}); });
testWidgetsWithLeakTracking('Font transitions respect themes', (WidgetTester tester) async { testWidgets('Font transitions respect themes', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
fromTitle: 'Page 1', fromTitle: 'Page 1',
@ -300,7 +299,7 @@ void main() {
checkOpacity(tester, flying(tester, find.text('Page 1')).last, 0.5292819738388062); checkOpacity(tester, flying(tester, find.text('Page 1')).last, 0.5292819738388062);
}); });
testWidgetsWithLeakTracking('Fullscreen dialogs do not create heroes', (WidgetTester tester) async { testWidgets('Fullscreen dialogs do not create heroes', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Placeholder(), home: Placeholder(),
@ -334,7 +333,7 @@ void main() {
expect(() => flying(tester, find.text('Page 2')), throwsAssertionError); expect(() => flying(tester, find.text('Page 2')), throwsAssertionError);
}); });
testWidgetsWithLeakTracking('Turning off transition works', (WidgetTester tester) async { testWidgets('Turning off transition works', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
from: const CupertinoNavigationBar( from: const CupertinoNavigationBar(
@ -358,7 +357,7 @@ void main() {
expect(() => flying(tester, find.text('Page 2')), throwsAssertionError); expect(() => flying(tester, find.text('Page 2')), throwsAssertionError);
}); });
testWidgetsWithLeakTracking('Popping mid-transition is symmetrical', (WidgetTester tester) async { testWidgets('Popping mid-transition is symmetrical', (WidgetTester tester) async {
await startTransitionBetween(tester, fromTitle: 'Page 1'); await startTransitionBetween(tester, fromTitle: 'Page 1');
// Be mid-transition. // Be mid-transition.
@ -406,7 +405,7 @@ void main() {
checkColorAndPositionAt50ms(); checkColorAndPositionAt50ms();
}); });
testWidgetsWithLeakTracking('Popping mid-transition is symmetrical RTL', (WidgetTester tester) async { testWidgets('Popping mid-transition is symmetrical RTL', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
fromTitle: 'Page 1', fromTitle: 'Page 1',
@ -457,7 +456,7 @@ void main() {
checkColorAndPositionAt50ms(); checkColorAndPositionAt50ms();
}); });
testWidgetsWithLeakTracking('There should be no global keys in the hero flight', (WidgetTester tester) async { testWidgets('There should be no global keys in the hero flight', (WidgetTester tester) async {
await startTransitionBetween(tester, fromTitle: 'Page 1'); await startTransitionBetween(tester, fromTitle: 'Page 1');
// Be mid-transition. // Be mid-transition.
@ -472,7 +471,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('DartPerformanceMode is latency mid-animation', (WidgetTester tester) async { testWidgets('DartPerformanceMode is latency mid-animation', (WidgetTester tester) async {
DartPerformanceMode? mode; DartPerformanceMode? mode;
// before the animation starts, no requests are active. // before the animation starts, no requests are active.
@ -492,7 +491,7 @@ void main() {
expect(mode, isNull); expect(mode, isNull);
}); });
testWidgetsWithLeakTracking('Multiple nav bars tags do not conflict if in different navigators', (WidgetTester tester) async { testWidgets('Multiple nav bars tags do not conflict if in different navigators', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTabScaffold( home: CupertinoTabScaffold(
@ -567,7 +566,7 @@ void main() {
expect(find.text('Tab 1 Page 2', skipOffstage: false), findsNothing); expect(find.text('Tab 1 Page 2', skipOffstage: false), findsNothing);
}); });
testWidgetsWithLeakTracking('Transition box grows to large title size', (WidgetTester tester) async { testWidgets('Transition box grows to large title size', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
fromTitle: 'Page 1', fromTitle: 'Page 1',
@ -591,7 +590,7 @@ void main() {
checkBackgroundBoxHeight(tester, 84.33018499612808); checkBackgroundBoxHeight(tester, 84.33018499612808);
}); });
testWidgetsWithLeakTracking('Large transition box shrinks to standard nav bar size', (WidgetTester tester) async { testWidgets('Large transition box shrinks to standard nav bar size', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
from: const CupertinoSliverNavigationBar(), from: const CupertinoSliverNavigationBar(),
@ -615,7 +614,7 @@ void main() {
checkBackgroundBoxHeight(tester, 55.66981500387192); checkBackgroundBoxHeight(tester, 55.66981500387192);
}); });
testWidgetsWithLeakTracking('Hero flight removed at the end of page transition', (WidgetTester tester) async { testWidgets('Hero flight removed at the end of page transition', (WidgetTester tester) async {
await startTransitionBetween(tester, fromTitle: 'Page 1'); await startTransitionBetween(tester, fromTitle: 'Page 1');
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
@ -630,7 +629,7 @@ void main() {
expect(() => flying(tester, find.text('Page 1')), throwsAssertionError); expect(() => flying(tester, find.text('Page 1')), throwsAssertionError);
}); });
testWidgetsWithLeakTracking('Exact widget is reused to build inside the transition', (WidgetTester tester) async { testWidgets('Exact widget is reused to build inside the transition', (WidgetTester tester) async {
const Widget userMiddle = Placeholder(); const Widget userMiddle = Placeholder();
await startTransitionBetween( await startTransitionBetween(
tester, tester,
@ -646,7 +645,7 @@ void main() {
expect(flying(tester, find.byWidget(userMiddle)), findsOneWidget); expect(flying(tester, find.byWidget(userMiddle)), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Middle is not shown if alwaysShowMiddle is false and the nav bar is expanded', (WidgetTester tester) async { testWidgets('Middle is not shown if alwaysShowMiddle is false and the nav bar is expanded', (WidgetTester tester) async {
const Widget userMiddle = Placeholder(); const Widget userMiddle = Placeholder();
await startTransitionBetween( await startTransitionBetween(
tester, tester,
@ -663,7 +662,7 @@ void main() {
expect(flying(tester, find.byWidget(userMiddle)), findsNothing); expect(flying(tester, find.byWidget(userMiddle)), findsNothing);
}); });
testWidgetsWithLeakTracking('Middle is shown if alwaysShowMiddle is false but the nav bar is collapsed', (WidgetTester tester) async { testWidgets('Middle is shown if alwaysShowMiddle is false but the nav bar is collapsed', (WidgetTester tester) async {
const Widget userMiddle = Placeholder(); const Widget userMiddle = Placeholder();
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
@ -712,7 +711,7 @@ void main() {
expect(flying(tester, find.byWidget(userMiddle)), findsOneWidget); expect(flying(tester, find.byWidget(userMiddle)), findsOneWidget);
}); });
testWidgetsWithLeakTracking('First appearance of back chevron fades in from the right', (WidgetTester tester) async { testWidgets('First appearance of back chevron fades in from the right', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: scaffoldForNavBar(null), home: scaffoldForNavBar(null),
@ -751,7 +750,7 @@ void main() {
)); ));
}); });
testWidgetsWithLeakTracking('First appearance of back chevron fades in from the left in RTL', (WidgetTester tester) async { testWidgets('First appearance of back chevron fades in from the left in RTL', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget? navigator) { builder: (BuildContext context, Widget? navigator) {
@ -803,7 +802,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Back chevron fades out and in when both pages have it', (WidgetTester tester) async { testWidgets('Back chevron fades out and in when both pages have it', (WidgetTester tester) async {
await startTransitionBetween(tester, fromTitle: 'Page 1'); await startTransitionBetween(tester, fromTitle: 'Page 1');
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
@ -829,7 +828,7 @@ void main() {
expect(tester.getTopLeft(backChevrons.last), const Offset(14.0, 7.0)); expect(tester.getTopLeft(backChevrons.last), const Offset(14.0, 7.0));
}); });
testWidgetsWithLeakTracking('Bottom middle just fades if top page has a custom leading', (WidgetTester tester) async { testWidgets('Bottom middle just fades if top page has a custom leading', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
fromTitle: 'Page 1', fromTitle: 'Page 1',
@ -860,7 +859,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Bottom leading fades in place', (WidgetTester tester) async { testWidgets('Bottom leading fades in place', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
from: const CupertinoSliverNavigationBar(leading: Text('custom')), from: const CupertinoSliverNavigationBar(leading: Text('custom')),
@ -886,7 +885,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Bottom trailing fades in place', (WidgetTester tester) async { testWidgets('Bottom trailing fades in place', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
from: const CupertinoSliverNavigationBar(trailing: Text('custom')), from: const CupertinoSliverNavigationBar(trailing: Text('custom')),
@ -918,7 +917,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Bottom back label fades and slides to the left', (WidgetTester tester) async { testWidgets('Bottom back label fades and slides to the left', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
fromTitle: 'Page 1', fromTitle: 'Page 1',
@ -960,7 +959,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Bottom back label fades and slides to the right in RTL', (WidgetTester tester) async { testWidgets('Bottom back label fades and slides to the right in RTL', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
fromTitle: 'Page 1', fromTitle: 'Page 1',
@ -1004,7 +1003,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Bottom large title moves to top back label', (WidgetTester tester) async { testWidgets('Bottom large title moves to top back label', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
from: const CupertinoSliverNavigationBar(), from: const CupertinoSliverNavigationBar(),
@ -1056,7 +1055,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Long title turns into the word back mid transition', (WidgetTester tester) async { testWidgets('Long title turns into the word back mid transition', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
from: const CupertinoSliverNavigationBar(), from: const CupertinoSliverNavigationBar(),
@ -1106,7 +1105,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Bottom large title and top back label transitions their font', (WidgetTester tester) async { testWidgets('Bottom large title and top back label transitions their font', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
from: const CupertinoSliverNavigationBar(), from: const CupertinoSliverNavigationBar(),
@ -1145,7 +1144,7 @@ void main() {
expect(topBackLabel.text.style!.letterSpacing, moreOrLessEquals(-0.23270857974886894)); expect(topBackLabel.text.style!.letterSpacing, moreOrLessEquals(-0.23270857974886894));
}); });
testWidgetsWithLeakTracking('Top middle fades in and slides in from the right', (WidgetTester tester) async { testWidgets('Top middle fades in and slides in from the right', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
toTitle: 'Page 2', toTitle: 'Page 2',
@ -1176,7 +1175,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Top middle never changes size during the animation', (WidgetTester tester) async { testWidgets('Top middle never changes size during the animation', (WidgetTester tester) async {
await tester.binding.setSurfaceSize(const Size(1080.0 / 2.75, 600)); await tester.binding.setSurfaceSize(const Size(1080.0 / 2.75, 600));
addTearDown(() async { addTearDown(() async {
await tester.binding.setSurfaceSize(const Size(800.0, 600.0)); await tester.binding.setSurfaceSize(const Size(800.0, 600.0));
@ -1200,7 +1199,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('Top middle fades in and slides in from the left in RTL', (WidgetTester tester) async { testWidgets('Top middle fades in and slides in from the left in RTL', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
toTitle: 'Page 2', toTitle: 'Page 2',
@ -1232,7 +1231,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Top large title fades in and slides in from the right', (WidgetTester tester) async { testWidgets('Top large title fades in and slides in from the right', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
to: const CupertinoSliverNavigationBar(), to: const CupertinoSliverNavigationBar(),
@ -1258,7 +1257,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Top large title fades in and slides in from the left in RTL', (WidgetTester tester) async { testWidgets('Top large title fades in and slides in from the left in RTL', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
to: const CupertinoSliverNavigationBar(), to: const CupertinoSliverNavigationBar(),
@ -1285,7 +1284,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Components are not unnecessarily rebuilt during transitions', (WidgetTester tester) async { testWidgets('Components are not unnecessarily rebuilt during transitions', (WidgetTester tester) async {
int bottomBuildTimes = 0; int bottomBuildTimes = 0;
int topBuildTimes = 0; int topBuildTimes = 0;
await startTransitionBetween( await startTransitionBetween(
@ -1330,7 +1329,7 @@ void main() {
expect(topBuildTimes, 3); expect(topBuildTimes, 3);
}); });
testWidgetsWithLeakTracking('Back swipe gesture transitions', (WidgetTester tester) async { testWidgets('Back swipe gesture transitions', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
fromTitle: 'Page 1', fromTitle: 'Page 1',
@ -1393,7 +1392,7 @@ void main() {
expect(find.text('Page 1'), findsOneWidget); expect(find.text('Page 1'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('textScaleFactor is set to 1.0 on transition', (WidgetTester tester) async { testWidgets('textScaleFactor is set to 1.0 on transition', (WidgetTester tester) async {
await startTransitionBetween(tester, fromTitle: 'Page 1', textScale: 99); await startTransitionBetween(tester, fromTitle: 'Page 1', textScale: 99);
await tester.pump(const Duration(milliseconds: 50)); await tester.pump(const Duration(milliseconds: 50));
@ -1401,7 +1400,7 @@ void main() {
expect(tester.firstWidget<RichText>(flying(tester, find.byType(RichText))).textScaleFactor, 1); expect(tester.firstWidget<RichText>(flying(tester, find.byType(RichText))).textScaleFactor, 1);
}); });
testWidgetsWithLeakTracking('Back swipe gesture cancels properly with transition', (WidgetTester tester) async { testWidgets('Back swipe gesture cancels properly with transition', (WidgetTester tester) async {
await startTransitionBetween( await startTransitionBetween(
tester, tester,
fromTitle: 'Page 1', fromTitle: 'Page 1',

View File

@ -4,10 +4,9 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('test iOS page transition (LTR)', (WidgetTester tester) async { testWidgets('test iOS page transition (LTR)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
onGenerateRoute: (RouteSettings settings) { onGenerateRoute: (RouteSettings settings) {
@ -80,7 +79,7 @@ void main() {
expect(widget1InitialTopLeft, equals(widget1TransientTopLeft)); expect(widget1InitialTopLeft, equals(widget1TransientTopLeft));
}); });
testWidgetsWithLeakTracking('test iOS page transition (RTL)', (WidgetTester tester) async { testWidgets('test iOS page transition (RTL)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[ localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
@ -151,7 +150,7 @@ void main() {
expect(widget1InitialTopLeft, equals(widget1TransientTopLeft)); expect(widget1InitialTopLeft, equals(widget1TransientTopLeft));
}); });
testWidgetsWithLeakTracking('test iOS fullscreen dialog transition', (WidgetTester tester) async { testWidgets('test iOS fullscreen dialog transition', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Center(child: Text('Page 1')), home: Center(child: Text('Page 1')),
@ -211,7 +210,7 @@ void main() {
expect(widget1InitialTopLeft, equals(widget1TransientTopLeft)); expect(widget1InitialTopLeft, equals(widget1TransientTopLeft));
}); });
testWidgetsWithLeakTracking('test only edge swipes work (LTR)', (WidgetTester tester) async { testWidgets('test only edge swipes work (LTR)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
onGenerateRoute: (RouteSettings settings) { onGenerateRoute: (RouteSettings settings) {
@ -272,7 +271,7 @@ void main() {
expect(find.text('Page 2'), isOnstage); expect(find.text('Page 2'), isOnstage);
}); });
testWidgetsWithLeakTracking('test edge swipes work with media query padding (LTR)', (WidgetTester tester) async { testWidgets('test edge swipes work with media query padding (LTR)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget? navigator) { builder: (BuildContext context, Widget? navigator) {
@ -316,7 +315,7 @@ void main() {
expect(find.text('Page 2'), isOnstage); expect(find.text('Page 2'), isOnstage);
}); });
testWidgetsWithLeakTracking('test edge swipes work with media query padding (RLT)', (WidgetTester tester) async { testWidgets('test edge swipes work with media query padding (RLT)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget? navigator) { builder: (BuildContext context, Widget? navigator) {
@ -364,7 +363,7 @@ void main() {
expect(find.text('Page 2'), isOnstage); expect(find.text('Page 2'), isOnstage);
}); });
testWidgetsWithLeakTracking('test only edge swipes work (RTL)', (WidgetTester tester) async { testWidgets('test only edge swipes work (RTL)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
localizationsDelegates: const <LocalizationsDelegate<dynamic>>[ localizationsDelegates: const <LocalizationsDelegate<dynamic>>[
@ -429,7 +428,7 @@ void main() {
expect(find.text('Page 2'), isOnstage); expect(find.text('Page 2'), isOnstage);
}); });
testWidgetsWithLeakTracking('test edge swipe then drop back at starting point works', (WidgetTester tester) async { testWidgets('test edge swipe then drop back at starting point works', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
onGenerateRoute: (RouteSettings settings) { onGenerateRoute: (RouteSettings settings) {
@ -464,7 +463,7 @@ void main() {
expect(find.text('Page 2'), isOnstage); expect(find.text('Page 2'), isOnstage);
}); });
testWidgetsWithLeakTracking('CupertinoPage does not lose its state when transitioning out', (WidgetTester tester) async { testWidgets('CupertinoPage does not lose its state when transitioning out', (WidgetTester tester) async {
final GlobalKey<NavigatorState> navigator = GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> navigator = GlobalKey<NavigatorState>();
await tester.pumpWidget(KeepsStateTestWidget(navigatorKey: navigator)); await tester.pumpWidget(KeepsStateTestWidget(navigatorKey: navigator));
expect(find.text('subpage'), findsOneWidget); expect(find.text('subpage'), findsOneWidget);
@ -477,7 +476,7 @@ void main() {
expect(find.text('home'), findsOneWidget); expect(find.text('home'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('CupertinoPage restores its state', (WidgetTester tester) async { testWidgets('CupertinoPage restores its state', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
RootRestorationScope( RootRestorationScope(
restorationId: 'root', restorationId: 'root',

View File

@ -8,7 +8,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../rendering/rendering_tester.dart'; import '../rendering/rendering_tester.dart';
@ -19,7 +18,7 @@ class SpyFixedExtentScrollController extends FixedExtentScrollController {
} }
void main() { void main() {
testWidgetsWithLeakTracking('Picker respects theme styling', (WidgetTester tester) async { testWidgets('Picker respects theme styling', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Align( home: Align(
@ -58,7 +57,7 @@ void main() {
group('layout', () { group('layout', () {
// Regression test for https://github.com/flutter/flutter/issues/22999 // Regression test for https://github.com/flutter/flutter/issues/22999
testWidgetsWithLeakTracking('CupertinoPicker.builder test', (WidgetTester tester) async { testWidgets('CupertinoPicker.builder test', (WidgetTester tester) async {
Widget buildFrame(int childCount) { Widget buildFrame(int childCount) {
return Directionality( return Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -81,7 +80,7 @@ void main() {
expect(tester.renderObject(find.text('1')).attached, true); expect(tester.renderObject(find.text('1')).attached, true);
}); });
testWidgetsWithLeakTracking('selected item is in the middle', (WidgetTester tester) async { testWidgets('selected item is in the middle', (WidgetTester tester) async {
final FixedExtentScrollController controller = FixedExtentScrollController(initialItem: 1); final FixedExtentScrollController controller = FixedExtentScrollController(initialItem: 1);
addTearDown(controller.dispose); addTearDown(controller.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -128,7 +127,7 @@ void main() {
}); });
}); });
testWidgetsWithLeakTracking('picker dark mode', (WidgetTester tester) async { testWidgets('picker dark mode', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.light), theme: const CupertinoThemeData(brightness: Brightness.light),
@ -180,7 +179,7 @@ void main() {
expect(find.byType(CupertinoPicker), paints..rect(color: const Color(0xFF654321))); expect(find.byType(CupertinoPicker), paints..rect(color: const Color(0xFF654321)));
}); });
testWidgetsWithLeakTracking('picker selectionOverlay', (WidgetTester tester) async { testWidgets('picker selectionOverlay', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.light), theme: const CupertinoThemeData(brightness: Brightness.light),
@ -203,7 +202,7 @@ void main() {
expect(find.byType(CupertinoPicker), paints..rrect(color: const Color(0x12345678))); expect(find.byType(CupertinoPicker), paints..rrect(color: const Color(0x12345678)));
}); });
testWidgetsWithLeakTracking('CupertinoPicker.selectionOverlay is nullable', (WidgetTester tester) async { testWidgets('CupertinoPicker.selectionOverlay is nullable', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.light), theme: const CupertinoThemeData(brightness: Brightness.light),
@ -227,7 +226,7 @@ void main() {
}); });
group('scroll', () { group('scroll', () {
testWidgetsWithLeakTracking( testWidgets(
'scrolling calls onSelectedItemChanged and triggers haptic feedback', 'scrolling calls onSelectedItemChanged and triggers haptic feedback',
(WidgetTester tester) async { (WidgetTester tester) async {
final List<int> selectedItems = <int>[]; final List<int> selectedItems = <int>[];
@ -281,7 +280,7 @@ void main() {
variant: TargetPlatformVariant.only(TargetPlatform.iOS), variant: TargetPlatformVariant.only(TargetPlatform.iOS),
); );
testWidgetsWithLeakTracking( testWidgets(
'do not trigger haptic effects on non-iOS devices', 'do not trigger haptic effects on non-iOS devices',
(WidgetTester tester) async { (WidgetTester tester) async {
final List<int> selectedItems = <int>[]; final List<int> selectedItems = <int>[];
@ -318,7 +317,7 @@ void main() {
variant: TargetPlatformVariant(TargetPlatform.values.where((TargetPlatform platform) => platform != TargetPlatform.iOS).toSet()), variant: TargetPlatformVariant(TargetPlatform.values.where((TargetPlatform platform) => platform != TargetPlatform.iOS).toSet()),
); );
testWidgetsWithLeakTracking('a drag in between items settles back', (WidgetTester tester) async { testWidgets('a drag in between items settles back', (WidgetTester tester) async {
final FixedExtentScrollController controller = FixedExtentScrollController(initialItem: 10); final FixedExtentScrollController controller = FixedExtentScrollController(initialItem: 10);
addTearDown(controller.dispose); addTearDown(controller.dispose);
final List<int> selectedItems = <int>[]; final List<int> selectedItems = <int>[];
@ -373,7 +372,7 @@ void main() {
expect(selectedItems, <int>[9]); expect(selectedItems, <int>[9]);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgetsWithLeakTracking('a big fling that overscrolls springs back', (WidgetTester tester) async { testWidgets('a big fling that overscrolls springs back', (WidgetTester tester) async {
final FixedExtentScrollController controller = final FixedExtentScrollController controller =
FixedExtentScrollController(initialItem: 10); FixedExtentScrollController(initialItem: 10);
addTearDown(controller.dispose); addTearDown(controller.dispose);
@ -436,7 +435,7 @@ void main() {
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
}); });
testWidgetsWithLeakTracking('Picker adapts to MaterialApp dark mode', (WidgetTester tester) async { testWidgets('Picker adapts to MaterialApp dark mode', (WidgetTester tester) async {
Widget buildCupertinoPicker(Brightness brightness) { Widget buildCupertinoPicker(Brightness brightness) {
return MaterialApp( return MaterialApp(
theme: ThemeData(brightness: brightness), theme: ThemeData(brightness: brightness),
@ -477,7 +476,7 @@ void main() {
}); });
group('CupertinoPickerDefaultSelectionOverlay', () { group('CupertinoPickerDefaultSelectionOverlay', () {
testWidgetsWithLeakTracking('should be using directional decoration', (WidgetTester tester) async { testWidgets('should be using directional decoration', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.light), theme: const CupertinoThemeData(brightness: Brightness.light),
@ -500,7 +499,7 @@ void main() {
}); });
}); });
testWidgetsWithLeakTracking('Scroll controller is detached upon dispose', (WidgetTester tester) async { testWidgets('Scroll controller is detached upon dispose', (WidgetTester tester) async {
final SpyFixedExtentScrollController controller = SpyFixedExtentScrollController(); final SpyFixedExtentScrollController controller = SpyFixedExtentScrollController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
expect(controller.hasListeners, false); expect(controller.hasListeners, false);
@ -532,7 +531,7 @@ void main() {
expect(controller.positions.length, 0); expect(controller.positions.length, 0);
}); });
testWidgetsWithLeakTracking( testWidgets(
'Registers taps and does not crash with certain diameterRatio', (WidgetTester tester) async { 'Registers taps and does not crash with certain diameterRatio', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/126491 // Regression test for https://github.com/flutter/flutter/issues/126491

View File

@ -7,12 +7,11 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
void main() { void main() {
testWidgetsWithLeakTracking('Radio control test', (WidgetTester tester) async { testWidgets('Radio control test', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
final List<int?> log = <int?>[]; final List<int?> log = <int?>[];
@ -64,7 +63,7 @@ void main() {
expect(log, isEmpty); expect(log, isEmpty);
}); });
testWidgetsWithLeakTracking('Radio can be toggled when toggleable is set', (WidgetTester tester) async { testWidgets('Radio can be toggled when toggleable is set', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
final List<int?> log = <int?>[]; final List<int?> log = <int?>[];
@ -119,7 +118,7 @@ void main() {
expect(log, equals(<int>[1])); expect(log, equals(<int>[1]));
}); });
testWidgetsWithLeakTracking('Radio selected semantics - platform adaptive', (WidgetTester tester) async { testWidgets('Radio selected semantics - platform adaptive', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
@ -154,7 +153,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}, variant: TargetPlatformVariant.all()); }, variant: TargetPlatformVariant.all());
testWidgetsWithLeakTracking('Radio semantics', (WidgetTester tester) async { testWidgets('Radio semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
@ -242,7 +241,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('has semantic events', (WidgetTester tester) async { testWidgets('has semantic events', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
final Key key = UniqueKey(); final Key key = UniqueKey();
dynamic semanticEvent; dynamic semanticEvent;
@ -279,7 +278,7 @@ void main() {
tester.binding.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, null); tester.binding.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, null);
}); });
testWidgetsWithLeakTracking('Radio can be controlled by keyboard shortcuts', (WidgetTester tester) async { testWidgets('Radio can be controlled by keyboard shortcuts', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
int? groupValue = 1; int? groupValue = 1;
const Key radioKey0 = Key('radio0'); const Key radioKey0 = Key('radio0');
@ -352,7 +351,7 @@ void main() {
expect(groupValue, equals(2)); expect(groupValue, equals(2));
}); });
testWidgetsWithLeakTracking('Show a checkmark when useCheckmarkStyle is true', (WidgetTester tester) async { testWidgets('Show a checkmark when useCheckmarkStyle is true', (WidgetTester tester) async {
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: Center( home: Center(
child: CupertinoRadio<int>( child: CupertinoRadio<int>(
@ -407,7 +406,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Do not crash when widget disappears while pointer is down', (WidgetTester tester) async { testWidgets('Do not crash when widget disappears while pointer is down', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
Widget buildRadio(bool show) { Widget buildRadio(bool show) {

View File

@ -10,7 +10,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
late FakeBuilder mockHelper; late FakeBuilder mockHelper;
@ -35,7 +34,7 @@ void main() {
} }
void uiTestGroup() { void uiTestGroup() {
testWidgetsWithLeakTracking("doesn't invoke anything without user interaction", (WidgetTester tester) async { testWidgets("doesn't invoke anything without user interaction", (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CustomScrollView( home: CustomScrollView(
@ -57,7 +56,7 @@ void main() {
); );
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgetsWithLeakTracking('calls the indicator builder when starting to overscroll', (WidgetTester tester) async { testWidgets('calls the indicator builder when starting to overscroll', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CustomScrollView( home: CustomScrollView(
@ -91,7 +90,7 @@ void main() {
); );
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgetsWithLeakTracking( testWidgets(
"don't call the builder if overscroll doesn't move slivers like on Android", "don't call the builder if overscroll doesn't move slivers like on Android",
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -125,7 +124,7 @@ void main() {
variant: TargetPlatformVariant.only(TargetPlatform.android), variant: TargetPlatformVariant.only(TargetPlatform.android),
); );
testWidgetsWithLeakTracking('let the builder update as canceled drag scrolls away', (WidgetTester tester) async { testWidgets('let the builder update as canceled drag scrolls away', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CustomScrollView( home: CustomScrollView(
@ -187,7 +186,7 @@ void main() {
); );
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgetsWithLeakTracking('drag past threshold triggers refresh task', (WidgetTester tester) async { testWidgets('drag past threshold triggers refresh task', (WidgetTester tester) async {
final List<MethodCall> platformCallLog = <MethodCall>[]; final List<MethodCall> platformCallLog = <MethodCall>[];
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async { tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(SystemChannels.platform, (MethodCall methodCall) async {
@ -269,7 +268,7 @@ void main() {
); );
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgetsWithLeakTracking( testWidgets(
'refreshing task keeps the sliver expanded forever until done', 'refreshing task keeps the sliver expanded forever until done',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -344,7 +343,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
); );
testWidgetsWithLeakTracking( testWidgets(
'refreshing task keeps the sliver expanded forever until completes with error', 'refreshing task keeps the sliver expanded forever until completes with error',
(WidgetTester tester) async { (WidgetTester tester) async {
final FlutterError error = FlutterError('Oops'); final FlutterError error = FlutterError('Oops');
@ -432,7 +431,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
); );
testWidgetsWithLeakTracking('expanded refreshing sliver scrolls normally', (WidgetTester tester) async { testWidgets('expanded refreshing sliver scrolls normally', (WidgetTester tester) async {
mockHelper.refreshIndicator = const Center(child: Text('-1')); mockHelper.refreshIndicator = const Center(child: Text('-1'));
await tester.pumpWidget( await tester.pumpWidget(
@ -521,7 +520,7 @@ void main() {
); );
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgetsWithLeakTracking('expanded refreshing sliver goes away when done', (WidgetTester tester) async { testWidgets('expanded refreshing sliver goes away when done', (WidgetTester tester) async {
mockHelper.refreshIndicator = const Center(child: Text('-1')); mockHelper.refreshIndicator = const Center(child: Text('-1'));
await tester.pumpWidget( await tester.pumpWidget(
@ -589,7 +588,7 @@ void main() {
); );
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgetsWithLeakTracking('builder still called when sliver snapped back more than 90%', (WidgetTester tester) async { testWidgets('builder still called when sliver snapped back more than 90%', (WidgetTester tester) async {
mockHelper.refreshIndicator = const Center(child: Text('-1')); mockHelper.refreshIndicator = const Center(child: Text('-1'));
await tester.pumpWidget( await tester.pumpWidget(
@ -687,7 +686,7 @@ void main() {
expect(find.text('-1'), findsOneWidget); expect(find.text('-1'), findsOneWidget);
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgetsWithLeakTracking( testWidgets(
'retracting sliver during done cannot be pulled to refresh again until fully retracted', 'retracting sliver during done cannot be pulled to refresh again until fully retracted',
(WidgetTester tester) async { (WidgetTester tester) async {
mockHelper.refreshIndicator = const Center(child: Text('-1')); mockHelper.refreshIndicator = const Center(child: Text('-1'));
@ -792,7 +791,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
); );
testWidgetsWithLeakTracking( testWidgets(
'sliver held in overscroll when task finishes completes normally', 'sliver held in overscroll when task finishes completes normally',
(WidgetTester tester) async { (WidgetTester tester) async {
mockHelper.refreshIndicator = const Center(child: Text('-1')); mockHelper.refreshIndicator = const Center(child: Text('-1'));
@ -844,7 +843,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
); );
testWidgetsWithLeakTracking( testWidgets(
'sliver scrolled away when task completes properly removes itself', 'sliver scrolled away when task completes properly removes itself',
(WidgetTester tester) async { (WidgetTester tester) async {
if (testListLength < 4) { if (testListLength < 4) {
@ -930,7 +929,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
); );
testWidgetsWithLeakTracking( testWidgets(
"don't do anything unless it can be overscrolled at the start of the list", "don't do anything unless it can be overscrolled at the start of the list",
(WidgetTester tester) async { (WidgetTester tester) async {
mockHelper.refreshIndicator = const Center(child: Text('-1')); mockHelper.refreshIndicator = const Center(child: Text('-1'));
@ -958,7 +957,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
); );
testWidgetsWithLeakTracking( testWidgets(
'without an onRefresh, builder is called with arm for one frame then sliver goes away', 'without an onRefresh, builder is called with arm for one frame then sliver goes away',
(WidgetTester tester) async { (WidgetTester tester) async {
mockHelper.refreshIndicator = const Center(child: Text('-1')); mockHelper.refreshIndicator = const Center(child: Text('-1'));
@ -1015,7 +1014,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
); );
testWidgetsWithLeakTracking('Should not crash when dragged', (WidgetTester tester) async { testWidgets('Should not crash when dragged', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CustomScrollView( home: CustomScrollView(
@ -1040,7 +1039,7 @@ void main() {
// Test to make sure the refresh sliver's overscroll isn't eaten by the // Test to make sure the refresh sliver's overscroll isn't eaten by the
// nav bar sliver https://github.com/flutter/flutter/issues/74516. // nav bar sliver https://github.com/flutter/flutter/issues/74516.
testWidgetsWithLeakTracking( testWidgets(
'properly displays when the refresh sliver is behind the large title nav bar sliver', 'properly displays when the refresh sliver is behind the large title nav bar sliver',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -1083,7 +1082,7 @@ void main() {
} }
void stateMachineTestGroup() { void stateMachineTestGroup() {
testWidgetsWithLeakTracking('starts in inactive state', (WidgetTester tester) async { testWidgets('starts in inactive state', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CustomScrollView( home: CustomScrollView(
@ -1103,7 +1102,7 @@ void main() {
); );
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgetsWithLeakTracking('goes to drag and returns to inactive in a small drag', (WidgetTester tester) async { testWidgets('goes to drag and returns to inactive in a small drag', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CustomScrollView( home: CustomScrollView(
@ -1133,7 +1132,7 @@ void main() {
); );
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgetsWithLeakTracking('goes to armed the frame it passes the threshold', (WidgetTester tester) async { testWidgets('goes to armed the frame it passes the threshold', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CustomScrollView( home: CustomScrollView(
@ -1168,7 +1167,7 @@ void main() {
); );
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS })); }, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));
testWidgetsWithLeakTracking( testWidgets(
'goes to refresh the frame it crossed back the refresh threshold', 'goes to refresh the frame it crossed back the refresh threshold',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -1217,7 +1216,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
); );
testWidgetsWithLeakTracking( testWidgets(
'goes to done internally as soon as the task finishes', 'goes to done internally as soon as the task finishes',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -1265,7 +1264,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
); );
testWidgetsWithLeakTracking( testWidgets(
'goes back to inactive when retracting back past 10% of arming distance', 'goes back to inactive when retracting back past 10% of arming distance',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -1350,7 +1349,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
); );
testWidgetsWithLeakTracking( testWidgets(
'goes back to inactive if already scrolled away when task completes', 'goes back to inactive if already scrolled away when task completes',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -1414,7 +1413,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
); );
testWidgetsWithLeakTracking( testWidgets(
"don't have to build any indicators or occupy space during refresh", "don't have to build any indicators or occupy space during refresh",
(WidgetTester tester) async { (WidgetTester tester) async {
mockHelper.refreshIndicator = const Center(child: Text('-1')); mockHelper.refreshIndicator = const Center(child: Text('-1'));
@ -1464,7 +1463,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }),
); );
testWidgetsWithLeakTracking('buildRefreshIndicator progress', (WidgetTester tester) async { testWidgets('buildRefreshIndicator progress', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Builder( home: Builder(
@ -1511,7 +1510,7 @@ void main() {
expect(tester.widget<CupertinoActivityIndicator>(find.byType(CupertinoActivityIndicator)).progress, 100.0 / 100.0); expect(tester.widget<CupertinoActivityIndicator>(find.byType(CupertinoActivityIndicator)).progress, 100.0 / 100.0);
}); });
testWidgetsWithLeakTracking('indicator should not become larger when overscrolled', (WidgetTester tester) async { testWidgets('indicator should not become larger when overscrolled', (WidgetTester tester) async {
// test for https://github.com/flutter/flutter/issues/79841 // test for https://github.com/flutter/flutter/issues/79841
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
@ -1547,7 +1546,7 @@ void main() {
// correct by coincidence. // correct by coincidence.
group('state machine test short list', stateMachineTestGroup); group('state machine test short list', stateMachineTestGroup);
testWidgetsWithLeakTracking( testWidgets(
'Does not crash when paintExtent > remainingPaintExtent', 'Does not crash when paintExtent > remainingPaintExtent',
(WidgetTester tester) async { (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/46871. // Regression test for https://github.com/flutter/flutter/issues/46871.

View File

@ -12,7 +12,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
@ -23,7 +22,7 @@ void main() {
navigatorObserver = MockNavigatorObserver(); navigatorObserver = MockNavigatorObserver();
}); });
testWidgetsWithLeakTracking('Middle auto-populates with title', (WidgetTester tester) async { testWidgets('Middle auto-populates with title', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Placeholder(), home: Placeholder(),
@ -53,7 +52,7 @@ void main() {
expect(tester.getCenter(find.text('An iPod')).dx, 400.0); expect(tester.getCenter(find.text('An iPod')).dx, 400.0);
}); });
testWidgetsWithLeakTracking('Large title auto-populates with title', (WidgetTester tester) async { testWidgets('Large title auto-populates with title', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Placeholder(), home: Placeholder(),
@ -118,7 +117,7 @@ void main() {
expect(tester.getCenter(find.byWidget(titles[0].widget)).dx, 400.0); expect(tester.getCenter(find.byWidget(titles[0].widget)).dx, 400.0);
}); });
testWidgetsWithLeakTracking('Leading auto-populates with back button with previous title', (WidgetTester tester) async { testWidgets('Leading auto-populates with back button with previous title', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Placeholder(), home: Placeholder(),
@ -165,7 +164,7 @@ void main() {
expect(tester.getTopLeft(find.text('An iPod')).dx, moreOrLessEquals(8.0 + 4.0 + 34.0 + 6.0, epsilon: 0.5)); expect(tester.getTopLeft(find.text('An iPod')).dx, moreOrLessEquals(8.0 + 4.0 + 34.0 + 6.0, epsilon: 0.5));
}); });
testWidgetsWithLeakTracking('Previous title is correct on first transition frame', (WidgetTester tester) async { testWidgets('Previous title is correct on first transition frame', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Placeholder(), home: Placeholder(),
@ -208,7 +207,7 @@ void main() {
expect(find.widgetWithText(CupertinoButton, 'An iPod'), findsOneWidget); expect(find.widgetWithText(CupertinoButton, 'An iPod'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Previous title stays up to date with changing routes', (WidgetTester tester) async { testWidgets('Previous title stays up to date with changing routes', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Placeholder(), home: Placeholder(),
@ -272,7 +271,7 @@ void main() {
expect(tester.getTopLeft(find.text('Back')).dx, moreOrLessEquals(8.0 + 4.0 + 34.0 + 6.0, epsilon: 0.5)); expect(tester.getTopLeft(find.text('Back')).dx, moreOrLessEquals(8.0 + 4.0 + 34.0 + 6.0, epsilon: 0.5));
}); });
testWidgetsWithLeakTracking('Back swipe dismiss interrupted by route push', (WidgetTester tester) async { testWidgets('Back swipe dismiss interrupted by route push', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/28728 // Regression test for https://github.com/flutter/flutter/issues/28728
final GlobalKey scaffoldKey = GlobalKey(); final GlobalKey scaffoldKey = GlobalKey();
@ -378,7 +377,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Fullscreen route animates correct transform values over time', (WidgetTester tester) async { testWidgets('Fullscreen route animates correct transform values over time', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Builder( home: Builder(
@ -563,11 +562,11 @@ void main() {
expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(-0.0, epsilon: 1.0)); expect(tester.getTopLeft(find.byType(Placeholder)).dx, moreOrLessEquals(-0.0, epsilon: 1.0));
} }
testWidgetsWithLeakTracking('CupertinoPageRoute has parallax when non fullscreenDialog route is pushed on top', (WidgetTester tester) async { testWidgets('CupertinoPageRoute has parallax when non fullscreenDialog route is pushed on top', (WidgetTester tester) async {
await testParallax(tester, fromFullscreenDialog: false); await testParallax(tester, fromFullscreenDialog: false);
}); });
testWidgetsWithLeakTracking('FullscreenDialog CupertinoPageRoute has parallax when non fullscreenDialog route is pushed on top', (WidgetTester tester) async { testWidgets('FullscreenDialog CupertinoPageRoute has parallax when non fullscreenDialog route is pushed on top', (WidgetTester tester) async {
await testParallax(tester, fromFullscreenDialog: true); await testParallax(tester, fromFullscreenDialog: true);
}); });
@ -652,15 +651,15 @@ void main() {
expect(tester.getTopLeft(find.byType(Placeholder)).dx, 0.0); expect(tester.getTopLeft(find.byType(Placeholder)).dx, 0.0);
} }
testWidgetsWithLeakTracking('CupertinoPageRoute has no parallax when fullscreenDialog route is pushed on top', (WidgetTester tester) async { testWidgets('CupertinoPageRoute has no parallax when fullscreenDialog route is pushed on top', (WidgetTester tester) async {
await testNoParallax(tester, fromFullscreenDialog: false); await testNoParallax(tester, fromFullscreenDialog: false);
}); });
testWidgetsWithLeakTracking('FullscreenDialog CupertinoPageRoute has no parallax when fullscreenDialog route is pushed on top', (WidgetTester tester) async { testWidgets('FullscreenDialog CupertinoPageRoute has no parallax when fullscreenDialog route is pushed on top', (WidgetTester tester) async {
await testNoParallax(tester, fromFullscreenDialog: true); await testNoParallax(tester, fromFullscreenDialog: true);
}); });
testWidgetsWithLeakTracking('Animated push/pop is not linear', (WidgetTester tester) async { testWidgets('Animated push/pop is not linear', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Text('1'), home: Text('1'),
@ -712,7 +711,7 @@ void main() {
expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(607, epsilon: 1)); expect(tester.getTopLeft(find.text('2')).dx, moreOrLessEquals(607, epsilon: 1));
}); });
testWidgetsWithLeakTracking('Dragged pop gesture is linear', (WidgetTester tester) async { testWidgets('Dragged pop gesture is linear', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Text('1'), home: Text('1'),
@ -759,7 +758,7 @@ void main() {
}); });
// Regression test for https://github.com/flutter/flutter/issues/137033. // Regression test for https://github.com/flutter/flutter/issues/137033.
testWidgetsWithLeakTracking('Update pages during a drag gesture will not stuck', (WidgetTester tester) async { testWidgets('Update pages during a drag gesture will not stuck', (WidgetTester tester) async {
await tester.pumpWidget(const _TestPageUpdate()); await tester.pumpWidget(const _TestPageUpdate());
@ -792,7 +791,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Pop gesture snapping is not linear', (WidgetTester tester) async { testWidgets('Pop gesture snapping is not linear', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Text('1'), home: Text('1'),
@ -839,7 +838,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Snapped drags forwards and backwards should signal didStart/StopUserGesture', (WidgetTester tester) async { testWidgets('Snapped drags forwards and backwards should signal didStart/StopUserGesture', (WidgetTester tester) async {
final GlobalKey<NavigatorState> navigatorKey = GlobalKey(); final GlobalKey<NavigatorState> navigatorKey = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -893,7 +892,7 @@ void main() {
}); });
/// Regression test for https://github.com/flutter/flutter/issues/29596. /// Regression test for https://github.com/flutter/flutter/issues/29596.
testWidgetsWithLeakTracking('test edge swipe then drop back at ending point works', (WidgetTester tester) async { testWidgets('test edge swipe then drop back at ending point works', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
navigatorObservers: <NavigatorObserver>[navigatorObserver], navigatorObservers: <NavigatorObserver>[navigatorObserver],
@ -930,7 +929,7 @@ void main() {
expect(navigatorObserver.invocations.removeLast(), NavigatorInvocation.didPop); expect(navigatorObserver.invocations.removeLast(), NavigatorInvocation.didPop);
}); });
testWidgetsWithLeakTracking('test edge swipe then drop back at starting point works', (WidgetTester tester) async { testWidgets('test edge swipe then drop back at starting point works', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
navigatorObservers: <NavigatorObserver>[navigatorObserver], navigatorObservers: <NavigatorObserver>[navigatorObserver],
@ -987,7 +986,7 @@ void main() {
); );
} }
testWidgetsWithLeakTracking('when route is not fullscreenDialog, it has a barrierColor', (WidgetTester tester) async { testWidgets('when route is not fullscreenDialog, it has a barrierColor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: SizedBox.expand(), home: SizedBox.expand(),
@ -1002,7 +1001,7 @@ void main() {
expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, const Color(0x18000000)); expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, const Color(0x18000000));
}); });
testWidgetsWithLeakTracking('when route is a fullscreenDialog, it has no barrierColor', (WidgetTester tester) async { testWidgets('when route is a fullscreenDialog, it has no barrierColor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: SizedBox.expand(), home: SizedBox.expand(),
@ -1017,7 +1016,7 @@ void main() {
expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, isNull); expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, isNull);
}); });
testWidgetsWithLeakTracking('when route is not fullscreenDialog, it has a _CupertinoEdgeShadowDecoration', (WidgetTester tester) async { testWidgets('when route is not fullscreenDialog, it has a _CupertinoEdgeShadowDecoration', (WidgetTester tester) async {
PaintPattern paintsShadowRect({required double dx, required Color color}) { PaintPattern paintsShadowRect({required double dx, required Color color}) {
return paints..everything((Symbol methodName, List<dynamic> arguments) { return paints..everything((Symbol methodName, List<dynamic> arguments) {
if (methodName != #drawRect) { if (methodName != #drawRect) {
@ -1107,7 +1106,7 @@ void main() {
expect(box, paintsShadowRect(dx: 754, color: const Color(0x00000000))); expect(box, paintsShadowRect(dx: 754, color: const Color(0x00000000)));
}); });
testWidgetsWithLeakTracking('when route is fullscreenDialog, it has no visible _CupertinoEdgeShadowDecoration', (WidgetTester tester) async { testWidgets('when route is fullscreenDialog, it has no visible _CupertinoEdgeShadowDecoration', (WidgetTester tester) async {
PaintPattern paintsNoShadows() { PaintPattern paintsNoShadows() {
return paints..everything((Symbol methodName, List<dynamic> arguments) { return paints..everything((Symbol methodName, List<dynamic> arguments) {
if (methodName != #drawRect) { if (methodName != #drawRect) {
@ -1149,7 +1148,7 @@ void main() {
}); });
}); });
testWidgetsWithLeakTracking('ModalPopup overlay dark mode', (WidgetTester tester) async { testWidgets('ModalPopup overlay dark mode', (WidgetTester tester) async {
late StateSetter stateSetter; late StateSetter stateSetter;
Brightness brightness = Brightness.light; Brightness brightness = Brightness.light;
@ -1222,7 +1221,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('During back swipe the route ignores input', (WidgetTester tester) async { testWidgets('During back swipe the route ignores input', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/39989 // Regression test for https://github.com/flutter/flutter/issues/39989
final GlobalKey homeScaffoldKey = GlobalKey(); final GlobalKey homeScaffoldKey = GlobalKey();
@ -1285,7 +1284,7 @@ void main() {
expect(pageTapCount, 1); expect(pageTapCount, 1);
}); });
testWidgetsWithLeakTracking('showCupertinoModalPopup uses root navigator by default', (WidgetTester tester) async { testWidgets('showCupertinoModalPopup uses root navigator by default', (WidgetTester tester) async {
final PopupObserver rootObserver = PopupObserver(); final PopupObserver rootObserver = PopupObserver();
final PopupObserver nestedObserver = PopupObserver(); final PopupObserver nestedObserver = PopupObserver();
@ -1318,7 +1317,7 @@ void main() {
expect(nestedObserver.popupCount, 0); expect(nestedObserver.popupCount, 0);
}); });
testWidgetsWithLeakTracking('back swipe to screen edges does not dismiss the hero animation', (WidgetTester tester) async { testWidgets('back swipe to screen edges does not dismiss the hero animation', (WidgetTester tester) async {
final GlobalKey<NavigatorState> navigator = GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> navigator = GlobalKey<NavigatorState>();
final UniqueKey container = UniqueKey(); final UniqueKey container = UniqueKey();
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
@ -1388,7 +1387,7 @@ void main() {
expect(firstPosition, greaterThan(thirdPosition)); expect(firstPosition, greaterThan(thirdPosition));
}); });
testWidgetsWithLeakTracking('showCupertinoModalPopup uses nested navigator if useRootNavigator is false', (WidgetTester tester) async { testWidgets('showCupertinoModalPopup uses nested navigator if useRootNavigator is false', (WidgetTester tester) async {
final PopupObserver rootObserver = PopupObserver(); final PopupObserver rootObserver = PopupObserver();
final PopupObserver nestedObserver = PopupObserver(); final PopupObserver nestedObserver = PopupObserver();
@ -1422,7 +1421,7 @@ void main() {
expect(nestedObserver.popupCount, 1); expect(nestedObserver.popupCount, 1);
}); });
testWidgetsWithLeakTracking('showCupertinoDialog uses root navigator by default', (WidgetTester tester) async { testWidgets('showCupertinoDialog uses root navigator by default', (WidgetTester tester) async {
final DialogObserver rootObserver = DialogObserver(); final DialogObserver rootObserver = DialogObserver();
final DialogObserver nestedObserver = DialogObserver(); final DialogObserver nestedObserver = DialogObserver();
@ -1455,7 +1454,7 @@ void main() {
expect(nestedObserver.dialogCount, 0); expect(nestedObserver.dialogCount, 0);
}); });
testWidgetsWithLeakTracking('showCupertinoDialog uses nested navigator if useRootNavigator is false', (WidgetTester tester) async { testWidgets('showCupertinoDialog uses nested navigator if useRootNavigator is false', (WidgetTester tester) async {
final DialogObserver rootObserver = DialogObserver(); final DialogObserver rootObserver = DialogObserver();
final DialogObserver nestedObserver = DialogObserver(); final DialogObserver nestedObserver = DialogObserver();
@ -1489,7 +1488,7 @@ void main() {
expect(nestedObserver.dialogCount, 1); expect(nestedObserver.dialogCount, 1);
}); });
testWidgetsWithLeakTracking('showCupertinoModalPopup does not allow for semantics dismiss by default', (WidgetTester tester) async { testWidgets('showCupertinoModalPopup does not allow for semantics dismiss by default', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS; debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
@ -1524,7 +1523,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('showCupertinoModalPopup allows for semantics dismiss when set', (WidgetTester tester) async { testWidgets('showCupertinoModalPopup allows for semantics dismiss when set', (WidgetTester tester) async {
debugDefaultTargetPlatformOverride = TargetPlatform.iOS; debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
@ -1560,7 +1559,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('showCupertinoModalPopup passes RouteSettings to PopupRoute', (WidgetTester tester) async { testWidgets('showCupertinoModalPopup passes RouteSettings to PopupRoute', (WidgetTester tester) async {
final RouteSettingsObserver routeSettingsObserver = RouteSettingsObserver(); final RouteSettingsObserver routeSettingsObserver = RouteSettingsObserver();
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
@ -1591,7 +1590,7 @@ void main() {
expect(routeSettingsObserver.routeName, '/modal'); expect(routeSettingsObserver.routeName, '/modal');
}); });
testWidgetsWithLeakTracking('showCupertinoModalPopup transparent barrier color is transparent', (WidgetTester tester) async { testWidgets('showCupertinoModalPopup transparent barrier color is transparent', (WidgetTester tester) async {
const Color kTransparentColor = Color(0x00000000); const Color kTransparentColor = Color(0x00000000);
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
@ -1617,7 +1616,7 @@ void main() {
expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, null); expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, null);
}); });
testWidgetsWithLeakTracking('showCupertinoModalPopup null barrier color must be default gray barrier color', (WidgetTester tester) async { testWidgets('showCupertinoModalPopup null barrier color must be default gray barrier color', (WidgetTester tester) async {
// Barrier color for a Cupertino modal barrier. // Barrier color for a Cupertino modal barrier.
// Extracted from https://developer.apple.com/design/resources/. // Extracted from https://developer.apple.com/design/resources/.
const Color kModalBarrierColor = CupertinoDynamicColor.withBrightness( const Color kModalBarrierColor = CupertinoDynamicColor.withBrightness(
@ -1647,7 +1646,7 @@ void main() {
expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, kModalBarrierColor); expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, kModalBarrierColor);
}); });
testWidgetsWithLeakTracking('showCupertinoModalPopup custom barrier color', (WidgetTester tester) async { testWidgets('showCupertinoModalPopup custom barrier color', (WidgetTester tester) async {
const Color customColor = Color(0x11223344); const Color customColor = Color(0x11223344);
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
@ -1673,7 +1672,7 @@ void main() {
expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, customColor); expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, customColor);
}); });
testWidgetsWithLeakTracking('showCupertinoModalPopup barrier dismissible', (WidgetTester tester) async { testWidgets('showCupertinoModalPopup barrier dismissible', (WidgetTester tester) async {
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
child: Builder(builder: (BuildContext context) { child: Builder(builder: (BuildContext context) {
@ -1698,7 +1697,7 @@ void main() {
expect(find.text('Visible'), findsNothing); expect(find.text('Visible'), findsNothing);
}); });
testWidgetsWithLeakTracking('showCupertinoModalPopup barrier not dismissible', (WidgetTester tester) async { testWidgets('showCupertinoModalPopup barrier not dismissible', (WidgetTester tester) async {
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
child: Builder(builder: (BuildContext context) { child: Builder(builder: (BuildContext context) {
@ -1724,7 +1723,7 @@ void main() {
expect(find.text('Visible'), findsOneWidget); expect(find.text('Visible'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('CupertinoPage works', (WidgetTester tester) async { testWidgets('CupertinoPage works', (WidgetTester tester) async {
final LocalKey pageKey = UniqueKey(); final LocalKey pageKey = UniqueKey();
final TransitionDetector detector = TransitionDetector(); final TransitionDetector detector = TransitionDetector();
List<Page<void>> myPages = <Page<void>>[ List<Page<void>> myPages = <Page<void>>[
@ -1785,7 +1784,7 @@ void main() {
expect(find.widgetWithText(CupertinoNavigationBar, 'title two'), findsOneWidget); expect(find.widgetWithText(CupertinoNavigationBar, 'title two'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('CupertinoPage can toggle MaintainState', (WidgetTester tester) async { testWidgets('CupertinoPage can toggle MaintainState', (WidgetTester tester) async {
final LocalKey pageKeyOne = UniqueKey(); final LocalKey pageKeyOne = UniqueKey();
final LocalKey pageKeyTwo = UniqueKey(); final LocalKey pageKeyTwo = UniqueKey();
final TransitionDetector detector = TransitionDetector(); final TransitionDetector detector = TransitionDetector();
@ -1834,7 +1833,7 @@ void main() {
expect(find.text('second'), findsOneWidget); expect(find.text('second'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Popping routes should cancel down events', (WidgetTester tester) async { testWidgets('Popping routes should cancel down events', (WidgetTester tester) async {
await tester.pumpWidget(const _TestPostRouteCancel()); await tester.pumpWidget(const _TestPostRouteCancel());
final TestGesture gesture = await tester.createGesture(); final TestGesture gesture = await tester.createGesture();
@ -1853,7 +1852,7 @@ void main() {
expect(find.text('PointerCancelEvents: 1'), findsOneWidget); expect(find.text('PointerCancelEvents: 1'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Popping routes during back swipe should not crash', (WidgetTester tester) async { testWidgets('Popping routes during back swipe should not crash', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/63984#issuecomment-675679939 // Regression test for https://github.com/flutter/flutter/issues/63984#issuecomment-675679939
final CupertinoPageRoute<void> r = CupertinoPageRoute<void>(builder: (BuildContext context) { final CupertinoPageRoute<void> r = CupertinoPageRoute<void>(builder: (BuildContext context) {
@ -1903,7 +1902,7 @@ void main() {
await tester.pump(); await tester.pump();
}); });
testWidgetsWithLeakTracking('CupertinoModalPopupRoute is state restorable', (WidgetTester tester) async { testWidgets('CupertinoModalPopupRoute is state restorable', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
restorationScopeId: 'app', restorationScopeId: 'app',
@ -1934,7 +1933,7 @@ void main() {
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/33615 }, skip: isBrowser); // https://github.com/flutter/flutter/issues/33615
group('showCupertinoDialog avoids overlapping display features', () { group('showCupertinoDialog avoids overlapping display features', () {
testWidgetsWithLeakTracking('positioning with anchorPoint', (WidgetTester tester) async { testWidgets('positioning with anchorPoint', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
@ -1972,7 +1971,7 @@ void main() {
expect(tester.getBottomRight(find.byType(Placeholder)), const Offset(800.0, 600.0)); expect(tester.getBottomRight(find.byType(Placeholder)), const Offset(800.0, 600.0));
}); });
testWidgetsWithLeakTracking('positioning with Directionality', (WidgetTester tester) async { testWidgets('positioning with Directionality', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
@ -2012,7 +2011,7 @@ void main() {
expect(tester.getBottomRight(find.byType(Placeholder)), const Offset(800.0, 600.0)); expect(tester.getBottomRight(find.byType(Placeholder)), const Offset(800.0, 600.0));
}); });
testWidgetsWithLeakTracking('positioning by default', (WidgetTester tester) async { testWidgets('positioning by default', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
@ -2051,7 +2050,7 @@ void main() {
}); });
group('showCupertinoModalPopup avoids overlapping display features', () { group('showCupertinoModalPopup avoids overlapping display features', () {
testWidgetsWithLeakTracking('positioning using anchorPoint', (WidgetTester tester) async { testWidgets('positioning using anchorPoint', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
@ -2089,7 +2088,7 @@ void main() {
expect(tester.getBottomRight(find.byType(Placeholder)).dx, 800); expect(tester.getBottomRight(find.byType(Placeholder)).dx, 800);
}); });
testWidgetsWithLeakTracking('positioning using Directionality', (WidgetTester tester) async { testWidgets('positioning using Directionality', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
@ -2129,7 +2128,7 @@ void main() {
expect(tester.getBottomRight(find.byType(Placeholder)).dx, 800); expect(tester.getBottomRight(find.byType(Placeholder)).dx, 800);
}); });
testWidgetsWithLeakTracking('default positioning', (WidgetTester tester) async { testWidgets('default positioning', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {

View File

@ -6,13 +6,12 @@ import 'dart:typed_data';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../image_data.dart'; import '../image_data.dart';
/// Integration tests testing both [CupertinoPageScaffold] and [CupertinoTabScaffold]. /// Integration tests testing both [CupertinoPageScaffold] and [CupertinoTabScaffold].
void main() { void main() {
testWidgetsWithLeakTracking('Contents are behind translucent bar', (WidgetTester tester) async { testWidgets('Contents are behind translucent bar', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
@ -28,7 +27,7 @@ void main() {
expect(tester.getTopLeft(find.byType(Center)), Offset.zero); expect(tester.getTopLeft(find.byType(Center)), Offset.zero);
}); });
testWidgetsWithLeakTracking('Opaque bar pushes contents down', (WidgetTester tester) async { testWidgets('Opaque bar pushes contents down', (WidgetTester tester) async {
late BuildContext childContext; late BuildContext childContext;
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -56,7 +55,7 @@ void main() {
expect(tester.getRect(find.byType(Container)), const Rect.fromLTRB(0, 44, 800, 600)); expect(tester.getRect(find.byType(Container)), const Rect.fromLTRB(0, 44, 800, 600));
}); });
testWidgetsWithLeakTracking('dark mode and obstruction work', (WidgetTester tester) async { testWidgets('dark mode and obstruction work', (WidgetTester tester) async {
const Color dynamicColor = CupertinoDynamicColor.withBrightness( const Color dynamicColor = CupertinoDynamicColor.withBrightness(
color: Color(0xFFF8F8F8), color: Color(0xFFF8F8F8),
darkColor: Color(0xEE333333), darkColor: Color(0xEE333333),
@ -103,7 +102,7 @@ void main() {
expect(find.byType(CupertinoPageScaffold), paints..rect(color: backgroundColor.darkColor)); expect(find.byType(CupertinoPageScaffold), paints..rect(color: backgroundColor.darkColor));
}); });
testWidgetsWithLeakTracking('Contents padding from viewInsets', (WidgetTester tester) async { testWidgets('Contents padding from viewInsets', (WidgetTester tester) async {
await tester.pumpWidget(Directionality( await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
child: MediaQuery( child: MediaQuery(
@ -161,7 +160,7 @@ void main() {
expect(tester.getSize(find.byType(Container)).height, 600.0); expect(tester.getSize(find.byType(Container)).height, 600.0);
}); });
testWidgetsWithLeakTracking('Contents bottom padding are not consumed by viewInsets when resizeToAvoidBottomInset overridden', (WidgetTester tester) async { testWidgets('Contents bottom padding are not consumed by viewInsets when resizeToAvoidBottomInset overridden', (WidgetTester tester) async {
const Widget child = CupertinoPageScaffold( const Widget child = CupertinoPageScaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
navigationBar: CupertinoNavigationBar( navigationBar: CupertinoNavigationBar(
@ -199,7 +198,7 @@ void main() {
expect(initialPoint, finalPoint); expect(initialPoint, finalPoint);
}); });
testWidgetsWithLeakTracking('Contents are between opaque bars', (WidgetTester tester) async { testWidgets('Contents are between opaque bars', (WidgetTester tester) async {
const Center page1Center = Center(); const Center page1Center = Center();
await tester.pumpWidget( await tester.pumpWidget(
@ -236,7 +235,7 @@ void main() {
expect(tester.getSize(find.byWidget(page1Center)).height, 600.0 - 44.0 - 50.0); expect(tester.getSize(find.byWidget(page1Center)).height, 600.0 - 44.0 - 50.0);
}); });
testWidgetsWithLeakTracking('Contents have automatic sliver padding between translucent bars', (WidgetTester tester) async { testWidgets('Contents have automatic sliver padding between translucent bars', (WidgetTester tester) async {
const SizedBox content = SizedBox(height: 600.0, width: 600.0); const SizedBox content = SizedBox(height: 600.0, width: 600.0);
await tester.pumpWidget( await tester.pumpWidget(
@ -290,7 +289,7 @@ void main() {
expect(tester.getBottomLeft(find.byWidget(content)).dy, 600 - 20.0 - 50.0); expect(tester.getBottomLeft(find.byWidget(content)).dy, 600 - 20.0 - 50.0);
}); });
testWidgetsWithLeakTracking('iOS independent tab navigation', (WidgetTester tester) async { testWidgets('iOS independent tab navigation', (WidgetTester tester) async {
// A full on iOS information architecture app with 2 tabs, and 2 pages // A full on iOS information architecture app with 2 tabs, and 2 pages
// in each with independent navigation states. // in each with independent navigation states.
await tester.pumpWidget( await tester.pumpWidget(
@ -399,7 +398,7 @@ void main() {
expect(find.text('Page 2 of tab 1', skipOffstage: false), isOffstage); expect(find.text('Page 2 of tab 1', skipOffstage: false), isOffstage);
}); });
testWidgetsWithLeakTracking('Decorated with white background by default', (WidgetTester tester) async { testWidgets('Decorated with white background by default', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
@ -415,7 +414,7 @@ void main() {
expect(decoration.color, isSameColorAs(CupertinoColors.white)); expect(decoration.color, isSameColorAs(CupertinoColors.white));
}); });
testWidgetsWithLeakTracking('Overrides background color', (WidgetTester tester) async { testWidgets('Overrides background color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: CupertinoPageScaffold( home: CupertinoPageScaffold(
@ -432,7 +431,7 @@ void main() {
expect(decoration.color, const Color(0xFF010203)); expect(decoration.color, const Color(0xFF010203));
}); });
testWidgetsWithLeakTracking('Lists in CupertinoPageScaffold scroll to the top when status bar tapped', (WidgetTester tester) async { testWidgets('Lists in CupertinoPageScaffold scroll to the top when status bar tapped', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
@ -484,7 +483,7 @@ void main() {
expect(find.text('12'), findsNothing); expect(find.text('12'), findsNothing);
}); });
testWidgetsWithLeakTracking('resizeToAvoidBottomInset is supported even when no navigationBar', (WidgetTester tester) async { testWidgets('resizeToAvoidBottomInset is supported even when no navigationBar', (WidgetTester tester) async {
Widget buildFrame(bool showNavigationBar, bool showKeyboard) { Widget buildFrame(bool showNavigationBar, bool showKeyboard) {
return CupertinoApp( return CupertinoApp(
home: MediaQuery( home: MediaQuery(
@ -529,7 +528,7 @@ void main() {
expect(positionWithInsetNoNavBar, equals(positionWithInsetWithNavBar)); expect(positionWithInsetNoNavBar, equals(positionWithInsetWithNavBar));
}); });
testWidgetsWithLeakTracking('textScaleFactor is set to 1.0', (WidgetTester tester) async { testWidgets('textScaleFactor is set to 1.0', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Builder(builder: (BuildContext context) { home: Builder(builder: (BuildContext context) {

View File

@ -4,7 +4,6 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
const Color _kScrollbarColor = Color(0x59000000); const Color _kScrollbarColor = Color(0x59000000);
@ -14,7 +13,7 @@ const Offset _kGestureOffset = Offset(0, -25);
const Radius _kScrollbarRadius = Radius.circular(1.5); const Radius _kScrollbarRadius = Radius.circular(1.5);
void main() { void main() {
testWidgetsWithLeakTracking('Paints iOS spec', (WidgetTester tester) async { testWidgets('Paints iOS spec', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -52,7 +51,7 @@ void main() {
)); ));
}); });
testWidgetsWithLeakTracking('Paints iOS spec with nav bar', (WidgetTester tester) async { testWidgets('Paints iOS spec with nav bar', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: MediaQuery( home: MediaQuery(
@ -97,7 +96,7 @@ void main() {
)); ));
}); });
testWidgetsWithLeakTracking("should not paint when there isn't enough space", (WidgetTester tester) async { testWidgets("should not paint when there isn't enough space", (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: MediaQuery( home: MediaQuery(

View File

@ -8,7 +8,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
const CupertinoDynamicColor _kScrollbarColor = CupertinoDynamicColor.withBrightness( const CupertinoDynamicColor _kScrollbarColor = CupertinoDynamicColor.withBrightness(
color: Color(0x59000000), color: Color(0x59000000),
@ -21,7 +20,7 @@ void main() {
const Duration kScrollbarResizeDuration = Duration(milliseconds: 100); const Duration kScrollbarResizeDuration = Duration(milliseconds: 100);
const Duration kLongPressDuration = Duration(milliseconds: 100); const Duration kLongPressDuration = Duration(milliseconds: 100);
testWidgetsWithLeakTracking('Scrollbar never goes away until finger lift', (WidgetTester tester) async { testWidgets('Scrollbar never goes away until finger lift', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -59,7 +58,7 @@ void main() {
)); ));
}); });
testWidgetsWithLeakTracking('Scrollbar dark mode', (WidgetTester tester) async { testWidgets('Scrollbar dark mode', (WidgetTester tester) async {
Brightness brightness = Brightness.light; Brightness brightness = Brightness.light;
late StateSetter setState; late StateSetter setState;
await tester.pumpWidget( await tester.pumpWidget(
@ -96,7 +95,7 @@ void main() {
)); ));
}); });
testWidgetsWithLeakTracking('Scrollbar thumb can be dragged with long press', (WidgetTester tester) async { testWidgets('Scrollbar thumb can be dragged with long press', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -169,7 +168,7 @@ void main() {
await tester.pump(kScrollbarFadeDuration); await tester.pump(kScrollbarFadeDuration);
}); });
testWidgetsWithLeakTracking('Scrollbar thumb can be dragged with long press - reverse', (WidgetTester tester) async { testWidgets('Scrollbar thumb can be dragged with long press - reverse', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -245,7 +244,7 @@ void main() {
await tester.pump(kScrollbarFadeDuration); await tester.pump(kScrollbarFadeDuration);
}); });
testWidgetsWithLeakTracking('Scrollbar changes thickness and radius when dragged', (WidgetTester tester) async { testWidgets('Scrollbar changes thickness and radius when dragged', (WidgetTester tester) async {
const double thickness = 20; const double thickness = 20;
const double thicknessWhileDragging = 40; const double thicknessWhileDragging = 40;
const double radius = 10; const double radius = 10;
@ -343,7 +342,7 @@ void main() {
await tester.pump(kScrollbarFadeDuration); await tester.pump(kScrollbarFadeDuration);
}); });
testWidgetsWithLeakTracking('When thumbVisibility is true, must pass a controller or find PrimaryScrollController', (WidgetTester tester) async { testWidgets('When thumbVisibility is true, must pass a controller or find PrimaryScrollController', (WidgetTester tester) async {
Widget viewWithScroll() { Widget viewWithScroll() {
return const Directionality( return const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -368,7 +367,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('When thumbVisibility is true, must pass a controller or find PrimaryScrollController that is attached to a scroll view', (WidgetTester tester) async { testWidgets('When thumbVisibility is true, must pass a controller or find PrimaryScrollController that is attached to a scroll view', (WidgetTester tester) async {
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
Widget viewWithScroll() { Widget viewWithScroll() {
@ -403,7 +402,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('When thumbVisibility is true, must pass a controller or find PrimaryScrollController', (WidgetTester tester) async { testWidgets('When thumbVisibility is true, must pass a controller or find PrimaryScrollController', (WidgetTester tester) async {
Widget viewWithScroll() { Widget viewWithScroll() {
return const Directionality( return const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -428,7 +427,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('When thumbVisibility is true, must pass a controller or find PrimaryScrollController that is attached to a scroll view', (WidgetTester tester) async { testWidgets('When thumbVisibility is true, must pass a controller or find PrimaryScrollController that is attached to a scroll view', (WidgetTester tester) async {
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
Widget viewWithScroll() { Widget viewWithScroll() {
@ -463,7 +462,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('On first render with thumbVisibility: true, the thumb shows with PrimaryScrollController', (WidgetTester tester) async { testWidgets('On first render with thumbVisibility: true, the thumb shows with PrimaryScrollController', (WidgetTester tester) async {
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
Widget viewWithScroll() { Widget viewWithScroll() {
@ -498,7 +497,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('On first render with thumbVisibility: true, the thumb shows', (WidgetTester tester) async { testWidgets('On first render with thumbVisibility: true, the thumb shows', (WidgetTester tester) async {
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
Widget viewWithScroll() { Widget viewWithScroll() {
@ -532,7 +531,7 @@ void main() {
expect(find.byType(CupertinoScrollbar), paints..rrect()); expect(find.byType(CupertinoScrollbar), paints..rrect());
}); });
testWidgetsWithLeakTracking('On first render with thumbVisibility: true, the thumb shows with PrimaryScrollController', (WidgetTester tester) async { testWidgets('On first render with thumbVisibility: true, the thumb shows with PrimaryScrollController', (WidgetTester tester) async {
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
Widget viewWithScroll() { Widget viewWithScroll() {
@ -567,7 +566,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('On first render with thumbVisibility: true, the thumb shows', (WidgetTester tester) async { testWidgets('On first render with thumbVisibility: true, the thumb shows', (WidgetTester tester) async {
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
Widget viewWithScroll() { Widget viewWithScroll() {
@ -601,7 +600,7 @@ void main() {
expect(find.byType(CupertinoScrollbar), paints..rrect()); expect(find.byType(CupertinoScrollbar), paints..rrect());
}); });
testWidgetsWithLeakTracking('On first render with thumbVisibility: false, the thumb is hidden', (WidgetTester tester) async { testWidgets('On first render with thumbVisibility: false, the thumb is hidden', (WidgetTester tester) async {
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
Widget viewWithScroll() { Widget viewWithScroll() {
@ -630,7 +629,7 @@ void main() {
expect(find.byType(CupertinoScrollbar), isNot(paints..rect())); expect(find.byType(CupertinoScrollbar), isNot(paints..rect()));
}); });
testWidgetsWithLeakTracking('With thumbVisibility: true, fling a scroll. While it is still scrolling, set thumbVisibility: false. The thumb should not fade out until the scrolling stops.', (WidgetTester tester) async { testWidgets('With thumbVisibility: true, fling a scroll. While it is still scrolling, set thumbVisibility: false. The thumb should not fade out until the scrolling stops.', (WidgetTester tester) async {
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
bool thumbVisibility = true; bool thumbVisibility = true;
@ -688,7 +687,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'With thumbVisibility: false, set thumbVisibility: true. The thumb should be always shown directly', 'With thumbVisibility: false, set thumbVisibility: true. The thumb should be always shown directly',
(WidgetTester tester) async { (WidgetTester tester) async {
final ScrollController controller = ScrollController(); final ScrollController controller = ScrollController();
@ -743,7 +742,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'With thumbVisibility: false, fling a scroll. While it is still scrolling, set thumbVisibility: true. ' 'With thumbVisibility: false, fling a scroll. While it is still scrolling, set thumbVisibility: true. '
'The thumb should not fade even after the scrolling stops', 'The thumb should not fade even after the scrolling stops',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -811,7 +810,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'Toggling thumbVisibility while not scrolling fades the thumb in/out. ' 'Toggling thumbVisibility while not scrolling fades the thumb in/out. '
'This works even when you have never scrolled at all yet', 'This works even when you have never scrolled at all yet',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -867,7 +866,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('Scrollbar thumb can be dragged with long press - horizontal axis', (WidgetTester tester) async { testWidgets('Scrollbar thumb can be dragged with long press - horizontal axis', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -942,7 +941,7 @@ void main() {
await tester.pump(kScrollbarFadeDuration); await tester.pump(kScrollbarFadeDuration);
}); });
testWidgetsWithLeakTracking('Scrollbar thumb can be dragged with long press - horizontal axis, reverse', (WidgetTester tester) async { testWidgets('Scrollbar thumb can be dragged with long press - horizontal axis, reverse', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -1018,7 +1017,7 @@ void main() {
await tester.pump(kScrollbarFadeDuration); await tester.pump(kScrollbarFadeDuration);
}); });
testWidgetsWithLeakTracking('Tapping the track area pages the Scroll View', (WidgetTester tester) async { testWidgets('Tapping the track area pages the Scroll View', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -1078,7 +1077,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Throw if interactive with the bar when no position attached', (WidgetTester tester) async { testWidgets('Throw if interactive with the bar when no position attached', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
@ -1123,7 +1122,7 @@ void main() {
FlutterError.onError = handler; FlutterError.onError = handler;
}); });
testWidgetsWithLeakTracking('Interactive scrollbars should have a valid scroll controller', (WidgetTester tester) async { testWidgets('Interactive scrollbars should have a valid scroll controller', (WidgetTester tester) async {
final ScrollController primaryScrollController = ScrollController(); final ScrollController primaryScrollController = ScrollController();
addTearDown(primaryScrollController.dispose); addTearDown(primaryScrollController.dispose);
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
@ -1166,7 +1165,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Simultaneous dragging and pointer scrolling does not cause a crash', (WidgetTester tester) async { testWidgets('Simultaneous dragging and pointer scrolling does not cause a crash', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/70105 // Regression test for https://github.com/flutter/flutter/issues/70105
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);
@ -1278,7 +1277,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('CupertinoScrollbar scrollOrientation works correctly', (WidgetTester tester) async { testWidgets('CupertinoScrollbar scrollOrientation works correctly', (WidgetTester tester) async {
final ScrollController scrollController = ScrollController(); final ScrollController scrollController = ScrollController();
addTearDown(scrollController.dispose); addTearDown(scrollController.dispose);

View File

@ -4,10 +4,9 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking( testWidgets(
'default search field has a border radius', 'default search field has a border radius',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -34,7 +33,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'decoration overrides default background color', 'decoration overrides default background color',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -63,7 +62,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'decoration overrides default border radius', 'decoration overrides default border radius',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -92,7 +91,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'text entries are padded by default', 'text entries are padded by default',
(WidgetTester tester) async { (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(text: 'initial'); final TextEditingController controller = TextEditingController(text: 'initial');
@ -115,7 +114,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('can change keyboard type', (WidgetTester tester) async { testWidgets('can change keyboard type', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Center( home: Center(
@ -131,7 +130,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'can control text content via controller', 'can control text content via controller',
(WidgetTester tester) async { (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(); final TextEditingController controller = TextEditingController();
@ -159,7 +158,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('placeholder color', (WidgetTester tester) async { testWidgets('placeholder color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
theme: CupertinoThemeData(brightness: Brightness.dark), theme: CupertinoThemeData(brightness: Brightness.dark),
@ -187,7 +186,7 @@ void main() {
expect(placeholder.style!.color!.value, CupertinoColors.systemGrey.color.value); expect(placeholder.style!.color!.value, CupertinoColors.systemGrey.color.value);
}); });
testWidgetsWithLeakTracking( testWidgets(
"placeholderStyle modifies placeholder's style and doesn't affect text's style", "placeholderStyle modifies placeholder's style and doesn't affect text's style",
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -221,7 +220,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'prefix widget is in front of the text', 'prefix widget is in front of the text',
(WidgetTester tester) async { (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(text: 'input'); final TextEditingController controller = TextEditingController(text: 'input');
@ -251,7 +250,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'suffix widget is after the text', 'suffix widget is after the text',
(WidgetTester tester) async { (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(text: 'Hi'); final TextEditingController controller = TextEditingController(text: 'Hi');
@ -283,7 +282,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('prefix widget visibility', (WidgetTester tester) async { testWidgets('prefix widget visibility', (WidgetTester tester) async {
const Key prefixIcon = Key('prefix'); const Key prefixIcon = Key('prefix');
await tester.pumpWidget( await tester.pumpWidget(
@ -312,7 +311,7 @@ void main() {
expect(find.byKey(prefixIcon), findsOneWidget); expect(find.byKey(prefixIcon), findsOneWidget);
}); });
testWidgetsWithLeakTracking( testWidgets(
'suffix widget respects visibility mode', 'suffix widget respects visibility mode',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -335,7 +334,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'clear button shows with right visibility mode', 'clear button shows with right visibility mode',
(WidgetTester tester) async { (WidgetTester tester) async {
TextEditingController controller = TextEditingController(); TextEditingController controller = TextEditingController();
@ -381,7 +380,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'clear button removes text', 'clear button removes text',
(WidgetTester tester) async { (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(); final TextEditingController controller = TextEditingController();
@ -409,7 +408,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'tapping clear button also calls onChanged when text not empty', 'tapping clear button also calls onChanged when text not empty',
(WidgetTester tester) async { (WidgetTester tester) async {
String value = 'text entry'; String value = 'text entry';
@ -439,7 +438,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'RTL puts attachments to the right places', 'RTL puts attachments to the right places',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -467,7 +466,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'Can modify prefix and suffix insets', 'Can modify prefix and suffix insets',
(WidgetTester tester) async { (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -494,7 +493,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'custom suffix onTap overrides default clearing behavior', 'custom suffix onTap overrides default clearing behavior',
(WidgetTester tester) async { (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(text: 'Text'); final TextEditingController controller = TextEditingController(text: 'Text');
@ -520,7 +519,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('onTap is properly forwarded to the inner text field', (WidgetTester tester) async { testWidgets('onTap is properly forwarded to the inner text field', (WidgetTester tester) async {
int onTapCallCount = 0; int onTapCallCount = 0;
// onTap can be null. // onTap can be null.
@ -550,7 +549,7 @@ void main() {
expect(onTapCallCount, 1); expect(onTapCallCount, 1);
}); });
testWidgetsWithLeakTracking('autocorrect is properly forwarded to the inner text field', (WidgetTester tester) async { testWidgets('autocorrect is properly forwarded to the inner text field', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Center( home: Center(
@ -565,7 +564,7 @@ void main() {
expect(textField.autocorrect, false); expect(textField.autocorrect, false);
}); });
testWidgetsWithLeakTracking('enabled is properly forwarded to the inner text field', (WidgetTester tester) async { testWidgets('enabled is properly forwarded to the inner text field', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Center( home: Center(
@ -580,7 +579,7 @@ void main() {
expect(textField.enabled, false); expect(textField.enabled, false);
}); });
testWidgetsWithLeakTracking('textInputAction is set to TextInputAction.search by default', (WidgetTester tester) async { testWidgets('textInputAction is set to TextInputAction.search by default', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Center( home: Center(
@ -593,7 +592,7 @@ void main() {
expect(textField.textInputAction, TextInputAction.search); expect(textField.textInputAction, TextInputAction.search);
}); });
testWidgetsWithLeakTracking('autofocus:true gives focus to the widget', (WidgetTester tester) async { testWidgets('autofocus:true gives focus to the widget', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -610,7 +609,7 @@ void main() {
expect(focusNode.hasFocus, isTrue); expect(focusNode.hasFocus, isTrue);
}); });
testWidgetsWithLeakTracking('smartQuotesType is properly forwarded to the inner text field', (WidgetTester tester) async { testWidgets('smartQuotesType is properly forwarded to the inner text field', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Center( home: Center(
@ -625,7 +624,7 @@ void main() {
expect(textField.smartQuotesType, SmartQuotesType.disabled); expect(textField.smartQuotesType, SmartQuotesType.disabled);
}); });
testWidgetsWithLeakTracking('smartDashesType is properly forwarded to the inner text field', (WidgetTester tester) async { testWidgets('smartDashesType is properly forwarded to the inner text field', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Center( home: Center(
@ -640,7 +639,7 @@ void main() {
expect(textField.smartDashesType, SmartDashesType.disabled); expect(textField.smartDashesType, SmartDashesType.disabled);
}); });
testWidgetsWithLeakTracking( testWidgets(
'enableIMEPersonalizedLearning is properly forwarded to the inner text field', (WidgetTester tester) async { 'enableIMEPersonalizedLearning is properly forwarded to the inner text field', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(

View File

@ -14,7 +14,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
@ -94,7 +93,7 @@ Color getBackgroundColor(WidgetTester tester, int childIndex) {
} }
void main() { void main() {
testWidgetsWithLeakTracking('Tap changes toggle state', (WidgetTester tester) async { testWidgets('Tap changes toggle state', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('Child 1'); children[0] = const Text('Child 1');
children[1] = const Text('Child 2'); children[1] = const Text('Child 2');
@ -128,7 +127,7 @@ void main() {
expect(sharedValue, 1); expect(sharedValue, 1);
}); });
testWidgetsWithLeakTracking('Need at least 2 children', (WidgetTester tester) async { testWidgets('Need at least 2 children', (WidgetTester tester) async {
await expectLater( await expectLater(
() => tester.pumpWidget( () => tester.pumpWidget(
boilerplate( boilerplate(
@ -162,7 +161,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Padding works', (WidgetTester tester) async { testWidgets('Padding works', (WidgetTester tester) async {
const Key key = Key('Container'); const Key key = Key('Container');
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
@ -249,7 +248,7 @@ void main() {
await verifyPadding(padding: const EdgeInsets.fromLTRB(1, 3, 5, 7)); await verifyPadding(padding: const EdgeInsets.fromLTRB(1, 3, 5, 7));
}); });
testWidgetsWithLeakTracking('Value attribute must be the key of one of the children widgets', (WidgetTester tester) async { testWidgets('Value attribute must be the key of one of the children widgets', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('Child 1'); children[0] = const Text('Child 1');
children[1] = const Text('Child 2'); children[1] = const Text('Child 2');
@ -272,7 +271,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Widgets have correct default text/icon styles, change correctly on selection', (WidgetTester tester) async { testWidgets('Widgets have correct default text/icon styles, change correctly on selection', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('Child 1'); children[0] = const Text('Child 1');
children[1] = const Icon(IconData(1)); children[1] = const Icon(IconData(1));
@ -315,7 +314,7 @@ void main() {
expect(iconTheme.data.color, isSameColorAs(CupertinoColors.white)); expect(iconTheme.data.color, isSameColorAs(CupertinoColors.white));
}); });
testWidgetsWithLeakTracking( testWidgets(
'Segmented controls respects themes', 'Segmented controls respects themes',
(WidgetTester tester) async { (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
@ -361,7 +360,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('SegmentedControl is correct when user provides custom colors', (WidgetTester tester) async { testWidgets('SegmentedControl is correct when user provides custom colors', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('Child 1'); children[0] = const Text('Child 1');
children[1] = const Icon(IconData(1)); children[1] = const Icon(IconData(1));
@ -422,7 +421,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Widgets are centered within segments', (WidgetTester tester) async { testWidgets('Widgets are centered within segments', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('Child 1'); children[0] = const Text('Child 1');
children[1] = const Text('Child 2'); children[1] = const Text('Child 2');
@ -449,7 +448,7 @@ void main() {
expect(tester.getCenter(find.text('Child 2')), const Offset(142.0, 100.0)); expect(tester.getCenter(find.text('Child 2')), const Offset(142.0, 100.0));
}); });
testWidgetsWithLeakTracking('Tap calls onValueChanged', (WidgetTester tester) async { testWidgets('Tap calls onValueChanged', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('Child 1'); children[0] = const Text('Child 1');
children[1] = const Text('Child 2'); children[1] = const Text('Child 2');
@ -478,7 +477,7 @@ void main() {
expect(value, isTrue); expect(value, isTrue);
}); });
testWidgetsWithLeakTracking('State does not change if onValueChanged does not call setState()', (WidgetTester tester) async { testWidgets('State does not change if onValueChanged does not call setState()', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('Child 1'); children[0] = const Text('Child 1');
children[1] = const Text('Child 2'); children[1] = const Text('Child 2');
@ -509,7 +508,7 @@ void main() {
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white)); expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white));
}); });
testWidgetsWithLeakTracking( testWidgets(
'Background color of child should change on selection, ' 'Background color of child should change on selection, '
'and should not change when tapped again', 'and should not change when tapped again',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -529,7 +528,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'Children can be non-Text or Icon widgets (in this case, ' 'Children can be non-Text or Icon widgets (in this case, '
'a Container or Placeholder widget)', 'a Container or Placeholder widget)',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -562,7 +561,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('Passed in value is child initially selected', (WidgetTester tester) async { testWidgets('Passed in value is child initially selected', (WidgetTester tester) async {
await tester.pumpWidget(setupSimpleSegmentedControl()); await tester.pumpWidget(setupSimpleSegmentedControl());
expect(getSelectedIndex(tester), 0); expect(getSelectedIndex(tester), 0);
@ -571,7 +570,7 @@ void main() {
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white)); expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white));
}); });
testWidgetsWithLeakTracking('Null input for value results in no child initially selected', (WidgetTester tester) async { testWidgets('Null input for value results in no child initially selected', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('Child 1'); children[0] = const Text('Child 1');
children[1] = const Text('Child 2'); children[1] = const Text('Child 2');
@ -602,7 +601,7 @@ void main() {
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white)); expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white));
}); });
testWidgetsWithLeakTracking('Long press changes background color of not-selected child', (WidgetTester tester) async { testWidgets('Long press changes background color of not-selected child', (WidgetTester tester) async {
await tester.pumpWidget(setupSimpleSegmentedControl()); await tester.pumpWidget(setupSimpleSegmentedControl());
expect(getBackgroundColor(tester, 0), CupertinoColors.activeBlue); expect(getBackgroundColor(tester, 0), CupertinoColors.activeBlue);
@ -620,7 +619,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Long press does not change background color of currently-selected child', (WidgetTester tester) async { testWidgets('Long press does not change background color of currently-selected child', (WidgetTester tester) async {
await tester.pumpWidget(setupSimpleSegmentedControl()); await tester.pumpWidget(setupSimpleSegmentedControl());
expect(getBackgroundColor(tester, 0), CupertinoColors.activeBlue); expect(getBackgroundColor(tester, 0), CupertinoColors.activeBlue);
@ -638,7 +637,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Height of segmented control is determined by tallest widget', (WidgetTester tester) async { testWidgets('Height of segmented control is determined by tallest widget', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = Container( children[0] = Container(
constraints: const BoxConstraints.tightFor(height: 100.0), constraints: const BoxConstraints.tightFor(height: 100.0),
@ -669,7 +668,7 @@ void main() {
expect(buttonBox.size.height, 400.0); expect(buttonBox.size.height, 400.0);
}); });
testWidgetsWithLeakTracking('Width of each segmented control segment is determined by widest widget', (WidgetTester tester) async { testWidgets('Width of each segmented control segment is determined by widest widget', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = Container( children[0] = Container(
constraints: const BoxConstraints.tightFor(width: 50.0), constraints: const BoxConstraints.tightFor(width: 50.0),
@ -708,7 +707,7 @@ void main() {
expect(childWidth, getSurroundingRect(tester, child: 2).width); expect(childWidth, getSurroundingRect(tester, child: 2).width);
}); });
testWidgetsWithLeakTracking('Width is finite in unbounded space', (WidgetTester tester) async { testWidgets('Width is finite in unbounded space', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('Child 1'); children[0] = const Text('Child 1');
children[1] = const Text('Child 2'); children[1] = const Text('Child 2');
@ -736,7 +735,7 @@ void main() {
expect(segmentedControl.size.width.isFinite, isTrue); expect(segmentedControl.size.width.isFinite, isTrue);
}); });
testWidgetsWithLeakTracking('Directionality test - RTL should reverse order of widgets', (WidgetTester tester) async { testWidgets('Directionality test - RTL should reverse order of widgets', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('Child 1'); children[0] = const Text('Child 1');
children[1] = const Text('Child 2'); children[1] = const Text('Child 2');
@ -756,7 +755,7 @@ void main() {
expect(tester.getTopRight(find.text('Child 1')).dx > tester.getTopRight(find.text('Child 2')).dx, isTrue); expect(tester.getTopRight(find.text('Child 1')).dx > tester.getTopRight(find.text('Child 2')).dx, isTrue);
}); });
testWidgetsWithLeakTracking('Correct initial selection and toggling behavior - RTL', (WidgetTester tester) async { testWidgets('Correct initial selection and toggling behavior - RTL', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('Child 1'); children[0] = const Text('Child 1');
children[1] = const Text('Child 2'); children[1] = const Text('Child 2');
@ -799,7 +798,7 @@ void main() {
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue); expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
}); });
testWidgetsWithLeakTracking('Segmented control semantics', (WidgetTester tester) async { testWidgets('Segmented control semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
@ -902,7 +901,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Non-centered taps work on smaller widgets', (WidgetTester tester) async { testWidgets('Non-centered taps work on smaller widgets', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('Child 1'); children[0] = const Text('Child 1');
children[1] = const Text('Child 2'); children[1] = const Text('Child 2');
@ -944,7 +943,7 @@ void main() {
expect(sharedValue, 0); expect(sharedValue, 0);
}); });
testWidgetsWithLeakTracking('Hit-tests report accurate local position in segments', (WidgetTester tester) async { testWidgets('Hit-tests report accurate local position in segments', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
late TapDownDetails tapDownDetails; late TapDownDetails tapDownDetails;
children[0] = GestureDetector( children[0] = GestureDetector(
@ -984,7 +983,7 @@ void main() {
expect(tapDownDetails.globalPosition, segment0GlobalOffset + const Offset(7, 11)); expect(tapDownDetails.globalPosition, segment0GlobalOffset + const Offset(7, 11));
}); });
testWidgetsWithLeakTracking( testWidgets(
'Segment still hittable with a child that has no hitbox', 'Segment still hittable with a child that has no hitbox',
(WidgetTester tester) async { (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/57326. // Regression test for https://github.com/flutter/flutter/issues/57326.
@ -1023,7 +1022,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('Animation is correct when the selected segment changes', (WidgetTester tester) async { testWidgets('Animation is correct when the selected segment changes', (WidgetTester tester) async {
await tester.pumpWidget(setupSimpleSegmentedControl()); await tester.pumpWidget(setupSimpleSegmentedControl());
await tester.tap(find.text('Child 2')); await tester.tap(find.text('Child 2'));
@ -1053,7 +1052,7 @@ void main() {
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue); expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
}); });
testWidgetsWithLeakTracking('Animation is correct when widget is rebuilt', (WidgetTester tester) async { testWidgets('Animation is correct when widget is rebuilt', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('Child 1'); children[0] = const Text('Child 1');
children[1] = const Text('Child 2'); children[1] = const Text('Child 2');
@ -1205,7 +1204,7 @@ void main() {
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue); expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
}); });
testWidgetsWithLeakTracking('Multiple segments are pressed', (WidgetTester tester) async { testWidgets('Multiple segments are pressed', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('A'); children[0] = const Text('A');
children[1] = const Text('B'); children[1] = const Text('B');
@ -1252,7 +1251,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Transition is triggered while a transition is already occurring', (WidgetTester tester) async { testWidgets('Transition is triggered while a transition is already occurring', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('A'); children[0] = const Text('A');
children[1] = const Text('B'); children[1] = const Text('B');
@ -1314,7 +1313,7 @@ void main() {
expect(getBackgroundColor(tester, 2), CupertinoColors.activeBlue); expect(getBackgroundColor(tester, 2), CupertinoColors.activeBlue);
}); });
testWidgetsWithLeakTracking('Segment is selected while it is transitioning to unselected state', (WidgetTester tester) async { testWidgets('Segment is selected while it is transitioning to unselected state', (WidgetTester tester) async {
await tester.pumpWidget(setupSimpleSegmentedControl()); await tester.pumpWidget(setupSimpleSegmentedControl());
await tester.tap(find.text('Child 2')); await tester.tap(find.text('Child 2'));
@ -1342,7 +1341,7 @@ void main() {
expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white)); expect(getBackgroundColor(tester, 1), isSameColorAs(CupertinoColors.white));
}); });
testWidgetsWithLeakTracking('Add segment while animation is running', (WidgetTester tester) async { testWidgets('Add segment while animation is running', (WidgetTester tester) async {
Map<int, Widget> children = <int, Widget>{}; Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('A'); children[0] = const Text('A');
children[1] = const Text('B'); children[1] = const Text('B');
@ -1390,7 +1389,7 @@ void main() {
expect(getBackgroundColor(tester, 3), isSameColorAs(CupertinoColors.white)); expect(getBackgroundColor(tester, 3), isSameColorAs(CupertinoColors.white));
}); });
testWidgetsWithLeakTracking('Remove segment while animation is running', (WidgetTester tester) async { testWidgets('Remove segment while animation is running', (WidgetTester tester) async {
Map<int, Widget> children = <int, Widget>{}; Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('A'); children[0] = const Text('A');
children[1] = const Text('B'); children[1] = const Text('B');
@ -1435,7 +1434,7 @@ void main() {
expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue); expect(getBackgroundColor(tester, 1), CupertinoColors.activeBlue);
}); });
testWidgetsWithLeakTracking('Remove currently animating segment', (WidgetTester tester) async { testWidgets('Remove currently animating segment', (WidgetTester tester) async {
Map<int, Widget> children = <int, Widget>{}; Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('A'); children[0] = const Text('A');
children[1] = const Text('B'); children[1] = const Text('B');
@ -1487,7 +1486,7 @@ void main() {
}); });
// Regression test: https://github.com/flutter/flutter/issues/43414. // Regression test: https://github.com/flutter/flutter/issues/43414.
testWidgetsWithLeakTracking("Quick double tap doesn't break the internal state", (WidgetTester tester) async { testWidgets("Quick double tap doesn't break the internal state", (WidgetTester tester) async {
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('A'), 0: Text('A'),
1: Text('B'), 1: Text('B'),
@ -1527,7 +1526,7 @@ void main() {
expect(sharedValue, 2); expect(sharedValue, 2);
}); });
testWidgetsWithLeakTracking('Golden Test Placeholder Widget', (WidgetTester tester) async { testWidgets('Golden Test Placeholder Widget', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = Container(); children[0] = Container();
children[1] = const Placeholder(); children[1] = const Placeholder();
@ -1561,7 +1560,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Golden Test Pressed State', (WidgetTester tester) async { testWidgets('Golden Test Pressed State', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('A'); children[0] = const Text('A');
children[1] = const Text('B'); children[1] = const Text('B');
@ -1603,7 +1602,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Hovering over Cupertino segmented control updates cursor to clickable on Web', (WidgetTester tester) async { testWidgets('Hovering over Cupertino segmented control updates cursor to clickable on Web', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('A'); children[0] = const Text('A');
children[1] = const Text('B'); children[1] = const Text('B');

View File

@ -9,7 +9,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
@ -33,7 +32,7 @@ void main() {
return tester.dragFrom(topLeft + const Offset(unit, unit), const Offset(delta, 0.0)); return tester.dragFrom(topLeft + const Offset(unit, unit), const Offset(delta, 0.0));
} }
testWidgetsWithLeakTracking('Slider does not move when tapped (LTR)', (WidgetTester tester) async { testWidgets('Slider does not move when tapped (LTR)', (WidgetTester tester) async {
final Key sliderKey = UniqueKey(); final Key sliderKey = UniqueKey();
double value = 0.0; double value = 0.0;
@ -69,7 +68,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
}); });
testWidgetsWithLeakTracking('Slider does not move when tapped (RTL)', (WidgetTester tester) async { testWidgets('Slider does not move when tapped (RTL)', (WidgetTester tester) async {
final Key sliderKey = UniqueKey(); final Key sliderKey = UniqueKey();
double value = 0.0; double value = 0.0;
@ -105,7 +104,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
}); });
testWidgetsWithLeakTracking('Slider calls onChangeStart once when interaction begins', (WidgetTester tester) async { testWidgets('Slider calls onChangeStart once when interaction begins', (WidgetTester tester) async {
final Key sliderKey = UniqueKey(); final Key sliderKey = UniqueKey();
double value = 0.0; double value = 0.0;
int numberOfTimesOnChangeStartIsCalled = 0; int numberOfTimesOnChangeStartIsCalled = 0;
@ -146,7 +145,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
}); });
testWidgetsWithLeakTracking('Slider calls onChangeEnd once after interaction has ended', (WidgetTester tester) async { testWidgets('Slider calls onChangeEnd once after interaction has ended', (WidgetTester tester) async {
final Key sliderKey = UniqueKey(); final Key sliderKey = UniqueKey();
double value = 0.0; double value = 0.0;
int numberOfTimesOnChangeEndIsCalled = 0; int numberOfTimesOnChangeEndIsCalled = 0;
@ -187,7 +186,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
}); });
testWidgetsWithLeakTracking('Slider moves when dragged (LTR)', (WidgetTester tester) async { testWidgets('Slider moves when dragged (LTR)', (WidgetTester tester) async {
final Key sliderKey = UniqueKey(); final Key sliderKey = UniqueKey();
double value = 0.0; double value = 0.0;
late double startValue; late double startValue;
@ -241,7 +240,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
}); });
testWidgetsWithLeakTracking('Slider moves when dragged (RTL)', (WidgetTester tester) async { testWidgets('Slider moves when dragged (RTL)', (WidgetTester tester) async {
final Key sliderKey = UniqueKey(); final Key sliderKey = UniqueKey();
double value = 0.0; double value = 0.0;
late double startValue; late double startValue;
@ -295,7 +294,7 @@ void main() {
expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); expect(SchedulerBinding.instance.transientCallbackCount, equals(0));
}); });
testWidgetsWithLeakTracking('Slider Semantics', (WidgetTester tester) async { testWidgets('Slider Semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget( await tester.pumpWidget(
@ -359,7 +358,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Slider Semantics can be updated', (WidgetTester tester) async { testWidgets('Slider Semantics can be updated', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
double value = 0.5; double value = 0.5;
await tester.pumpWidget( await tester.pumpWidget(
@ -410,7 +409,7 @@ void main() {
handle.dispose(); handle.dispose();
}); });
testWidgetsWithLeakTracking('Slider respects themes', (WidgetTester tester) async { testWidgets('Slider respects themes', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -445,7 +444,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Themes can be overridden', (WidgetTester tester) async { testWidgets('Themes can be overridden', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.dark), theme: const CupertinoThemeData(brightness: Brightness.dark),
@ -464,7 +463,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Themes can be overridden by dynamic colors', (WidgetTester tester) async { testWidgets('Themes can be overridden by dynamic colors', (WidgetTester tester) async {
const CupertinoDynamicColor activeColor = CupertinoDynamicColor( const CupertinoDynamicColor activeColor = CupertinoDynamicColor(
color: Color(0x00000001), color: Color(0x00000001),
darkColor: Color(0x00000002), darkColor: Color(0x00000002),
@ -520,7 +519,7 @@ void main() {
expect(find.byType(CupertinoSlider), paints..rrect(color: activeColor.highContrastElevatedColor)); expect(find.byType(CupertinoSlider), paints..rrect(color: activeColor.highContrastElevatedColor));
}); });
testWidgetsWithLeakTracking('track color is dynamic', (WidgetTester tester) async { testWidgets('track color is dynamic', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
theme: const CupertinoThemeData(brightness: Brightness.light), theme: const CupertinoThemeData(brightness: Brightness.light),
@ -568,7 +567,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Thumb color can be overridden', (WidgetTester tester) async { testWidgets('Thumb color can be overridden', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -616,7 +615,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Hovering over Cupertino slider thumb updates cursor to clickable on Web', (WidgetTester tester) async { testWidgets('Hovering over Cupertino slider thumb updates cursor to clickable on Web', (WidgetTester tester) async {
final Key sliderKey = UniqueKey(); final Key sliderKey = UniqueKey();
double value = 0.0; double value = 0.0;

View File

@ -9,7 +9,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
@ -94,7 +93,7 @@ void main() {
groupValue = 0; groupValue = 0;
}); });
testWidgetsWithLeakTracking('Need at least 2 children', (WidgetTester tester) async { testWidgets('Need at least 2 children', (WidgetTester tester) async {
groupValue = null; groupValue = null;
await expectLater( await expectLater(
() => tester.pumpWidget( () => tester.pumpWidget(
@ -147,7 +146,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Padding works', (WidgetTester tester) async { testWidgets('Padding works', (WidgetTester tester) async {
const Key key = Key('Container'); const Key key = Key('Container');
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
@ -224,7 +223,7 @@ void main() {
await verifyPadding(padding: const EdgeInsets.fromLTRB(1, 3, 5, 7)); await verifyPadding(padding: const EdgeInsets.fromLTRB(1, 3, 5, 7));
}); });
testWidgetsWithLeakTracking('Tap changes toggle state', (WidgetTester tester) async { testWidgets('Tap changes toggle state', (WidgetTester tester) async {
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('Child 1'), 0: Text('Child 1'),
1: Text('Child 2'), 1: Text('Child 2'),
@ -256,7 +255,7 @@ void main() {
expect(groupValue, 1); expect(groupValue, 1);
}); });
testWidgetsWithLeakTracking( testWidgets(
'Segmented controls respect theme', 'Segmented controls respect theme',
(WidgetTester tester) async { (WidgetTester tester) async {
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
@ -294,7 +293,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('SegmentedControl dark mode', (WidgetTester tester) async { testWidgets('SegmentedControl dark mode', (WidgetTester tester) async {
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('Child 1'), 0: Text('Child 1'),
1: Icon(IconData(1)), 1: Icon(IconData(1)),
@ -346,7 +345,7 @@ void main() {
expect(decorationDark.color!.value, CupertinoColors.systemRed.darkColor.value); expect(decorationDark.color!.value, CupertinoColors.systemRed.darkColor.value);
}); });
testWidgetsWithLeakTracking( testWidgets(
'Children can be non-Text or Icon widgets (in this case, ' 'Children can be non-Text or Icon widgets (in this case, '
'a Container or Placeholder widget)', 'a Container or Placeholder widget)',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -370,13 +369,13 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('Passed in value is child initially selected', (WidgetTester tester) async { testWidgets('Passed in value is child initially selected', (WidgetTester tester) async {
await tester.pumpWidget(setupSimpleSegmentedControl()); await tester.pumpWidget(setupSimpleSegmentedControl());
expect(getHighlightedIndex(tester), 0); expect(getHighlightedIndex(tester), 0);
}); });
testWidgetsWithLeakTracking('Null input for value results in no child initially selected', (WidgetTester tester) async { testWidgets('Null input for value results in no child initially selected', (WidgetTester tester) async {
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('Child 1'), 0: Text('Child 1'),
1: Text('Child 2'), 1: Text('Child 2'),
@ -402,7 +401,7 @@ void main() {
expect(getHighlightedIndex(tester), null); expect(getHighlightedIndex(tester), null);
}); });
testWidgetsWithLeakTracking('Long press not-selected child interactions', (WidgetTester tester) async { testWidgets('Long press not-selected child interactions', (WidgetTester tester) async {
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('Child 1'), 0: Text('Child 1'),
1: Text('Child 2'), 1: Text('Child 2'),
@ -466,7 +465,7 @@ void main() {
expect(getChildOpacityByName('Child 2'), 0.2); expect(getChildOpacityByName('Child 2'), 0.2);
}); });
testWidgetsWithLeakTracking('Long press does not change the opacity of currently-selected child', (WidgetTester tester) async { testWidgets('Long press does not change the opacity of currently-selected child', (WidgetTester tester) async {
double getChildOpacityByName(String childName) { double getChildOpacityByName(String childName) {
return tester.renderObject<RenderAnimatedOpacity>( return tester.renderObject<RenderAnimatedOpacity>(
find.ancestor(matching: find.byType(AnimatedOpacity), of: find.text(childName)), find.ancestor(matching: find.byType(AnimatedOpacity), of: find.text(childName)),
@ -487,7 +486,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Height of segmented control is determined by tallest widget', (WidgetTester tester) async { testWidgets('Height of segmented control is determined by tallest widget', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{ final Map<int, Widget> children = <int, Widget>{
0: Container(constraints: const BoxConstraints.tightFor(height: 100.0)), 0: Container(constraints: const BoxConstraints.tightFor(height: 100.0)),
1: Container(constraints: const BoxConstraints.tightFor(height: 400.0)), 1: Container(constraints: const BoxConstraints.tightFor(height: 400.0)),
@ -517,7 +516,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Width of each segmented control segment is determined by widest widget', (WidgetTester tester) async { testWidgets('Width of each segmented control segment is determined by widest widget', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{ final Map<int, Widget> children = <int, Widget>{
0: Container(constraints: const BoxConstraints.tightFor(width: 50.0)), 0: Container(constraints: const BoxConstraints.tightFor(width: 50.0)),
1: Container(constraints: const BoxConstraints.tightFor(width: 100.0)), 1: Container(constraints: const BoxConstraints.tightFor(width: 100.0)),
@ -548,7 +547,7 @@ void main() {
expect(childWidth, 200.0 + 9.25 * 2); expect(childWidth, 200.0 + 9.25 * 2);
}); });
testWidgetsWithLeakTracking('Width is finite in unbounded space', (WidgetTester tester) async { testWidgets('Width is finite in unbounded space', (WidgetTester tester) async {
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: SizedBox(width: 50), 0: SizedBox(width: 50),
1: SizedBox(width: 70), 1: SizedBox(width: 70),
@ -581,7 +580,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Directionality test - RTL should reverse order of widgets', (WidgetTester tester) async { testWidgets('Directionality test - RTL should reverse order of widgets', (WidgetTester tester) async {
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('Child 1'), 0: Text('Child 1'),
1: Text('Child 2'), 1: Text('Child 2'),
@ -608,7 +607,7 @@ void main() {
expect(tester.getTopRight(find.text('Child 1')).dx > tester.getTopRight(find.text('Child 2')).dx, isTrue); expect(tester.getTopRight(find.text('Child 1')).dx > tester.getTopRight(find.text('Child 2')).dx, isTrue);
}); });
testWidgetsWithLeakTracking('Correct initial selection and toggling behavior - RTL', (WidgetTester tester) async { testWidgets('Correct initial selection and toggling behavior - RTL', (WidgetTester tester) async {
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('Child 1'), 0: Text('Child 1'),
1: Text('Child 2'), 1: Text('Child 2'),
@ -645,7 +644,7 @@ void main() {
expect(getHighlightedIndex(tester), 0); expect(getHighlightedIndex(tester), 0);
}); });
testWidgetsWithLeakTracking('Segmented control semantics', (WidgetTester tester) async { testWidgets('Segmented control semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('Child 1'), 0: Text('Child 1'),
@ -738,7 +737,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Non-centered taps work on smaller widgets', (WidgetTester tester) async { testWidgets('Non-centered taps work on smaller widgets', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
children[0] = const Text('Child 1'); children[0] = const Text('Child 1');
children[1] = const SizedBox(); children[1] = const SizedBox();
@ -766,7 +765,7 @@ void main() {
expect(groupValue, 1); expect(groupValue, 1);
}); });
testWidgetsWithLeakTracking('Hit-tests report accurate local position in segments', (WidgetTester tester) async { testWidgets('Hit-tests report accurate local position in segments', (WidgetTester tester) async {
final Map<int, Widget> children = <int, Widget>{}; final Map<int, Widget> children = <int, Widget>{};
late TapDownDetails tapDownDetails; late TapDownDetails tapDownDetails;
children[0] = GestureDetector( children[0] = GestureDetector(
@ -798,7 +797,7 @@ void main() {
expect(tapDownDetails.globalPosition, segment0GlobalOffset + const Offset(7, 11)); expect(tapDownDetails.globalPosition, segment0GlobalOffset + const Offset(7, 11));
}); });
testWidgetsWithLeakTracking('Thumb animation is correct when the selected segment changes', (WidgetTester tester) async { testWidgets('Thumb animation is correct when the selected segment changes', (WidgetTester tester) async {
await tester.pumpWidget(setupSimpleSegmentedControl()); await tester.pumpWidget(setupSimpleSegmentedControl());
final Rect initialRect = currentUnscaledThumbRect(tester, useGlobalCoordinate: true); final Rect initialRect = currentUnscaledThumbRect(tester, useGlobalCoordinate: true);
@ -879,7 +878,7 @@ void main() {
expect(currentThumbScale(tester), moreOrLessEquals(1, epsilon: 0.01)); expect(currentThumbScale(tester), moreOrLessEquals(1, epsilon: 0.01));
}); });
testWidgetsWithLeakTracking( testWidgets(
'Thumb does not go out of bounds in animation', 'Thumb does not go out of bounds in animation',
(WidgetTester tester) async { (WidgetTester tester) async {
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
@ -936,7 +935,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('Transition is triggered while a transition is already occurring', (WidgetTester tester) async { testWidgets('Transition is triggered while a transition is already occurring', (WidgetTester tester) async {
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('A'), 0: Text('A'),
1: Text('B'), 1: Text('B'),
@ -986,7 +985,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Insert segment while animation is running', (WidgetTester tester) async { testWidgets('Insert segment while animation is running', (WidgetTester tester) async {
final Map<int, Widget> children = SplayTreeMap<int, Widget>((int a, int b) => a - b); final Map<int, Widget> children = SplayTreeMap<int, Widget>((int a, int b) => a - b);
children[0] = const Text('A'); children[0] = const Text('A');
@ -1032,7 +1031,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('change selection programmatically when dragging', (WidgetTester tester) async { testWidgets('change selection programmatically when dragging', (WidgetTester tester) async {
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('A'), 0: Text('A'),
1: Text('B'), 1: Text('B'),
@ -1091,7 +1090,7 @@ void main() {
expect(callbackCalled, isFalse); expect(callbackCalled, isFalse);
}); });
testWidgetsWithLeakTracking('Disallow new gesture when dragging', (WidgetTester tester) async { testWidgets('Disallow new gesture when dragging', (WidgetTester tester) async {
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('A'), 0: Text('A'),
1: Text('B'), 1: Text('B'),
@ -1146,7 +1145,7 @@ void main() {
expect(callbackCalled, isFalse); expect(callbackCalled, isFalse);
}); });
testWidgetsWithLeakTracking('gesture outlives the widget', (WidgetTester tester) async { testWidgets('gesture outlives the widget', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/63338. // Regression test for https://github.com/flutter/flutter/issues/63338.
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('A'), 0: Text('A'),
@ -1184,7 +1183,7 @@ void main() {
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
}); });
testWidgetsWithLeakTracking('computeDryLayout is pure', (WidgetTester tester) async { testWidgets('computeDryLayout is pure', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/73362. // Regression test for https://github.com/flutter/flutter/issues/73362.
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('A'), 0: Text('A'),
@ -1218,7 +1217,7 @@ void main() {
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
}); });
testWidgetsWithLeakTracking('Has consistent size, independent of groupValue', (WidgetTester tester) async { testWidgets('Has consistent size, independent of groupValue', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/62063. // Regression test for https://github.com/flutter/flutter/issues/62063.
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('A'), 0: Text('A'),
@ -1252,7 +1251,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('ScrollView + SlidingSegmentedControl interaction', (WidgetTester tester) async { testWidgets('ScrollView + SlidingSegmentedControl interaction', (WidgetTester tester) async {
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('Child 1'), 0: Text('Child 1'),
1: Text('Child 2'), 1: Text('Child 2'),
@ -1339,7 +1338,7 @@ void main() {
expect(groupValue, 1); expect(groupValue, 1);
}); });
testWidgetsWithLeakTracking('Hovering over Cupertino sliding segmented control updates cursor to clickable on Web', (WidgetTester tester) async { testWidgets('Hovering over Cupertino sliding segmented control updates cursor to clickable on Web', (WidgetTester tester) async {
const Map<int, Widget> children = <int, Widget>{ const Map<int, Widget> children = <int, Widget>{
0: Text('A'), 0: Text('A'),
1: Text('BB'), 1: Text('BB'),

View File

@ -7,12 +7,11 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
testWidgetsWithLeakTracking('more than three suggestions throws an error', (WidgetTester tester) async { testWidgets('more than three suggestions throws an error', (WidgetTester tester) async {
Future<void> pumpToolbar(List<String> suggestions) async { Future<void> pumpToolbar(List<String> suggestions) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -62,7 +61,7 @@ void main() {
expect(labels, isNot(contains('yeller'))); expect(labels, isNot(contains('yeller')));
}); });
testWidgetsWithLeakTracking('buildButtonItems builds a disabled "No Replacements Found" button when no suggestions', (WidgetTester tester) async { testWidgets('buildButtonItems builds a disabled "No Replacements Found" button when no suggestions', (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(); final TextEditingController controller = TextEditingController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();

View File

@ -14,10 +14,9 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('Switch can toggle on tap', (WidgetTester tester) async { testWidgets('Switch can toggle on tap', (WidgetTester tester) async {
final Key switchKey = UniqueKey(); final Key switchKey = UniqueKey();
bool value = false; bool value = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -47,7 +46,7 @@ void main() {
expect(value, isTrue); expect(value, isTrue);
}); });
testWidgetsWithLeakTracking('CupertinoSwitch can be toggled by keyboard shortcuts', (WidgetTester tester) async { testWidgets('CupertinoSwitch can be toggled by keyboard shortcuts', (WidgetTester tester) async {
bool value = true; bool value = true;
Widget buildApp({bool enabled = true}) { Widget buildApp({bool enabled = true}) {
return CupertinoApp( return CupertinoApp(
@ -80,7 +79,7 @@ void main() {
expect(value, isTrue); expect(value, isTrue);
}); });
testWidgetsWithLeakTracking('Switch emits light haptic vibration on tap', (WidgetTester tester) async { testWidgets('Switch emits light haptic vibration on tap', (WidgetTester tester) async {
final Key switchKey = UniqueKey(); final Key switchKey = UniqueKey();
bool value = false; bool value = false;
@ -120,7 +119,7 @@ void main() {
expect(log.single, isMethodCall('HapticFeedback.vibrate', arguments: 'HapticFeedbackType.lightImpact')); expect(log.single, isMethodCall('HapticFeedback.vibrate', arguments: 'HapticFeedbackType.lightImpact'));
}, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); }, variant: TargetPlatformVariant.only(TargetPlatform.iOS));
testWidgetsWithLeakTracking('Using other widgets that rebuild the switch will not cause vibrations', (WidgetTester tester) async { testWidgets('Using other widgets that rebuild the switch will not cause vibrations', (WidgetTester tester) async {
final Key switchKey = UniqueKey(); final Key switchKey = UniqueKey();
final Key switchKey2 = UniqueKey(); final Key switchKey2 = UniqueKey();
bool value = false; bool value = false;
@ -191,7 +190,7 @@ void main() {
expect(log[3], isMethodCall('HapticFeedback.vibrate', arguments: 'HapticFeedbackType.lightImpact')); expect(log[3], isMethodCall('HapticFeedback.vibrate', arguments: 'HapticFeedbackType.lightImpact'));
}, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); }, variant: TargetPlatformVariant.only(TargetPlatform.iOS));
testWidgetsWithLeakTracking('Haptic vibration triggers on drag', (WidgetTester tester) async { testWidgets('Haptic vibration triggers on drag', (WidgetTester tester) async {
bool value = false; bool value = false;
final List<MethodCall> log = <MethodCall>[]; final List<MethodCall> log = <MethodCall>[];
@ -229,7 +228,7 @@ void main() {
expect(log[0], isMethodCall('HapticFeedback.vibrate', arguments: 'HapticFeedbackType.lightImpact')); expect(log[0], isMethodCall('HapticFeedback.vibrate', arguments: 'HapticFeedbackType.lightImpact'));
}, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); }, variant: TargetPlatformVariant.only(TargetPlatform.iOS));
testWidgetsWithLeakTracking('No haptic vibration triggers from a programmatic value change', (WidgetTester tester) async { testWidgets('No haptic vibration triggers from a programmatic value change', (WidgetTester tester) async {
final Key switchKey = UniqueKey(); final Key switchKey = UniqueKey();
bool value = false; bool value = false;
@ -281,7 +280,7 @@ void main() {
expect(log, hasLength(0)); expect(log, hasLength(0));
}, variant: TargetPlatformVariant.only(TargetPlatform.iOS)); }, variant: TargetPlatformVariant.only(TargetPlatform.iOS));
testWidgetsWithLeakTracking('Switch can drag (LTR)', (WidgetTester tester) async { testWidgets('Switch can drag (LTR)', (WidgetTester tester) async {
bool value = false; bool value = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -325,7 +324,7 @@ void main() {
expect(value, isFalse); expect(value, isFalse);
}); });
testWidgetsWithLeakTracking('Switch can drag with dragStartBehavior', (WidgetTester tester) async { testWidgets('Switch can drag with dragStartBehavior', (WidgetTester tester) async {
bool value = false; bool value = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -411,7 +410,7 @@ void main() {
await tester.pump(); await tester.pump();
}); });
testWidgetsWithLeakTracking('Switch can drag (RTL)', (WidgetTester tester) async { testWidgets('Switch can drag (RTL)', (WidgetTester tester) async {
bool value = false; bool value = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -456,7 +455,7 @@ void main() {
expect(value, isFalse); expect(value, isFalse);
}); });
testWidgetsWithLeakTracking('can veto switch dragging result', (WidgetTester tester) async { testWidgets('can veto switch dragging result', (WidgetTester tester) async {
bool value = false; bool value = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -528,7 +527,7 @@ void main() {
expect(position.value, 1.0); expect(position.value, 1.0);
}); });
testWidgetsWithLeakTracking('Switch is translucent when disabled', (WidgetTester tester) async { testWidgets('Switch is translucent when disabled', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -546,7 +545,7 @@ void main() {
expect(tester.widget<Opacity>(find.byType(Opacity).first).opacity, 0.5); expect(tester.widget<Opacity>(find.byType(Opacity).first).opacity, 0.5);
}); });
testWidgetsWithLeakTracking('Switch is using track color when set', (WidgetTester tester) async { testWidgets('Switch is using track color when set', (WidgetTester tester) async {
const Color trackColor = Color(0xFF00FF00); const Color trackColor = Color(0xFF00FF00);
await tester.pumpWidget( await tester.pumpWidget(
@ -568,7 +567,7 @@ void main() {
expect(find.byType(CupertinoSwitch), paints..rrect(color: trackColor)); expect(find.byType(CupertinoSwitch), paints..rrect(color: trackColor));
}); });
testWidgetsWithLeakTracking('Switch is using default thumb color', (WidgetTester tester) async { testWidgets('Switch is using default thumb color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -594,7 +593,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Switch is using thumb color when set', (WidgetTester tester) async { testWidgets('Switch is using thumb color when set', (WidgetTester tester) async {
const Color thumbColor = Color(0xFF000000); const Color thumbColor = Color(0xFF000000);
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
@ -622,7 +621,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Switch is opaque when enabled', (WidgetTester tester) async { testWidgets('Switch is opaque when enabled', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -640,7 +639,7 @@ void main() {
expect(tester.widget<Opacity>(find.byType(Opacity).first).opacity, 1.0); expect(tester.widget<Opacity>(find.byType(Opacity).first).opacity, 1.0);
}); });
testWidgetsWithLeakTracking('Switch turns translucent after becoming disabled', (WidgetTester tester) async { testWidgets('Switch turns translucent after becoming disabled', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -671,7 +670,7 @@ void main() {
expect(tester.widget<Opacity>(find.byType(Opacity).first).opacity, 0.5); expect(tester.widget<Opacity>(find.byType(Opacity).first).opacity, 0.5);
}); });
testWidgetsWithLeakTracking('Switch turns opaque after becoming enabled', (WidgetTester tester) async { testWidgets('Switch turns opaque after becoming enabled', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -702,7 +701,7 @@ void main() {
expect(tester.widget<Opacity>(find.byType(Opacity).first).opacity, 1.0); expect(tester.widget<Opacity>(find.byType(Opacity).first).opacity, 1.0);
}); });
testWidgetsWithLeakTracking('Switch renders correctly before, during, and after being tapped', (WidgetTester tester) async { testWidgets('Switch renders correctly before, during, and after being tapped', (WidgetTester tester) async {
final Key switchKey = UniqueKey(); final Key switchKey = UniqueKey();
bool value = false; bool value = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -780,7 +779,7 @@ void main() {
style: PaintingStyle.stroke, style: PaintingStyle.stroke,
); );
testWidgetsWithLeakTracking('Switch renders switch labels correctly before, during, and after being tapped', (WidgetTester tester) async { testWidgets('Switch renders switch labels correctly before, during, and after being tapped', (WidgetTester tester) async {
final Key switchKey = UniqueKey(); final Key switchKey = UniqueKey();
bool value = false; bool value = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -830,7 +829,7 @@ void main() {
expect(switchRenderObject, offLabelPaintPattern(alpha: 0)); expect(switchRenderObject, offLabelPaintPattern(alpha: 0));
}); });
testWidgetsWithLeakTracking('Switch renders switch labels correctly before, during, and after being tapped in high contrast', (WidgetTester tester) async { testWidgets('Switch renders switch labels correctly before, during, and after being tapped in high contrast', (WidgetTester tester) async {
final Key switchKey = UniqueKey(); final Key switchKey = UniqueKey();
bool value = false; bool value = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -883,7 +882,7 @@ void main() {
expect(switchRenderObject, offLabelPaintPattern(highContrast: true, alpha: 0)); expect(switchRenderObject, offLabelPaintPattern(highContrast: true, alpha: 0));
}); });
testWidgetsWithLeakTracking('Switch renders switch labels correctly before, during, and after being tapped with direction rtl', (WidgetTester tester) async { testWidgets('Switch renders switch labels correctly before, during, and after being tapped with direction rtl', (WidgetTester tester) async {
final Key switchKey = UniqueKey(); final Key switchKey = UniqueKey();
bool value = false; bool value = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -933,7 +932,7 @@ void main() {
expect(switchRenderObject, offLabelPaintPattern(isRtl: true, alpha: 0)); expect(switchRenderObject, offLabelPaintPattern(isRtl: true, alpha: 0));
}); });
testWidgetsWithLeakTracking('Switch renders correctly in dark mode', (WidgetTester tester) async { testWidgets('Switch renders correctly in dark mode', (WidgetTester tester) async {
final Key switchKey = UniqueKey(); final Key switchKey = UniqueKey();
bool value = false; bool value = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -978,7 +977,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Switch can apply the ambient theme and be opted out', (WidgetTester tester) async { testWidgets('Switch can apply the ambient theme and be opted out', (WidgetTester tester) async {
final Key switchKey = UniqueKey(); final Key switchKey = UniqueKey();
bool value = false; bool value = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -1038,7 +1037,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Hovering over Cupertino switch updates cursor to clickable on Web', (WidgetTester tester) async { testWidgets('Hovering over Cupertino switch updates cursor to clickable on Web', (WidgetTester tester) async {
const bool value = false; const bool value = false;
// Disabled CupertinoSwitch does not update cursor on Web. // Disabled CupertinoSwitch does not update cursor on Web.
await tester.pumpWidget( await tester.pumpWidget(
@ -1094,7 +1093,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('CupertinoSwitch is focusable and has correct focus color', (WidgetTester tester) async { testWidgets('CupertinoSwitch is focusable and has correct focus color', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'CupertinoSwitch'); final FocusNode focusNode = FocusNode(debugLabel: 'CupertinoSwitch');
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
@ -1176,7 +1175,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('CupertinoSwitch.onFocusChange callback', (WidgetTester tester) async { testWidgets('CupertinoSwitch.onFocusChange callback', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'CupertinoSwitch'); final FocusNode focusNode = FocusNode(debugLabel: 'CupertinoSwitch');
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
bool focused = false; bool focused = false;

View File

@ -6,7 +6,6 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../image_data.dart'; import '../image_data.dart';
import '../rendering/rendering_tester.dart' show TestCallbackPainter; import '../rendering/rendering_tester.dart' show TestCallbackPainter;
@ -51,7 +50,7 @@ void main() {
); );
} }
testWidgetsWithLeakTracking('Tab switching', (WidgetTester tester) async { testWidgets('Tab switching', (WidgetTester tester) async {
final List<int> tabsPainted = <int>[]; final List<int> tabsPainted = <int>[];
await tester.pumpWidget( await tester.pumpWidget(
@ -105,7 +104,7 @@ void main() {
expect(selectedTabs, const <int>[1, 0]); expect(selectedTabs, const <int>[1, 0]);
}); });
testWidgetsWithLeakTracking('Tabs are lazy built and moved offstage when inactive', (WidgetTester tester) async { testWidgets('Tabs are lazy built and moved offstage when inactive', (WidgetTester tester) async {
final List<int> tabsBuilt = <int>[]; final List<int> tabsBuilt = <int>[];
await tester.pumpWidget( await tester.pumpWidget(
@ -140,7 +139,7 @@ void main() {
expect(find.text('Page 2', skipOffstage: false), isOffstage); expect(find.text('Page 2', skipOffstage: false), isOffstage);
}); });
testWidgetsWithLeakTracking('Last tab gets focus', (WidgetTester tester) async { testWidgets('Last tab gets focus', (WidgetTester tester) async {
// 2 nodes for 2 tabs // 2 nodes for 2 tabs
final List<FocusNode> focusNodes = <FocusNode>[ final List<FocusNode> focusNodes = <FocusNode>[
FocusNode(debugLabel: 'Node 1'), FocusNode(debugLabel: 'Node 1'),
@ -179,7 +178,7 @@ void main() {
expect(focusNodes[1].hasFocus, isFalse); expect(focusNodes[1].hasFocus, isFalse);
}); });
testWidgetsWithLeakTracking('Do not affect focus order in the route', (WidgetTester tester) async { testWidgets('Do not affect focus order in the route', (WidgetTester tester) async {
final List<FocusNode> focusNodes = <FocusNode>[ final List<FocusNode> focusNodes = <FocusNode>[
FocusNode(debugLabel: 'Node 1'), FocusNode(debugLabel: 'Node 1'),
FocusNode(debugLabel: 'Node 2'), FocusNode(debugLabel: 'Node 2'),
@ -245,7 +244,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Programmatic tab switching by changing the index of an existing controller', (WidgetTester tester) async { testWidgets('Programmatic tab switching by changing the index of an existing controller', (WidgetTester tester) async {
final CupertinoTabController controller = CupertinoTabController(initialIndex: 1); final CupertinoTabController controller = CupertinoTabController(initialIndex: 1);
addTearDown(controller.dispose); addTearDown(controller.dispose);
final List<int> tabsPainted = <int>[]; final List<int> tabsPainted = <int>[];
@ -284,7 +283,7 @@ void main() {
expect(selectedTabs, const <int>[1]); expect(selectedTabs, const <int>[1]);
}); });
testWidgetsWithLeakTracking('Programmatic tab switching by passing in a new controller', (WidgetTester tester) async { testWidgets('Programmatic tab switching by passing in a new controller', (WidgetTester tester) async {
final List<int> tabsPainted = <int>[]; final List<int> tabsPainted = <int>[];
await tester.pumpWidget( await tester.pumpWidget(
@ -336,7 +335,7 @@ void main() {
expect(selectedTabs, const <int>[0]); expect(selectedTabs, const <int>[0]);
}); });
testWidgetsWithLeakTracking('Tab bar respects themes', (WidgetTester tester) async { testWidgets('Tab bar respects themes', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTabScaffold( home: CupertinoTabScaffold(
@ -394,7 +393,7 @@ void main() {
expect(tab2.text.style!.color, isSameColorAs(CupertinoColors.systemRed.darkColor)); expect(tab2.text.style!.color, isSameColorAs(CupertinoColors.systemRed.darkColor));
}); });
testWidgetsWithLeakTracking('Tab contents are padded when there are view insets', (WidgetTester tester) async { testWidgets('Tab contents are padded when there are view insets', (WidgetTester tester) async {
late BuildContext innerContext; late BuildContext innerContext;
await tester.pumpWidget( await tester.pumpWidget(
@ -420,7 +419,7 @@ void main() {
expect(MediaQuery.of(innerContext).padding.bottom, 0); expect(MediaQuery.of(innerContext).padding.bottom, 0);
}); });
testWidgetsWithLeakTracking('Tab contents are not inset when resizeToAvoidBottomInset overridden', (WidgetTester tester) async { testWidgets('Tab contents are not inset when resizeToAvoidBottomInset overridden', (WidgetTester tester) async {
late BuildContext innerContext; late BuildContext innerContext;
await tester.pumpWidget( await tester.pumpWidget(
@ -447,7 +446,7 @@ void main() {
expect(MediaQuery.of(innerContext).padding.bottom, 50); expect(MediaQuery.of(innerContext).padding.bottom, 50);
}); });
testWidgetsWithLeakTracking('Tab contents bottom padding are not consumed by viewInsets when resizeToAvoidBottomInset overridden', (WidgetTester tester) async { testWidgets('Tab contents bottom padding are not consumed by viewInsets when resizeToAvoidBottomInset overridden', (WidgetTester tester) async {
final Widget child = Localizations( final Widget child = Localizations(
locale: const Locale('en', 'US'), locale: const Locale('en', 'US'),
delegates: const <LocalizationsDelegate<dynamic>>[ delegates: const <LocalizationsDelegate<dynamic>>[
@ -495,7 +494,7 @@ void main() {
expect(initialPoint, finalPoint); expect(initialPoint, finalPoint);
}); });
testWidgetsWithLeakTracking( testWidgets(
'Opaque tab bar consumes bottom padding while non opaque tab bar does not', 'Opaque tab bar consumes bottom padding while non opaque tab bar does not',
(WidgetTester tester) async { (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/43581. // Regression test for https://github.com/flutter/flutter/issues/43581.
@ -527,7 +526,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('Tab and page scaffolds do not double stack view insets', (WidgetTester tester) async { testWidgets('Tab and page scaffolds do not double stack view insets', (WidgetTester tester) async {
late BuildContext innerContext; late BuildContext innerContext;
await tester.pumpWidget( await tester.pumpWidget(
@ -557,7 +556,7 @@ void main() {
expect(MediaQuery.of(innerContext).padding.bottom, 0); expect(MediaQuery.of(innerContext).padding.bottom, 0);
}); });
testWidgetsWithLeakTracking('Deleting tabs after selecting them should switch to the last available tab', (WidgetTester tester) async { testWidgets('Deleting tabs after selecting them should switch to the last available tab', (WidgetTester tester) async {
final List<int> tabsBuilt = <int>[]; final List<int> tabsBuilt = <int>[];
await tester.pumpWidget( await tester.pumpWidget(
@ -627,7 +626,7 @@ void main() {
}); });
// Regression test for https://github.com/flutter/flutter/issues/33455 // Regression test for https://github.com/flutter/flutter/issues/33455
testWidgetsWithLeakTracking('Adding new tabs does not crash the app', (WidgetTester tester) async { testWidgets('Adding new tabs does not crash the app', (WidgetTester tester) async {
final List<int> tabsPainted = <int>[]; final List<int> tabsPainted = <int>[];
final CupertinoTabController controller = CupertinoTabController(); final CupertinoTabController controller = CupertinoTabController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
@ -682,7 +681,7 @@ void main() {
expect(tabsPainted, const <int>[0, 0, 18]); expect(tabsPainted, const <int>[0, 0, 18]);
}); });
testWidgetsWithLeakTracking( testWidgets(
'If a controller is initially provided then the parent stops doing so for rebuilds, ' 'If a controller is initially provided then the parent stops doing so for rebuilds, '
'a new instance of CupertinoTabController should be created and used by the widget, ' 'a new instance of CupertinoTabController should be created and used by the widget, '
"while preserving the previous controller's tab index", "while preserving the previous controller's tab index",
@ -747,7 +746,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'Do not call dispose on a controller that we do not own ' 'Do not call dispose on a controller that we do not own '
'but do remove from its listeners when done listening to it', 'but do remove from its listeners when done listening to it',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -785,7 +784,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('The owner can dispose the old controller', (WidgetTester tester) async { testWidgets('The owner can dispose the old controller', (WidgetTester tester) async {
CupertinoTabController controller = CupertinoTabController(initialIndex: 2); CupertinoTabController controller = CupertinoTabController(initialIndex: 2);
await tester.pumpWidget( await tester.pumpWidget(
@ -824,7 +823,7 @@ void main() {
expect(find.text('Tab 3'), findsNothing); expect(find.text('Tab 3'), findsNothing);
}); });
testWidgetsWithLeakTracking('A controller can control more than one CupertinoTabScaffold, ' testWidgets('A controller can control more than one CupertinoTabScaffold, '
'removal of listeners does not break the controller', 'removal of listeners does not break the controller',
(WidgetTester tester) async { (WidgetTester tester) async {
final List<int> tabsPainted0 = <int>[]; final List<int> tabsPainted0 = <int>[];
@ -939,7 +938,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('Assert when current tab index >= number of tabs', (WidgetTester tester) async { testWidgets('Assert when current tab index >= number of tabs', (WidgetTester tester) async {
final CupertinoTabController controller = CupertinoTabController(initialIndex: 2); final CupertinoTabController controller = CupertinoTabController(initialIndex: 2);
addTearDown(controller.dispose); addTearDown(controller.dispose);
@ -981,7 +980,7 @@ void main() {
expect(message, contains('with 3 tabs')); expect(message, contains('with 3 tabs'));
}); });
testWidgetsWithLeakTracking("Don't replace focus nodes for existing tabs when changing tab count", (WidgetTester tester) async { testWidgets("Don't replace focus nodes for existing tabs when changing tab count", (WidgetTester tester) async {
final CupertinoTabController controller = CupertinoTabController(initialIndex: 2); final CupertinoTabController controller = CupertinoTabController(initialIndex: 2);
addTearDown(controller.dispose); addTearDown(controller.dispose);
@ -1036,7 +1035,7 @@ void main() {
expect(scopes.sublist(0, 3), equals(newScopes.sublist(0, 3))); expect(scopes.sublist(0, 3), equals(newScopes.sublist(0, 3)));
}); });
testWidgetsWithLeakTracking('Current tab index cannot go below zero or be null', (WidgetTester tester) async { testWidgets('Current tab index cannot go below zero or be null', (WidgetTester tester) async {
void expectAssertionError(VoidCallback callback, String errorMessage) { void expectAssertionError(VoidCallback callback, String errorMessage) {
try { try {
callback(); callback();
@ -1053,7 +1052,7 @@ void main() {
expectAssertionError(() => controller.index = -1, '>= 0'); expectAssertionError(() => controller.index = -1, '>= 0');
}); });
testWidgetsWithLeakTracking('Does not lose state when focusing on text input', (WidgetTester tester) async { testWidgets('Does not lose state when focusing on text input', (WidgetTester tester) async {
// Regression testing for https://github.com/flutter/flutter/issues/28457. // Regression testing for https://github.com/flutter/flutter/issues/28457.
await tester.pumpWidget( await tester.pumpWidget(
@ -1095,7 +1094,7 @@ void main() {
expect(find.text("don't lose me"), findsOneWidget); expect(find.text("don't lose me"), findsOneWidget);
}); });
testWidgetsWithLeakTracking('textScaleFactor is set to 1.0', (WidgetTester tester) async { testWidgets('textScaleFactor is set to 1.0', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Builder(builder: (BuildContext context) { home: Builder(builder: (BuildContext context) {
@ -1137,7 +1136,7 @@ void main() {
expect(contents, isNot(contains(predicate((RichText t) => t.textScaler != const TextScaler.linear(99.0))))); expect(contents, isNot(contains(predicate((RichText t) => t.textScaler != const TextScaler.linear(99.0)))));
}); });
testWidgetsWithLeakTracking('state restoration', (WidgetTester tester) async { testWidgets('state restoration', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
restorationScopeId: 'app', restorationScopeId: 'app',
@ -1192,7 +1191,7 @@ void main() {
expect(find.text('Content 3'), findsNothing); expect(find.text('Content 3'), findsNothing);
}); });
testWidgetsWithLeakTracking('switch from internal to external controller with state restoration', (WidgetTester tester) async { testWidgets('switch from internal to external controller with state restoration', (WidgetTester tester) async {
Widget buildWidget({CupertinoTabController? controller}) { Widget buildWidget({CupertinoTabController? controller}) {
return CupertinoApp( return CupertinoApp(
restorationScopeId: 'app', restorationScopeId: 'app',
@ -1267,7 +1266,7 @@ void main() {
.setMockMethodCallHandler(SystemChannels.platform, null); .setMockMethodCallHandler(SystemChannels.platform, null);
}); });
testWidgetsWithLeakTracking('System back navigation inside of tabs', (WidgetTester tester) async { testWidgets('System back navigation inside of tabs', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: MediaQuery( home: MediaQuery(

View File

@ -4,10 +4,9 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('Use home', (WidgetTester tester) async { testWidgets('Use home', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTabView( home: CupertinoTabView(
@ -19,7 +18,7 @@ void main() {
expect(find.text('home'), findsOneWidget); expect(find.text('home'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Use routes', (WidgetTester tester) async { testWidgets('Use routes', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTabView( home: CupertinoTabView(
@ -33,7 +32,7 @@ void main() {
expect(find.text('first route'), findsOneWidget); expect(find.text('first route'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Use home and named routes', (WidgetTester tester) async { testWidgets('Use home and named routes', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTabView( home: CupertinoTabView(
@ -59,7 +58,7 @@ void main() {
expect(find.text('second named route'), findsOneWidget); expect(find.text('second named route'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Use onGenerateRoute', (WidgetTester tester) async { testWidgets('Use onGenerateRoute', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTabView( home: CupertinoTabView(
@ -81,7 +80,7 @@ void main() {
expect(find.text('generated home'), findsOneWidget); expect(find.text('generated home'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Use onUnknownRoute', (WidgetTester tester) async { testWidgets('Use onUnknownRoute', (WidgetTester tester) async {
late String unknownForRouteCalled; late String unknownForRouteCalled;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -102,7 +101,7 @@ void main() {
expect(tester.takeException(), isAssertionError); expect(tester.takeException(), isAssertionError);
}); });
testWidgetsWithLeakTracking('Can use navigatorKey to navigate', (WidgetTester tester) async { testWidgets('Can use navigatorKey to navigate', (WidgetTester tester) async {
final GlobalKey<NavigatorState> key = GlobalKey(); final GlobalKey<NavigatorState> key = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -123,7 +122,7 @@ void main() {
expect(find.text('second route'), findsOneWidget); expect(find.text('second route'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Changing the key resets the navigator', (WidgetTester tester) async { testWidgets('Changing the key resets the navigator', (WidgetTester tester) async {
final GlobalKey<NavigatorState> key = GlobalKey(); final GlobalKey<NavigatorState> key = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -173,7 +172,7 @@ void main() {
expect(find.text('second route'), findsNothing); expect(find.text('second route'), findsNothing);
}); });
testWidgetsWithLeakTracking('Throws FlutterError when onUnknownRoute is null', (WidgetTester tester) async { testWidgets('Throws FlutterError when onUnknownRoute is null', (WidgetTester tester) async {
final GlobalKey<NavigatorState> key = GlobalKey(); final GlobalKey<NavigatorState> key = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -210,7 +209,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Throws FlutterError when onUnknownRoute returns null', (WidgetTester tester) async { testWidgets('Throws FlutterError when onUnknownRoute returns null', (WidgetTester tester) async {
final GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>();
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -240,7 +239,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Navigator of CupertinoTabView restores state', (WidgetTester tester) async { testWidgets('Navigator of CupertinoTabView restores state', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
restorationScopeId: 'app', restorationScopeId: 'app',

View File

@ -5,13 +5,12 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
const String text = 'Hello World! How are you? Life is good!'; const String text = 'Hello World! How are you? Life is good!';
const String alternativeText = 'Everything is awesome!!'; const String alternativeText = 'Everything is awesome!!';
void main() { void main() {
testWidgetsWithLeakTracking('CupertinoTextField restoration', (WidgetTester tester) async { testWidgets('CupertinoTextField restoration', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
restorationScopeId: 'app', restorationScopeId: 'app',
@ -22,7 +21,7 @@ void main() {
await restoreAndVerify(tester); await restoreAndVerify(tester);
}); });
testWidgetsWithLeakTracking('CupertinoTextField restoration with external controller', (WidgetTester tester) async { testWidgets('CupertinoTextField restoration with external controller', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
restorationScopeId: 'app', restorationScopeId: 'app',

File diff suppressed because it is too large Load Diff

View File

@ -5,10 +5,9 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('Passes textAlign to underlying CupertinoTextField', (WidgetTester tester) async { testWidgets('Passes textAlign to underlying CupertinoTextField', (WidgetTester tester) async {
const TextAlign alignment = TextAlign.center; const TextAlign alignment = TextAlign.center;
await tester.pumpWidget( await tester.pumpWidget(
@ -28,7 +27,7 @@ void main() {
expect(textFieldWidget.textAlign, alignment); expect(textFieldWidget.textAlign, alignment);
}); });
testWidgetsWithLeakTracking('Passes scrollPhysics to underlying TextField', (WidgetTester tester) async { testWidgets('Passes scrollPhysics to underlying TextField', (WidgetTester tester) async {
const ScrollPhysics scrollPhysics = ScrollPhysics(); const ScrollPhysics scrollPhysics = ScrollPhysics();
await tester.pumpWidget( await tester.pumpWidget(
@ -48,7 +47,7 @@ void main() {
expect(textFieldWidget.scrollPhysics, scrollPhysics); expect(textFieldWidget.scrollPhysics, scrollPhysics);
}); });
testWidgetsWithLeakTracking('Passes textAlignVertical to underlying CupertinoTextField', (WidgetTester tester) async { testWidgets('Passes textAlignVertical to underlying CupertinoTextField', (WidgetTester tester) async {
const TextAlignVertical textAlignVertical = TextAlignVertical.bottom; const TextAlignVertical textAlignVertical = TextAlignVertical.bottom;
await tester.pumpWidget( await tester.pumpWidget(
@ -68,7 +67,7 @@ void main() {
expect(textFieldWidget.textAlignVertical, textAlignVertical); expect(textFieldWidget.textAlignVertical, textAlignVertical);
}); });
testWidgetsWithLeakTracking('Passes textInputAction to underlying CupertinoTextField', (WidgetTester tester) async { testWidgets('Passes textInputAction to underlying CupertinoTextField', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -86,7 +85,7 @@ void main() {
expect(textFieldWidget.textInputAction, TextInputAction.next); expect(textFieldWidget.textInputAction, TextInputAction.next);
}); });
testWidgetsWithLeakTracking('Passes onEditingComplete to underlying CupertinoTextField', (WidgetTester tester) async { testWidgets('Passes onEditingComplete to underlying CupertinoTextField', (WidgetTester tester) async {
void onEditingComplete() {} void onEditingComplete() {}
await tester.pumpWidget( await tester.pumpWidget(
@ -106,7 +105,7 @@ void main() {
expect(textFieldWidget.onEditingComplete, onEditingComplete); expect(textFieldWidget.onEditingComplete, onEditingComplete);
}); });
testWidgetsWithLeakTracking('Passes cursor attributes to underlying CupertinoTextField', (WidgetTester tester) async { testWidgets('Passes cursor attributes to underlying CupertinoTextField', (WidgetTester tester) async {
const double cursorWidth = 3.14; const double cursorWidth = 3.14;
const double cursorHeight = 6.28; const double cursorHeight = 6.28;
const Radius cursorRadius = Radius.circular(2); const Radius cursorRadius = Radius.circular(2);
@ -134,7 +133,7 @@ void main() {
expect(textFieldWidget.cursorColor, cursorColor); expect(textFieldWidget.cursorColor, cursorColor);
}); });
testWidgetsWithLeakTracking('onFieldSubmit callbacks are called', (WidgetTester tester) async { testWidgets('onFieldSubmit callbacks are called', (WidgetTester tester) async {
bool called = false; bool called = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -155,7 +154,7 @@ void main() {
expect(called, true); expect(called, true);
}); });
testWidgetsWithLeakTracking('onChanged callbacks are called', (WidgetTester tester) async { testWidgets('onChanged callbacks are called', (WidgetTester tester) async {
late String value; late String value;
await tester.pumpWidget( await tester.pumpWidget(
@ -175,7 +174,7 @@ void main() {
expect(value, 'Soup'); expect(value, 'Soup');
}); });
testWidgetsWithLeakTracking('autovalidateMode is passed to super', (WidgetTester tester) async { testWidgets('autovalidateMode is passed to super', (WidgetTester tester) async {
int validateCalled = 0; int validateCalled = 0;
await tester.pumpWidget( await tester.pumpWidget(
@ -198,7 +197,7 @@ void main() {
expect(validateCalled, 2); expect(validateCalled, 2);
}); });
testWidgetsWithLeakTracking('validate is called if widget is enabled', (WidgetTester tester) async { testWidgets('validate is called if widget is enabled', (WidgetTester tester) async {
int validateCalled = 0; int validateCalled = 0;
await tester.pumpWidget( await tester.pumpWidget(
@ -222,7 +221,7 @@ void main() {
expect(validateCalled, 2); expect(validateCalled, 2);
}); });
testWidgetsWithLeakTracking('readonly text form field will hide cursor by default', (WidgetTester tester) async { testWidgets('readonly text form field will hide cursor by default', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -263,7 +262,7 @@ void main() {
expect(renderEditable, paintsExactlyCountTimes(#drawRect, 0)); expect(renderEditable, paintsExactlyCountTimes(#drawRect, 0));
}, skip: isBrowser); // [intended] We do not use Flutter-rendered context menu on the Web. }, skip: isBrowser); // [intended] We do not use Flutter-rendered context menu on the Web.
testWidgetsWithLeakTracking('onTap is called upon tap', (WidgetTester tester) async { testWidgets('onTap is called upon tap', (WidgetTester tester) async {
int tapCount = 0; int tapCount = 0;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -289,7 +288,7 @@ void main() {
}); });
// Regression test for https://github.com/flutter/flutter/issues/54472. // Regression test for https://github.com/flutter/flutter/issues/54472.
testWidgetsWithLeakTracking('reset resets the text fields value to the initialValue', (WidgetTester tester) async { testWidgets('reset resets the text fields value to the initialValue', (WidgetTester tester) async {
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: Center( home: Center(
child: CupertinoTextFormFieldRow( child: CupertinoTextFormFieldRow(
@ -308,7 +307,7 @@ void main() {
}); });
// Regression test for https://github.com/flutter/flutter/issues/54472. // Regression test for https://github.com/flutter/flutter/issues/54472.
testWidgetsWithLeakTracking('didChange changes text fields value', (WidgetTester tester) async { testWidgets('didChange changes text fields value', (WidgetTester tester) async {
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
home: Center( home: Center(
child: CupertinoTextFormFieldRow( child: CupertinoTextFormFieldRow(
@ -327,7 +326,7 @@ void main() {
expect(find.text('changedValue'), findsOneWidget); expect(find.text('changedValue'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('onChanged callbacks value and FormFieldState.value are sync', (WidgetTester tester) async { testWidgets('onChanged callbacks value and FormFieldState.value are sync', (WidgetTester tester) async {
bool called = false; bool called = false;
late FormFieldState<String> state; late FormFieldState<String> state;
@ -353,7 +352,7 @@ void main() {
expect(called, true); expect(called, true);
}); });
testWidgetsWithLeakTracking('autofillHints is passed to super', (WidgetTester tester) async { testWidgets('autofillHints is passed to super', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -369,7 +368,7 @@ void main() {
expect(widget.autofillHints, equals(const <String>[AutofillHints.countryName])); expect(widget.autofillHints, equals(const <String>[AutofillHints.countryName]));
}); });
testWidgetsWithLeakTracking('autovalidateMode is passed to super', (WidgetTester tester) async { testWidgets('autovalidateMode is passed to super', (WidgetTester tester) async {
int validateCalled = 0; int validateCalled = 0;
await tester.pumpWidget( await tester.pumpWidget(
@ -392,7 +391,7 @@ void main() {
expect(validateCalled, 1); expect(validateCalled, 1);
}); });
testWidgetsWithLeakTracking('AutovalidateMode.always mode shows error from the start', (WidgetTester tester) async { testWidgets('AutovalidateMode.always mode shows error from the start', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -412,7 +411,7 @@ void main() {
expect(errorText.data, 'Error'); expect(errorText.data, 'Error');
}); });
testWidgetsWithLeakTracking('Shows error text upon invalid input', (WidgetTester tester) async { testWidgets('Shows error text upon invalid input', (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(text: ''); final TextEditingController controller = TextEditingController(text: '');
addTearDown(controller.dispose); addTearDown(controller.dispose);
await tester.pumpWidget( await tester.pumpWidget(
@ -440,7 +439,7 @@ void main() {
expect(errorText.data, 'Error'); expect(errorText.data, 'Error');
}); });
testWidgetsWithLeakTracking('Shows prefix', (WidgetTester tester) async { testWidgets('Shows prefix', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -458,7 +457,7 @@ void main() {
expect(errorText.data, 'Enter Value'); expect(errorText.data, 'Enter Value');
}); });
testWidgetsWithLeakTracking('Passes textDirection to underlying CupertinoTextField', (WidgetTester tester) async { testWidgets('Passes textDirection to underlying CupertinoTextField', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -492,7 +491,7 @@ void main() {
expect(rtlTextFieldWidget.textDirection, TextDirection.rtl); expect(rtlTextFieldWidget.textDirection, TextDirection.rtl);
}); });
testWidgetsWithLeakTracking( testWidgets(
'CupertinoTextFormFieldRow onChanged is called when the form is reset', (WidgetTester tester) async { 'CupertinoTextFormFieldRow onChanged is called when the form is reset', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/123009. // Regression test for https://github.com/flutter/flutter/issues/123009.
final GlobalKey<FormFieldState<String>> stateKey = GlobalKey<FormFieldState<String>>(); final GlobalKey<FormFieldState<String>> stateKey = GlobalKey<FormFieldState<String>>();

View File

@ -15,7 +15,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/clipboard_utils.dart'; import '../widgets/clipboard_utils.dart';
import '../widgets/editable_text_utils.dart' show findRenderEditable, textOffsetToPosition; import '../widgets/editable_text_utils.dart' show findRenderEditable, textOffsetToPosition;
@ -111,13 +110,13 @@ void main() {
); );
} }
testWidgetsWithLeakTracking('should return false when there is no text', (WidgetTester tester) async { testWidgets('should return false when there is no text', (WidgetTester tester) async {
final GlobalKey<EditableTextState> key = GlobalKey(); final GlobalKey<EditableTextState> key = GlobalKey();
await tester.pumpWidget(createEditableText(key: key)); await tester.pumpWidget(createEditableText(key: key));
expect(cupertinoTextSelectionControls.canSelectAll(key.currentState!), false); expect(cupertinoTextSelectionControls.canSelectAll(key.currentState!), false);
}); });
testWidgetsWithLeakTracking('should return true when there is text and collapsed selection', (WidgetTester tester) async { testWidgets('should return true when there is text and collapsed selection', (WidgetTester tester) async {
final GlobalKey<EditableTextState> key = GlobalKey(); final GlobalKey<EditableTextState> key = GlobalKey();
await tester.pumpWidget(createEditableText( await tester.pumpWidget(createEditableText(
key: key, key: key,
@ -126,7 +125,7 @@ void main() {
expect(cupertinoTextSelectionControls.canSelectAll(key.currentState!), true); expect(cupertinoTextSelectionControls.canSelectAll(key.currentState!), true);
}); });
testWidgetsWithLeakTracking('should return false when there is text and partial uncollapsed selection', (WidgetTester tester) async { testWidgets('should return false when there is text and partial uncollapsed selection', (WidgetTester tester) async {
final GlobalKey<EditableTextState> key = GlobalKey(); final GlobalKey<EditableTextState> key = GlobalKey();
await tester.pumpWidget(createEditableText( await tester.pumpWidget(createEditableText(
key: key, key: key,
@ -136,7 +135,7 @@ void main() {
expect(cupertinoTextSelectionControls.canSelectAll(key.currentState!), false); expect(cupertinoTextSelectionControls.canSelectAll(key.currentState!), false);
}); });
testWidgetsWithLeakTracking('should return false when there is text and full selection', (WidgetTester tester) async { testWidgets('should return false when there is text and full selection', (WidgetTester tester) async {
final GlobalKey<EditableTextState> key = GlobalKey(); final GlobalKey<EditableTextState> key = GlobalKey();
await tester.pumpWidget(createEditableText( await tester.pumpWidget(createEditableText(
key: key, key: key,
@ -148,7 +147,7 @@ void main() {
}); });
group('cupertino handles', () { group('cupertino handles', () {
testWidgetsWithLeakTracking('draws transparent handle correctly', (WidgetTester tester) async { testWidgets('draws transparent handle correctly', (WidgetTester tester) async {
await tester.pumpWidget(RepaintBoundary( await tester.pumpWidget(RepaintBoundary(
child: CupertinoTheme( child: CupertinoTheme(
data: const CupertinoThemeData( data: const CupertinoThemeData(
@ -196,7 +195,7 @@ void main() {
'${widget.painter?.runtimeType}' == '_LeftCupertinoChevronPainter', '${widget.painter?.runtimeType}' == '_LeftCupertinoChevronPainter',
); );
testWidgetsWithLeakTracking('All menu items show when they fit.', (WidgetTester tester) async { testWidgets('All menu items show when they fit.', (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(text: 'abc def ghi'); final TextEditingController controller = TextEditingController(text: 'abc def ghi');
addTearDown(controller.dispose); addTearDown(controller.dispose);
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
@ -254,7 +253,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
); );
testWidgetsWithLeakTracking("When a menu item doesn't fit, a second page is used.", (WidgetTester tester) async { testWidgets("When a menu item doesn't fit, a second page is used.", (WidgetTester tester) async {
// Set the screen size to more narrow, so that Paste can't fit. // Set the screen size to more narrow, so that Paste can't fit.
tester.view.physicalSize = const Size(1000, 800); tester.view.physicalSize = const Size(1000, 800);
addTearDown(tester.view.reset); addTearDown(tester.view.reset);
@ -362,7 +361,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
); );
testWidgetsWithLeakTracking('A smaller menu puts each button on its own page.', (WidgetTester tester) async { testWidgets('A smaller menu puts each button on its own page.', (WidgetTester tester) async {
// Set the screen size to more narrow, so that two buttons can't fit on // Set the screen size to more narrow, so that two buttons can't fit on
// the same page. // the same page.
tester.view.physicalSize = const Size(640, 800); tester.view.physicalSize = const Size(640, 800);
@ -508,7 +507,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
); );
testWidgetsWithLeakTracking('Handles very long locale strings', (WidgetTester tester) async { testWidgets('Handles very long locale strings', (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(text: 'abc def ghi'); final TextEditingController controller = TextEditingController(text: 'abc def ghi');
addTearDown(controller.dispose); addTearDown(controller.dispose);
await tester.pumpWidget(CupertinoApp( await tester.pumpWidget(CupertinoApp(
@ -620,7 +619,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
); );
testWidgetsWithLeakTracking( testWidgets(
'When selecting multiple lines over max lines', 'When selecting multiple lines over max lines',
(WidgetTester tester) async { (WidgetTester tester) async {
final TextEditingController controller = TextEditingController(text: 'abc\ndef\nghi\njkl\nmno\npqr'); final TextEditingController controller = TextEditingController(text: 'abc\ndef\nghi\njkl\nmno\npqr');
@ -689,7 +688,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('iOS selection handles scale with rich text (selection style 1)', (WidgetTester tester) async { testWidgets('iOS selection handles scale with rich text (selection style 1)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Center( home: Center(
@ -769,7 +768,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
); );
testWidgetsWithLeakTracking('iOS selection handles scale with rich text (selection style 2)', (WidgetTester tester) async { testWidgets('iOS selection handles scale with rich text (selection style 2)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Center( home: Center(
@ -853,7 +852,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
); );
testWidgetsWithLeakTracking('iOS selection handles scale with rich text (grapheme clusters)', (WidgetTester tester) async { testWidgets('iOS selection handles scale with rich text (grapheme clusters)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Center( home: Center(
@ -934,7 +933,7 @@ void main() {
variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }), variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS }),
); );
testWidgetsWithLeakTracking( testWidgets(
'iOS selection handles scaling falls back to preferredLineHeight when the current frame does not match the previous', (WidgetTester tester) async { 'iOS selection handles scaling falls back to preferredLineHeight when the current frame does not match the previous', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(

View File

@ -4,12 +4,11 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
TestWidgetsFlutterBinding.ensureInitialized(); TestWidgetsFlutterBinding.ensureInitialized();
testWidgetsWithLeakTracking('can press', (WidgetTester tester) async { testWidgets('can press', (WidgetTester tester) async {
bool pressed = false; bool pressed = false;
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
@ -30,7 +29,7 @@ void main() {
expect(pressed, true); expect(pressed, true);
}); });
testWidgetsWithLeakTracking('background darkens when pressed', (WidgetTester tester) async { testWidgets('background darkens when pressed', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: Center( home: Center(
@ -76,7 +75,7 @@ void main() {
expect(boxDecoration.color, const Color(0x00000000)); expect(boxDecoration.color, const Color(0x00000000));
}); });
testWidgetsWithLeakTracking('passing null to onPressed disables the button', (WidgetTester tester) async { testWidgets('passing null to onPressed disables the button', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const CupertinoApp( const CupertinoApp(
home: Center( home: Center(

View File

@ -10,7 +10,6 @@ library;
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/editable_text_utils.dart' show textOffsetToPosition; import '../widgets/editable_text_utils.dart' show textOffsetToPosition;
@ -112,7 +111,7 @@ void main() {
); );
} }
testWidgetsWithLeakTracking('chevrons point to the correct side', (WidgetTester tester) async { testWidgets('chevrons point to the correct side', (WidgetTester tester) async {
// Add enough TestBoxes to need 3 pages. // Add enough TestBoxes to need 3 pages.
final List<Widget> children = List<Widget>.generate(15, (int i) => const TestBox()); final List<Widget> children = List<Widget>.generate(15, (int i) => const TestBox());
await tester.pumpWidget( await tester.pumpWidget(
@ -152,7 +151,7 @@ void main() {
expect(findOverflowBackButton(), overflowBackPaintPattern()); expect(findOverflowBackButton(), overflowBackPaintPattern());
}, skip: kIsWeb); // Path.combine is not implemented in the HTML backend https://github.com/flutter/flutter/issues/44572 }, skip: kIsWeb); // Path.combine is not implemented in the HTML backend https://github.com/flutter/flutter/issues/44572
testWidgetsWithLeakTracking('paginates children if they overflow', (WidgetTester tester) async { testWidgets('paginates children if they overflow', (WidgetTester tester) async {
late StateSetter setState; late StateSetter setState;
final List<Widget> children = List<Widget>.generate(7, (int i) => const TestBox()); final List<Widget> children = List<Widget>.generate(7, (int i) => const TestBox());
await tester.pumpWidget( await tester.pumpWidget(
@ -247,7 +246,7 @@ void main() {
expect(findOverflowBackButton(), findsNothing); expect(findOverflowBackButton(), findsNothing);
}, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web. }, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web.
testWidgetsWithLeakTracking('does not paginate if children fit with zero margin', (WidgetTester tester) async { testWidgets('does not paginate if children fit with zero margin', (WidgetTester tester) async {
final List<Widget> children = List<Widget>.generate(7, (int i) => const TestBox()); final List<Widget> children = List<Widget>.generate(7, (int i) => const TestBox());
final double spacerWidth = 1.0 / tester.view.devicePixelRatio; final double spacerWidth = 1.0 / tester.view.devicePixelRatio;
final double dividerWidth = 1.0 / tester.view.devicePixelRatio; final double dividerWidth = 1.0 / tester.view.devicePixelRatio;
@ -274,7 +273,7 @@ void main() {
expect(findOverflowBackButton(), findsNothing); expect(findOverflowBackButton(), findsNothing);
}, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web. }, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web.
testWidgetsWithLeakTracking('positions itself at anchorAbove if it fits', (WidgetTester tester) async { testWidgets('positions itself at anchorAbove if it fits', (WidgetTester tester) async {
late StateSetter setState; late StateSetter setState;
const double height = 50.0; const double height = 50.0;
const double anchorBelowY = 500.0; const double anchorBelowY = 500.0;
@ -340,7 +339,7 @@ void main() {
expect(toolbarY, equals(anchorAboveY - height + _kToolbarArrowSize.height - _kToolbarContentDistance)); expect(toolbarY, equals(anchorAboveY - height + _kToolbarArrowSize.height - _kToolbarContentDistance));
}, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web. }, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web.
testWidgetsWithLeakTracking('can create and use a custom toolbar', (WidgetTester tester) async { testWidgets('can create and use a custom toolbar', (WidgetTester tester) async {
final TextEditingController controller = TextEditingController( final TextEditingController controller = TextEditingController(
text: 'Select me custom menu', text: 'Select me custom menu',
); );
@ -375,7 +374,7 @@ void main() {
for (final Brightness? themeBrightness in <Brightness?>[...Brightness.values, null]) { for (final Brightness? themeBrightness in <Brightness?>[...Brightness.values, null]) {
for (final Brightness? mediaBrightness in <Brightness?>[...Brightness.values, null]) { for (final Brightness? mediaBrightness in <Brightness?>[...Brightness.values, null]) {
testWidgetsWithLeakTracking('draws dark buttons in dark mode and light button in light mode when theme is $themeBrightness and MediaQuery is $mediaBrightness', (WidgetTester tester) async { testWidgets('draws dark buttons in dark mode and light button in light mode when theme is $themeBrightness and MediaQuery is $mediaBrightness', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
theme: CupertinoThemeData( theme: CupertinoThemeData(
@ -432,7 +431,7 @@ void main() {
} }
} }
testWidgetsWithLeakTracking('draws a shadow below the toolbar in light mode', (WidgetTester tester) async { testWidgets('draws a shadow below the toolbar in light mode', (WidgetTester tester) async {
late StateSetter setState; late StateSetter setState;
const double height = 50.0; const double height = 50.0;
double anchorAboveY = 0.0; double anchorAboveY = 0.0;
@ -499,7 +498,7 @@ void main() {
); );
}, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web. }, skip: kIsWeb); // [intended] We do not use Flutter-rendered context menu on the Web.
testWidgetsWithLeakTracking('Basic golden tests', (WidgetTester tester) async { testWidgets('Basic golden tests', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
Widget buildToolbar(Brightness brightness, Offset offset) { Widget buildToolbar(Brightness brightness, Offset offset) {
final Widget toolbar = CupertinoTextSelectionToolbar( final Widget toolbar = CupertinoTextSelectionToolbar(

View File

@ -5,7 +5,6 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
int buildCount = 0; int buildCount = 0;
CupertinoThemeData? actualTheme; CupertinoThemeData? actualTheme;
@ -47,7 +46,7 @@ void main() {
actualIconTheme = null; actualIconTheme = null;
}); });
testWidgetsWithLeakTracking('Default theme has defaults', (WidgetTester tester) async { testWidgets('Default theme has defaults', (WidgetTester tester) async {
final CupertinoThemeData theme = await testTheme(tester, const CupertinoThemeData()); final CupertinoThemeData theme = await testTheme(tester, const CupertinoThemeData());
expect(theme.brightness, isNull); expect(theme.brightness, isNull);
@ -56,7 +55,7 @@ void main() {
expect(theme.applyThemeToAll, false); expect(theme.applyThemeToAll, false);
}); });
testWidgetsWithLeakTracking('Theme attributes cascade', (WidgetTester tester) async { testWidgets('Theme attributes cascade', (WidgetTester tester) async {
final CupertinoThemeData theme = await testTheme(tester, const CupertinoThemeData( final CupertinoThemeData theme = await testTheme(tester, const CupertinoThemeData(
primaryColor: CupertinoColors.systemRed, primaryColor: CupertinoColors.systemRed,
)); ));
@ -64,7 +63,7 @@ void main() {
expect(theme.textTheme.actionTextStyle.color, isSameColorAs(CupertinoColors.systemRed.color)); expect(theme.textTheme.actionTextStyle.color, isSameColorAs(CupertinoColors.systemRed.color));
}); });
testWidgetsWithLeakTracking('Dependent attribute can be overridden from cascaded value', (WidgetTester tester) async { testWidgets('Dependent attribute can be overridden from cascaded value', (WidgetTester tester) async {
final CupertinoThemeData theme = await testTheme(tester, const CupertinoThemeData( final CupertinoThemeData theme = await testTheme(tester, const CupertinoThemeData(
brightness: Brightness.dark, brightness: Brightness.dark,
textTheme: CupertinoTextThemeData( textTheme: CupertinoTextThemeData(
@ -78,7 +77,7 @@ void main() {
expect(theme.textTheme.textStyle.color, isSameColorAs(CupertinoColors.black)); expect(theme.textTheme.textStyle.color, isSameColorAs(CupertinoColors.black));
}); });
testWidgetsWithLeakTracking( testWidgets(
'Reading themes creates dependencies', 'Reading themes creates dependencies',
(WidgetTester tester) async { (WidgetTester tester) async {
// Reading the theme creates a dependency. // Reading the theme creates a dependency.
@ -119,7 +118,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'copyWith works', 'copyWith works',
(WidgetTester tester) async { (WidgetTester tester) async {
const CupertinoThemeData originalTheme = CupertinoThemeData( const CupertinoThemeData originalTheme = CupertinoThemeData(
@ -142,7 +141,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking("Theme has default IconThemeData, which is derived from the theme's primary color", (WidgetTester tester) async { testWidgets("Theme has default IconThemeData, which is derived from the theme's primary color", (WidgetTester tester) async {
const CupertinoDynamicColor primaryColor = CupertinoColors.systemRed; const CupertinoDynamicColor primaryColor = CupertinoColors.systemRed;
const CupertinoThemeData themeData = CupertinoThemeData(primaryColor: primaryColor); const CupertinoThemeData themeData = CupertinoThemeData(primaryColor: primaryColor);
@ -159,7 +158,7 @@ void main() {
expect(darkColor, isSameColorAs(primaryColor.darkColor)); expect(darkColor, isSameColorAs(primaryColor.darkColor));
}); });
testWidgetsWithLeakTracking('IconTheme.of creates a dependency on iconTheme', (WidgetTester tester) async { testWidgets('IconTheme.of creates a dependency on iconTheme', (WidgetTester tester) async {
IconThemeData iconTheme = await testIconTheme(tester, const CupertinoThemeData(primaryColor: CupertinoColors.destructiveRed)); IconThemeData iconTheme = await testIconTheme(tester, const CupertinoThemeData(primaryColor: CupertinoColors.destructiveRed));
expect(buildCount, 1); expect(buildCount, 1);
@ -170,7 +169,7 @@ void main() {
expect(iconTheme.color, CupertinoColors.activeOrange); expect(iconTheme.color, CupertinoColors.activeOrange);
}); });
testWidgetsWithLeakTracking('CupertinoTheme diagnostics', (WidgetTester tester) async { testWidgets('CupertinoTheme diagnostics', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const CupertinoThemeData().debugFillProperties(builder); const CupertinoThemeData().debugFillProperties(builder);
@ -202,7 +201,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('CupertinoTheme.toStringDeep uses single-line style', (WidgetTester tester) async { testWidgets('CupertinoTheme.toStringDeep uses single-line style', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/47651. // Regression test for https://github.com/flutter/flutter/issues/47651.
expect( expect(
const CupertinoTheme( const CupertinoTheme(
@ -213,7 +212,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('CupertinoThemeData equality', (WidgetTester tester) async { testWidgets('CupertinoThemeData equality', (WidgetTester tester) async {
const CupertinoThemeData a = CupertinoThemeData(brightness: Brightness.dark); const CupertinoThemeData a = CupertinoThemeData(brightness: Brightness.dark);
final CupertinoThemeData b = a.copyWith(); final CupertinoThemeData b = a.copyWith();
final CupertinoThemeData c = a.copyWith(brightness: Brightness.light); final CupertinoThemeData c = a.copyWith(brightness: Brightness.light);
@ -236,7 +235,7 @@ void main() {
} }
void dynamicColorsTestGroup() { void dynamicColorsTestGroup() {
testWidgetsWithLeakTracking('CupertinoTheme.of resolves colors', (WidgetTester tester) async { testWidgets('CupertinoTheme.of resolves colors', (WidgetTester tester) async {
final CupertinoThemeData data = CupertinoThemeData(brightness: currentBrightness, primaryColor: CupertinoColors.systemRed); final CupertinoThemeData data = CupertinoThemeData(brightness: currentBrightness, primaryColor: CupertinoColors.systemRed);
final CupertinoThemeData theme = await testTheme(tester, data); final CupertinoThemeData theme = await testTheme(tester, data);
@ -244,7 +243,7 @@ void main() {
colorMatches(theme.primaryColor, CupertinoColors.systemRed); colorMatches(theme.primaryColor, CupertinoColors.systemRed);
}); });
testWidgetsWithLeakTracking('CupertinoTheme.of resolves default values', (WidgetTester tester) async { testWidgets('CupertinoTheme.of resolves default values', (WidgetTester tester) async {
const CupertinoDynamicColor primaryColor = CupertinoColors.systemRed; const CupertinoDynamicColor primaryColor = CupertinoColors.systemRed;
final CupertinoThemeData data = CupertinoThemeData(brightness: currentBrightness, primaryColor: primaryColor); final CupertinoThemeData data = CupertinoThemeData(brightness: currentBrightness, primaryColor: primaryColor);

View File

@ -4,7 +4,6 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class TestNotifier extends ChangeNotifier { class TestNotifier extends ChangeNotifier {
void notify() { void notify() {
@ -62,7 +61,7 @@ class Counter with ChangeNotifier {
} }
void main() { void main() {
testWidgetsWithLeakTracking('ChangeNotifier can not dispose in callback', (WidgetTester tester) async { testWidgets('ChangeNotifier can not dispose in callback', (WidgetTester tester) async {
final TestNotifier test = TestNotifier(); final TestNotifier test = TestNotifier();
bool callbackDidFinish = false; bool callbackDidFinish = false;
void foo() { void foo() {
@ -80,7 +79,7 @@ void main() {
test.dispose(); test.dispose();
}); });
testWidgetsWithLeakTracking('ChangeNotifier', (WidgetTester tester) async { testWidgets('ChangeNotifier', (WidgetTester tester) async {
final List<String> log = <String>[]; final List<String> log = <String>[];
void listener() { void listener() {
log.add('listener'); log.add('listener');

View File

@ -5,10 +5,9 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('debugPrintGestureArenaDiagnostics', (WidgetTester tester) async { testWidgets('debugPrintGestureArenaDiagnostics', (WidgetTester tester) async {
PointerEvent event; PointerEvent event;
debugPrintGestureArenaDiagnostics = true; debugPrintGestureArenaDiagnostics = true;
final DebugPrintCallback oldCallback = debugPrint; final DebugPrintCallback oldCallback = debugPrint;
@ -54,7 +53,7 @@ void main() {
debugPrint = oldCallback; debugPrint = oldCallback;
}); });
testWidgetsWithLeakTracking('debugPrintRecognizerCallbacksTrace', (WidgetTester tester) async { testWidgets('debugPrintRecognizerCallbacksTrace', (WidgetTester tester) async {
PointerEvent event; PointerEvent event;
debugPrintRecognizerCallbacksTrace = true; debugPrintRecognizerCallbacksTrace = true;
final DebugPrintCallback oldCallback = debugPrint; final DebugPrintCallback oldCallback = debugPrint;
@ -96,7 +95,7 @@ void main() {
debugPrint = oldCallback; debugPrint = oldCallback;
}); });
testWidgetsWithLeakTracking('debugPrintGestureArenaDiagnostics and debugPrintRecognizerCallbacksTrace', (WidgetTester tester) async { testWidgets('debugPrintGestureArenaDiagnostics and debugPrintRecognizerCallbacksTrace', (WidgetTester tester) async {
PointerEvent event; PointerEvent event;
debugPrintGestureArenaDiagnostics = true; debugPrintGestureArenaDiagnostics = true;
debugPrintRecognizerCallbacksTrace = true; debugPrintRecognizerCallbacksTrace = true;

View File

@ -8,10 +8,9 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('PointerEvent resampling on a widget', (WidgetTester tester) async { testWidgets('PointerEvent resampling on a widget', (WidgetTester tester) async {
Duration currentTestFrameTime() => Duration( Duration currentTestFrameTime() => Duration(
milliseconds: TestWidgetsFlutterBinding.instance.clock.now().millisecondsSinceEpoch, milliseconds: TestWidgetsFlutterBinding.instance.clock.now().millisecondsSinceEpoch,
); );
@ -115,7 +114,7 @@ void main() {
expect(events[3], isA<PointerUpEvent>()); expect(events[3], isA<PointerUpEvent>());
}); });
testWidgetsWithLeakTracking('Timer should be canceled when resampling stopped', (WidgetTester tester) async { testWidgets('Timer should be canceled when resampling stopped', (WidgetTester tester) async {
// A timer will be started when event's timeStamp is larger than sampleTime. // A timer will be started when event's timeStamp is larger than sampleTime.
final ui.PointerDataPacket packet = ui.PointerDataPacket( final ui.PointerDataPacket packet = ui.PointerDataPacket(
data: <ui.PointerData>[ data: <ui.PointerData>[

View File

@ -6,7 +6,6 @@ import 'dart:ui' as ui;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class TestResult { class TestResult {
bool dragStarted = false; bool dragStarted = false;
@ -93,7 +92,7 @@ class NestedDraggableCase extends StatelessWidget {
} }
void main() { void main() {
testWidgetsWithLeakTracking('Scroll Views get the same ScrollConfiguration as GestureDetectors', (WidgetTester tester) async { testWidgets('Scroll Views get the same ScrollConfiguration as GestureDetectors', (WidgetTester tester) async {
tester.view.gestureSettings = const ui.GestureSettings(physicalTouchSlop: 4); tester.view.gestureSettings = const ui.GestureSettings(physicalTouchSlop: 4);
addTearDown(tester.view.reset); addTearDown(tester.view.reset);
@ -116,7 +115,7 @@ void main() {
expect(result.dragUpdate, true); expect(result.dragUpdate, true);
}); });
testWidgetsWithLeakTracking('Scroll Views get the same ScrollConfiguration as Draggables', (WidgetTester tester) async { testWidgets('Scroll Views get the same ScrollConfiguration as Draggables', (WidgetTester tester) async {
tester.view.gestureSettings = const ui.GestureSettings(physicalTouchSlop: 4); tester.view.gestureSettings = const ui.GestureSettings(physicalTouchSlop: 4);
addTearDown(tester.view.reset); addTearDown(tester.view.reset);

View File

@ -4,7 +4,7 @@
import 'package:fake_async/fake_async.dart'; import 'package:fake_async/fake_async.dart';
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:meta/meta.dart'; import 'package:meta/meta.dart';
class GestureTester { class GestureTester {
@ -26,7 +26,7 @@ typedef GestureTest = void Function(GestureTester tester);
@isTest @isTest
void testGesture(String description, GestureTest callback) { void testGesture(String description, GestureTest callback) {
testWidgetsWithLeakTracking(description, (_) async { testWidgets(description, (_) async {
FakeAsync().run((FakeAsync async) { FakeAsync().run((FakeAsync async) {
callback(GestureTester._(async)); callback(GestureTester._(async));
}); });

View File

@ -5,10 +5,9 @@
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('kTouchSlop is evaluated in the global coordinate space when scaled up', (WidgetTester tester) async { testWidgets('kTouchSlop is evaluated in the global coordinate space when scaled up', (WidgetTester tester) async {
int doubleTapCount = 0; int doubleTapCount = 0;
final Key redContainer = UniqueKey(); final Key redContainer = UniqueKey();
@ -52,7 +51,7 @@ void main() {
expect(doubleTapCount, 0); expect(doubleTapCount, 0);
}); });
testWidgetsWithLeakTracking('kTouchSlop is evaluated in the global coordinate space when scaled down', (WidgetTester tester) async { testWidgets('kTouchSlop is evaluated in the global coordinate space when scaled down', (WidgetTester tester) async {
int doubleTapCount = 0; int doubleTapCount = 0;
final Key redContainer = UniqueKey(); final Key redContainer = UniqueKey();

View File

@ -5,10 +5,9 @@
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('gets local coordinates', (WidgetTester tester) async { testWidgets('gets local coordinates', (WidgetTester tester) async {
int longPressCount = 0; int longPressCount = 0;
int longPressUpCount = 0; int longPressUpCount = 0;
final List<LongPressEndDetails> endDetails = <LongPressEndDetails>[]; final List<LongPressEndDetails> endDetails = <LongPressEndDetails>[];
@ -54,7 +53,7 @@ void main() {
expect(endDetails.single.globalPosition, const Offset(400, 300)); expect(endDetails.single.globalPosition, const Offset(400, 300));
}); });
testWidgetsWithLeakTracking('scaled up', (WidgetTester tester) async { testWidgets('scaled up', (WidgetTester tester) async {
int longPressCount = 0; int longPressCount = 0;
int longPressUpCount = 0; int longPressUpCount = 0;
final List<LongPressEndDetails> endDetails = <LongPressEndDetails>[]; final List<LongPressEndDetails> endDetails = <LongPressEndDetails>[];
@ -129,7 +128,7 @@ void main() {
expect(moveDetails.single.localOffsetFromOrigin, const Offset(0, 100.0 / 2.0)); expect(moveDetails.single.localOffsetFromOrigin, const Offset(0, 100.0 / 2.0));
}); });
testWidgetsWithLeakTracking('scaled down', (WidgetTester tester) async { testWidgets('scaled down', (WidgetTester tester) async {
int longPressCount = 0; int longPressCount = 0;
int longPressUpCount = 0; int longPressUpCount = 0;
final List<LongPressEndDetails> endDetails = <LongPressEndDetails>[]; final List<LongPressEndDetails> endDetails = <LongPressEndDetails>[];

View File

@ -7,11 +7,10 @@ import 'dart:math' as math;
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
group('Horizontal', () { group('Horizontal', () {
testWidgetsWithLeakTracking('gets local coordinates', (WidgetTester tester) async { testWidgets('gets local coordinates', (WidgetTester tester) async {
int dragCancelCount = 0; int dragCancelCount = 0;
final List<DragDownDetails> downDetails = <DragDownDetails>[]; final List<DragDownDetails> downDetails = <DragDownDetails>[];
final List<DragEndDetails> endDetails = <DragEndDetails>[]; final List<DragEndDetails> endDetails = <DragEndDetails>[];
@ -66,7 +65,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('kTouchSlop is evaluated in the global coordinate space when scaled up', (WidgetTester tester) async { testWidgets('kTouchSlop is evaluated in the global coordinate space when scaled up', (WidgetTester tester) async {
int dragCancelCount = 0; int dragCancelCount = 0;
final List<DragDownDetails> downDetails = <DragDownDetails>[]; final List<DragDownDetails> downDetails = <DragDownDetails>[];
final List<DragEndDetails> endDetails = <DragEndDetails>[]; final List<DragEndDetails> endDetails = <DragEndDetails>[];
@ -164,7 +163,7 @@ void main() {
updateDetails.clear(); updateDetails.clear();
}); });
testWidgetsWithLeakTracking('kTouchSlop is evaluated in the global coordinate space when scaled down', (WidgetTester tester) async { testWidgets('kTouchSlop is evaluated in the global coordinate space when scaled down', (WidgetTester tester) async {
int dragCancelCount = 0; int dragCancelCount = 0;
final List<DragDownDetails> downDetails = <DragDownDetails>[]; final List<DragDownDetails> downDetails = <DragDownDetails>[];
final List<DragEndDetails> endDetails = <DragEndDetails>[]; final List<DragEndDetails> endDetails = <DragEndDetails>[];
@ -262,7 +261,7 @@ void main() {
updateDetails.clear(); updateDetails.clear();
}); });
testWidgetsWithLeakTracking('kTouchSlop is evaluated in the global coordinate space when rotated 45 degrees', (WidgetTester tester) async { testWidgets('kTouchSlop is evaluated in the global coordinate space when rotated 45 degrees', (WidgetTester tester) async {
int dragCancelCount = 0; int dragCancelCount = 0;
final List<DragDownDetails> downDetails = <DragDownDetails>[]; final List<DragDownDetails> downDetails = <DragDownDetails>[];
final List<DragEndDetails> endDetails = <DragEndDetails>[]; final List<DragEndDetails> endDetails = <DragEndDetails>[];
@ -339,7 +338,7 @@ void main() {
}); });
group('Vertical', () { group('Vertical', () {
testWidgetsWithLeakTracking('gets local coordinates', (WidgetTester tester) async { testWidgets('gets local coordinates', (WidgetTester tester) async {
int dragCancelCount = 0; int dragCancelCount = 0;
final List<DragDownDetails> downDetails = <DragDownDetails>[]; final List<DragDownDetails> downDetails = <DragDownDetails>[];
final List<DragEndDetails> endDetails = <DragEndDetails>[]; final List<DragEndDetails> endDetails = <DragEndDetails>[];
@ -394,7 +393,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('kTouchSlop is evaluated in the global coordinate space when scaled up', (WidgetTester tester) async { testWidgets('kTouchSlop is evaluated in the global coordinate space when scaled up', (WidgetTester tester) async {
int dragCancelCount = 0; int dragCancelCount = 0;
final List<DragDownDetails> downDetails = <DragDownDetails>[]; final List<DragDownDetails> downDetails = <DragDownDetails>[];
final List<DragEndDetails> endDetails = <DragEndDetails>[]; final List<DragEndDetails> endDetails = <DragEndDetails>[];
@ -492,7 +491,7 @@ void main() {
updateDetails.clear(); updateDetails.clear();
}); });
testWidgetsWithLeakTracking('kTouchSlop is evaluated in the global coordinate space when scaled down', (WidgetTester tester) async { testWidgets('kTouchSlop is evaluated in the global coordinate space when scaled down', (WidgetTester tester) async {
int dragCancelCount = 0; int dragCancelCount = 0;
final List<DragDownDetails> downDetails = <DragDownDetails>[]; final List<DragDownDetails> downDetails = <DragDownDetails>[];
final List<DragEndDetails> endDetails = <DragEndDetails>[]; final List<DragEndDetails> endDetails = <DragEndDetails>[];
@ -590,7 +589,7 @@ void main() {
updateDetails.clear(); updateDetails.clear();
}); });
testWidgetsWithLeakTracking('kTouchSlop is evaluated in the global coordinate space when rotated 45 degrees', (WidgetTester tester) async { testWidgets('kTouchSlop is evaluated in the global coordinate space when rotated 45 degrees', (WidgetTester tester) async {
int dragCancelCount = 0; int dragCancelCount = 0;
final List<DragDownDetails> downDetails = <DragDownDetails>[]; final List<DragDownDetails> downDetails = <DragDownDetails>[];
final List<DragEndDetails> endDetails = <DragEndDetails>[]; final List<DragEndDetails> endDetails = <DragEndDetails>[];

View File

@ -4,10 +4,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('gets local coordinates', (WidgetTester tester) async { testWidgets('gets local coordinates', (WidgetTester tester) async {
final List<ScaleStartDetails> startDetails = <ScaleStartDetails>[]; final List<ScaleStartDetails> startDetails = <ScaleStartDetails>[];
final List<ScaleUpdateDetails> updateDetails = <ScaleUpdateDetails>[]; final List<ScaleUpdateDetails> updateDetails = <ScaleUpdateDetails>[];

View File

@ -5,10 +5,9 @@
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('gets local coordinates', (WidgetTester tester) async { testWidgets('gets local coordinates', (WidgetTester tester) async {
int tapCount = 0; int tapCount = 0;
int tapCancelCount = 0; int tapCancelCount = 0;
final List<TapDownDetails> downDetails = <TapDownDetails>[]; final List<TapDownDetails> downDetails = <TapDownDetails>[];
@ -49,7 +48,7 @@ void main() {
expect(upDetails.single.globalPosition, const Offset(400, 300)); expect(upDetails.single.globalPosition, const Offset(400, 300));
}); });
testWidgetsWithLeakTracking('kTouchSlop is evaluated in the global coordinate space when scaled up', (WidgetTester tester) async { testWidgets('kTouchSlop is evaluated in the global coordinate space when scaled up', (WidgetTester tester) async {
int tapCount = 0; int tapCount = 0;
int tapCancelCount = 0; int tapCancelCount = 0;
final List<TapDownDetails> downDetails = <TapDownDetails>[]; final List<TapDownDetails> downDetails = <TapDownDetails>[];
@ -112,7 +111,7 @@ void main() {
expect(upDetails, isEmpty); expect(upDetails, isEmpty);
}); });
testWidgetsWithLeakTracking('kTouchSlop is evaluated in the global coordinate space when scaled down', (WidgetTester tester) async { testWidgets('kTouchSlop is evaluated in the global coordinate space when scaled down', (WidgetTester tester) async {
int tapCount = 0; int tapCount = 0;
int tapCancelCount = 0; int tapCancelCount = 0;
final List<TapDownDetails> downDetails = <TapDownDetails>[]; final List<TapDownDetails> downDetails = <TapDownDetails>[];

View File

@ -4,7 +4,6 @@
import 'package:flutter/gestures.dart'; import 'package:flutter/gestures.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'velocity_tracker_data.dart'; import 'velocity_tracker_data.dart';
bool _withinTolerance(double actual, double expected) { bool _withinTolerance(double actual, double expected) {
@ -35,7 +34,7 @@ void main() {
Offset(-71.51939428321249, 3716.7385187526947), Offset(-71.51939428321249, 3716.7385187526947),
]; ];
testWidgetsWithLeakTracking('Velocity tracker gives expected results', (WidgetTester tester) async { testWidgets('Velocity tracker gives expected results', (WidgetTester tester) async {
final VelocityTracker tracker = VelocityTracker.withKind(PointerDeviceKind.touch); final VelocityTracker tracker = VelocityTracker.withKind(PointerDeviceKind.touch);
int i = 0; int i = 0;
for (final PointerEvent event in velocityEventData) { for (final PointerEvent event in velocityEventData) {
@ -49,7 +48,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('Velocity control test', (WidgetTester tester) async { testWidgets('Velocity control test', (WidgetTester tester) async {
const Velocity velocity1 = Velocity(pixelsPerSecond: Offset(7.0, 0.0)); const Velocity velocity1 = Velocity(pixelsPerSecond: Offset(7.0, 0.0));
const Velocity velocity2 = Velocity(pixelsPerSecond: Offset(12.0, 0.0)); const Velocity velocity2 = Velocity(pixelsPerSecond: Offset(12.0, 0.0));
expect(velocity1, equals(const Velocity(pixelsPerSecond: Offset(7.0, 0.0)))); expect(velocity1, equals(const Velocity(pixelsPerSecond: Offset(7.0, 0.0))));
@ -61,7 +60,7 @@ void main() {
expect(velocity1, hasOneLineDescription); expect(velocity1, hasOneLineDescription);
}); });
testWidgetsWithLeakTracking('Interrupted velocity estimation', (WidgetTester tester) async { testWidgets('Interrupted velocity estimation', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/pull/7510 // Regression test for https://github.com/flutter/flutter/pull/7510
final VelocityTracker tracker = VelocityTracker.withKind(PointerDeviceKind.touch); final VelocityTracker tracker = VelocityTracker.withKind(PointerDeviceKind.touch);
for (final PointerEvent event in interruptedVelocityEventData) { for (final PointerEvent event in interruptedVelocityEventData) {
@ -74,12 +73,12 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('No data velocity estimation', (WidgetTester tester) async { testWidgets('No data velocity estimation', (WidgetTester tester) async {
final VelocityTracker tracker = VelocityTracker.withKind(PointerDeviceKind.touch); final VelocityTracker tracker = VelocityTracker.withKind(PointerDeviceKind.touch);
expect(tracker.getVelocity(), Velocity.zero); expect(tracker.getVelocity(), Velocity.zero);
}); });
testWidgetsWithLeakTracking('FreeScrollStartVelocityTracker.getVelocity throws when no points', (WidgetTester tester) async { testWidgets('FreeScrollStartVelocityTracker.getVelocity throws when no points', (WidgetTester tester) async {
final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch); final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch);
AssertionError? exception; AssertionError? exception;
try { try {
@ -91,7 +90,7 @@ void main() {
expect(exception?.toString(), contains('at least 1 point')); expect(exception?.toString(), contains('at least 1 point'));
}); });
testWidgetsWithLeakTracking('FreeScrollStartVelocityTracker.getVelocity throws when the new point precedes the previous point', (WidgetTester tester) async { testWidgets('FreeScrollStartVelocityTracker.getVelocity throws when the new point precedes the previous point', (WidgetTester tester) async {
final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch); final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch);
AssertionError? exception; AssertionError? exception;
@ -106,7 +105,7 @@ void main() {
expect(exception?.toString(), contains('has a smaller timestamp')); expect(exception?.toString(), contains('has a smaller timestamp'));
}); });
testWidgetsWithLeakTracking('Estimate does not throw when there are more than 1 point', (WidgetTester tester) async { testWidgets('Estimate does not throw when there are more than 1 point', (WidgetTester tester) async {
final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch); final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch);
Offset position = Offset.zero; Offset position = Offset.zero;
Duration time = Duration.zero; Duration time = Duration.zero;
@ -128,7 +127,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('Makes consistent velocity estimates with consistent velocity', (WidgetTester tester) async { testWidgets('Makes consistent velocity estimates with consistent velocity', (WidgetTester tester) async {
final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch); final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch);
Offset position = Offset.zero; Offset position = Offset.zero;
Duration time = Duration.zero; Duration time = Duration.zero;
@ -146,7 +145,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('Assume zero velocity when there are no recent samples - base VelocityTracker', (WidgetTester tester) async { testWidgets('Assume zero velocity when there are no recent samples - base VelocityTracker', (WidgetTester tester) async {
final VelocityTracker tracker = VelocityTracker.withKind(PointerDeviceKind.touch); final VelocityTracker tracker = VelocityTracker.withKind(PointerDeviceKind.touch);
Offset position = Offset.zero; Offset position = Offset.zero;
Duration time = Duration.zero; Duration time = Duration.zero;
@ -163,7 +162,7 @@ void main() {
expect(tracker.getVelocity().pixelsPerSecond, Offset.zero); expect(tracker.getVelocity().pixelsPerSecond, Offset.zero);
}); });
testWidgetsWithLeakTracking('Assume zero velocity when there are no recent samples - IOS', (WidgetTester tester) async { testWidgets('Assume zero velocity when there are no recent samples - IOS', (WidgetTester tester) async {
final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch); final IOSScrollViewFlingVelocityTracker tracker = IOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch);
Offset position = Offset.zero; Offset position = Offset.zero;
Duration time = Duration.zero; Duration time = Duration.zero;
@ -180,7 +179,7 @@ void main() {
expect(tracker.getVelocity().pixelsPerSecond, Offset.zero); expect(tracker.getVelocity().pixelsPerSecond, Offset.zero);
}); });
testWidgetsWithLeakTracking('Assume zero velocity when there are no recent samples - MacOS', (WidgetTester tester) async { testWidgets('Assume zero velocity when there are no recent samples - MacOS', (WidgetTester tester) async {
final MacOSScrollViewFlingVelocityTracker tracker = MacOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch); final MacOSScrollViewFlingVelocityTracker tracker = MacOSScrollViewFlingVelocityTracker(PointerDeviceKind.touch);
Offset position = Offset.zero; Offset position = Offset.zero;
Duration time = Duration.zero; Duration time = Duration.zero;

View File

@ -10,14 +10,13 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
tearDown(() { tearDown(() {
LicenseRegistry.reset(); LicenseRegistry.reset();
}); });
testWidgetsWithLeakTracking('Material3 has sentence case labels', (WidgetTester tester) async { testWidgets('Material3 has sentence case labels', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: true), theme: ThemeData(useMaterial3: true),
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
@ -57,7 +56,7 @@ void main() {
expect(find.text('View licenses'), findsOneWidget); expect(find.text('View licenses'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Material2 - AboutListTile control test', (WidgetTester tester) async { testWidgets('Material2 - AboutListTile control test', (WidgetTester tester) async {
const FlutterLogo logo = FlutterLogo(); const FlutterLogo logo = FlutterLogo();
await tester.pumpWidget( await tester.pumpWidget(
@ -140,7 +139,7 @@ void main() {
expect(find.text('Pirate license'), findsOneWidget); expect(find.text('Pirate license'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Material3 - AboutListTile control test', (WidgetTester tester) async { testWidgets('Material3 - AboutListTile control test', (WidgetTester tester) async {
const FlutterLogo logo = FlutterLogo(); const FlutterLogo logo = FlutterLogo();
await tester.pumpWidget( await tester.pumpWidget(
@ -223,7 +222,7 @@ void main() {
expect(find.text('Pirate license'), findsOneWidget); expect(find.text('Pirate license'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('About box logic defaults to executable name for app name', (WidgetTester tester) async { testWidgets('About box logic defaults to executable name for app name', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
title: 'flutter_tester', title: 'flutter_tester',
@ -233,7 +232,7 @@ void main() {
expect(find.text('About flutter_tester'), findsOneWidget); expect(find.text('About flutter_tester'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('LicensePage control test', (WidgetTester tester) async { testWidgets('LicensePage control test', (WidgetTester tester) async {
LicenseRegistry.addLicense(() { LicenseRegistry.addLicense(() {
return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[ return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[
const LicenseEntryWithLineBreaks(<String>['AAA'], 'BBB'), const LicenseEntryWithLineBreaks(<String>['AAA'], 'BBB'),
@ -284,7 +283,7 @@ void main() {
expect(find.text('Another license'), findsOneWidget); expect(find.text('Another license'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('LicensePage control test with all properties', (WidgetTester tester) async { testWidgets('LicensePage control test with all properties', (WidgetTester tester) async {
const FlutterLogo logo = FlutterLogo(); const FlutterLogo logo = FlutterLogo();
LicenseRegistry.addLicense(() { LicenseRegistry.addLicense(() {
@ -360,7 +359,7 @@ void main() {
expect(find.text('Another license'), findsOneWidget); expect(find.text('Another license'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Material2 - _PackageLicensePage title style without AppBarTheme', (WidgetTester tester) async { testWidgets('Material2 - _PackageLicensePage title style without AppBarTheme', (WidgetTester tester) async {
LicenseRegistry.addLicense(() { LicenseRegistry.addLicense(() {
return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[ return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[
const LicenseEntryWithLineBreaks(<String>['AAA'], 'BBB'), const LicenseEntryWithLineBreaks(<String>['AAA'], 'BBB'),
@ -408,7 +407,7 @@ void main() {
expect(subtitle.style, subtitleTextStyle); expect(subtitle.style, subtitleTextStyle);
}); });
testWidgetsWithLeakTracking('Material3 - _PackageLicensePage title style without AppBarTheme', (WidgetTester tester) async { testWidgets('Material3 - _PackageLicensePage title style without AppBarTheme', (WidgetTester tester) async {
LicenseRegistry.addLicense(() { LicenseRegistry.addLicense(() {
return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[ return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[
const LicenseEntryWithLineBreaks(<String>['AAA'], 'BBB'), const LicenseEntryWithLineBreaks(<String>['AAA'], 'BBB'),
@ -456,7 +455,7 @@ void main() {
expect(subtitle.style, subtitleTextStyle); expect(subtitle.style, subtitleTextStyle);
}); });
testWidgetsWithLeakTracking('_PackageLicensePage title style with AppBarTheme', (WidgetTester tester) async { testWidgets('_PackageLicensePage title style with AppBarTheme', (WidgetTester tester) async {
LicenseRegistry.addLicense(() { LicenseRegistry.addLicense(() {
return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[ return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[
const LicenseEntryWithLineBreaks(<String>['AAA'], 'BBB'), const LicenseEntryWithLineBreaks(<String>['AAA'], 'BBB'),
@ -506,7 +505,7 @@ void main() {
expect(title.style, titleTextStyle); expect(title.style, titleTextStyle);
}); });
testWidgetsWithLeakTracking('Material2 - LicensePage respects the notch', (WidgetTester tester) async { testWidgets('Material2 - LicensePage respects the notch', (WidgetTester tester) async {
const double safeareaPadding = 27.0; const double safeareaPadding = 27.0;
LicenseRegistry.addLicense(() { LicenseRegistry.addLicense(() {
@ -537,7 +536,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material3 - LicensePage respects the notch', (WidgetTester tester) async { testWidgets('Material3 - LicensePage respects the notch', (WidgetTester tester) async {
const double safeareaPadding = 27.0; const double safeareaPadding = 27.0;
LicenseRegistry.addLicense(() { LicenseRegistry.addLicense(() {
@ -568,7 +567,7 @@ void main() {
); );
}, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933 }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
testWidgetsWithLeakTracking('LicensePage returns early if unmounted', (WidgetTester tester) async { testWidgets('LicensePage returns early if unmounted', (WidgetTester tester) async {
final Completer<LicenseEntry> licenseCompleter = Completer<LicenseEntry>(); final Completer<LicenseEntry> licenseCompleter = Completer<LicenseEntry>();
LicenseRegistry.addLicense(() { LicenseRegistry.addLicense(() {
return Stream<LicenseEntry>.fromFuture(licenseCompleter.future); return Stream<LicenseEntry>.fromFuture(licenseCompleter.future);
@ -593,7 +592,7 @@ void main() {
expect(licenseEntry.packagesCalled, false); expect(licenseEntry.packagesCalled, false);
}); });
testWidgetsWithLeakTracking('LicensePage returns late if unmounted', (WidgetTester tester) async { testWidgets('LicensePage returns late if unmounted', (WidgetTester tester) async {
final Completer<LicenseEntry> licenseCompleter = Completer<LicenseEntry>(); final Completer<LicenseEntry> licenseCompleter = Completer<LicenseEntry>();
LicenseRegistry.addLicense(() { LicenseRegistry.addLicense(() {
return Stream<LicenseEntry>.fromFuture(licenseCompleter.future); return Stream<LicenseEntry>.fromFuture(licenseCompleter.future);
@ -618,7 +617,7 @@ void main() {
expect(licenseEntry.packagesCalled, true); expect(licenseEntry.packagesCalled, true);
}); });
testWidgetsWithLeakTracking('LicensePage logic defaults to executable name for app name', (WidgetTester tester) async { testWidgets('LicensePage logic defaults to executable name for app name', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
title: 'flutter_tester', title: 'flutter_tester',
@ -628,7 +627,7 @@ void main() {
expect(find.text('flutter_tester'), findsOneWidget); expect(find.text('flutter_tester'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('AboutListTile dense property is applied', (WidgetTester tester) async { testWidgets('AboutListTile dense property is applied', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp( await tester.pumpWidget(const MaterialApp(
home: Material(child: Center(child: AboutListTile())), home: Material(child: Center(child: AboutListTile())),
)); ));
@ -648,7 +647,7 @@ void main() {
expect(tileRect.height, 48.0); expect(tileRect.height, 48.0);
}); });
testWidgetsWithLeakTracking('showLicensePage uses nested navigator by default', (WidgetTester tester) async { testWidgets('showLicensePage uses nested navigator by default', (WidgetTester tester) async {
final LicensePageObserver rootObserver = LicensePageObserver(); final LicensePageObserver rootObserver = LicensePageObserver();
final LicensePageObserver nestedObserver = LicensePageObserver(); final LicensePageObserver nestedObserver = LicensePageObserver();
@ -686,7 +685,7 @@ void main() {
expect(nestedObserver.licensePageCount, 1); expect(nestedObserver.licensePageCount, 1);
}); });
testWidgetsWithLeakTracking('showLicensePage uses root navigator if useRootNavigator is true', (WidgetTester tester) async { testWidgets('showLicensePage uses root navigator if useRootNavigator is true', (WidgetTester tester) async {
final LicensePageObserver rootObserver = LicensePageObserver(); final LicensePageObserver rootObserver = LicensePageObserver();
final LicensePageObserver nestedObserver = LicensePageObserver(); final LicensePageObserver nestedObserver = LicensePageObserver();
@ -732,7 +731,7 @@ void main() {
rootObserver = AboutDialogObserver(); rootObserver = AboutDialogObserver();
}); });
testWidgetsWithLeakTracking('Barrier is dismissible with default parameter', (WidgetTester tester) async { testWidgets('Barrier is dismissible with default parameter', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
navigatorObservers: <NavigatorObserver>[rootObserver], navigatorObservers: <NavigatorObserver>[rootObserver],
@ -764,7 +763,7 @@ void main() {
expect(rootObserver.dialogCount, 0); expect(rootObserver.dialogCount, 0);
}); });
testWidgetsWithLeakTracking('Barrier is not dismissible with barrierDismissible is false', (WidgetTester tester) async { testWidgets('Barrier is not dismissible with barrierDismissible is false', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
navigatorObservers: <NavigatorObserver>[rootObserver], navigatorObservers: <NavigatorObserver>[rootObserver],
@ -798,7 +797,7 @@ void main() {
}); });
}); });
testWidgetsWithLeakTracking('Barrier color', (WidgetTester tester) async { testWidgets('Barrier color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Material( home: Material(
@ -852,7 +851,7 @@ void main() {
expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, Colors.pink); expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).color, Colors.pink);
}); });
testWidgetsWithLeakTracking('Barrier Label', (WidgetTester tester) async { testWidgets('Barrier Label', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Material( home: Material(
@ -879,7 +878,7 @@ void main() {
expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).semanticsLabel, 'Custom Label'); expect(tester.widget<ModalBarrier>(find.byType(ModalBarrier).last).semanticsLabel, 'Custom Label');
}); });
testWidgetsWithLeakTracking('showAboutDialog uses root navigator by default', (WidgetTester tester) async { testWidgets('showAboutDialog uses root navigator by default', (WidgetTester tester) async {
final AboutDialogObserver rootObserver = AboutDialogObserver(); final AboutDialogObserver rootObserver = AboutDialogObserver();
final AboutDialogObserver nestedObserver = AboutDialogObserver(); final AboutDialogObserver nestedObserver = AboutDialogObserver();
@ -912,7 +911,7 @@ void main() {
expect(nestedObserver.dialogCount, 0); expect(nestedObserver.dialogCount, 0);
}); });
testWidgetsWithLeakTracking('showAboutDialog uses nested navigator if useRootNavigator is false', (WidgetTester tester) async { testWidgets('showAboutDialog uses nested navigator if useRootNavigator is false', (WidgetTester tester) async {
final AboutDialogObserver rootObserver = AboutDialogObserver(); final AboutDialogObserver rootObserver = AboutDialogObserver();
final AboutDialogObserver nestedObserver = AboutDialogObserver(); final AboutDialogObserver nestedObserver = AboutDialogObserver();
@ -947,7 +946,7 @@ void main() {
}); });
group('showAboutDialog avoids overlapping display features', () { group('showAboutDialog avoids overlapping display features', () {
testWidgetsWithLeakTracking('default positioning', (WidgetTester tester) async { testWidgets('default positioning', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
return MediaQuery( return MediaQuery(
@ -988,7 +987,7 @@ void main() {
expect(tester.getBottomRight(find.byType(AboutDialog)), const Offset(390.0, 600.0)); expect(tester.getBottomRight(find.byType(AboutDialog)), const Offset(390.0, 600.0));
}); });
testWidgetsWithLeakTracking('positioning using anchorPoint', (WidgetTester tester) async { testWidgets('positioning using anchorPoint', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
return MediaQuery( return MediaQuery(
@ -1030,7 +1029,7 @@ void main() {
expect(tester.getBottomRight(find.byType(AboutDialog)), const Offset(800.0, 600.0)); expect(tester.getBottomRight(find.byType(AboutDialog)), const Offset(800.0, 600.0));
}); });
testWidgetsWithLeakTracking('positioning using Directionality', (WidgetTester tester) async { testWidgets('positioning using Directionality', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
return MediaQuery( return MediaQuery(
@ -1075,7 +1074,7 @@ void main() {
}); });
}); });
testWidgetsWithLeakTracking("AboutListTile's child should not be offset when the icon is not specified.", (WidgetTester tester) async { testWidgets("AboutListTile's child should not be offset when the icon is not specified.", (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: Scaffold( home: Scaffold(
@ -1095,7 +1094,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking("AboutDialog's contents are scrollable", (WidgetTester tester) async { testWidgets("AboutDialog's contents are scrollable", (WidgetTester tester) async {
final Key contentKey = UniqueKey(); final Key contentKey = UniqueKey();
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Navigator( home: Navigator(
@ -1143,7 +1142,7 @@ void main() {
expect(box.localToGlobal(Offset.zero), equals(originalOffset.translate(0.0, -20.0))); expect(box.localToGlobal(Offset.zero), equals(originalOffset.translate(0.0, -20.0)));
}); });
testWidgetsWithLeakTracking("Material2 - LicensePage's color must be same whether loading or done", (WidgetTester tester) async { testWidgets("Material2 - LicensePage's color must be same whether loading or done", (WidgetTester tester) async {
const Color scaffoldColor = Color(0xFF123456); const Color scaffoldColor = Color(0xFF123456);
const Color cardColor = Color(0xFF654321); const Color cardColor = Color(0xFF654321);
@ -1190,7 +1189,7 @@ void main() {
expect(materialDones[1].color, cardColor); expect(materialDones[1].color, cardColor);
}); });
testWidgetsWithLeakTracking("Material3 - LicensePage's color must be same whether loading or done", (WidgetTester tester) async { testWidgets("Material3 - LicensePage's color must be same whether loading or done", (WidgetTester tester) async {
const Color scaffoldColor = Color(0xFF123456); const Color scaffoldColor = Color(0xFF123456);
const Color cardColor = Color(0xFF654321); const Color cardColor = Color(0xFF654321);
@ -1237,7 +1236,7 @@ void main() {
expect(materialDones[1].color, cardColor); expect(materialDones[1].color, cardColor);
}); });
testWidgetsWithLeakTracking('Conflicting scrollbars are not applied by ScrollBehavior to _PackageLicensePage', (WidgetTester tester) async { testWidgets('Conflicting scrollbars are not applied by ScrollBehavior to _PackageLicensePage', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/83819 // Regression test for https://github.com/flutter/flutter/issues/83819
LicenseRegistry.addLicense(() { LicenseRegistry.addLicense(() {
return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[ return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[
@ -1279,7 +1278,7 @@ void main() {
}, variant: TargetPlatformVariant.all()); }, variant: TargetPlatformVariant.all());
testWidgetsWithLeakTracking('ListView of license entries is primary', (WidgetTester tester) async { testWidgets('ListView of license entries is primary', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/120710 // Regression test for https://github.com/flutter/flutter/issues/120710
LicenseRegistry.addLicense(() { LicenseRegistry.addLicense(() {
return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[ return Stream<LicenseEntry>.fromIterable(<LicenseEntry>[
@ -1338,7 +1337,7 @@ void main() {
await tester.pumpAndSettle(); // No exception triggered. await tester.pumpAndSettle(); // No exception triggered.
}, variant: TargetPlatformVariant.all()); }, variant: TargetPlatformVariant.all());
testWidgetsWithLeakTracking('LicensePage padding', (WidgetTester tester) async { testWidgets('LicensePage padding', (WidgetTester tester) async {
const FlutterLogo logo = FlutterLogo(); const FlutterLogo logo = FlutterLogo();
await tester.pumpWidget( await tester.pumpWidget(
@ -1381,7 +1380,7 @@ void main() {
expect(appLegaleseBottomPadding, 18.0); expect(appLegaleseBottomPadding, 18.0);
}); });
testWidgetsWithLeakTracking('LicensePage has no extra padding between app icon and app powered text', (WidgetTester tester) async { testWidgets('LicensePage has no extra padding between app icon and app powered text', (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/99559 // This is a regression test for https://github.com/flutter/flutter/issues/99559
const FlutterLogo logo = FlutterLogo(); const FlutterLogo logo = FlutterLogo();
@ -1414,7 +1413,7 @@ void main() {
expect(appIconBottomPadding, 18.0); expect(appIconBottomPadding, 18.0);
}); });
testWidgetsWithLeakTracking('Material2 - Error handling test', (WidgetTester tester) async { testWidgets('Material2 - Error handling test', (WidgetTester tester) async {
LicenseRegistry.addLicense(() => Stream<LicenseEntry>.error(Exception('Injected failure'))); LicenseRegistry.addLicense(() => Stream<LicenseEntry>.error(Exception('Injected failure')));
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -1437,7 +1436,7 @@ void main() {
expect(find.text('Exception: Injected failure'), findsOneWidget); expect(find.text('Exception: Injected failure'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Material3 - Error handling test', (WidgetTester tester) async { testWidgets('Material3 - Error handling test', (WidgetTester tester) async {
LicenseRegistry.addLicense(() => Stream<LicenseEntry>.error(Exception('Injected failure'))); LicenseRegistry.addLicense(() => Stream<LicenseEntry>.error(Exception('Injected failure')));
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -1460,7 +1459,7 @@ void main() {
expect(find.text('Exception: Injected failure'), findsOneWidget); expect(find.text('Exception: Injected failure'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Material2 - LicensePage master view layout position - ltr', (WidgetTester tester) async { testWidgets('Material2 - LicensePage master view layout position - ltr', (WidgetTester tester) async {
const TextDirection textDirection = TextDirection.ltr; const TextDirection textDirection = TextDirection.ltr;
const Size defaultSize = Size(800.0, 600.0); const Size defaultSize = Size(800.0, 600.0);
const Size wideSize = Size(1200.0, 600.0); const Size wideSize = Size(1200.0, 600.0);
@ -1525,7 +1524,7 @@ void main() {
expect(tester.getCenter(find.byType(ListView)), const Offset(160, 356)); expect(tester.getCenter(find.byType(ListView)), const Offset(160, 356));
}); });
testWidgetsWithLeakTracking('Material3 - LicensePage master view layout position - ltr', (WidgetTester tester) async { testWidgets('Material3 - LicensePage master view layout position - ltr', (WidgetTester tester) async {
const TextDirection textDirection = TextDirection.ltr; const TextDirection textDirection = TextDirection.ltr;
const Size defaultSize = Size(800.0, 600.0); const Size defaultSize = Size(800.0, 600.0);
const Size wideSize = Size(1200.0, 600.0); const Size wideSize = Size(1200.0, 600.0);
@ -1592,7 +1591,7 @@ void main() {
expect(tester.getCenter(find.byType(ListView)), const Offset(160, 356)); expect(tester.getCenter(find.byType(ListView)), const Offset(160, 356));
}); });
testWidgetsWithLeakTracking('Material2 - LicensePage master view layout position - rtl', (WidgetTester tester) async { testWidgets('Material2 - LicensePage master view layout position - rtl', (WidgetTester tester) async {
const TextDirection textDirection = TextDirection.rtl; const TextDirection textDirection = TextDirection.rtl;
const Size defaultSize = Size(800.0, 600.0); const Size defaultSize = Size(800.0, 600.0);
const Size wideSize = Size(1200.0, 600.0); const Size wideSize = Size(1200.0, 600.0);
@ -1657,7 +1656,7 @@ void main() {
expect(tester.getCenter(find.byType(ListView)), const Offset(1040.0, 356.0)); expect(tester.getCenter(find.byType(ListView)), const Offset(1040.0, 356.0));
}); });
testWidgetsWithLeakTracking('Material3 - LicensePage master view layout position - rtl', (WidgetTester tester) async { testWidgets('Material3 - LicensePage master view layout position - rtl', (WidgetTester tester) async {
const TextDirection textDirection = TextDirection.rtl; const TextDirection textDirection = TextDirection.rtl;
const Size defaultSize = Size(800.0, 600.0); const Size defaultSize = Size(800.0, 600.0);
const Size wideSize = Size(1200.0, 600.0); const Size wideSize = Size(1200.0, 600.0);
@ -1724,7 +1723,7 @@ void main() {
expect(tester.getCenter(find.byType(ListView)), const Offset(1040.0, 356.0)); expect(tester.getCenter(find.byType(ListView)), const Offset(1040.0, 356.0));
}); });
testWidgetsWithLeakTracking('License page title in lateral UI does not use AppBarTheme.foregroundColor', (WidgetTester tester) async { testWidgets('License page title in lateral UI does not use AppBarTheme.foregroundColor', (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/108991 // This is a regression test for https://github.com/flutter/flutter/issues/108991
final ThemeData theme = ThemeData( final ThemeData theme = ThemeData(
appBarTheme: const AppBarTheme(foregroundColor: Color(0xFFFFFFFF)), appBarTheme: const AppBarTheme(foregroundColor: Color(0xFFFFFFFF)),
@ -1765,7 +1764,7 @@ void main() {
expect(renderParagraph.text.style!.color, theme.textTheme.titleLarge!.color); expect(renderParagraph.text.style!.color, theme.textTheme.titleLarge!.color);
}); });
testWidgetsWithLeakTracking('License page default title text color in the nested UI', (WidgetTester tester) async { testWidgets('License page default title text color in the nested UI', (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/108991 // This is a regression test for https://github.com/flutter/flutter/issues/108991
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
const String title = 'License ABC'; const String title = 'License ABC';
@ -1806,7 +1805,7 @@ void main() {
// support is deprecated and the APIs are removed, these tests // support is deprecated and the APIs are removed, these tests
// can be deleted. // can be deleted.
testWidgetsWithLeakTracking('License page default title text color in the nested UI', (WidgetTester tester) async { testWidgets('License page default title text color in the nested UI', (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/108991 // This is a regression test for https://github.com/flutter/flutter/issues/108991
final ThemeData theme = ThemeData(useMaterial3: false); final ThemeData theme = ThemeData(useMaterial3: false);
const String title = 'License ABC'; const String title = 'License ABC';

View File

@ -4,7 +4,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
/// Adds the basic requirements for a Chip. /// Adds the basic requirements for a Chip.
Widget wrapForChip({ Widget wrapForChip({
@ -73,7 +72,7 @@ void checkChipMaterialClipBehavior(WidgetTester tester, Clip clipBehavior) {
} }
void main() { void main() {
testWidgetsWithLeakTracking('ActionChip defaults', (WidgetTester tester) async { testWidgets('ActionChip defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
const String label = 'action chip'; const String label = 'action chip';
@ -147,7 +146,7 @@ void main() {
expect(decoration.color, null); expect(decoration.color, null);
}); });
testWidgetsWithLeakTracking('ActionChip.elevated defaults', (WidgetTester tester) async { testWidgets('ActionChip.elevated defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
const String label = 'action chip'; const String label = 'action chip';
@ -221,7 +220,7 @@ void main() {
expect(decoration.color, theme.colorScheme.onSurface.withOpacity(0.12)); expect(decoration.color, theme.colorScheme.onSurface.withOpacity(0.12));
}); });
testWidgetsWithLeakTracking('ActionChip.color resolves material states', (WidgetTester tester) async { testWidgets('ActionChip.color resolves material states', (WidgetTester tester) async {
const Color disabledColor = Color(0xff00ff00); const Color disabledColor = Color(0xff00ff00);
const Color backgroundColor = Color(0xff0000ff); const Color backgroundColor = Color(0xff0000ff);
final MaterialStateProperty<Color?> color = MaterialStateProperty.resolveWith((Set<MaterialState> states) { final MaterialStateProperty<Color?> color = MaterialStateProperty.resolveWith((Set<MaterialState> states) {
@ -280,7 +279,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('ActionChip uses provided state color properties', (WidgetTester tester) async { testWidgets('ActionChip uses provided state color properties', (WidgetTester tester) async {
const Color disabledColor = Color(0xff00ff00); const Color disabledColor = Color(0xff00ff00);
const Color backgroundColor = Color(0xff0000ff); const Color backgroundColor = Color(0xff0000ff);
Widget buildApp({ required bool enabled, required bool selected }) { Widget buildApp({ required bool enabled, required bool selected }) {
@ -335,7 +334,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('ActionChip can be tapped', (WidgetTester tester) async { testWidgets('ActionChip can be tapped', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Material( home: Material(
@ -351,7 +350,7 @@ void main() {
expect(tester.takeException(), null); expect(tester.takeException(), null);
}); });
testWidgetsWithLeakTracking('ActionChip clipBehavior properly passes through to the Material', (WidgetTester tester) async { testWidgets('ActionChip clipBehavior properly passes through to the Material', (WidgetTester tester) async {
const Text label = Text('label'); const Text label = Text('label');
await tester.pumpWidget(wrapForChip(child: ActionChip(label: label, onPressed: () { }))); await tester.pumpWidget(wrapForChip(child: ActionChip(label: label, onPressed: () { })));
checkChipMaterialClipBehavior(tester, Clip.none); checkChipMaterialClipBehavior(tester, Clip.none);
@ -360,7 +359,7 @@ void main() {
checkChipMaterialClipBehavior(tester, Clip.antiAlias); checkChipMaterialClipBehavior(tester, Clip.antiAlias);
}); });
testWidgetsWithLeakTracking('ActionChip uses provided iconTheme', (WidgetTester tester) async { testWidgets('ActionChip uses provided iconTheme', (WidgetTester tester) async {
Widget buildChip({ IconThemeData? iconTheme }) { Widget buildChip({ IconThemeData? iconTheme }) {
return MaterialApp( return MaterialApp(
home: Material( home: Material(

View File

@ -5,7 +5,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
test('ActionIconThemeData copyWith, ==, hashCode basics', () { test('ActionIconThemeData copyWith, ==, hashCode basics', () {
@ -14,7 +13,7 @@ void main() {
const ActionIconThemeData().copyWith().hashCode); const ActionIconThemeData().copyWith().hashCode);
}); });
testWidgetsWithLeakTracking('ActionIconThemeData copyWith overrides all properties', (WidgetTester tester) async { testWidgets('ActionIconThemeData copyWith overrides all properties', (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/126762. // This is a regression test for https://github.com/flutter/flutter/issues/126762.
Widget originalButtonBuilder(BuildContext context) { Widget originalButtonBuilder(BuildContext context) {
return const SizedBox(); return const SizedBox();
@ -58,7 +57,7 @@ void main() {
expect(themeData.endDrawerButtonIconBuilder, null); expect(themeData.endDrawerButtonIconBuilder, null);
}); });
testWidgetsWithLeakTracking('Default ActionIconThemeData debugFillProperties', testWidgets('Default ActionIconThemeData debugFillProperties',
(WidgetTester tester) async { (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ActionIconThemeData().debugFillProperties(builder); const ActionIconThemeData().debugFillProperties(builder);
@ -71,7 +70,7 @@ void main() {
expect(description, <String>[]); expect(description, <String>[]);
}); });
testWidgetsWithLeakTracking('ActionIconThemeData implements debugFillProperties', testWidgets('ActionIconThemeData implements debugFillProperties',
(WidgetTester tester) async { (WidgetTester tester) async {
Widget actionButtonIconBuilder(BuildContext context) { Widget actionButtonIconBuilder(BuildContext context) {
return const Icon(IconData(0)); return const Icon(IconData(0));
@ -99,7 +98,7 @@ void main() {
]); ]);
}); });
testWidgetsWithLeakTracking('Action buttons use ThemeData action icon theme', (WidgetTester tester) async { testWidgets('Action buttons use ThemeData action icon theme', (WidgetTester tester) async {
const Color green = Color(0xff00ff00); const Color green = Color(0xff00ff00);
const IconData icon = IconData(0); const IconData icon = IconData(0);
@ -160,7 +159,7 @@ void main() {
// This test is essentially the same as 'Action buttons use ThemeData action icon theme'. In // This test is essentially the same as 'Action buttons use ThemeData action icon theme'. In
// this case the theme is introduced with the ActionIconTheme widget instead of // this case the theme is introduced with the ActionIconTheme widget instead of
// ThemeData.actionIconTheme. // ThemeData.actionIconTheme.
testWidgetsWithLeakTracking('Action buttons use ActionIconTheme', (WidgetTester tester) async { testWidgets('Action buttons use ActionIconTheme', (WidgetTester tester) async {
const Color green = Color(0xff00ff00); const Color green = Color(0xff00ff00);
const IconData icon = IconData(0); const IconData icon = IconData(0);

View File

@ -7,7 +7,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/clipboard_utils.dart'; import '../widgets/clipboard_utils.dart';
import '../widgets/editable_text_utils.dart'; import '../widgets/editable_text_utils.dart';
import '../widgets/live_text_utils.dart'; import '../widgets/live_text_utils.dart';
@ -27,7 +26,7 @@ void main() {
await Clipboard.setData(const ClipboardData(text: 'Clipboard data')); await Clipboard.setData(const ClipboardData(text: 'Clipboard data'));
}); });
testWidgetsWithLeakTracking('Builds the right toolbar on each platform, including web, and shows buttonItems', (WidgetTester tester) async { testWidgets('Builds the right toolbar on each platform, including web, and shows buttonItems', (WidgetTester tester) async {
const String buttonText = 'Click me'; const String buttonText = 'Click me';
await tester.pumpWidget( await tester.pumpWidget(
@ -82,7 +81,7 @@ void main() {
skip: isBrowser, // [intended] see https://github.com/flutter/flutter/issues/108382 skip: isBrowser, // [intended] see https://github.com/flutter/flutter/issues/108382
); );
testWidgetsWithLeakTracking('Can build children directly as well', (WidgetTester tester) async { testWidgets('Can build children directly as well', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
@ -105,7 +104,7 @@ void main() {
expect(find.byKey(key), findsOneWidget); expect(find.byKey(key), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Can build from EditableTextState', (WidgetTester tester) async { testWidgets('Can build from EditableTextState', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
final TextEditingController controller = TextEditingController(); final TextEditingController controller = TextEditingController();
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
@ -173,7 +172,7 @@ void main() {
variant: TargetPlatformVariant.all(), variant: TargetPlatformVariant.all(),
); );
testWidgetsWithLeakTracking('Can build for editable text from raw parameters', (WidgetTester tester) async { testWidgets('Can build for editable text from raw parameters', (WidgetTester tester) async {
final GlobalKey key = GlobalKey(); final GlobalKey key = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -275,7 +274,7 @@ void main() {
); );
group('buttonItems', () { group('buttonItems', () {
testWidgetsWithLeakTracking('getEditableTextButtonItems builds the correct button items per-platform', (WidgetTester tester) async { testWidgets('getEditableTextButtonItems builds the correct button items per-platform', (WidgetTester tester) async {
// Fill the clipboard so that the Paste option is available in the text // Fill the clipboard so that the Paste option is available in the text
// selection menu. // selection menu.
await Clipboard.setData(const ClipboardData(text: 'Clipboard data')); await Clipboard.setData(const ClipboardData(text: 'Clipboard data'));
@ -374,7 +373,7 @@ void main() {
skip: kIsWeb, // [intended] skip: kIsWeb, // [intended]
); );
testWidgetsWithLeakTracking('getAdaptiveButtons builds the correct button widgets per-platform', (WidgetTester tester) async { testWidgets('getAdaptiveButtons builds the correct button widgets per-platform', (WidgetTester tester) async {
const String buttonText = 'Click me'; const String buttonText = 'Click me';
await tester.pumpWidget( await tester.pumpWidget(

View File

@ -9,7 +9,6 @@ import 'dart:math' as math show pi;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
class MockCanvas extends Fake implements Canvas { class MockCanvas extends Fake implements Canvas {
@ -95,7 +94,7 @@ class RecordedScale extends RecordedCanvasCall {
} }
void main() { void main() {
testWidgetsWithLeakTracking('IconTheme color', (WidgetTester tester) async { testWidgets('IconTheme color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -116,7 +115,7 @@ void main() {
expect(canvas.capturedPaint, hasColor(0xFF666666)); expect(canvas.capturedPaint, hasColor(0xFF666666));
}); });
testWidgetsWithLeakTracking('IconTheme opacity', (WidgetTester tester) async { testWidgets('IconTheme opacity', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -138,7 +137,7 @@ void main() {
expect(canvas.capturedPaint, hasColor(0x80666666)); expect(canvas.capturedPaint, hasColor(0x80666666));
}); });
testWidgetsWithLeakTracking('color overrides IconTheme color', (WidgetTester tester) async { testWidgets('color overrides IconTheme color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -160,7 +159,7 @@ void main() {
expect(canvas.capturedPaint, hasColor(0xFF0000FF)); expect(canvas.capturedPaint, hasColor(0xFF0000FF));
}); });
testWidgetsWithLeakTracking('IconTheme size', (WidgetTester tester) async { testWidgets('IconTheme size', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -184,7 +183,7 @@ void main() {
expect(canvas.capturedSy, 0.25); expect(canvas.capturedSy, 0.25);
}); });
testWidgetsWithLeakTracking('size overridesIconTheme size', (WidgetTester tester) async { testWidgets('size overridesIconTheme size', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -209,7 +208,7 @@ void main() {
expect(canvas.capturedSy, 2); expect(canvas.capturedSy, 2);
}); });
testWidgetsWithLeakTracking('Semantic label', (WidgetTester tester) async { testWidgets('Semantic label', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget( await tester.pumpWidget(
@ -229,7 +228,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Inherited text direction rtl', (WidgetTester tester) async { testWidgets('Inherited text direction rtl', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.rtl, textDirection: TextDirection.rtl,
@ -258,7 +257,7 @@ void main() {
matchesGoldenFile('animated_icons_test.icon.rtl.png')); matchesGoldenFile('animated_icons_test.icon.rtl.png'));
}); });
testWidgetsWithLeakTracking('Inherited text direction ltr', (WidgetTester tester) async { testWidgets('Inherited text direction ltr', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -285,7 +284,7 @@ void main() {
matchesGoldenFile('animated_icons_test.icon.ltr.png')); matchesGoldenFile('animated_icons_test.icon.ltr.png'));
}); });
testWidgetsWithLeakTracking('Inherited text direction overridden', (WidgetTester tester) async { testWidgets('Inherited text direction overridden', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -311,7 +310,7 @@ void main() {
]); ]);
}); });
testWidgetsWithLeakTracking('Direction has no effect on position of widget', (WidgetTester tester) async { testWidgets('Direction has no effect on position of widget', (WidgetTester tester) async {
const AnimatedIcon icon = AnimatedIcon( const AnimatedIcon icon = AnimatedIcon(
progress: AlwaysStoppedAnimation<double>(0.0), progress: AlwaysStoppedAnimation<double>(0.0),
icon: AnimatedIcons.arrow_menu, icon: AnimatedIcons.arrow_menu,

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
const AppBarTheme appBarTheme = AppBarTheme( const AppBarTheme appBarTheme = AppBarTheme(
@ -43,7 +42,7 @@ void main() {
expect(identical(AppBarTheme.lerp(data, data, 0.5), data), true); expect(identical(AppBarTheme.lerp(data, data, 0.5), data), true);
}); });
testWidgetsWithLeakTracking('Material2 - Passing no AppBarTheme returns defaults', (WidgetTester tester) async { testWidgets('Material2 - Passing no AppBarTheme returns defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: false); final ThemeData theme = ThemeData(useMaterial3: false);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -78,7 +77,7 @@ void main() {
expect(tester.getSize(find.byType(AppBar)).width, 800); expect(tester.getSize(find.byType(AppBar)).width, 800);
}); });
testWidgetsWithLeakTracking('Material3 - Passing no AppBarTheme returns defaults', (WidgetTester tester) async { testWidgets('Material3 - Passing no AppBarTheme returns defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -118,7 +117,7 @@ void main() {
expect(tester.getSize(find.byType(AppBar)).width, 800); expect(tester.getSize(find.byType(AppBar)).width, 800);
}); });
testWidgetsWithLeakTracking('AppBar uses values from AppBarTheme', (WidgetTester tester) async { testWidgets('AppBar uses values from AppBarTheme', (WidgetTester tester) async {
final AppBarTheme appBarTheme = _appBarTheme(); final AppBarTheme appBarTheme = _appBarTheme();
await tester.pumpWidget( await tester.pumpWidget(
@ -155,7 +154,7 @@ void main() {
expect(tester.getSize(find.byType(AppBar)).width, 800); expect(tester.getSize(find.byType(AppBar)).width, 800);
}); });
testWidgetsWithLeakTracking('AppBar widget properties take priority over theme', (WidgetTester tester) async { testWidgets('AppBar widget properties take priority over theme', (WidgetTester tester) async {
const Brightness brightness = Brightness.dark; const Brightness brightness = Brightness.dark;
const SystemUiOverlayStyle systemOverlayStyle = SystemUiOverlayStyle.light; const SystemUiOverlayStyle systemOverlayStyle = SystemUiOverlayStyle.light;
const Color color = Colors.orange; const Color color = Colors.orange;
@ -211,7 +210,7 @@ void main() {
expect(text.style, toolbarTextStyle); expect(text.style, toolbarTextStyle);
}); });
testWidgetsWithLeakTracking('AppBar icon color takes priority over everything', (WidgetTester tester) async { testWidgets('AppBar icon color takes priority over everything', (WidgetTester tester) async {
const Color color = Colors.lime; const Color color = Colors.lime;
const IconThemeData iconThemeData = IconThemeData(color: Colors.green); const IconThemeData iconThemeData = IconThemeData(color: Colors.green);
const IconThemeData actionsIconThemeData = IconThemeData(color: Colors.lightBlue); const IconThemeData actionsIconThemeData = IconThemeData(color: Colors.lightBlue);
@ -231,7 +230,7 @@ void main() {
expect(actionIconText.text.style!.color, color); expect(actionIconText.text.style!.color, color);
}); });
testWidgetsWithLeakTracking('AppBarTheme properties take priority over ThemeData properties', (WidgetTester tester) async { testWidgets('AppBarTheme properties take priority over ThemeData properties', (WidgetTester tester) async {
final AppBarTheme appBarTheme = _appBarTheme(); final AppBarTheme appBarTheme = _appBarTheme();
await tester.pumpWidget( await tester.pumpWidget(
@ -265,7 +264,7 @@ void main() {
expect(text.style, appBarTheme.toolbarTextStyle); expect(text.style, appBarTheme.toolbarTextStyle);
}); });
testWidgetsWithLeakTracking('Material2 - ThemeData colorScheme is used when no AppBarTheme is set', (WidgetTester tester) async { testWidgets('Material2 - ThemeData colorScheme is used when no AppBarTheme is set', (WidgetTester tester) async {
final ThemeData lightTheme = ThemeData.from(colorScheme: const ColorScheme.light(), useMaterial3: false); final ThemeData lightTheme = ThemeData.from(colorScheme: const ColorScheme.light(), useMaterial3: false);
final ThemeData darkTheme = ThemeData.from(colorScheme: const ColorScheme.dark(), useMaterial3: false); final ThemeData darkTheme = ThemeData.from(colorScheme: const ColorScheme.dark(), useMaterial3: false);
Widget buildFrame(ThemeData appTheme) { Widget buildFrame(ThemeData appTheme) {
@ -339,7 +338,7 @@ void main() {
expect(text.style, Typography.material2014().englishLike.bodyMedium!.merge(Typography.material2014().black.bodyMedium).copyWith(color: darkTheme.colorScheme.onSurface)); expect(text.style, Typography.material2014().englishLike.bodyMedium!.merge(Typography.material2014().black.bodyMedium).copyWith(color: darkTheme.colorScheme.onSurface));
}); });
testWidgetsWithLeakTracking('Material3 - ThemeData colorScheme is used when no AppBarTheme is set', (WidgetTester tester) async { testWidgets('Material3 - ThemeData colorScheme is used when no AppBarTheme is set', (WidgetTester tester) async {
final ThemeData lightTheme = ThemeData.from(colorScheme: const ColorScheme.light(), useMaterial3: true); final ThemeData lightTheme = ThemeData.from(colorScheme: const ColorScheme.light(), useMaterial3: true);
final ThemeData darkTheme = ThemeData.from(colorScheme: const ColorScheme.dark(), useMaterial3: true); final ThemeData darkTheme = ThemeData.from(colorScheme: const ColorScheme.dark(), useMaterial3: true);
Widget buildFrame(ThemeData appTheme) { Widget buildFrame(ThemeData appTheme) {
@ -413,7 +412,7 @@ void main() {
expect(text.style, Typography.material2021().englishLike.bodyMedium!.merge(Typography.material2021().black.bodyMedium).copyWith(color: darkTheme.colorScheme.onSurface, decorationColor: darkTheme.colorScheme.onSurface)); expect(text.style, Typography.material2021().englishLike.bodyMedium!.merge(Typography.material2021().black.bodyMedium).copyWith(color: darkTheme.colorScheme.onSurface, decorationColor: darkTheme.colorScheme.onSurface));
}); });
testWidgetsWithLeakTracking('AppBar iconTheme with color=null defers to outer IconTheme', (WidgetTester tester) async { testWidgets('AppBar iconTheme with color=null defers to outer IconTheme', (WidgetTester tester) async {
// Verify claim made in https://github.com/flutter/flutter/pull/71184#issuecomment-737419215 // Verify claim made in https://github.com/flutter/flutter/pull/71184#issuecomment-737419215
Widget buildFrame({ Color? appIconColor, Color? appBarIconColor }) { Widget buildFrame({ Color? appIconColor, Color? appBarIconColor }) {
@ -453,7 +452,7 @@ void main() {
expect(getIconText().text.style!.color, Colors.purple); expect(getIconText().text.style!.color, Colors.purple);
}); });
testWidgetsWithLeakTracking('AppBar uses AppBarTheme.centerTitle when centerTitle is null', (WidgetTester tester) async { testWidgets('AppBar uses AppBarTheme.centerTitle when centerTitle is null', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(appBarTheme: const AppBarTheme(centerTitle: true)), theme: ThemeData(appBarTheme: const AppBarTheme(centerTitle: true)),
home: Scaffold(appBar: AppBar( home: Scaffold(appBar: AppBar(
@ -465,7 +464,7 @@ void main() {
expect(navToolBar.centerMiddle, true); expect(navToolBar.centerMiddle, true);
}); });
testWidgetsWithLeakTracking('AppBar.centerTitle takes priority over AppBarTheme.centerTitle', (WidgetTester tester) async { testWidgets('AppBar.centerTitle takes priority over AppBarTheme.centerTitle', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(appBarTheme: const AppBarTheme(centerTitle: true)), theme: ThemeData(appBarTheme: const AppBarTheme(centerTitle: true)),
home: Scaffold( home: Scaffold(
@ -481,7 +480,7 @@ void main() {
expect(navToolBar.centerMiddle, false); expect(navToolBar.centerMiddle, false);
}); });
testWidgetsWithLeakTracking('AppBar.centerTitle adapts to TargetPlatform when AppBarTheme.centerTitle is null', (WidgetTester tester) async{ testWidgets('AppBar.centerTitle adapts to TargetPlatform when AppBarTheme.centerTitle is null', (WidgetTester tester) async{
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(platform: TargetPlatform.iOS), theme: ThemeData(platform: TargetPlatform.iOS),
home: Scaffold(appBar: AppBar( home: Scaffold(appBar: AppBar(
@ -495,7 +494,7 @@ void main() {
expect(navToolBar.centerMiddle, true); expect(navToolBar.centerMiddle, true);
}); });
testWidgetsWithLeakTracking('AppBar.shadowColor takes priority over AppBarTheme.shadowColor', (WidgetTester tester) async { testWidgets('AppBar.shadowColor takes priority over AppBarTheme.shadowColor', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(appBarTheme: const AppBarTheme(shadowColor: Colors.red)), theme: ThemeData(appBarTheme: const AppBarTheme(shadowColor: Colors.red)),
home: Scaffold( home: Scaffold(
@ -511,7 +510,7 @@ void main() {
expect(appBar.shadowColor, Colors.yellow); expect(appBar.shadowColor, Colors.yellow);
}); });
testWidgetsWithLeakTracking('AppBar.surfaceTintColor takes priority over AppBarTheme.surfaceTintColor', (WidgetTester tester) async { testWidgets('AppBar.surfaceTintColor takes priority over AppBarTheme.surfaceTintColor', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(appBarTheme: const AppBarTheme(surfaceTintColor: Colors.red)), theme: ThemeData(appBarTheme: const AppBarTheme(surfaceTintColor: Colors.red)),
home: Scaffold( home: Scaffold(
@ -527,7 +526,7 @@ void main() {
expect(appBar.surfaceTintColor, Colors.yellow); expect(appBar.surfaceTintColor, Colors.yellow);
}); });
testWidgetsWithLeakTracking('Material3 - AppBarTheme.iconTheme.color takes priority over IconButtonTheme.foregroundColor', (WidgetTester tester) async { testWidgets('Material3 - AppBarTheme.iconTheme.color takes priority over IconButtonTheme.foregroundColor', (WidgetTester tester) async {
const IconThemeData overallIconTheme = IconThemeData(color: Colors.yellow); const IconThemeData overallIconTheme = IconThemeData(color: Colors.yellow);
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData( theme: ThemeData(
@ -553,7 +552,7 @@ void main() {
expect(actionIconButtonColor, overallIconTheme.color); expect(actionIconButtonColor, overallIconTheme.color);
}); });
testWidgetsWithLeakTracking('Material3 - AppBarTheme.iconTheme.size takes priority over IconButtonTheme.iconSize', (WidgetTester tester) async { testWidgets('Material3 - AppBarTheme.iconTheme.size takes priority over IconButtonTheme.iconSize', (WidgetTester tester) async {
const IconThemeData overallIconTheme = IconThemeData(size: 30.0); const IconThemeData overallIconTheme = IconThemeData(size: 30.0);
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData( theme: ThemeData(
@ -580,7 +579,7 @@ void main() {
}); });
testWidgetsWithLeakTracking('Material3 - AppBarTheme.actionsIconTheme.color takes priority over IconButtonTheme.foregroundColor', (WidgetTester tester) async { testWidgets('Material3 - AppBarTheme.actionsIconTheme.color takes priority over IconButtonTheme.foregroundColor', (WidgetTester tester) async {
const IconThemeData actionsIconTheme = IconThemeData(color: Colors.yellow); const IconThemeData actionsIconTheme = IconThemeData(color: Colors.yellow);
final IconButtonThemeData iconButtonTheme = IconButtonThemeData( final IconButtonThemeData iconButtonTheme = IconButtonThemeData(
style: IconButton.styleFrom(foregroundColor: Colors.red), style: IconButton.styleFrom(foregroundColor: Colors.red),
@ -608,7 +607,7 @@ void main() {
expect(actionIconButtonColor, actionsIconTheme.color); expect(actionIconButtonColor, actionsIconTheme.color);
}); });
testWidgetsWithLeakTracking('Material3 - AppBarTheme.actionsIconTheme.size takes priority over IconButtonTheme.iconSize', (WidgetTester tester) async { testWidgets('Material3 - AppBarTheme.actionsIconTheme.size takes priority over IconButtonTheme.iconSize', (WidgetTester tester) async {
const IconThemeData actionsIconTheme = IconThemeData(size: 30.0); const IconThemeData actionsIconTheme = IconThemeData(size: 30.0);
final IconButtonThemeData iconButtonTheme = IconButtonThemeData( final IconButtonThemeData iconButtonTheme = IconButtonThemeData(
style: IconButton.styleFrom(iconSize: 32.0), style: IconButton.styleFrom(iconSize: 32.0),
@ -635,7 +634,7 @@ void main() {
expect(actionIconButtonSize, actionsIconTheme.size); expect(actionIconButtonSize, actionsIconTheme.size);
}); });
testWidgetsWithLeakTracking('Material3 - AppBarTheme.foregroundColor takes priority over IconButtonTheme.foregroundColor', (WidgetTester tester) async { testWidgets('Material3 - AppBarTheme.foregroundColor takes priority over IconButtonTheme.foregroundColor', (WidgetTester tester) async {
final IconButtonThemeData iconButtonTheme = IconButtonThemeData( final IconButtonThemeData iconButtonTheme = IconButtonThemeData(
style: IconButton.styleFrom(foregroundColor: Colors.red), style: IconButton.styleFrom(foregroundColor: Colors.red),
); );
@ -670,7 +669,7 @@ void main() {
expect(actionIconButtonColor, appBarTheme.foregroundColor); expect(actionIconButtonColor, appBarTheme.foregroundColor);
}); });
testWidgetsWithLeakTracking('AppBar uses AppBarTheme.titleSpacing', (WidgetTester tester) async { testWidgets('AppBar uses AppBarTheme.titleSpacing', (WidgetTester tester) async {
const double kTitleSpacing = 10; const double kTitleSpacing = 10;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(appBarTheme: const AppBarTheme(titleSpacing: kTitleSpacing)), theme: ThemeData(appBarTheme: const AppBarTheme(titleSpacing: kTitleSpacing)),
@ -685,7 +684,7 @@ void main() {
expect(navToolBar.middleSpacing, kTitleSpacing); expect(navToolBar.middleSpacing, kTitleSpacing);
}); });
testWidgetsWithLeakTracking('AppBar.titleSpacing takes priority over AppBarTheme.titleSpacing', (WidgetTester tester) async { testWidgets('AppBar.titleSpacing takes priority over AppBarTheme.titleSpacing', (WidgetTester tester) async {
const double kTitleSpacing = 10; const double kTitleSpacing = 10;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(appBarTheme: const AppBarTheme(titleSpacing: kTitleSpacing)), theme: ThemeData(appBarTheme: const AppBarTheme(titleSpacing: kTitleSpacing)),
@ -701,7 +700,7 @@ void main() {
expect(navToolBar.middleSpacing, 40); expect(navToolBar.middleSpacing, 40);
}); });
testWidgetsWithLeakTracking('SliverAppBar uses AppBarTheme.titleSpacing', (WidgetTester tester) async { testWidgets('SliverAppBar uses AppBarTheme.titleSpacing', (WidgetTester tester) async {
const double kTitleSpacing = 10; const double kTitleSpacing = 10;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(appBarTheme: const AppBarTheme(titleSpacing: kTitleSpacing)), theme: ThemeData(appBarTheme: const AppBarTheme(titleSpacing: kTitleSpacing)),
@ -718,7 +717,7 @@ void main() {
expect(navToolBar.middleSpacing, kTitleSpacing); expect(navToolBar.middleSpacing, kTitleSpacing);
}); });
testWidgetsWithLeakTracking('SliverAppBar.titleSpacing takes priority over AppBarTheme.titleSpacing ', (WidgetTester tester) async { testWidgets('SliverAppBar.titleSpacing takes priority over AppBarTheme.titleSpacing ', (WidgetTester tester) async {
const double kTitleSpacing = 10; const double kTitleSpacing = 10;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(appBarTheme: const AppBarTheme(titleSpacing: kTitleSpacing)), theme: ThemeData(appBarTheme: const AppBarTheme(titleSpacing: kTitleSpacing)),
@ -736,7 +735,7 @@ void main() {
expect(navToolbar.middleSpacing, 40); expect(navToolbar.middleSpacing, 40);
}); });
testWidgetsWithLeakTracking('SliverAppBar.medium uses AppBarTheme properties', (WidgetTester tester) async { testWidgets('SliverAppBar.medium uses AppBarTheme properties', (WidgetTester tester) async {
const String title = 'Medium App Bar'; const String title = 'Medium App Bar';
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -792,7 +791,7 @@ void main() {
expect(titleOffset.dx, iconOffset.dx + appBarTheme.titleSpacing!); expect(titleOffset.dx, iconOffset.dx + appBarTheme.titleSpacing!);
}); });
testWidgetsWithLeakTracking('SliverAppBar.medium properties take priority over AppBarTheme properties', (WidgetTester tester) async { testWidgets('SliverAppBar.medium properties take priority over AppBarTheme properties', (WidgetTester tester) async {
const String title = 'Medium App Bar'; const String title = 'Medium App Bar';
const Color backgroundColor = Color(0xff000099); const Color backgroundColor = Color(0xff000099);
const Color foregroundColor = Color(0xff00ff98); const Color foregroundColor = Color(0xff00ff98);
@ -869,7 +868,7 @@ void main() {
expect(titleOffset.dx, iconOffset.dx + titleSpacing); expect(titleOffset.dx, iconOffset.dx + titleSpacing);
}); });
testWidgetsWithLeakTracking('SliverAppBar.large uses AppBarTheme properties', (WidgetTester tester) async { testWidgets('SliverAppBar.large uses AppBarTheme properties', (WidgetTester tester) async {
const String title = 'Large App Bar'; const String title = 'Large App Bar';
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -925,7 +924,7 @@ void main() {
expect(titleOffset.dx, iconOffset.dx + appBarTheme.titleSpacing!); expect(titleOffset.dx, iconOffset.dx + appBarTheme.titleSpacing!);
}); });
testWidgetsWithLeakTracking('SliverAppBar.large properties take priority over AppBarTheme properties', (WidgetTester tester) async { testWidgets('SliverAppBar.large properties take priority over AppBarTheme properties', (WidgetTester tester) async {
const String title = 'Large App Bar'; const String title = 'Large App Bar';
const Color backgroundColor = Color(0xff000099); const Color backgroundColor = Color(0xff000099);
const Color foregroundColor = Color(0xff00ff98); const Color foregroundColor = Color(0xff00ff98);
@ -1002,7 +1001,7 @@ void main() {
expect(titleOffset.dx, iconOffset.dx + titleSpacing); expect(titleOffset.dx, iconOffset.dx + titleSpacing);
}); });
testWidgetsWithLeakTracking( testWidgets(
'SliverAppBar medium & large supports foregroundColor', (WidgetTester tester) async { 'SliverAppBar medium & large supports foregroundColor', (WidgetTester tester) async {
const String title = 'AppBar title'; const String title = 'AppBar title';
const AppBarTheme appBarTheme = AppBarTheme(foregroundColor: Color(0xff00ff20)); const AppBarTheme appBarTheme = AppBarTheme(foregroundColor: Color(0xff00ff20));
@ -1046,7 +1045,7 @@ void main() {
expect(largeTitle.text.style!.color, foregroundColor); expect(largeTitle.text.style!.color, foregroundColor);
}); });
testWidgetsWithLeakTracking('Default AppBarTheme debugFillProperties', (WidgetTester tester) async { testWidgets('Default AppBarTheme debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const AppBarTheme().debugFillProperties(builder); const AppBarTheme().debugFillProperties(builder);
@ -1058,7 +1057,7 @@ void main() {
expect(description, <String>[]); expect(description, <String>[]);
}); });
testWidgetsWithLeakTracking('AppBarTheme implements debugFillProperties', (WidgetTester tester) async { testWidgets('AppBarTheme implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const AppBarTheme( const AppBarTheme(
backgroundColor: Color(0xff000000), backgroundColor: Color(0xff000000),
@ -1113,7 +1112,7 @@ void main() {
}, skip: kIsWeb); // https://github.com/flutter/flutter/issues/87364 }, skip: kIsWeb); // https://github.com/flutter/flutter/issues/87364
// This is a regression test for https://github.com/flutter/flutter/issues/130485. // This is a regression test for https://github.com/flutter/flutter/issues/130485.
testWidgetsWithLeakTracking('Material3 - AppBarTheme.iconTheme correctly applies custom white color in dark mode', (WidgetTester tester) async { testWidgets('Material3 - AppBarTheme.iconTheme correctly applies custom white color in dark mode', (WidgetTester tester) async {
final ThemeData themeData = ThemeData( final ThemeData themeData = ThemeData(
useMaterial3: true, useMaterial3: true,
brightness: Brightness.dark, brightness: Brightness.dark,

View File

@ -4,10 +4,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking("builder doesn't get called if app doesn't change", (WidgetTester tester) async { testWidgets("builder doesn't get called if app doesn't change", (WidgetTester tester) async {
final List<String> log = <String>[]; final List<String> log = <String>[];
final Widget app = MaterialApp( final Widget app = MaterialApp(
home: const Placeholder(), home: const Placeholder(),
@ -34,7 +33,7 @@ void main() {
expect(log, <String>['build']); expect(log, <String>['build']);
}); });
testWidgetsWithLeakTracking("builder doesn't get called if app doesn't change", (WidgetTester tester) async { testWidgets("builder doesn't get called if app doesn't change", (WidgetTester tester) async {
final List<String> log = <String>[]; final List<String> log = <String>[];
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(

View File

@ -8,7 +8,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class StateMarker extends StatefulWidget { class StateMarker extends StatefulWidget {
const StateMarker({ super.key, this.child }); const StateMarker({ super.key, this.child });
@ -32,7 +31,7 @@ class StateMarkerState extends State<StateMarker> {
} }
void main() { void main() {
testWidgetsWithLeakTracking('Can nest apps', (WidgetTester tester) async { testWidgets('Can nest apps', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: MaterialApp( home: MaterialApp(
@ -44,7 +43,7 @@ void main() {
expect(find.text('Home sweet home'), findsOneWidget); expect(find.text('Home sweet home'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Focus handling', (WidgetTester tester) async { testWidgets('Focus handling', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Material( home: Material(
@ -57,7 +56,7 @@ void main() {
expect(focusNode.hasFocus, isTrue); expect(focusNode.hasFocus, isTrue);
}); });
testWidgetsWithLeakTracking('Can place app inside FocusScope', (WidgetTester tester) async { testWidgets('Can place app inside FocusScope', (WidgetTester tester) async {
final FocusScopeNode focusScopeNode = FocusScopeNode(); final FocusScopeNode focusScopeNode = FocusScopeNode();
await tester.pumpWidget(FocusScope( await tester.pumpWidget(FocusScope(
@ -72,7 +71,7 @@ void main() {
focusScopeNode.dispose(); focusScopeNode.dispose();
}); });
testWidgetsWithLeakTracking('Can show grid without losing sync', (WidgetTester tester) async { testWidgets('Can show grid without losing sync', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: StateMarker(), home: StateMarker(),
@ -94,7 +93,7 @@ void main() {
expect(state2.marker, equals('original')); expect(state2.marker, equals('original'));
}); });
testWidgetsWithLeakTracking('Do not rebuild page during a route transition', (WidgetTester tester) async { testWidgets('Do not rebuild page during a route transition', (WidgetTester tester) async {
int buildCounter = 0; int buildCounter = 0;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -139,7 +138,7 @@ void main() {
expect(find.text('Y'), findsOneWidget); expect(find.text('Y'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Do rebuild the home page if it changes', (WidgetTester tester) async { testWidgets('Do rebuild the home page if it changes', (WidgetTester tester) async {
int buildCounter = 0; int buildCounter = 0;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -167,7 +166,7 @@ void main() {
expect(find.text('B'), findsOneWidget); expect(find.text('B'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Do not rebuild the home page if it does not actually change', (WidgetTester tester) async { testWidgets('Do not rebuild the home page if it does not actually change', (WidgetTester tester) async {
int buildCounter = 0; int buildCounter = 0;
final Widget home = Builder( final Widget home = Builder(
builder: (BuildContext context) { builder: (BuildContext context) {
@ -189,7 +188,7 @@ void main() {
expect(buildCounter, 1); expect(buildCounter, 1);
}); });
testWidgetsWithLeakTracking('Do rebuild pages that come from the routes table if the MaterialApp changes', (WidgetTester tester) async { testWidgets('Do rebuild pages that come from the routes table if the MaterialApp changes', (WidgetTester tester) async {
int buildCounter = 0; int buildCounter = 0;
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) { '/': (BuildContext context) {
@ -211,7 +210,7 @@ void main() {
expect(buildCounter, 2); expect(buildCounter, 2);
}); });
testWidgetsWithLeakTracking('Cannot pop the initial route', (WidgetTester tester) async { testWidgets('Cannot pop the initial route', (WidgetTester tester) async {
await tester.pumpWidget(const MaterialApp(home: Text('Home'))); await tester.pumpWidget(const MaterialApp(home: Text('Home')));
expect(find.text('Home'), findsOneWidget); expect(find.text('Home'), findsOneWidget);
@ -224,7 +223,7 @@ void main() {
expect(find.text('Home'), findsOneWidget); expect(find.text('Home'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Default initialRoute', (WidgetTester tester) async { testWidgets('Default initialRoute', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(routes: <String, WidgetBuilder>{ await tester.pumpWidget(MaterialApp(routes: <String, WidgetBuilder>{
'/': (BuildContext context) => const Text('route "/"'), '/': (BuildContext context) => const Text('route "/"'),
})); }));
@ -232,7 +231,7 @@ void main() {
expect(find.text('route "/"'), findsOneWidget); expect(find.text('route "/"'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('One-step initial route', (WidgetTester tester) async { testWidgets('One-step initial route', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
initialRoute: '/a', initialRoute: '/a',
@ -251,7 +250,7 @@ void main() {
expect(find.text('route "/b"', skipOffstage: false), findsNothing); expect(find.text('route "/b"', skipOffstage: false), findsNothing);
}); });
testWidgetsWithLeakTracking('Return value from pop is correct', (WidgetTester tester) async { testWidgets('Return value from pop is correct', (WidgetTester tester) async {
late Future<Object?> result; late Future<Object?> result;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -291,7 +290,7 @@ void main() {
expect(await result, equals('all done')); expect(await result, equals('all done'));
}); });
testWidgetsWithLeakTracking('Two-step initial route', (WidgetTester tester) async { testWidgets('Two-step initial route', (WidgetTester tester) async {
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) => const Text('route "/"'), '/': (BuildContext context) => const Text('route "/"'),
'/a': (BuildContext context) => const Text('route "/a"'), '/a': (BuildContext context) => const Text('route "/a"'),
@ -311,7 +310,7 @@ void main() {
expect(find.text('route "/b"', skipOffstage: false), findsNothing); expect(find.text('route "/b"', skipOffstage: false), findsNothing);
}); });
testWidgetsWithLeakTracking('Initial route with missing step', (WidgetTester tester) async { testWidgets('Initial route with missing step', (WidgetTester tester) async {
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) => const Text('route "/"'), '/': (BuildContext context) => const Text('route "/"'),
'/a': (BuildContext context) => const Text('route "/a"'), '/a': (BuildContext context) => const Text('route "/a"'),
@ -336,7 +335,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('Make sure initialRoute is only used the first time', (WidgetTester tester) async { testWidgets('Make sure initialRoute is only used the first time', (WidgetTester tester) async {
final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{ final Map<String, WidgetBuilder> routes = <String, WidgetBuilder>{
'/': (BuildContext context) => const Text('route "/"'), '/': (BuildContext context) => const Text('route "/"'),
'/a': (BuildContext context) => const Text('route "/a"'), '/a': (BuildContext context) => const Text('route "/a"'),
@ -371,7 +370,7 @@ void main() {
expect(find.text('route "/b"', skipOffstage: false), findsNothing); expect(find.text('route "/b"', skipOffstage: false), findsNothing);
}); });
testWidgetsWithLeakTracking('onGenerateRoute / onUnknownRoute', (WidgetTester tester) async { testWidgets('onGenerateRoute / onUnknownRoute', (WidgetTester tester) async {
final List<String> log = <String>[]; final List<String> log = <String>[];
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -393,7 +392,7 @@ void main() {
expect(tester.takeException(), isAssertionError); expect(tester.takeException(), isAssertionError);
}); });
testWidgetsWithLeakTracking('MaterialApp with builder and no route information works.', (WidgetTester tester) async { testWidgets('MaterialApp with builder and no route information works.', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/18904 // Regression test for https://github.com/flutter/flutter/issues/18904
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -404,7 +403,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking("WidgetsApp doesn't rebuild routes when MediaQuery updates", (WidgetTester tester) async { testWidgets("WidgetsApp doesn't rebuild routes when MediaQuery updates", (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/37878 // Regression test for https://github.com/flutter/flutter/issues/37878
addTearDown(tester.platformDispatcher.clearAllTestValues); addTearDown(tester.platformDispatcher.clearAllTestValues);
addTearDown(tester.view.reset); addTearDown(tester.view.reset);
@ -464,7 +463,7 @@ void main() {
expect(dependentBuildCount, equals(5)); expect(dependentBuildCount, equals(5));
}); });
testWidgetsWithLeakTracking('Can get text scale from media query', (WidgetTester tester) async { testWidgets('Can get text scale from media query', (WidgetTester tester) async {
TextScaler? textScaler; TextScaler? textScaler;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Builder(builder:(BuildContext context) { home: Builder(builder:(BuildContext context) {
@ -475,7 +474,7 @@ void main() {
expect(textScaler, TextScaler.noScaling); expect(textScaler, TextScaler.noScaling);
}); });
testWidgetsWithLeakTracking('MaterialApp.navigatorKey', (WidgetTester tester) async { testWidgets('MaterialApp.navigatorKey', (WidgetTester tester) async {
final GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> key = GlobalKey<NavigatorState>();
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
navigatorKey: key, navigatorKey: key,
@ -496,7 +495,7 @@ void main() {
expect(key.currentState, isA<NavigatorState>()); expect(key.currentState, isA<NavigatorState>());
}); });
testWidgetsWithLeakTracking('Has default material and cupertino localizations', (WidgetTester tester) async { testWidgets('Has default material and cupertino localizations', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Builder( home: Builder(
@ -518,7 +517,7 @@ void main() {
expect(find.text('Select All'), findsOneWidget); expect(find.text('Select All'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('MaterialApp uses regular theme when themeMode is light', (WidgetTester tester) async { testWidgets('MaterialApp uses regular theme when themeMode is light', (WidgetTester tester) async {
addTearDown(tester.platformDispatcher.clearAllTestValues); addTearDown(tester.platformDispatcher.clearAllTestValues);
// Mock the test to explicitly report a light platformBrightness. // Mock the test to explicitly report a light platformBrightness.
@ -566,7 +565,7 @@ void main() {
expect(appliedTheme.brightness, Brightness.light); expect(appliedTheme.brightness, Brightness.light);
}); });
testWidgetsWithLeakTracking('MaterialApp uses darkTheme when themeMode is dark', (WidgetTester tester) async { testWidgets('MaterialApp uses darkTheme when themeMode is dark', (WidgetTester tester) async {
addTearDown(tester.platformDispatcher.clearAllTestValues); addTearDown(tester.platformDispatcher.clearAllTestValues);
// Mock the test to explicitly report a light platformBrightness. // Mock the test to explicitly report a light platformBrightness.
@ -614,7 +613,7 @@ void main() {
expect(appliedTheme.brightness, Brightness.dark); expect(appliedTheme.brightness, Brightness.dark);
}); });
testWidgetsWithLeakTracking('MaterialApp uses regular theme when themeMode is system and platformBrightness is light', (WidgetTester tester) async { testWidgets('MaterialApp uses regular theme when themeMode is system and platformBrightness is light', (WidgetTester tester) async {
addTearDown(tester.platformDispatcher.clearAllTestValues); addTearDown(tester.platformDispatcher.clearAllTestValues);
// Mock the test to explicitly report a light platformBrightness. // Mock the test to explicitly report a light platformBrightness.
@ -642,7 +641,7 @@ void main() {
expect(appliedTheme.brightness, Brightness.light); expect(appliedTheme.brightness, Brightness.light);
}); });
testWidgetsWithLeakTracking('MaterialApp uses darkTheme when themeMode is system and platformBrightness is dark', (WidgetTester tester) async { testWidgets('MaterialApp uses darkTheme when themeMode is system and platformBrightness is dark', (WidgetTester tester) async {
addTearDown(tester.platformDispatcher.clearAllTestValues); addTearDown(tester.platformDispatcher.clearAllTestValues);
// Mock the test to explicitly report a dark platformBrightness. // Mock the test to explicitly report a dark platformBrightness.
@ -668,7 +667,7 @@ void main() {
expect(appliedTheme.brightness, Brightness.dark); expect(appliedTheme.brightness, Brightness.dark);
}); });
testWidgetsWithLeakTracking('MaterialApp uses light theme when platformBrightness is dark but no dark theme is provided', (WidgetTester tester) async { testWidgets('MaterialApp uses light theme when platformBrightness is dark but no dark theme is provided', (WidgetTester tester) async {
addTearDown(tester.platformDispatcher.clearAllTestValues); addTearDown(tester.platformDispatcher.clearAllTestValues);
// Mock the test to explicitly report a dark platformBrightness. // Mock the test to explicitly report a dark platformBrightness.
@ -693,7 +692,7 @@ void main() {
expect(appliedTheme.brightness, Brightness.light); expect(appliedTheme.brightness, Brightness.light);
}); });
testWidgetsWithLeakTracking('MaterialApp uses fallback light theme when platformBrightness is dark but no theme is provided at all', (WidgetTester tester) async { testWidgets('MaterialApp uses fallback light theme when platformBrightness is dark but no theme is provided at all', (WidgetTester tester) async {
addTearDown(tester.platformDispatcher.clearAllTestValues); addTearDown(tester.platformDispatcher.clearAllTestValues);
// Mock the test to explicitly report a dark platformBrightness. // Mock the test to explicitly report a dark platformBrightness.
@ -715,7 +714,7 @@ void main() {
expect(appliedTheme.brightness, Brightness.light); expect(appliedTheme.brightness, Brightness.light);
}); });
testWidgetsWithLeakTracking('MaterialApp uses fallback light theme when platformBrightness is light and a dark theme is provided', (WidgetTester tester) async { testWidgets('MaterialApp uses fallback light theme when platformBrightness is light and a dark theme is provided', (WidgetTester tester) async {
addTearDown(tester.platformDispatcher.clearAllTestValues); addTearDown(tester.platformDispatcher.clearAllTestValues);
// Mock the test to explicitly report a dark platformBrightness. // Mock the test to explicitly report a dark platformBrightness.
@ -740,7 +739,7 @@ void main() {
expect(appliedTheme.brightness, Brightness.light); expect(appliedTheme.brightness, Brightness.light);
}); });
testWidgetsWithLeakTracking('MaterialApp uses dark theme when platformBrightness is dark', (WidgetTester tester) async { testWidgets('MaterialApp uses dark theme when platformBrightness is dark', (WidgetTester tester) async {
addTearDown(tester.platformDispatcher.clearAllTestValues); addTearDown(tester.platformDispatcher.clearAllTestValues);
// Mock the test to explicitly report a dark platformBrightness. // Mock the test to explicitly report a dark platformBrightness.
@ -768,7 +767,7 @@ void main() {
expect(appliedTheme.brightness, Brightness.dark); expect(appliedTheme.brightness, Brightness.dark);
}); });
testWidgetsWithLeakTracking('MaterialApp uses high contrast theme when appropriate', (WidgetTester tester) async { testWidgets('MaterialApp uses high contrast theme when appropriate', (WidgetTester tester) async {
addTearDown(tester.platformDispatcher.clearAllTestValues); addTearDown(tester.platformDispatcher.clearAllTestValues);
tester.platformDispatcher.platformBrightnessTestValue = Brightness.light; tester.platformDispatcher.platformBrightnessTestValue = Brightness.light;
@ -796,7 +795,7 @@ void main() {
expect(appliedTheme.primaryColor, Colors.blue); expect(appliedTheme.primaryColor, Colors.blue);
}); });
testWidgetsWithLeakTracking('MaterialApp uses high contrast dark theme when appropriate', (WidgetTester tester) async { testWidgets('MaterialApp uses high contrast dark theme when appropriate', (WidgetTester tester) async {
addTearDown(tester.platformDispatcher.clearAllTestValues); addTearDown(tester.platformDispatcher.clearAllTestValues);
tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark; tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark;
@ -830,7 +829,7 @@ void main() {
expect(appliedTheme.primaryColor, Colors.green); expect(appliedTheme.primaryColor, Colors.green);
}); });
testWidgetsWithLeakTracking('MaterialApp uses dark theme when no high contrast dark theme is provided', (WidgetTester tester) async { testWidgets('MaterialApp uses dark theme when no high contrast dark theme is provided', (WidgetTester tester) async {
addTearDown(tester.platformDispatcher.clearAllTestValues); addTearDown(tester.platformDispatcher.clearAllTestValues);
tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark; tester.platformDispatcher.platformBrightnessTestValue = Brightness.dark;
@ -858,7 +857,7 @@ void main() {
expect(appliedTheme.primaryColor, Colors.lightGreen); expect(appliedTheme.primaryColor, Colors.lightGreen);
}); });
testWidgetsWithLeakTracking('MaterialApp animates theme changes', (WidgetTester tester) async { testWidgets('MaterialApp animates theme changes', (WidgetTester tester) async {
final ThemeData lightTheme = ThemeData.light(); final ThemeData lightTheme = ThemeData.light();
final ThemeData darkTheme = ThemeData.dark(); final ThemeData darkTheme = ThemeData.dark();
await tester.pumpWidget( await tester.pumpWidget(
@ -898,7 +897,7 @@ void main() {
expect(tester.widget<Material>(find.byType(Material)).color, halfBGColor); expect(tester.widget<Material>(find.byType(Material)).color, halfBGColor);
}); });
testWidgetsWithLeakTracking('MaterialApp theme animation can be turned off', (WidgetTester tester) async { testWidgets('MaterialApp theme animation can be turned off', (WidgetTester tester) async {
final ThemeData lightTheme = ThemeData.light(); final ThemeData lightTheme = ThemeData.light();
final ThemeData darkTheme = ThemeData.dark(); final ThemeData darkTheme = ThemeData.dark();
int scaffoldRebuilds = 0; int scaffoldRebuilds = 0;
@ -940,7 +939,7 @@ void main() {
expect(scaffoldRebuilds, 2); expect(scaffoldRebuilds, 2);
}); });
testWidgetsWithLeakTracking('MaterialApp switches themes when the platformBrightness changes.', (WidgetTester tester) async { testWidgets('MaterialApp switches themes when the platformBrightness changes.', (WidgetTester tester) async {
addTearDown(tester.platformDispatcher.clearAllTestValues); addTearDown(tester.platformDispatcher.clearAllTestValues);
// Mock the test to explicitly report a light platformBrightness. // Mock the test to explicitly report a light platformBrightness.
@ -979,7 +978,7 @@ void main() {
expect(themeAfterBrightnessChange!.brightness, Brightness.dark); expect(themeAfterBrightnessChange!.brightness, Brightness.dark);
}); });
testWidgetsWithLeakTracking('Material2 - MaterialApp provides default overscroll color', (WidgetTester tester) async { testWidgets('Material2 - MaterialApp provides default overscroll color', (WidgetTester tester) async {
Future<void> slowDrag(WidgetTester tester, Offset start, Offset offset) async { Future<void> slowDrag(WidgetTester tester, Offset start, Offset offset) async {
final TestGesture gesture = await tester.startGesture(start); final TestGesture gesture = await tester.startGesture(start);
for (int index = 0; index < 10; index += 1) { for (int index = 0; index < 10; index += 1) {
@ -1011,7 +1010,7 @@ void main() {
expect(painter, paints..circle(color: glowSecondaryColor)); expect(painter, paints..circle(color: glowSecondaryColor));
}); });
testWidgetsWithLeakTracking('MaterialApp can customize initial routes', (WidgetTester tester) async { testWidgets('MaterialApp can customize initial routes', (WidgetTester tester) async {
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -1058,7 +1057,7 @@ void main() {
expect(find.text('regular page two'), findsNothing); expect(find.text('regular page two'), findsNothing);
}); });
testWidgetsWithLeakTracking('MaterialApp does create HeroController with the MaterialRectArcTween', (WidgetTester tester) async { testWidgets('MaterialApp does create HeroController with the MaterialRectArcTween', (WidgetTester tester) async {
final HeroController controller = MaterialApp.createMaterialHeroController(); final HeroController controller = MaterialApp.createMaterialHeroController();
addTearDown(controller.dispose); addTearDown(controller.dispose);
final Tween<Rect?> tween = controller.createRectTween!( final Tween<Rect?> tween = controller.createRectTween!(
@ -1068,7 +1067,7 @@ void main() {
expect(tween, isA<MaterialRectArcTween>()); expect(tween, isA<MaterialRectArcTween>());
}); });
testWidgetsWithLeakTracking('MaterialApp.navigatorKey can be updated', (WidgetTester tester) async { testWidgets('MaterialApp.navigatorKey can be updated', (WidgetTester tester) async {
final GlobalKey<NavigatorState> key1 = GlobalKey<NavigatorState>(); final GlobalKey<NavigatorState> key1 = GlobalKey<NavigatorState>();
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
navigatorKey: key1, navigatorKey: key1,
@ -1084,7 +1083,7 @@ void main() {
expect(key1.currentState, isNull); expect(key1.currentState, isNull);
}); });
testWidgetsWithLeakTracking('MaterialApp.router works', (WidgetTester tester) async { testWidgets('MaterialApp.router works', (WidgetTester tester) async {
final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider( final PlatformRouteInformationProvider provider = PlatformRouteInformationProvider(
initialRouteInformation: RouteInformation( initialRouteInformation: RouteInformation(
uri: Uri.parse('initial'), uri: Uri.parse('initial'),
@ -1117,7 +1116,7 @@ void main() {
expect(find.text('popped'), findsOneWidget); expect(find.text('popped'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('MaterialApp.router route information parser is optional', (WidgetTester tester) async { testWidgets('MaterialApp.router route information parser is optional', (WidgetTester tester) async {
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate( final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate(
builder: (BuildContext context, RouteInformation information) { builder: (BuildContext context, RouteInformation information) {
return Text(information.uri.toString()); return Text(information.uri.toString());
@ -1143,7 +1142,7 @@ void main() {
expect(find.text('popped'), findsOneWidget); expect(find.text('popped'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('MaterialApp.router throw if route information provider is provided but no route information parser', (WidgetTester tester) async { testWidgets('MaterialApp.router throw if route information provider is provided but no route information parser', (WidgetTester tester) async {
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate( final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate(
builder: (BuildContext context, RouteInformation information) { builder: (BuildContext context, RouteInformation information) {
return Text(information.uri.toString()); return Text(information.uri.toString());
@ -1170,7 +1169,7 @@ void main() {
provider.dispose(); provider.dispose();
}); });
testWidgetsWithLeakTracking('MaterialApp.router throw if route configuration is provided along with other delegate', (WidgetTester tester) async { testWidgets('MaterialApp.router throw if route configuration is provided along with other delegate', (WidgetTester tester) async {
final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate( final SimpleNavigatorRouterDelegate delegate = SimpleNavigatorRouterDelegate(
builder: (BuildContext context, RouteInformation information) { builder: (BuildContext context, RouteInformation information) {
return Text(information.uri.toString()); return Text(information.uri.toString());
@ -1192,7 +1191,7 @@ void main() {
expect(tester.takeException(), isAssertionError); expect(tester.takeException(), isAssertionError);
}); });
testWidgetsWithLeakTracking('MaterialApp.router router config works', (WidgetTester tester) async { testWidgets('MaterialApp.router router config works', (WidgetTester tester) async {
late SimpleNavigatorRouterDelegate routerDelegate; late SimpleNavigatorRouterDelegate routerDelegate;
addTearDown(() => routerDelegate.dispose()); addTearDown(() => routerDelegate.dispose());
late PlatformRouteInformationProvider provider; late PlatformRouteInformationProvider provider;
@ -1229,7 +1228,7 @@ void main() {
expect(find.text('popped'), findsOneWidget); expect(find.text('popped'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('MaterialApp.builder can build app without a Navigator', (WidgetTester tester) async { testWidgets('MaterialApp.builder can build app without a Navigator', (WidgetTester tester) async {
Widget? builderChild; Widget? builderChild;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
@ -1240,7 +1239,7 @@ void main() {
expect(builderChild, isNull); expect(builderChild, isNull);
}); });
testWidgetsWithLeakTracking('MaterialApp has correct default ScrollBehavior', (WidgetTester tester) async { testWidgets('MaterialApp has correct default ScrollBehavior', (WidgetTester tester) async {
late BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -1255,7 +1254,7 @@ void main() {
expect(ScrollConfiguration.of(capturedContext).runtimeType, MaterialScrollBehavior); expect(ScrollConfiguration.of(capturedContext).runtimeType, MaterialScrollBehavior);
}); });
testWidgetsWithLeakTracking('A ScrollBehavior can be set for MaterialApp', (WidgetTester tester) async { testWidgets('A ScrollBehavior can be set for MaterialApp', (WidgetTester tester) async {
late BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -1273,7 +1272,7 @@ void main() {
expect(scrollBehavior.getScrollPhysics(capturedContext).runtimeType, NeverScrollableScrollPhysics); expect(scrollBehavior.getScrollPhysics(capturedContext).runtimeType, NeverScrollableScrollPhysics);
}); });
testWidgetsWithLeakTracking('Material2 - ScrollBehavior default android overscroll indicator', (WidgetTester tester) async { testWidgets('Material2 - ScrollBehavior default android overscroll indicator', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
scrollBehavior: const MaterialScrollBehavior(), scrollBehavior: const MaterialScrollBehavior(),
@ -1292,7 +1291,7 @@ void main() {
expect(find.byType(GlowingOverscrollIndicator), findsOneWidget); expect(find.byType(GlowingOverscrollIndicator), findsOneWidget);
}, variant: TargetPlatformVariant.only(TargetPlatform.android)); }, variant: TargetPlatformVariant.only(TargetPlatform.android));
testWidgetsWithLeakTracking('Material3 - ScrollBehavior default android overscroll indicator', (WidgetTester tester) async { testWidgets('Material3 - ScrollBehavior default android overscroll indicator', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: true), theme: ThemeData(useMaterial3: true),
scrollBehavior: const MaterialScrollBehavior(), scrollBehavior: const MaterialScrollBehavior(),
@ -1311,7 +1310,7 @@ void main() {
expect(find.byType(GlowingOverscrollIndicator), findsNothing); expect(find.byType(GlowingOverscrollIndicator), findsNothing);
}, variant: TargetPlatformVariant.only(TargetPlatform.android)); }, variant: TargetPlatformVariant.only(TargetPlatform.android));
testWidgetsWithLeakTracking('MaterialScrollBehavior default stretch android overscroll indicator', (WidgetTester tester) async { testWidgets('MaterialScrollBehavior default stretch android overscroll indicator', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: ListView( home: ListView(
children: const <Widget>[ children: const <Widget>[
@ -1328,7 +1327,7 @@ void main() {
expect(find.byType(GlowingOverscrollIndicator), findsNothing); expect(find.byType(GlowingOverscrollIndicator), findsNothing);
}, variant: TargetPlatformVariant.only(TargetPlatform.android)); }, variant: TargetPlatformVariant.only(TargetPlatform.android));
testWidgetsWithLeakTracking('Overscroll indicator can be set by theme', (WidgetTester tester) async { testWidgets('Overscroll indicator can be set by theme', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
// The current default is M3 and stretch overscroll, setting via the theme should override. // The current default is M3 and stretch overscroll, setting via the theme should override.
theme: ThemeData().copyWith(useMaterial3: false), theme: ThemeData().copyWith(useMaterial3: false),
@ -1347,7 +1346,7 @@ void main() {
expect(find.byType(StretchingOverscrollIndicator), findsNothing); expect(find.byType(StretchingOverscrollIndicator), findsNothing);
}, variant: TargetPlatformVariant.only(TargetPlatform.android)); }, variant: TargetPlatformVariant.only(TargetPlatform.android));
testWidgetsWithLeakTracking('Material3 - ListView clip behavior updates overscroll indicator clip behavior', (WidgetTester tester) async { testWidgets('Material3 - ListView clip behavior updates overscroll indicator clip behavior', (WidgetTester tester) async {
Widget buildFrame(Clip clipBehavior) { Widget buildFrame(Clip clipBehavior) {
return MaterialApp( return MaterialApp(
theme: ThemeData(useMaterial3: true), theme: ThemeData(useMaterial3: true),
@ -1423,7 +1422,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}, variant: TargetPlatformVariant.only(TargetPlatform.android)); }, variant: TargetPlatformVariant.only(TargetPlatform.android));
testWidgetsWithLeakTracking('When `useInheritedMediaQuery` is true an existing MediaQuery is used if one is available', (WidgetTester tester) async { testWidgets('When `useInheritedMediaQuery` is true an existing MediaQuery is used if one is available', (WidgetTester tester) async {
late BuildContext capturedContext; late BuildContext capturedContext;
final UniqueKey uniqueKey = UniqueKey(); final UniqueKey uniqueKey = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
@ -1443,7 +1442,7 @@ void main() {
expect(capturedContext.dependOnInheritedWidgetOfExactType<MediaQuery>()?.key, uniqueKey); expect(capturedContext.dependOnInheritedWidgetOfExactType<MediaQuery>()?.key, uniqueKey);
}); });
testWidgetsWithLeakTracking('Assert in buildScrollbar that controller != null when using it (vertical)', (WidgetTester tester) async { testWidgets('Assert in buildScrollbar that controller != null when using it (vertical)', (WidgetTester tester) async {
const ScrollBehavior defaultBehavior = MaterialScrollBehavior(); const ScrollBehavior defaultBehavior = MaterialScrollBehavior();
late BuildContext capturedContext; late BuildContext capturedContext;
@ -1488,7 +1487,7 @@ void main() {
} }
}, variant: TargetPlatformVariant.all()); }, variant: TargetPlatformVariant.all());
testWidgetsWithLeakTracking('Assert in buildScrollbar that controller != null when using it (horizontal)', (WidgetTester tester) async { testWidgets('Assert in buildScrollbar that controller != null when using it (horizontal)', (WidgetTester tester) async {
const ScrollBehavior defaultBehavior = MaterialScrollBehavior(); const ScrollBehavior defaultBehavior = MaterialScrollBehavior();
late BuildContext capturedContext; late BuildContext capturedContext;
@ -1526,7 +1525,7 @@ void main() {
} }
}, variant: TargetPlatformVariant.all()); }, variant: TargetPlatformVariant.all());
testWidgetsWithLeakTracking('Override theme animation using AnimationStyle', (WidgetTester tester) async { testWidgets('Override theme animation using AnimationStyle', (WidgetTester tester) async {
final ThemeData lightTheme = ThemeData.light(); final ThemeData lightTheme = ThemeData.light();
final ThemeData darkTheme = ThemeData.dark(); final ThemeData darkTheme = ThemeData.dark();
@ -1591,7 +1590,7 @@ void main() {
expect(tester.widget<Material>(find.byType(Material)).color, const Color(0xfffffbfe)); expect(tester.widget<Material>(find.byType(Material)).color, const Color(0xfffffbfe));
}); });
testWidgetsWithLeakTracking('AnimationStyle.noAnimation removes AnimatedTheme from the tree', (WidgetTester tester) async { testWidgets('AnimationStyle.noAnimation removes AnimatedTheme from the tree', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(themeAnimationStyle: AnimationStyle())); await tester.pumpWidget(MaterialApp(themeAnimationStyle: AnimationStyle()));
expect(find.byType(AnimatedTheme), findsOneWidget); expect(find.byType(AnimatedTheme), findsOneWidget);

View File

@ -5,7 +5,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
class User { class User {
const User({ const User({
@ -46,7 +45,7 @@ void main() {
User(name: 'Charlie', email: 'charlie123@gmail.com'), User(name: 'Charlie', email: 'charlie123@gmail.com'),
]; ];
testWidgetsWithLeakTracking('can filter and select a list of string options', (WidgetTester tester) async { testWidgets('can filter and select a list of string options', (WidgetTester tester) async {
late String lastSelection; late String lastSelection;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -106,7 +105,7 @@ void main() {
expect(list.semanticChildCount, 6); expect(list.semanticChildCount, 6);
}); });
testWidgetsWithLeakTracking('can filter and select a list of custom User options', (WidgetTester tester) async { testWidgets('can filter and select a list of custom User options', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
@ -160,7 +159,7 @@ void main() {
expect(list.semanticChildCount, 1); expect(list.semanticChildCount, 1);
}); });
testWidgetsWithLeakTracking('displayStringForOption is displayed in the options', (WidgetTester tester) async { testWidgets('displayStringForOption is displayed in the options', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
@ -203,7 +202,7 @@ void main() {
expect(field.controller!.text, kOptionsUsers.first.name); expect(field.controller!.text, kOptionsUsers.first.name);
}); });
testWidgetsWithLeakTracking('can build a custom field', (WidgetTester tester) async { testWidgets('can build a custom field', (WidgetTester tester) async {
final GlobalKey fieldKey = GlobalKey(); final GlobalKey fieldKey = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -227,7 +226,7 @@ void main() {
expect(find.byType(TextFormField), findsNothing); expect(find.byType(TextFormField), findsNothing);
}); });
testWidgetsWithLeakTracking('can build custom options', (WidgetTester tester) async { testWidgets('can build custom options', (WidgetTester tester) async {
final GlobalKey optionsKey = GlobalKey(); final GlobalKey optionsKey = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -256,7 +255,7 @@ void main() {
expect(find.byKey(optionsKey), findsOneWidget); expect(find.byKey(optionsKey), findsOneWidget);
}); });
testWidgetsWithLeakTracking('the default Autocomplete options widget has a maximum height of 200', (WidgetTester tester) async { testWidgets('the default Autocomplete options widget has a maximum height of 200', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(home: Scaffold( await tester.pumpWidget(MaterialApp(home: Scaffold(
body: Autocomplete<String>( body: Autocomplete<String>(
optionsBuilder: (TextEditingValue textEditingValue) { optionsBuilder: (TextEditingValue textEditingValue) {
@ -277,7 +276,7 @@ void main() {
expect(resultingHeight, equals(200)); expect(resultingHeight, equals(200));
}); });
testWidgetsWithLeakTracking('the options height restricts to max desired height', (WidgetTester tester) async { testWidgets('the options height restricts to max desired height', (WidgetTester tester) async {
const double desiredHeight = 150.0; const double desiredHeight = 150.0;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( home: Scaffold(
@ -306,7 +305,7 @@ void main() {
expect(resultingHeight, equals(desiredHeight)); expect(resultingHeight, equals(desiredHeight));
}); });
testWidgetsWithLeakTracking('The height of options shrinks to height of resulting items, if less than maxHeight', (WidgetTester tester) async { testWidgets('The height of options shrinks to height of resulting items, if less than maxHeight', (WidgetTester tester) async {
// Returns a Future with the height of the default [Autocomplete] options widget // Returns a Future with the height of the default [Autocomplete] options widget
// after the provided text had been entered into the [Autocomplete] field. // after the provided text had been entered into the [Autocomplete] field.
Future<double> getDefaultOptionsHeight( Future<double> getDefaultOptionsHeight(
@ -354,7 +353,7 @@ void main() {
expect(oneItemsHeight, lessThan(twoItemsHeight)); expect(oneItemsHeight, lessThan(twoItemsHeight));
}); });
testWidgetsWithLeakTracking('initialValue sets initial text field value', (WidgetTester tester) async { testWidgets('initialValue sets initial text field value', (WidgetTester tester) async {
late String lastSelection; late String lastSelection;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -415,7 +414,7 @@ void main() {
} }
} }
testWidgetsWithLeakTracking('keyboard navigation of the options properly highlights the option', (WidgetTester tester) async { testWidgets('keyboard navigation of the options properly highlights the option', (WidgetTester tester) async {
const Color highlightColor = Color(0xFF112233); const Color highlightColor = Color(0xFF112233);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -454,7 +453,7 @@ void main() {
checkOptionHighlight(tester, 'elephant', highlightColor); checkOptionHighlight(tester, 'elephant', highlightColor);
}); });
testWidgetsWithLeakTracking('keyboard navigation keeps the highlighted option scrolled into view', (WidgetTester tester) async { testWidgets('keyboard navigation keeps the highlighted option scrolled into view', (WidgetTester tester) async {
const Color highlightColor = Color(0xFF112233); const Color highlightColor = Color(0xFF112233);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -518,7 +517,7 @@ void main() {
}); });
group('optionsViewOpenDirection', () { group('optionsViewOpenDirection', () {
testWidgetsWithLeakTracking('default (down)', (WidgetTester tester) async { testWidgets('default (down)', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
@ -533,7 +532,7 @@ void main() {
expect(actual, equals(OptionsViewOpenDirection.down)); expect(actual, equals(OptionsViewOpenDirection.down));
}); });
testWidgetsWithLeakTracking('down', (WidgetTester tester) async { testWidgets('down', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
@ -549,7 +548,7 @@ void main() {
expect(actual, equals(OptionsViewOpenDirection.down)); expect(actual, equals(OptionsViewOpenDirection.down));
}); });
testWidgetsWithLeakTracking('up', (WidgetTester tester) async { testWidgets('up', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(

View File

@ -5,10 +5,9 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('BackButton control test', (WidgetTester tester) async { testWidgets('BackButton control test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: const Material(child: Text('Home')), home: const Material(child: Text('Home')),
@ -35,7 +34,7 @@ void main() {
expect(find.text('Home'), findsOneWidget); expect(find.text('Home'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('BackButton onPressed overrides default pop behavior', (WidgetTester tester) async { testWidgets('BackButton onPressed overrides default pop behavior', (WidgetTester tester) async {
bool customCallbackWasCalled = false; bool customCallbackWasCalled = false;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -68,7 +67,7 @@ void main() {
expect(customCallbackWasCalled, true); expect(customCallbackWasCalled, true);
}); });
testWidgetsWithLeakTracking('BackButton icon', (WidgetTester tester) async { testWidgets('BackButton icon', (WidgetTester tester) async {
final Key androidKey = UniqueKey(); final Key androidKey = UniqueKey();
final Key iOSKey = UniqueKey(); final Key iOSKey = UniqueKey();
final Key linuxKey = UniqueKey(); final Key linuxKey = UniqueKey();
@ -116,7 +115,7 @@ void main() {
expect(windowsIcon.icon == androidIcon.icon, isTrue); expect(windowsIcon.icon == androidIcon.icon, isTrue);
}); });
testWidgetsWithLeakTracking('BackButton color', (WidgetTester tester) async { testWidgets('BackButton color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: Material( home: Material(
@ -134,7 +133,7 @@ void main() {
expect(iconText.text.style!.color, Colors.red); expect(iconText.text.style!.color, Colors.red);
}); });
testWidgetsWithLeakTracking('BackButton color with ButtonStyle', (WidgetTester tester) async { testWidgets('BackButton color with ButtonStyle', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: true), theme: ThemeData(useMaterial3: true),
@ -155,7 +154,7 @@ void main() {
expect(iconText.text.style!.color, Colors.red); expect(iconText.text.style!.color, Colors.red);
}); });
testWidgetsWithLeakTracking('BackButton.style.iconColor parameter overrides BackButton.color', (WidgetTester tester) async { testWidgets('BackButton.style.iconColor parameter overrides BackButton.color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: true), theme: ThemeData(useMaterial3: true),
@ -178,7 +177,7 @@ void main() {
expect(iconText.text.style!.color, Colors.red); expect(iconText.text.style!.color, Colors.red);
}); });
testWidgetsWithLeakTracking('BackButton semantics', (WidgetTester tester) async { testWidgets('BackButton semantics', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -221,7 +220,7 @@ void main() {
handle.dispose(); handle.dispose();
}, variant: TargetPlatformVariant.all()); }, variant: TargetPlatformVariant.all());
testWidgetsWithLeakTracking('CloseButton semantics', (WidgetTester tester) async { testWidgets('CloseButton semantics', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -264,7 +263,7 @@ void main() {
handle.dispose(); handle.dispose();
}, variant: TargetPlatformVariant.all()); }, variant: TargetPlatformVariant.all());
testWidgetsWithLeakTracking('CloseButton color', (WidgetTester tester) async { testWidgets('CloseButton color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: Material( home: Material(
@ -282,7 +281,7 @@ void main() {
expect(iconText.text.style!.color, Colors.red); expect(iconText.text.style!.color, Colors.red);
}); });
testWidgetsWithLeakTracking('CloseButton color with ButtonStyle', (WidgetTester tester) async { testWidgets('CloseButton color with ButtonStyle', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: true), theme: ThemeData(useMaterial3: true),
@ -303,7 +302,7 @@ void main() {
expect(iconText.text.style!.color, Colors.red); expect(iconText.text.style!.color, Colors.red);
}); });
testWidgetsWithLeakTracking('CloseButton.style.iconColor parameter overrides CloseButton.color', (WidgetTester tester) async { testWidgets('CloseButton.style.iconColor parameter overrides CloseButton.color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: true), theme: ThemeData(useMaterial3: true),
@ -326,7 +325,7 @@ void main() {
expect(iconText.text.style!.color, Colors.red); expect(iconText.text.style!.color, Colors.red);
}); });
testWidgetsWithLeakTracking('CloseButton onPressed overrides default pop behavior', (WidgetTester tester) async { testWidgets('CloseButton onPressed overrides default pop behavior', (WidgetTester tester) async {
bool customCallbackWasCalled = false; bool customCallbackWasCalled = false;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(

View File

@ -6,11 +6,10 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('Large Badge defaults', (WidgetTester tester) async { testWidgets('Large Badge defaults', (WidgetTester tester) async {
late final ThemeData theme; late final ThemeData theme;
await tester.pumpWidget( await tester.pumpWidget(
@ -56,7 +55,7 @@ void main() {
expect(box, paints..rrect(rrect: rrect, color: theme.colorScheme.error)); expect(box, paints..rrect(rrect: rrect, color: theme.colorScheme.error));
}); });
testWidgetsWithLeakTracking('Large Badge defaults with RTL', (WidgetTester tester) async { testWidgets('Large Badge defaults with RTL', (WidgetTester tester) async {
late final ThemeData theme; late final ThemeData theme;
await tester.pumpWidget( await tester.pumpWidget(
@ -99,7 +98,7 @@ void main() {
}); });
// Essentially the same as 'Large Badge defaults' // Essentially the same as 'Large Badge defaults'
testWidgetsWithLeakTracking('Badge.count', (WidgetTester tester) async { testWidgets('Badge.count', (WidgetTester tester) async {
late final ThemeData theme; late final ThemeData theme;
Widget buildFrame(int count) { Widget buildFrame(int count) {
@ -158,7 +157,7 @@ void main() {
expect(find.text('999+'), findsOneWidget); expect(find.text('999+'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Small Badge defaults', (WidgetTester tester) async { testWidgets('Small Badge defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData.light(useMaterial3: true); final ThemeData theme = ThemeData.light(useMaterial3: true);
await tester.pumpWidget( await tester.pumpWidget(
@ -189,7 +188,7 @@ void main() {
expect(box, paints..rrect(rrect: RRect.fromLTRBR(18, 0, 24, 6, const Radius.circular(3)), color: theme.colorScheme.error)); expect(box, paints..rrect(rrect: RRect.fromLTRBR(18, 0, 24, 6, const Radius.circular(3)), color: theme.colorScheme.error));
}); });
testWidgetsWithLeakTracking('Small Badge RTL defaults', (WidgetTester tester) async { testWidgets('Small Badge RTL defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData.light(useMaterial3: true); final ThemeData theme = ThemeData.light(useMaterial3: true);
await tester.pumpWidget( await tester.pumpWidget(
@ -222,7 +221,7 @@ void main() {
expect(box, paints..rrect(rrect: RRect.fromLTRBR(0, 0, 6, 6, const Radius.circular(3)), color: theme.colorScheme.error)); expect(box, paints..rrect(rrect: RRect.fromLTRBR(0, 0, 6, 6, const Radius.circular(3)), color: theme.colorScheme.error));
}); });
testWidgetsWithLeakTracking('Large Badge textStyle and colors', (WidgetTester tester) async { testWidgets('Large Badge textStyle and colors', (WidgetTester tester) async {
final ThemeData theme = ThemeData.light(useMaterial3: true); final ThemeData theme = ThemeData.light(useMaterial3: true);
const Color green = Color(0xff00ff00); const Color green = Color(0xff00ff00);
const Color black = Color(0xff000000); const Color black = Color(0xff000000);
@ -249,7 +248,7 @@ void main() {
expect(tester.renderObject(find.byType(Badge)), paints..rrect(color: black)); expect(tester.renderObject(find.byType(Badge)), paints..rrect(color: black));
}); });
testWidgetsWithLeakTracking('isLabelVisible', (WidgetTester tester) async { testWidgets('isLabelVisible', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData.light(useMaterial3: true), theme: ThemeData.light(useMaterial3: true),
@ -273,7 +272,7 @@ void main() {
expect(box, isNot(paints..rrect())); expect(box, isNot(paints..rrect()));
}); });
testWidgetsWithLeakTracking('Large Badge alignment', (WidgetTester tester) async { testWidgets('Large Badge alignment', (WidgetTester tester) async {
const Radius badgeRadius = Radius.circular(8); const Radius badgeRadius = Radius.circular(8);
Widget buildFrame(Alignment alignment, [Offset offset = Offset.zero]) { Widget buildFrame(Alignment alignment, [Offset offset = Offset.zero]) {
@ -348,7 +347,7 @@ void main() {
expect(box, paints..rrect(rrect: RRect.fromLTRBR(200 - 16, 200 - 16, 200, 200, badgeRadius).shift(offset))); expect(box, paints..rrect(rrect: RRect.fromLTRBR(200 - 16, 200 - 16, 200, 200, badgeRadius).shift(offset)));
}); });
testWidgetsWithLeakTracking('Small Badge alignment', (WidgetTester tester) async { testWidgets('Small Badge alignment', (WidgetTester tester) async {
const Radius badgeRadius = Radius.circular(3); const Radius badgeRadius = Radius.circular(3);
Widget buildFrame(Alignment alignment, [Offset offset = Offset.zero]) { Widget buildFrame(Alignment alignment, [Offset offset = Offset.zero]) {

View File

@ -5,7 +5,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
test('BadgeThemeData copyWith, ==, hashCode basics', () { test('BadgeThemeData copyWith, ==, hashCode basics', () {
@ -31,7 +30,7 @@ void main() {
expect(themeData.offset, null); expect(themeData.offset, null);
}); });
testWidgetsWithLeakTracking('Default BadgeThemeData debugFillProperties', (WidgetTester tester) async { testWidgets('Default BadgeThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const BadgeThemeData().debugFillProperties(builder); const BadgeThemeData().debugFillProperties(builder);
@ -43,7 +42,7 @@ void main() {
expect(description, <String>[]); expect(description, <String>[]);
}); });
testWidgetsWithLeakTracking('BadgeThemeData implements debugFillProperties', (WidgetTester tester) async { testWidgets('BadgeThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const BadgeThemeData( const BadgeThemeData(
backgroundColor: Color(0xfffffff0), backgroundColor: Color(0xfffffff0),
@ -73,7 +72,7 @@ void main() {
]); ]);
}); });
testWidgetsWithLeakTracking('Badge uses ThemeData badge theme', (WidgetTester tester) async { testWidgets('Badge uses ThemeData badge theme', (WidgetTester tester) async {
const Color green = Color(0xff00ff00); const Color green = Color(0xff00ff00);
const Color black = Color(0xff000000); const Color black = Color(0xff000000);
const BadgeThemeData badgeTheme = BadgeThemeData( const BadgeThemeData badgeTheme = BadgeThemeData(
@ -122,7 +121,7 @@ void main() {
// This test is essentially the same as 'Badge uses ThemeData badge theme'. In // This test is essentially the same as 'Badge uses ThemeData badge theme'. In
// this case the theme is introduced with the BadgeTheme widget instead of // this case the theme is introduced with the BadgeTheme widget instead of
// ThemeData.badgeTheme. // ThemeData.badgeTheme.
testWidgetsWithLeakTracking('Badge uses BadgeTheme', (WidgetTester tester) async { testWidgets('Badge uses BadgeTheme', (WidgetTester tester) async {
const Color green = Color(0xff00ff00); const Color green = Color(0xff00ff00);
const Color black = Color(0xff000000); const Color black = Color(0xff000000);
const BadgeThemeData badgeTheme = BadgeThemeData( const BadgeThemeData badgeTheme = BadgeThemeData(

View File

@ -5,10 +5,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('MaterialBanner properties are respected', (WidgetTester tester) async { testWidgets('MaterialBanner properties are respected', (WidgetTester tester) async {
const String contentText = 'Content'; const String contentText = 'Content';
const Color backgroundColor = Colors.pink; const Color backgroundColor = Colors.pink;
const Color surfaceTintColor = Colors.green; const Color surfaceTintColor = Colors.green;
@ -48,7 +47,7 @@ void main() {
expect(divider.color, dividerColor); expect(divider.color, dividerColor);
}); });
testWidgetsWithLeakTracking('MaterialBanner properties are respected when presented by ScaffoldMessenger', (WidgetTester tester) async { testWidgets('MaterialBanner properties are respected when presented by ScaffoldMessenger', (WidgetTester tester) async {
const String contentText = 'Content'; const String contentText = 'Content';
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
const Color backgroundColor = Colors.pink; const Color backgroundColor = Colors.pink;
@ -105,7 +104,7 @@ void main() {
expect(divider.color, dividerColor); expect(divider.color, dividerColor);
}); });
testWidgetsWithLeakTracking('Actions laid out below content if more than one action', (WidgetTester tester) async { testWidgets('Actions laid out below content if more than one action', (WidgetTester tester) async {
const String contentText = 'Content'; const String contentText = 'Content';
await tester.pumpWidget( await tester.pumpWidget(
@ -132,7 +131,7 @@ void main() {
expect(contentBottomLeft.dx, lessThan(actionsTopLeft.dx)); expect(contentBottomLeft.dx, lessThan(actionsTopLeft.dx));
}); });
testWidgetsWithLeakTracking('Actions laid out below content if more than one action when presented by ScaffoldMessenger', (WidgetTester tester) async { testWidgets('Actions laid out below content if more than one action when presented by ScaffoldMessenger', (WidgetTester tester) async {
const String contentText = 'Content'; const String contentText = 'Content';
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -175,7 +174,7 @@ void main() {
expect(contentBottomLeft.dx, lessThan(actionsTopLeft.dx)); expect(contentBottomLeft.dx, lessThan(actionsTopLeft.dx));
}); });
testWidgetsWithLeakTracking('Actions laid out beside content if only one action', (WidgetTester tester) async { testWidgets('Actions laid out beside content if only one action', (WidgetTester tester) async {
const String contentText = 'Content'; const String contentText = 'Content';
await tester.pumpWidget( await tester.pumpWidget(
@ -198,7 +197,7 @@ void main() {
expect(contentBottomLeft.dx, lessThan(actionsTopRight.dx)); expect(contentBottomLeft.dx, lessThan(actionsTopRight.dx));
}); });
testWidgetsWithLeakTracking('Actions laid out beside content if only one action when presented by ScaffoldMessenger', (WidgetTester tester) async { testWidgets('Actions laid out beside content if only one action when presented by ScaffoldMessenger', (WidgetTester tester) async {
const String contentText = 'Content'; const String contentText = 'Content';
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -270,7 +269,7 @@ void main() {
); );
} }
testWidgetsWithLeakTracking('Elevation defaults to 0', (WidgetTester tester) async { testWidgets('Elevation defaults to 0', (WidgetTester tester) async {
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
await tester.pumpWidget(buildBanner(tapTarget)); await tester.pumpWidget(buildBanner(tapTarget));
@ -295,7 +294,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Uses elevation of MaterialBannerTheme by default', (WidgetTester tester) async { testWidgets('Uses elevation of MaterialBannerTheme by default', (WidgetTester tester) async {
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
await tester.pumpWidget(buildBanner(tapTarget, themeElevation: 6.0)); await tester.pumpWidget(buildBanner(tapTarget, themeElevation: 6.0));
@ -313,7 +312,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Scaffold body is pushed down if elevation is 0', (WidgetTester tester) async { testWidgets('Scaffold body is pushed down if elevation is 0', (WidgetTester tester) async {
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
await tester.pumpWidget(buildBanner(tapTarget, elevation: 0.0)); await tester.pumpWidget(buildBanner(tapTarget, elevation: 0.0));
@ -328,7 +327,7 @@ void main() {
}); });
}); });
testWidgetsWithLeakTracking('MaterialBanner control test', (WidgetTester tester) async { testWidgets('MaterialBanner control test', (WidgetTester tester) async {
const String helloMaterialBanner = 'Hello MaterialBanner'; const String helloMaterialBanner = 'Hello MaterialBanner';
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
const Key dismissTarget = Key('dismiss-target'); const Key dismissTarget = Key('dismiss-target');
@ -380,7 +379,7 @@ void main() {
expect(find.text(helloMaterialBanner), findsNothing); expect(find.text(helloMaterialBanner), findsNothing);
}); });
testWidgetsWithLeakTracking('MaterialBanner twice test', (WidgetTester tester) async { testWidgets('MaterialBanner twice test', (WidgetTester tester) async {
int materialBannerCount = 0; int materialBannerCount = 0;
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
const Key dismissTarget = Key('dismiss-target'); const Key dismissTarget = Key('dismiss-target');
@ -462,7 +461,7 @@ void main() {
expect(find.text('banner2'), findsNothing); expect(find.text('banner2'), findsNothing);
}); });
testWidgetsWithLeakTracking('ScaffoldMessenger does not duplicate a MaterialBanner when presenting a SnackBar.', (WidgetTester tester) async { testWidgets('ScaffoldMessenger does not duplicate a MaterialBanner when presenting a SnackBar.', (WidgetTester tester) async {
const Key materialBannerTapTarget = Key('materialbanner-tap-target'); const Key materialBannerTapTarget = Key('materialbanner-tap-target');
const Key snackBarTapTarget = Key('snackbar-tap-target'); const Key snackBarTapTarget = Key('snackbar-tap-target');
const String snackBarText = 'SnackBar'; const String snackBarText = 'SnackBar';
@ -520,7 +519,7 @@ void main() {
}); });
// Regression test for https://github.com/flutter/flutter/issues/39574 // Regression test for https://github.com/flutter/flutter/issues/39574
testWidgetsWithLeakTracking('Single action laid out beside content but aligned to the trailing edge', (WidgetTester tester) async { testWidgets('Single action laid out beside content but aligned to the trailing edge', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: MaterialBanner( home: MaterialBanner(
@ -541,7 +540,7 @@ void main() {
}); });
// Regression test for https://github.com/flutter/flutter/issues/39574 // Regression test for https://github.com/flutter/flutter/issues/39574
testWidgetsWithLeakTracking('Single action laid out beside content but aligned to the trailing edge when presented by ScaffoldMessenger', (WidgetTester tester) async { testWidgets('Single action laid out beside content but aligned to the trailing edge when presented by ScaffoldMessenger', (WidgetTester tester) async {
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( home: Scaffold(
@ -579,7 +578,7 @@ void main() {
}); });
// Regression test for https://github.com/flutter/flutter/issues/39574 // Regression test for https://github.com/flutter/flutter/issues/39574
testWidgetsWithLeakTracking('Single action laid out beside content but aligned to the trailing edge - RTL', (WidgetTester tester) async { testWidgets('Single action laid out beside content but aligned to the trailing edge - RTL', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Directionality( home: Directionality(
@ -602,7 +601,7 @@ void main() {
expect(actionsTopLeft.dx - 8, moreOrLessEquals(bannerTopLeft.dx)); // actions OverflowBar is padded by 8 expect(actionsTopLeft.dx - 8, moreOrLessEquals(bannerTopLeft.dx)); // actions OverflowBar is padded by 8
}); });
testWidgetsWithLeakTracking('Single action laid out beside content but aligned to the trailing edge when presented by ScaffoldMessenger - RTL', (WidgetTester tester) async { testWidgets('Single action laid out beside content but aligned to the trailing edge when presented by ScaffoldMessenger - RTL', (WidgetTester tester) async {
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Directionality( home: Directionality(
@ -642,7 +641,7 @@ void main() {
expect(actionsTopLeft.dx - 8, moreOrLessEquals(bannerTopLeft.dx)); // actions OverflowBar is padded by 8 expect(actionsTopLeft.dx - 8, moreOrLessEquals(bannerTopLeft.dx)); // actions OverflowBar is padded by 8
}); });
testWidgetsWithLeakTracking('Actions laid out below content if forced override', (WidgetTester tester) async { testWidgets('Actions laid out below content if forced override', (WidgetTester tester) async {
const String contentText = 'Content'; const String contentText = 'Content';
await tester.pumpWidget( await tester.pumpWidget(
@ -666,7 +665,7 @@ void main() {
expect(contentBottomLeft.dx, lessThan(actionsTopLeft.dx)); expect(contentBottomLeft.dx, lessThan(actionsTopLeft.dx));
}); });
testWidgetsWithLeakTracking('Actions laid out below content if forced override when presented by ScaffoldMessenger', (WidgetTester tester) async { testWidgets('Actions laid out below content if forced override when presented by ScaffoldMessenger', (WidgetTester tester) async {
const String contentText = 'Content'; const String contentText = 'Content';
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -706,7 +705,7 @@ void main() {
expect(contentBottomLeft.dx, lessThan(actionsTopLeft.dx)); expect(contentBottomLeft.dx, lessThan(actionsTopLeft.dx));
}); });
testWidgetsWithLeakTracking('Action widgets layout', (WidgetTester tester) async { testWidgets('Action widgets layout', (WidgetTester tester) async {
// This regression test ensures that the action widgets layout matches what // This regression test ensures that the action widgets layout matches what
// it was, before ButtonBar was replaced by OverflowBar. // it was, before ButtonBar was replaced by OverflowBar.
Widget buildFrame(int actionCount, TextDirection textDirection) { Widget buildFrame(int actionCount, TextDirection textDirection) {
@ -750,7 +749,7 @@ void main() {
expect(tester.getTopLeft(action2), const Offset(8, 130)); expect(tester.getTopLeft(action2), const Offset(8, 130));
}); });
testWidgetsWithLeakTracking('Action widgets layout when presented by ScaffoldMessenger', (WidgetTester tester) async { testWidgets('Action widgets layout when presented by ScaffoldMessenger', (WidgetTester tester) async {
// This regression test ensures that the action widgets layout matches what // This regression test ensures that the action widgets layout matches what
// it was, before ButtonBar was replaced by OverflowBar. // it was, before ButtonBar was replaced by OverflowBar.
@ -837,7 +836,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Action widgets layout with overflow', (WidgetTester tester) async { testWidgets('Action widgets layout with overflow', (WidgetTester tester) async {
// This regression test ensures that the action widgets layout matches what // This regression test ensures that the action widgets layout matches what
// it was, before ButtonBar was replaced by OverflowBar. // it was, before ButtonBar was replaced by OverflowBar.
const int actionCount = 4; const int actionCount = 4;
@ -872,7 +871,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('Action widgets layout with overflow when presented by ScaffoldMessenger', (WidgetTester tester) async { testWidgets('Action widgets layout with overflow when presented by ScaffoldMessenger', (WidgetTester tester) async {
// This regression test ensures that the action widgets layout matches what // This regression test ensures that the action widgets layout matches what
// it was, before ButtonBar was replaced by OverflowBar. // it was, before ButtonBar was replaced by OverflowBar.
@ -943,7 +942,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('[overflowAlignment] test', (WidgetTester tester) async { testWidgets('[overflowAlignment] test', (WidgetTester tester) async {
const int actionCount = 4; const int actionCount = 4;
Widget buildFrame(TextDirection textDirection, OverflowBarAlignment overflowAlignment) { Widget buildFrame(TextDirection textDirection, OverflowBarAlignment overflowAlignment) {
return MaterialApp( return MaterialApp(
@ -980,7 +979,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('[overflowAlignment] test when presented by ScaffoldMessenger', (WidgetTester tester) async { testWidgets('[overflowAlignment] test when presented by ScaffoldMessenger', (WidgetTester tester) async {
const int actionCount = 4; const int actionCount = 4;
Widget buildFrame(TextDirection textDirection, OverflowBarAlignment overflowAlignment) { Widget buildFrame(TextDirection textDirection, OverflowBarAlignment overflowAlignment) {
return MaterialApp( return MaterialApp(
@ -1055,7 +1054,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('ScaffoldMessenger will alert for MaterialBanners that cannot be presented', (WidgetTester tester) async { testWidgets('ScaffoldMessenger will alert for MaterialBanners that cannot be presented', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/103004 // Regression test for https://github.com/flutter/flutter/issues/103004
await tester.pumpWidget(const MaterialApp( await tester.pumpWidget(const MaterialApp(
home: Center(), home: Center(),
@ -1084,7 +1083,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Custom Margin respected', (WidgetTester tester) async { testWidgets('Custom Margin respected', (WidgetTester tester) async {
const EdgeInsets margin = EdgeInsets.all(30); const EdgeInsets margin = EdgeInsets.all(30);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(

View File

@ -5,7 +5,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
test('MaterialBannerThemeData copyWith, ==, hashCode basics', () { test('MaterialBannerThemeData copyWith, ==, hashCode basics', () {
@ -25,7 +24,7 @@ void main() {
expect(bannerTheme.leadingPadding, null); expect(bannerTheme.leadingPadding, null);
}); });
testWidgetsWithLeakTracking('Default MaterialBannerThemeData debugFillProperties', (WidgetTester tester) async { testWidgets('Default MaterialBannerThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const MaterialBannerThemeData().debugFillProperties(builder); const MaterialBannerThemeData().debugFillProperties(builder);
@ -37,7 +36,7 @@ void main() {
expect(description, <String>[]); expect(description, <String>[]);
}); });
testWidgetsWithLeakTracking('MaterialBannerThemeData implements debugFillProperties', (WidgetTester tester) async { testWidgets('MaterialBannerThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const MaterialBannerThemeData( const MaterialBannerThemeData(
backgroundColor: Color(0xfffffff0), backgroundColor: Color(0xfffffff0),
@ -67,7 +66,7 @@ void main() {
]); ]);
}); });
testWidgetsWithLeakTracking('Material3 - Passing no MaterialBannerThemeData returns defaults', (WidgetTester tester) async { testWidgets('Material3 - Passing no MaterialBannerThemeData returns defaults', (WidgetTester tester) async {
const String contentText = 'Content'; const String contentText = 'Content';
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
late final ThemeData localizedTheme; late final ThemeData localizedTheme;
@ -116,7 +115,7 @@ void main() {
expect(divider.color, theme.colorScheme.outlineVariant); expect(divider.color, theme.colorScheme.outlineVariant);
}); });
testWidgetsWithLeakTracking('Material3 - Passing no MaterialBannerThemeData returns defaults when presented by ScaffoldMessenger', (WidgetTester tester) async { testWidgets('Material3 - Passing no MaterialBannerThemeData returns defaults when presented by ScaffoldMessenger', (WidgetTester tester) async {
const String contentText = 'Content'; const String contentText = 'Content';
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
@ -179,7 +178,7 @@ void main() {
expect(divider.color, theme.colorScheme.outlineVariant); expect(divider.color, theme.colorScheme.outlineVariant);
}); });
testWidgetsWithLeakTracking('MaterialBanner uses values from MaterialBannerThemeData', (WidgetTester tester) async { testWidgets('MaterialBanner uses values from MaterialBannerThemeData', (WidgetTester tester) async {
final MaterialBannerThemeData bannerTheme = _bannerTheme(); final MaterialBannerThemeData bannerTheme = _bannerTheme();
const String contentText = 'Content'; const String contentText = 'Content';
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -218,7 +217,7 @@ void main() {
expect(find.byType(Divider), findsNothing); expect(find.byType(Divider), findsNothing);
}); });
testWidgetsWithLeakTracking('MaterialBanner uses values from MaterialBannerThemeData when presented by ScaffoldMessenger', (WidgetTester tester) async { testWidgets('MaterialBanner uses values from MaterialBannerThemeData when presented by ScaffoldMessenger', (WidgetTester tester) async {
final MaterialBannerThemeData bannerTheme = _bannerTheme(); final MaterialBannerThemeData bannerTheme = _bannerTheme();
const String contentText = 'Content'; const String contentText = 'Content';
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
@ -274,7 +273,7 @@ void main() {
expect(find.byType(Divider), findsNothing); expect(find.byType(Divider), findsNothing);
}); });
testWidgetsWithLeakTracking('MaterialBanner widget properties take priority over theme', (WidgetTester tester) async { testWidgets('MaterialBanner widget properties take priority over theme', (WidgetTester tester) async {
const Color backgroundColor = Colors.purple; const Color backgroundColor = Colors.purple;
const Color surfaceTintColor = Colors.red; const Color surfaceTintColor = Colors.red;
const Color shadowColor = Colors.orange; const Color shadowColor = Colors.orange;
@ -325,7 +324,7 @@ void main() {
expect(find.byType(Divider), findsNothing); expect(find.byType(Divider), findsNothing);
}); });
testWidgetsWithLeakTracking('MaterialBanner widget properties take priority over theme when presented by ScaffoldMessenger', (WidgetTester tester) async { testWidgets('MaterialBanner widget properties take priority over theme when presented by ScaffoldMessenger', (WidgetTester tester) async {
const Color backgroundColor = Colors.purple; const Color backgroundColor = Colors.purple;
const double elevation = 6.0; const double elevation = 6.0;
const TextStyle textStyle = TextStyle(color: Colors.green); const TextStyle textStyle = TextStyle(color: Colors.green);
@ -388,7 +387,7 @@ void main() {
expect(find.byType(Divider), findsNothing); expect(find.byType(Divider), findsNothing);
}); });
testWidgetsWithLeakTracking('MaterialBanner uses color scheme when necessary', (WidgetTester tester) async { testWidgets('MaterialBanner uses color scheme when necessary', (WidgetTester tester) async {
final ColorScheme colorScheme = const ColorScheme.light().copyWith(surface: Colors.purple); final ColorScheme colorScheme = const ColorScheme.light().copyWith(surface: Colors.purple);
const String contentText = 'Content'; const String contentText = 'Content';
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -410,7 +409,7 @@ void main() {
expect(material.color, colorScheme.surface); expect(material.color, colorScheme.surface);
}); });
testWidgetsWithLeakTracking('MaterialBanner uses color scheme when necessary when presented by ScaffoldMessenger', (WidgetTester tester) async { testWidgets('MaterialBanner uses color scheme when necessary when presented by ScaffoldMessenger', (WidgetTester tester) async {
final ColorScheme colorScheme = const ColorScheme.light().copyWith(surface: Colors.purple); final ColorScheme colorScheme = const ColorScheme.light().copyWith(surface: Colors.purple);
const String contentText = 'Content'; const String contentText = 'Content';
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
@ -454,7 +453,7 @@ void main() {
// support is deprecated and the APIs are removed, these tests // support is deprecated and the APIs are removed, these tests
// can be deleted. // can be deleted.
testWidgetsWithLeakTracking('Material2 - Passing no MaterialBannerThemeData returns defaults', (WidgetTester tester) async { testWidgets('Material2 - Passing no MaterialBannerThemeData returns defaults', (WidgetTester tester) async {
const String contentText = 'Content'; const String contentText = 'Content';
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -500,7 +499,7 @@ void main() {
expect(divider.color, null); expect(divider.color, null);
}); });
testWidgetsWithLeakTracking('Material2 - Passing no MaterialBannerThemeData returns defaults when presented by ScaffoldMessenger', (WidgetTester tester) async { testWidgets('Material2 - Passing no MaterialBannerThemeData returns defaults when presented by ScaffoldMessenger', (WidgetTester tester) async {
const String contentText = 'Content'; const String contentText = 'Content';
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');

View File

@ -10,9 +10,8 @@ library;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('Material3 - Shadow effect is not doubled', (WidgetTester tester) async { testWidgets('Material3 - Shadow effect is not doubled', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/123064 // Regression test for https://github.com/flutter/flutter/issues/123064
debugDisableShadows = false; debugDisableShadows = false;
@ -38,7 +37,7 @@ void main() {
debugDisableShadows = true; debugDisableShadows = true;
}); });
testWidgetsWithLeakTracking('Material3 - Only one layer with `color` is painted', (WidgetTester tester) async { testWidgets('Material3 - Only one layer with `color` is painted', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/122667 // Regression test for https://github.com/flutter/flutter/issues/122667
const Color bottomAppBarColor = Colors.black45; const Color bottomAppBarColor = Colors.black45;
@ -76,7 +75,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('No overlap with floating action button', (WidgetTester tester) async { testWidgets('No overlap with floating action button', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: Scaffold( home: Scaffold(
@ -107,7 +106,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material2 - Custom shape', (WidgetTester tester) async { testWidgets('Material2 - Custom shape', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
Future<void> pump(FloatingActionButtonLocation location) async { Future<void> pump(FloatingActionButtonLocation location) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -151,7 +150,7 @@ void main() {
); );
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44572 }, skip: isBrowser); // https://github.com/flutter/flutter/issues/44572
testWidgetsWithLeakTracking('Material3 - Custom shape', (WidgetTester tester) async { testWidgets('Material3 - Custom shape', (WidgetTester tester) async {
final Key key = UniqueKey(); final Key key = UniqueKey();
Future<void> pump(FloatingActionButtonLocation location) async { Future<void> pump(FloatingActionButtonLocation location) async {
await tester.pumpWidget( await tester.pumpWidget(
@ -195,7 +194,7 @@ void main() {
); );
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/44572 }, skip: isBrowser); // https://github.com/flutter/flutter/issues/44572
testWidgetsWithLeakTracking('Custom Padding', (WidgetTester tester) async { testWidgets('Custom Padding', (WidgetTester tester) async {
const EdgeInsets customPadding = EdgeInsets.all(10); const EdgeInsets customPadding = EdgeInsets.all(10);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -227,7 +226,7 @@ void main() {
expect(babRect, const Rect.fromLTRB(240, 520, 560, 600)); expect(babRect, const Rect.fromLTRB(240, 520, 560, 600));
}); });
testWidgetsWithLeakTracking('Material2 - Color defaults to Theme.bottomAppBarColor', (WidgetTester tester) async { testWidgets('Material2 - Color defaults to Theme.bottomAppBarColor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
@ -253,7 +252,7 @@ void main() {
expect(physicalShape.color, const Color(0xffffff00)); expect(physicalShape.color, const Color(0xffffff00));
}); });
testWidgetsWithLeakTracking('Material2 - Color overrides theme color', (WidgetTester tester) async { testWidgets('Material2 - Color overrides theme color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
@ -284,7 +283,7 @@ void main() {
}); });
testWidgetsWithLeakTracking('Material3 - Color overrides theme color', (WidgetTester tester) async { testWidgets('Material3 - Color overrides theme color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData.light(useMaterial3: true).copyWith( theme: ThemeData.light(useMaterial3: true).copyWith(
@ -312,7 +311,7 @@ void main() {
expect(physicalShape.color, const Color(0xff0000ff)); expect(physicalShape.color, const Color(0xff0000ff));
}); });
testWidgetsWithLeakTracking('Material3 - Shadow color is transparent', (WidgetTester tester) async { testWidgets('Material3 - Shadow color is transparent', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: true, theme: ThemeData(useMaterial3: true,
@ -334,7 +333,7 @@ void main() {
expect(physicalShape.shadowColor, Colors.transparent); expect(physicalShape.shadowColor, Colors.transparent);
}); });
testWidgetsWithLeakTracking('Material2 - Dark theme applies an elevation overlay color', (WidgetTester tester) async { testWidgets('Material2 - Dark theme applies an elevation overlay color', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData.from(useMaterial3: false, colorScheme: const ColorScheme.dark()), theme: ThemeData.from(useMaterial3: false, colorScheme: const ColorScheme.dark()),
@ -352,7 +351,7 @@ void main() {
expect(physicalShape.color, const Color(0xFF2D2D2D)); expect(physicalShape.color, const Color(0xFF2D2D2D));
}); });
testWidgetsWithLeakTracking('Material3 - Dark theme applies an elevation overlay color', (WidgetTester tester) async { testWidgets('Material3 - Dark theme applies an elevation overlay color', (WidgetTester tester) async {
const ColorScheme colorScheme = ColorScheme.dark(); const ColorScheme colorScheme = ColorScheme.dark();
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -375,7 +374,7 @@ void main() {
// This is a regression test for a bug we had where toggling the notch on/off // This is a regression test for a bug we had where toggling the notch on/off
// would crash, as the shouldReclip method of ShapeBorderClipper or // would crash, as the shouldReclip method of ShapeBorderClipper or
// _BottomAppBarClipper would try an illegal downcast. // _BottomAppBarClipper would try an illegal downcast.
testWidgetsWithLeakTracking('toggle shape to null', (WidgetTester tester) async { testWidgets('toggle shape to null', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: Scaffold( home: Scaffold(
@ -405,7 +404,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('no notch when notch param is null', (WidgetTester tester) async { testWidgets('no notch when notch param is null', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: Scaffold( home: Scaffold(
@ -435,7 +434,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('notch no margin', (WidgetTester tester) async { testWidgets('notch no margin', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: Scaffold( home: Scaffold(
@ -487,7 +486,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('notch with margin', (WidgetTester tester) async { testWidgets('notch with margin', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: Scaffold( home: Scaffold(
@ -539,7 +538,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material2 - Observes safe area', (WidgetTester tester) async { testWidgets('Material2 - Observes safe area', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
@ -564,7 +563,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material3 - Observes safe area', (WidgetTester tester) async { testWidgets('Material3 - Observes safe area', (WidgetTester tester) async {
const double safeAreaPadding = 50.0; const double safeAreaPadding = 50.0;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -595,7 +594,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('clipBehavior is propagated', (WidgetTester tester) async { testWidgets('clipBehavior is propagated', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: Scaffold( home: Scaffold(
@ -629,7 +628,7 @@ void main() {
expect(physicalShape.clipBehavior, Clip.antiAliasWithSaveLayer); expect(physicalShape.clipBehavior, Clip.antiAliasWithSaveLayer);
}); });
testWidgetsWithLeakTracking('Material2 - BottomAppBar with shape when Scaffold.bottomNavigationBar == null', (WidgetTester tester) async { testWidgets('Material2 - BottomAppBar with shape when Scaffold.bottomNavigationBar == null', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/80878 // Regression test for https://github.com/flutter/flutter/issues/80878
final ThemeData theme = ThemeData(useMaterial3: false); final ThemeData theme = ThemeData(useMaterial3: false);
await tester.pumpWidget( await tester.pumpWidget(
@ -665,7 +664,7 @@ void main() {
expect(tester.getSize(find.byType(BottomAppBar)), const Size(800, 50)); expect(tester.getSize(find.byType(BottomAppBar)), const Size(800, 50));
}); });
testWidgetsWithLeakTracking('Material3 - BottomAppBar with shape when Scaffold.bottomNavigationBar == null', (WidgetTester tester) async { testWidgets('Material3 - BottomAppBar with shape when Scaffold.bottomNavigationBar == null', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/80878 // Regression test for https://github.com/flutter/flutter/issues/80878
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget( await tester.pumpWidget(
@ -701,7 +700,7 @@ void main() {
expect(tester.getSize(find.byType(BottomAppBar)), const Size(800, 80)); expect(tester.getSize(find.byType(BottomAppBar)), const Size(800, 80));
}); });
testWidgetsWithLeakTracking('notch with margin and top padding, home safe area', (WidgetTester tester) async { testWidgets('notch with margin and top padding, home safe area', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/90024 // Regression test for https://github.com/flutter/flutter/issues/90024
await tester.pumpWidget( await tester.pumpWidget(
const MediaQuery( const MediaQuery(
@ -762,7 +761,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('BottomAppBar does not apply custom clipper without FAB', (WidgetTester tester) async { testWidgets('BottomAppBar does not apply custom clipper without FAB', (WidgetTester tester) async {
Widget buildWidget({Widget? fab}) { Widget buildWidget({Widget? fab}) {
return MaterialApp( return MaterialApp(
home: Scaffold( home: Scaffold(
@ -787,7 +786,7 @@ void main() {
expect(physicalShape.clipper.toString(), 'ShapeBorderClipper'); expect(physicalShape.clipper.toString(), 'ShapeBorderClipper');
}); });
testWidgetsWithLeakTracking('Material3 - BottomAppBar adds bottom padding to height', (WidgetTester tester) async { testWidgets('Material3 - BottomAppBar adds bottom padding to height', (WidgetTester tester) async {
const double bottomPadding = 35.0; const double bottomPadding = 35.0;
await tester.pumpWidget( await tester.pumpWidget(

View File

@ -9,7 +9,6 @@ library;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
test('BottomAppBarTheme lerp special cases', () { test('BottomAppBarTheme lerp special cases', () {
@ -19,7 +18,7 @@ void main() {
}); });
group('Material 2 tests', () { group('Material 2 tests', () {
testWidgetsWithLeakTracking('Material2 - BAB theme overrides color', (WidgetTester tester) async { testWidgets('Material2 - BAB theme overrides color', (WidgetTester tester) async {
const Color themedColor = Colors.black87; const Color themedColor = Colors.black87;
const BottomAppBarTheme theme = BottomAppBarTheme(color: themedColor); const BottomAppBarTheme theme = BottomAppBarTheme(color: themedColor);
@ -29,7 +28,7 @@ void main() {
expect(widget.color, themedColor); expect(widget.color, themedColor);
}); });
testWidgetsWithLeakTracking('Material2 - BAB color - Widget', (WidgetTester tester) async { testWidgets('Material2 - BAB color - Widget', (WidgetTester tester) async {
const Color themeColor = Colors.white10; const Color themeColor = Colors.white10;
const Color babThemeColor = Colors.black87; const Color babThemeColor = Colors.black87;
const Color babColor = Colors.pink; const Color babColor = Colors.pink;
@ -48,7 +47,7 @@ void main() {
expect(widget.color, babColor); expect(widget.color, babColor);
}); });
testWidgetsWithLeakTracking('Material2 - BAB color - BabTheme', (WidgetTester tester) async { testWidgets('Material2 - BAB color - BabTheme', (WidgetTester tester) async {
const Color themeColor = Colors.white10; const Color themeColor = Colors.white10;
const Color babThemeColor = Colors.black87; const Color babThemeColor = Colors.black87;
const BottomAppBarTheme theme = BottomAppBarTheme(color: babThemeColor); const BottomAppBarTheme theme = BottomAppBarTheme(color: babThemeColor);
@ -66,7 +65,7 @@ void main() {
expect(widget.color, babThemeColor); expect(widget.color, babThemeColor);
}); });
testWidgetsWithLeakTracking('Material2 - BAB color - Theme', (WidgetTester tester) async { testWidgets('Material2 - BAB color - Theme', (WidgetTester tester) async {
const Color themeColor = Colors.white10; const Color themeColor = Colors.white10;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -78,7 +77,7 @@ void main() {
expect(widget.color, themeColor); expect(widget.color, themeColor);
}); });
testWidgetsWithLeakTracking('Material2 - BAB color - Default', (WidgetTester tester) async { testWidgets('Material2 - BAB color - Default', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
home: const Scaffold(body: BottomAppBar()), home: const Scaffold(body: BottomAppBar()),
@ -89,7 +88,7 @@ void main() {
expect(widget.color, Colors.white); expect(widget.color, Colors.white);
}); });
testWidgetsWithLeakTracking('Material2 - BAB theme customizes shape', (WidgetTester tester) async { testWidgets('Material2 - BAB theme customizes shape', (WidgetTester tester) async {
const BottomAppBarTheme theme = BottomAppBarTheme( const BottomAppBarTheme theme = BottomAppBarTheme(
color: Colors.white30, color: Colors.white30,
shape: CircularNotchedRectangle(), shape: CircularNotchedRectangle(),
@ -104,7 +103,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material2 - BAB theme does not affect defaults', (WidgetTester tester) async { testWidgets('Material2 - BAB theme does not affect defaults', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
home: const Scaffold(body: BottomAppBar()), home: const Scaffold(body: BottomAppBar()),
@ -118,7 +117,7 @@ void main() {
}); });
group('Material 3 tests', () { group('Material 3 tests', () {
testWidgetsWithLeakTracking('Material3 - BAB theme overrides color', (WidgetTester tester) async { testWidgets('Material3 - BAB theme overrides color', (WidgetTester tester) async {
const Color themedColor = Colors.black87; const Color themedColor = Colors.black87;
const BottomAppBarTheme theme = BottomAppBarTheme( const BottomAppBarTheme theme = BottomAppBarTheme(
color: themedColor, color: themedColor,
@ -130,7 +129,7 @@ void main() {
expect(widget.color, themedColor); expect(widget.color, themedColor);
}); });
testWidgetsWithLeakTracking('Material3 - BAB color - Widget', (WidgetTester tester) async { testWidgets('Material3 - BAB color - Widget', (WidgetTester tester) async {
const Color themeColor = Colors.white10; const Color themeColor = Colors.white10;
const Color babThemeColor = Colors.black87; const Color babThemeColor = Colors.black87;
const Color babColor = Colors.pink; const Color babColor = Colors.pink;
@ -149,7 +148,7 @@ void main() {
expect(widget.color, babColor); expect(widget.color, babColor);
}); });
testWidgetsWithLeakTracking('Material3 - BAB color - BabTheme', (WidgetTester tester) async { testWidgets('Material3 - BAB color - BabTheme', (WidgetTester tester) async {
const Color themeColor = Colors.white10; const Color themeColor = Colors.white10;
const Color babThemeColor = Colors.black87; const Color babThemeColor = Colors.black87;
const BottomAppBarTheme theme = BottomAppBarTheme(color: babThemeColor); const BottomAppBarTheme theme = BottomAppBarTheme(color: babThemeColor);
@ -167,7 +166,7 @@ void main() {
expect(widget.color, babThemeColor); expect(widget.color, babThemeColor);
}); });
testWidgetsWithLeakTracking('Material3 - BAB theme does not affect defaults', (WidgetTester tester) async { testWidgets('Material3 - BAB theme does not affect defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: theme, theme: theme,
@ -180,7 +179,7 @@ void main() {
expect(widget.elevation, equals(3.0)); expect(widget.elevation, equals(3.0));
}); });
testWidgetsWithLeakTracking('Material3 - BAB theme overrides surfaceTintColor', (WidgetTester tester) async { testWidgets('Material3 - BAB theme overrides surfaceTintColor', (WidgetTester tester) async {
const Color color = Colors.blue; // base color that the surface tint will be applied to const Color color = Colors.blue; // base color that the surface tint will be applied to
const Color babThemeSurfaceTintColor = Colors.black87; const Color babThemeSurfaceTintColor = Colors.black87;
const BottomAppBarTheme theme = BottomAppBarTheme( const BottomAppBarTheme theme = BottomAppBarTheme(
@ -192,7 +191,7 @@ void main() {
expect(widget.color, ElevationOverlay.applySurfaceTint(color, babThemeSurfaceTintColor, 0)); expect(widget.color, ElevationOverlay.applySurfaceTint(color, babThemeSurfaceTintColor, 0));
}); });
testWidgetsWithLeakTracking('Material3 - BAB theme overrides shadowColor', (WidgetTester tester) async { testWidgets('Material3 - BAB theme overrides shadowColor', (WidgetTester tester) async {
const Color babThemeShadowColor = Colors.yellow; const Color babThemeShadowColor = Colors.yellow;
const BottomAppBarTheme theme = BottomAppBarTheme( const BottomAppBarTheme theme = BottomAppBarTheme(
shadowColor: babThemeShadowColor, elevation: 0 shadowColor: babThemeShadowColor, elevation: 0
@ -203,7 +202,7 @@ void main() {
expect(widget.shadowColor, babThemeShadowColor); expect(widget.shadowColor, babThemeShadowColor);
}); });
testWidgetsWithLeakTracking('Material3 - BAB surfaceTintColor - Widget', (WidgetTester tester) async { testWidgets('Material3 - BAB surfaceTintColor - Widget', (WidgetTester tester) async {
const Color color = Colors.white10; // base color that the surface tint will be applied to const Color color = Colors.white10; // base color that the surface tint will be applied to
const Color themeSurfaceTintColor = Colors.white10; const Color themeSurfaceTintColor = Colors.white10;
const Color babThemeSurfaceTintColor = Colors.black87; const Color babThemeSurfaceTintColor = Colors.black87;
@ -226,7 +225,7 @@ void main() {
expect(widget.color, ElevationOverlay.applySurfaceTint(color, babSurfaceTintColor, 3.0)); expect(widget.color, ElevationOverlay.applySurfaceTint(color, babSurfaceTintColor, 3.0));
}); });
testWidgetsWithLeakTracking('Material3 - BAB surfaceTintColor - BabTheme', (WidgetTester tester) async { testWidgets('Material3 - BAB surfaceTintColor - BabTheme', (WidgetTester tester) async {
const Color color = Colors.blue; // base color that the surface tint will be applied to const Color color = Colors.blue; // base color that the surface tint will be applied to
const Color themeColor = Colors.white10; const Color themeColor = Colors.white10;
const Color babThemeColor = Colors.black87; const Color babThemeColor = Colors.black87;

View File

@ -14,14 +14,13 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'package:vector_math/vector_math_64.dart' show Vector3; import 'package:vector_math/vector_math_64.dart' show Vector3;
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
import 'feedback_tester.dart'; import 'feedback_tester.dart';
void main() { void main() {
testWidgetsWithLeakTracking('BottomNavigationBar callback test', (WidgetTester tester) async { testWidgets('BottomNavigationBar callback test', (WidgetTester tester) async {
late int mutatedIndex; late int mutatedIndex;
await tester.pumpWidget( await tester.pumpWidget(
@ -51,7 +50,7 @@ void main() {
expect(mutatedIndex, 1); expect(mutatedIndex, 1);
}); });
testWidgetsWithLeakTracking('Material2 - BottomNavigationBar content test', (WidgetTester tester) async { testWidgets('Material2 - BottomNavigationBar content test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
@ -78,7 +77,7 @@ void main() {
expect(find.text('Alarm'), findsOneWidget); expect(find.text('Alarm'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Material3 - BottomNavigationBar content test', (WidgetTester tester) async { testWidgets('Material3 - BottomNavigationBar content test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
@ -105,7 +104,7 @@ void main() {
expect(find.text('Alarm'), findsOneWidget); expect(find.text('Alarm'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Material2 - Fixed BottomNavigationBar defaults', (WidgetTester tester) async { testWidgets('Material2 - Fixed BottomNavigationBar defaults', (WidgetTester tester) async {
const Color primaryColor = Color(0xFF000001); const Color primaryColor = Color(0xFF000001);
const Color unselectedWidgetColor = Color(0xFF000002); const Color unselectedWidgetColor = Color(0xFF000002);
@ -170,7 +169,7 @@ void main() {
expect(_getMaterial(tester).elevation, equals(8.0)); expect(_getMaterial(tester).elevation, equals(8.0));
}); });
testWidgetsWithLeakTracking('Material3 - Fixed BottomNavigationBar defaults', (WidgetTester tester) async { testWidgets('Material3 - Fixed BottomNavigationBar defaults', (WidgetTester tester) async {
const Color primaryColor = Color(0xFF000001); const Color primaryColor = Color(0xFF000001);
const Color unselectedWidgetColor = Color(0xFF000002); const Color unselectedWidgetColor = Color(0xFF000002);
@ -235,7 +234,7 @@ void main() {
expect(_getMaterial(tester).elevation, equals(8.0)); expect(_getMaterial(tester).elevation, equals(8.0));
}); });
testWidgetsWithLeakTracking('Custom selected and unselected font styles', (WidgetTester tester) async { testWidgets('Custom selected and unselected font styles', (WidgetTester tester) async {
const TextStyle selectedTextStyle = TextStyle(fontWeight: FontWeight.w200, fontSize: 18.0); const TextStyle selectedTextStyle = TextStyle(fontWeight: FontWeight.w200, fontSize: 18.0);
const TextStyle unselectedTextStyle = TextStyle(fontWeight: FontWeight.w600, fontSize: 12.0); const TextStyle unselectedTextStyle = TextStyle(fontWeight: FontWeight.w600, fontSize: 12.0);
@ -272,7 +271,7 @@ void main() {
expect(unselectedFontStyle.fontWeight, equals(unselectedTextStyle.fontWeight)); expect(unselectedFontStyle.fontWeight, equals(unselectedTextStyle.fontWeight));
}); });
testWidgetsWithLeakTracking('font size on text styles overrides font size params', (WidgetTester tester) async { testWidgets('font size on text styles overrides font size params', (WidgetTester tester) async {
const TextStyle selectedTextStyle = TextStyle(fontSize: 18.0); const TextStyle selectedTextStyle = TextStyle(fontSize: 18.0);
const TextStyle unselectedTextStyle = TextStyle(fontSize: 12.0); const TextStyle unselectedTextStyle = TextStyle(fontSize: 12.0);
const double selectedFontSize = 17.0; const double selectedFontSize = 17.0;
@ -310,7 +309,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Custom selected and unselected icon themes', (WidgetTester tester) async { testWidgets('Custom selected and unselected icon themes', (WidgetTester tester) async {
const IconThemeData selectedIconTheme = IconThemeData(size: 36, color: Color(0x00000001)); const IconThemeData selectedIconTheme = IconThemeData(size: 36, color: Color(0x00000001));
const IconThemeData unselectedIconTheme = IconThemeData(size: 18, color: Color(0x00000002)); const IconThemeData unselectedIconTheme = IconThemeData(size: 18, color: Color(0x00000002));
@ -344,7 +343,7 @@ void main() {
expect(unselectedIcon.fontSize, equals(unselectedIconTheme.size)); expect(unselectedIcon.fontSize, equals(unselectedIconTheme.size));
}); });
testWidgetsWithLeakTracking('color on icon theme overrides selected and unselected item colors', (WidgetTester tester) async { testWidgets('color on icon theme overrides selected and unselected item colors', (WidgetTester tester) async {
const IconThemeData selectedIconTheme = IconThemeData(size: 36, color: Color(0x00000001)); const IconThemeData selectedIconTheme = IconThemeData(size: 36, color: Color(0x00000001));
const IconThemeData unselectedIconTheme = IconThemeData(size: 18, color: Color(0x00000002)); const IconThemeData unselectedIconTheme = IconThemeData(size: 18, color: Color(0x00000002));
const Color selectedItemColor = Color(0x00000003); const Color selectedItemColor = Color(0x00000003);
@ -384,7 +383,7 @@ void main() {
expect(unselectedFontStyle.color, equals(unselectedItemColor)); expect(unselectedFontStyle.color, equals(unselectedItemColor));
}); });
testWidgetsWithLeakTracking('Padding is calculated properly on items - all labels', (WidgetTester tester) async { testWidgets('Padding is calculated properly on items - all labels', (WidgetTester tester) async {
const double selectedFontSize = 16.0; const double selectedFontSize = 16.0;
const double selectedIconSize = 36.0; const double selectedIconSize = 36.0;
const double unselectedIconSize = 20.0; const double unselectedIconSize = 20.0;
@ -425,7 +424,7 @@ void main() {
expect(unselectedItemPadding.bottom, equals(expectedUnselectedPadding)); expect(unselectedItemPadding.bottom, equals(expectedUnselectedPadding));
}); });
testWidgetsWithLeakTracking('Padding is calculated properly on items - selected labels only', (WidgetTester tester) async { testWidgets('Padding is calculated properly on items - selected labels only', (WidgetTester tester) async {
const double selectedFontSize = 16.0; const double selectedFontSize = 16.0;
const double selectedIconSize = 36.0; const double selectedIconSize = 36.0;
const double unselectedIconSize = 20.0; const double unselectedIconSize = 20.0;
@ -465,7 +464,7 @@ void main() {
expect(unselectedItemPadding.bottom, equals((selectedIconSize - unselectedIconSize) / 2.0)); expect(unselectedItemPadding.bottom, equals((selectedIconSize - unselectedIconSize) / 2.0));
}); });
testWidgetsWithLeakTracking('Padding is calculated properly on items - no labels', (WidgetTester tester) async { testWidgets('Padding is calculated properly on items - no labels', (WidgetTester tester) async {
const double selectedFontSize = 16.0; const double selectedFontSize = 16.0;
const double selectedIconSize = 36.0; const double selectedIconSize = 36.0;
const double unselectedIconSize = 20.0; const double unselectedIconSize = 20.0;
@ -505,7 +504,7 @@ void main() {
expect(unselectedItemPadding.bottom, equals((selectedIconSize - unselectedIconSize) / 2.0)); expect(unselectedItemPadding.bottom, equals((selectedIconSize - unselectedIconSize) / 2.0));
}); });
testWidgetsWithLeakTracking('Material2 - Shifting BottomNavigationBar defaults', (WidgetTester tester) async { testWidgets('Material2 - Shifting BottomNavigationBar defaults', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
@ -534,7 +533,7 @@ void main() {
expect(_getMaterial(tester).elevation, equals(8.0)); expect(_getMaterial(tester).elevation, equals(8.0));
}); });
testWidgetsWithLeakTracking('Material3 - Shifting BottomNavigationBar defaults', (WidgetTester tester) async { testWidgets('Material3 - Shifting BottomNavigationBar defaults', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
@ -563,7 +562,7 @@ void main() {
expect(_getMaterial(tester).elevation, equals(8.0)); expect(_getMaterial(tester).elevation, equals(8.0));
}); });
testWidgetsWithLeakTracking('Fixed BottomNavigationBar custom font size, color', (WidgetTester tester) async { testWidgets('Fixed BottomNavigationBar custom font size, color', (WidgetTester tester) async {
const Color primaryColor = Color(0xFF000000); const Color primaryColor = Color(0xFF000000);
const Color unselectedWidgetColor = Color(0xFFD501FF); const Color unselectedWidgetColor = Color(0xFFD501FF);
const Color selectedColor = Color(0xFF0004FF); const Color selectedColor = Color(0xFF0004FF);
@ -628,7 +627,7 @@ void main() {
}); });
testWidgetsWithLeakTracking('Shifting BottomNavigationBar custom font size, color', (WidgetTester tester) async { testWidgets('Shifting BottomNavigationBar custom font size, color', (WidgetTester tester) async {
const Color primaryColor = Color(0xFF000000); const Color primaryColor = Color(0xFF000000);
const Color unselectedWidgetColor = Color(0xFFD501FF); const Color unselectedWidgetColor = Color(0xFFD501FF);
const Color selectedColor = Color(0xFF0004FF); const Color selectedColor = Color(0xFF0004FF);
@ -675,7 +674,7 @@ void main() {
expect(unselectedIcon.color, equals(unselectedColor)); expect(unselectedIcon.color, equals(unselectedColor));
}); });
testWidgetsWithLeakTracking('label style color should override itemColor only for the label for BottomNavigationBarType.fixed', (WidgetTester tester) async { testWidgets('label style color should override itemColor only for the label for BottomNavigationBarType.fixed', (WidgetTester tester) async {
const Color primaryColor = Color(0xFF000000); const Color primaryColor = Color(0xFF000000);
const Color unselectedWidgetColor = Color(0xFFD501FF); const Color unselectedWidgetColor = Color(0xFFD501FF);
const Color selectedColor = Color(0xFF0004FF); const Color selectedColor = Color(0xFF0004FF);
@ -721,7 +720,7 @@ void main() {
expect(tester.renderObject<RenderParagraph>(find.text('Alarm')).text.style!.color, equals(unselectedLabelColor)); expect(tester.renderObject<RenderParagraph>(find.text('Alarm')).text.style!.color, equals(unselectedLabelColor));
}); });
testWidgetsWithLeakTracking('label style color should override itemColor only for the label for BottomNavigationBarType.shifting', (WidgetTester tester) async { testWidgets('label style color should override itemColor only for the label for BottomNavigationBarType.shifting', (WidgetTester tester) async {
const Color primaryColor = Color(0xFF000000); const Color primaryColor = Color(0xFF000000);
const Color unselectedWidgetColor = Color(0xFFD501FF); const Color unselectedWidgetColor = Color(0xFFD501FF);
const Color selectedColor = Color(0xFF0004FF); const Color selectedColor = Color(0xFF0004FF);
@ -767,7 +766,7 @@ void main() {
expect(tester.renderObject<RenderParagraph>(find.text('Alarm')).text.style!.color, equals(unselectedLabelColor)); expect(tester.renderObject<RenderParagraph>(find.text('Alarm')).text.style!.color, equals(unselectedLabelColor));
}); });
testWidgetsWithLeakTracking('iconTheme color should override itemColor for BottomNavigationBarType.fixed', (WidgetTester tester) async { testWidgets('iconTheme color should override itemColor for BottomNavigationBarType.fixed', (WidgetTester tester) async {
const Color primaryColor = Color(0xFF000000); const Color primaryColor = Color(0xFF000000);
const Color unselectedWidgetColor = Color(0xFFD501FF); const Color unselectedWidgetColor = Color(0xFFD501FF);
const Color selectedColor = Color(0xFF0004FF); const Color selectedColor = Color(0xFF0004FF);
@ -819,7 +818,7 @@ void main() {
expect(unselectedIcon.color, equals(unselectedIconThemeColor)); expect(unselectedIcon.color, equals(unselectedIconThemeColor));
}); });
testWidgetsWithLeakTracking('iconTheme color should override itemColor for BottomNavigationBarType.shifted', (WidgetTester tester) async { testWidgets('iconTheme color should override itemColor for BottomNavigationBarType.shifted', (WidgetTester tester) async {
const Color primaryColor = Color(0xFF000000); const Color primaryColor = Color(0xFF000000);
const Color unselectedWidgetColor = Color(0xFFD501FF); const Color unselectedWidgetColor = Color(0xFFD501FF);
const Color selectedLabelColor = Color(0xFFFF9900); const Color selectedLabelColor = Color(0xFFFF9900);
@ -867,7 +866,7 @@ void main() {
expect(unselectedIcon.color, equals(unselectedIconThemeColor)); expect(unselectedIcon.color, equals(unselectedIconThemeColor));
}); });
testWidgetsWithLeakTracking('iconTheme color should override itemColor color for BottomNavigationBarType.fixed', (WidgetTester tester) async { testWidgets('iconTheme color should override itemColor color for BottomNavigationBarType.fixed', (WidgetTester tester) async {
const Color primaryColor = Color(0xFF000000); const Color primaryColor = Color(0xFF000000);
const Color unselectedWidgetColor = Color(0xFFD501FF); const Color unselectedWidgetColor = Color(0xFFD501FF);
const Color selectedIconThemeColor = Color(0xFF1E7723); const Color selectedIconThemeColor = Color(0xFF1E7723);
@ -909,7 +908,7 @@ void main() {
expect(unselectedIcon.color, equals(unselectedIconThemeColor)); expect(unselectedIcon.color, equals(unselectedIconThemeColor));
}); });
testWidgetsWithLeakTracking('iconTheme color should override itemColor for BottomNavigationBarType.shifted', (WidgetTester tester) async { testWidgets('iconTheme color should override itemColor for BottomNavigationBarType.shifted', (WidgetTester tester) async {
const Color primaryColor = Color(0xFF000000); const Color primaryColor = Color(0xFF000000);
const Color unselectedWidgetColor = Color(0xFFD501FF); const Color unselectedWidgetColor = Color(0xFFD501FF);
const Color selectedColor = Color(0xFF0004FF); const Color selectedColor = Color(0xFF0004FF);
@ -955,7 +954,7 @@ void main() {
expect(unselectedIcon.color, equals(unselectedIconThemeColor)); expect(unselectedIcon.color, equals(unselectedIconThemeColor));
}); });
testWidgetsWithLeakTracking('Fixed BottomNavigationBar can hide unselected labels', (WidgetTester tester) async { testWidgets('Fixed BottomNavigationBar can hide unselected labels', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
@ -981,7 +980,7 @@ void main() {
expect(_getOpacity(tester, 'Alarm'), equals(0.0)); expect(_getOpacity(tester, 'Alarm'), equals(0.0));
}); });
testWidgetsWithLeakTracking('Fixed BottomNavigationBar can update background color', (WidgetTester tester) async { testWidgets('Fixed BottomNavigationBar can update background color', (WidgetTester tester) async {
const Color color = Colors.yellow; const Color color = Colors.yellow;
await tester.pumpWidget( await tester.pumpWidget(
@ -1008,7 +1007,7 @@ void main() {
expect(_getMaterial(tester).color, equals(color)); expect(_getMaterial(tester).color, equals(color));
}); });
testWidgetsWithLeakTracking('Shifting BottomNavigationBar background color is overridden by item color', (WidgetTester tester) async { testWidgets('Shifting BottomNavigationBar background color is overridden by item color', (WidgetTester tester) async {
const Color itemColor = Colors.yellow; const Color itemColor = Colors.yellow;
const Color backgroundColor = Colors.blue; const Color backgroundColor = Colors.blue;
@ -1037,7 +1036,7 @@ void main() {
expect(_getMaterial(tester).color, equals(itemColor)); expect(_getMaterial(tester).color, equals(itemColor));
}); });
testWidgetsWithLeakTracking('Specifying both selectedItemColor and fixedColor asserts', (WidgetTester tester) async { testWidgets('Specifying both selectedItemColor and fixedColor asserts', (WidgetTester tester) async {
expect( expect(
() { () {
return BottomNavigationBar( return BottomNavigationBar(
@ -1059,7 +1058,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Fixed BottomNavigationBar uses fixedColor when selectedItemColor not provided', (WidgetTester tester) async { testWidgets('Fixed BottomNavigationBar uses fixedColor when selectedItemColor not provided', (WidgetTester tester) async {
const Color fixedColor = Colors.black; const Color fixedColor = Colors.black;
await tester.pumpWidget( await tester.pumpWidget(
@ -1086,7 +1085,7 @@ void main() {
expect(tester.renderObject<RenderParagraph>(find.text('AC')).text.style!.color, equals(fixedColor)); expect(tester.renderObject<RenderParagraph>(find.text('AC')).text.style!.color, equals(fixedColor));
}); });
testWidgetsWithLeakTracking('setting selectedFontSize to zero hides all labels', (WidgetTester tester) async { testWidgets('setting selectedFontSize to zero hides all labels', (WidgetTester tester) async {
const double customElevation = 3.0; const double customElevation = 3.0;
await tester.pumpWidget( await tester.pumpWidget(
@ -1113,7 +1112,7 @@ void main() {
expect(_getMaterial(tester).elevation, equals(customElevation)); expect(_getMaterial(tester).elevation, equals(customElevation));
}); });
testWidgetsWithLeakTracking('Material2 - BottomNavigationBar adds bottom padding to height', (WidgetTester tester) async { testWidgets('Material2 - BottomNavigationBar adds bottom padding to height', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
@ -1141,7 +1140,7 @@ void main() {
expect(tester.getSize(find.byType(BottomNavigationBar)).height, expectedHeight); expect(tester.getSize(find.byType(BottomNavigationBar)).height, expectedHeight);
}); });
testWidgetsWithLeakTracking('Material3 - BottomNavigationBar adds bottom padding to height', (WidgetTester tester) async { testWidgets('Material3 - BottomNavigationBar adds bottom padding to height', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: MediaQuery( home: MediaQuery(
@ -1168,7 +1167,7 @@ void main() {
expect(tester.getSize(find.byType(BottomNavigationBar)).height >= expectedMinHeight, isTrue); expect(tester.getSize(find.byType(BottomNavigationBar)).height >= expectedMinHeight, isTrue);
}); });
testWidgetsWithLeakTracking('BottomNavigationBar adds bottom padding to height with a custom font size', (WidgetTester tester) async { testWidgets('BottomNavigationBar adds bottom padding to height with a custom font size', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: MediaQuery( home: MediaQuery(
@ -1196,7 +1195,7 @@ void main() {
expect(tester.getSize(find.byType(BottomNavigationBar)).height, expectedHeight); expect(tester.getSize(find.byType(BottomNavigationBar)).height, expectedHeight);
}); });
testWidgetsWithLeakTracking('BottomNavigationBar height will not change when toggle keyboard', (WidgetTester tester) async { testWidgets('BottomNavigationBar height will not change when toggle keyboard', (WidgetTester tester) async {
final Widget child = Scaffold( final Widget child = Scaffold(
bottomNavigationBar: BottomNavigationBar( bottomNavigationBar: BottomNavigationBar(
@ -1248,7 +1247,7 @@ void main() {
expect(tester.getSize(find.byType(BottomNavigationBar)).height, expectedHeight); expect(tester.getSize(find.byType(BottomNavigationBar)).height, expectedHeight);
}); });
testWidgetsWithLeakTracking('BottomNavigationBar action size test', (WidgetTester tester) async { testWidgets('BottomNavigationBar action size test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
@ -1303,7 +1302,7 @@ void main() {
expect(actions.elementAt(1).size.width, 480.0); expect(actions.elementAt(1).size.width, 480.0);
}); });
testWidgetsWithLeakTracking('BottomNavigationBar multiple taps test', (WidgetTester tester) async { testWidgets('BottomNavigationBar multiple taps test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
@ -1361,7 +1360,7 @@ void main() {
expect(actions.elementAt(3).localToGlobal(Offset.zero), equals(originalOrigin)); expect(actions.elementAt(3).localToGlobal(Offset.zero), equals(originalOrigin));
}); });
testWidgetsWithLeakTracking('BottomNavigationBar inherits shadowed app theme for shifting navbar', (WidgetTester tester) async { testWidgets('BottomNavigationBar inherits shadowed app theme for shifting navbar', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(brightness: Brightness.light), theme: ThemeData(brightness: Brightness.light),
@ -1399,7 +1398,7 @@ void main() {
expect(Theme.of(tester.element(find.text('Alarm'))).brightness, equals(Brightness.dark)); expect(Theme.of(tester.element(find.text('Alarm'))).brightness, equals(Brightness.dark));
}); });
testWidgetsWithLeakTracking('BottomNavigationBar inherits shadowed app theme for fixed navbar', (WidgetTester tester) async { testWidgets('BottomNavigationBar inherits shadowed app theme for fixed navbar', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(brightness: Brightness.light), theme: ThemeData(brightness: Brightness.light),
@ -1437,7 +1436,7 @@ void main() {
expect(Theme.of(tester.element(find.text('Alarm'))).brightness, equals(Brightness.dark)); expect(Theme.of(tester.element(find.text('Alarm'))).brightness, equals(Brightness.dark));
}); });
testWidgetsWithLeakTracking('BottomNavigationBar iconSize test', (WidgetTester tester) async { testWidgets('BottomNavigationBar iconSize test', (WidgetTester tester) async {
late double builderIconSize; late double builderIconSize;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -1473,7 +1472,7 @@ void main() {
expect(builderIconSize, 12.0); expect(builderIconSize, 12.0);
}); });
testWidgetsWithLeakTracking('Material2 - BottomNavigationBar responds to textScaleFactor', (WidgetTester tester) async { testWidgets('Material2 - BottomNavigationBar responds to textScaleFactor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
@ -1543,7 +1542,7 @@ void main() {
expect(box.size.height, equals(56.0)); expect(box.size.height, equals(56.0));
}); });
testWidgetsWithLeakTracking('Material3 - BottomNavigationBar responds to textScaleFactor', (WidgetTester tester) async { testWidgets('Material3 - BottomNavigationBar responds to textScaleFactor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
@ -1617,7 +1616,7 @@ void main() {
expect(box.size.height, greaterThanOrEqualTo(kBottomNavigationBarHeight)); expect(box.size.height, greaterThanOrEqualTo(kBottomNavigationBarHeight));
}); });
testWidgetsWithLeakTracking('Material2 - BottomNavigationBar does not grow with textScaleFactor when labels are provided', (WidgetTester tester) async { testWidgets('Material2 - BottomNavigationBar does not grow with textScaleFactor when labels are provided', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
@ -1691,7 +1690,7 @@ void main() {
expect(box.size.height, equals(kBottomNavigationBarHeight)); expect(box.size.height, equals(kBottomNavigationBarHeight));
}); });
testWidgetsWithLeakTracking('Material3 - BottomNavigationBar does not grow with textScaleFactor when labels are provided', (WidgetTester tester) async { testWidgets('Material3 - BottomNavigationBar does not grow with textScaleFactor when labels are provided', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
@ -1767,7 +1766,7 @@ void main() {
expect(box.size.height, equals(shiftingBox.size.height)); expect(box.size.height, equals(shiftingBox.size.height));
}); });
testWidgetsWithLeakTracking('Material2 - BottomNavigationBar shows tool tips with text scaling on long press when labels are provided', (WidgetTester tester) async { testWidgets('Material2 - BottomNavigationBar shows tool tips with text scaling on long press when labels are provided', (WidgetTester tester) async {
const String label = 'Foo'; const String label = 'Foo';
Widget buildApp({ required double textScaleFactor }) { Widget buildApp({ required double textScaleFactor }) {
@ -1825,7 +1824,7 @@ void main() {
expect(tester.getSize(find.text(label).last), equals(const Size(168.0, 56.0))); expect(tester.getSize(find.text(label).last), equals(const Size(168.0, 56.0)));
}); });
testWidgetsWithLeakTracking('Material3 - BottomNavigationBar shows tool tips with text scaling on long press when labels are provided', (WidgetTester tester) async { testWidgets('Material3 - BottomNavigationBar shows tool tips with text scaling on long press when labels are provided', (WidgetTester tester) async {
const String label = 'Foo'; const String label = 'Foo';
Widget buildApp({ required double textScaleFactor }) { Widget buildApp({ required double textScaleFactor }) {
@ -1882,7 +1881,7 @@ void main() {
expect(tester.getSize(find.text(label).last).height, equals(80.0)); expect(tester.getSize(find.text(label).last).height, equals(80.0));
}, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933 }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
testWidgetsWithLeakTracking('Different behaviour of tool tip in BottomNavigationBarItem', (WidgetTester tester) async { testWidgets('Different behaviour of tool tip in BottomNavigationBarItem', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
@ -1921,7 +1920,7 @@ void main() {
expect(find.byTooltip('C'), findsNothing); expect(find.byTooltip('C'), findsNothing);
}); });
testWidgetsWithLeakTracking('BottomNavigationBar limits width of tiles with long labels', (WidgetTester tester) async { testWidgets('BottomNavigationBar limits width of tiles with long labels', (WidgetTester tester) async {
final String longTextA = List<String>.generate(100, (int index) => 'A').toString(); final String longTextA = List<String>.generate(100, (int index) => 'A').toString();
final String longTextB = List<String>.generate(100, (int index) => 'B').toString(); final String longTextB = List<String>.generate(100, (int index) => 'B').toString();
@ -1953,7 +1952,7 @@ void main() {
expect(itemBoxB.size.width, equals(400.0)); expect(itemBoxB.size.width, equals(400.0));
}); });
testWidgetsWithLeakTracking('Material2 - BottomNavigationBar paints circles', (WidgetTester tester) async { testWidgets('Material2 - BottomNavigationBar paints circles', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
useMaterial3: false, useMaterial3: false,
@ -2025,7 +2024,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('BottomNavigationBar inactiveIcon shown', (WidgetTester tester) async { testWidgets('BottomNavigationBar inactiveIcon shown', (WidgetTester tester) async {
const Key filled = Key('filled'); const Key filled = Key('filled');
const Key stroked = Key('stroked'); const Key stroked = Key('stroked');
int selectedItem = 0; int selectedItem = 0;
@ -2078,7 +2077,7 @@ void main() {
expect(find.byKey(stroked), findsOneWidget); expect(find.byKey(stroked), findsOneWidget);
}); });
testWidgetsWithLeakTracking('BottomNavigationBar.fixed semantics', (WidgetTester tester) async { testWidgets('BottomNavigationBar.fixed semantics', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -2131,7 +2130,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('BottomNavigationBar.shifting semantics', (WidgetTester tester) async { testWidgets('BottomNavigationBar.shifting semantics', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -2185,7 +2184,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('BottomNavigationBar handles items.length changes', (WidgetTester tester) async { testWidgets('BottomNavigationBar handles items.length changes', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/10322 // Regression test for https://github.com/flutter/flutter/issues/10322
Widget buildFrame(int itemCount) { Widget buildFrame(int itemCount) {
@ -2223,7 +2222,7 @@ void main() {
expect(find.text('item 3'), findsNothing); expect(find.text('item 3'), findsNothing);
}); });
testWidgetsWithLeakTracking('BottomNavigationBar change backgroundColor test', (WidgetTester tester) async { testWidgets('BottomNavigationBar change backgroundColor test', (WidgetTester tester) async {
// Regression test for: https://github.com/flutter/flutter/issues/19653 // Regression test for: https://github.com/flutter/flutter/issues/19653
Color backgroundColor = Colors.red; Color backgroundColor = Colors.red;
@ -2320,7 +2319,7 @@ void main() {
); );
} }
for (int pump = 1; pump < 9; pump++) { for (int pump = 1; pump < 9; pump++) {
testWidgetsWithLeakTracking('pump $pump', (WidgetTester tester) async { testWidgets('pump $pump', (WidgetTester tester) async {
await tester.pumpWidget(runTest()); await tester.pumpWidget(runTest());
await tester.tap(find.text('Green')); await tester.tap(find.text('Green'));
@ -2373,7 +2372,7 @@ void main() {
); );
} }
for (int pump = 1; pump < 9; pump++) { for (int pump = 1; pump < 9; pump++) {
testWidgetsWithLeakTracking('pump $pump', (WidgetTester tester) async { testWidgets('pump $pump', (WidgetTester tester) async {
await tester.pumpWidget(runTest()); await tester.pumpWidget(runTest());
await tester.tap(find.text('Green')); await tester.tap(find.text('Green'));
@ -2388,7 +2387,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('BottomNavigationBar item label should not be nullable', (WidgetTester tester) async { testWidgets('BottomNavigationBar item label should not be nullable', (WidgetTester tester) async {
expect(() { expect(() {
MaterialApp( MaterialApp(
home: Scaffold( home: Scaffold(
@ -2409,7 +2408,7 @@ void main() {
}, throwsAssertionError); }, throwsAssertionError);
}); });
testWidgetsWithLeakTracking( testWidgets(
'BottomNavigationBar [showSelectedLabels]=false and [showUnselectedLabels]=false ' 'BottomNavigationBar [showSelectedLabels]=false and [showUnselectedLabels]=false '
'for shifting navbar, expect that there is no rendered text', 'for shifting navbar, expect that there is no rendered text',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -2446,7 +2445,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'BottomNavigationBar [showSelectedLabels]=false and [showUnselectedLabels]=false ' 'BottomNavigationBar [showSelectedLabels]=false and [showUnselectedLabels]=false '
'for fixed navbar, expect that there is no rendered text', 'for fixed navbar, expect that there is no rendered text',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -2484,7 +2483,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('BottomNavigationBar.fixed [showSelectedLabels]=false and [showUnselectedLabels]=false semantics', (WidgetTester tester) async { testWidgets('BottomNavigationBar.fixed [showSelectedLabels]=false and [showUnselectedLabels]=false semantics', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -2526,7 +2525,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('BottomNavigationBar.shifting [showSelectedLabels]=false and [showUnselectedLabels]=false semantics', (WidgetTester tester) async { testWidgets('BottomNavigationBar.shifting [showSelectedLabels]=false and [showUnselectedLabels]=false semantics', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
boilerplate( boilerplate(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -2569,7 +2568,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('BottomNavigationBar changes mouse cursor when the tile is hovered over', (WidgetTester tester) async { testWidgets('BottomNavigationBar changes mouse cursor when the tile is hovered over', (WidgetTester tester) async {
// Test BottomNavigationBar() constructor // Test BottomNavigationBar() constructor
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -2645,7 +2644,7 @@ void main() {
); );
} }
testWidgetsWithLeakTracking('BottomNavigationBar with enabled feedback', (WidgetTester tester) async { testWidgets('BottomNavigationBar with enabled feedback', (WidgetTester tester) async {
const bool enableFeedback = true; const bool enableFeedback = true;
await tester.pumpWidget(feedbackBoilerplate(enableFeedback: enableFeedback)); await tester.pumpWidget(feedbackBoilerplate(enableFeedback: enableFeedback));
@ -2656,7 +2655,7 @@ void main() {
expect(feedback.hapticCount, 0); expect(feedback.hapticCount, 0);
}); });
testWidgetsWithLeakTracking('BottomNavigationBar with disabled feedback', (WidgetTester tester) async { testWidgets('BottomNavigationBar with disabled feedback', (WidgetTester tester) async {
const bool enableFeedback = false; const bool enableFeedback = false;
await tester.pumpWidget(feedbackBoilerplate(enableFeedback: enableFeedback)); await tester.pumpWidget(feedbackBoilerplate(enableFeedback: enableFeedback));
@ -2667,7 +2666,7 @@ void main() {
expect(feedback.hapticCount, 0); expect(feedback.hapticCount, 0);
}); });
testWidgetsWithLeakTracking('BottomNavigationBar with enabled feedback by default', (WidgetTester tester) async { testWidgets('BottomNavigationBar with enabled feedback by default', (WidgetTester tester) async {
await tester.pumpWidget(feedbackBoilerplate()); await tester.pumpWidget(feedbackBoilerplate());
await tester.tap(find.byType(InkResponse).first); await tester.tap(find.byType(InkResponse).first);
@ -2676,7 +2675,7 @@ void main() {
expect(feedback.hapticCount, 0); expect(feedback.hapticCount, 0);
}); });
testWidgetsWithLeakTracking('BottomNavigationBar with disabled feedback using BottomNavigationBarTheme', (WidgetTester tester) async { testWidgets('BottomNavigationBar with disabled feedback using BottomNavigationBarTheme', (WidgetTester tester) async {
const bool enableFeedbackTheme = false; const bool enableFeedbackTheme = false;
await tester.pumpWidget(feedbackBoilerplate(enableFeedbackTheme: enableFeedbackTheme)); await tester.pumpWidget(feedbackBoilerplate(enableFeedbackTheme: enableFeedbackTheme));
@ -2687,7 +2686,7 @@ void main() {
expect(feedback.hapticCount, 0); expect(feedback.hapticCount, 0);
}); });
testWidgetsWithLeakTracking('BottomNavigationBar.enableFeedback overrides BottomNavigationBarTheme.enableFeedback', (WidgetTester tester) async { testWidgets('BottomNavigationBar.enableFeedback overrides BottomNavigationBarTheme.enableFeedback', (WidgetTester tester) async {
const bool enableFeedbackTheme = false; const bool enableFeedbackTheme = false;
const bool enableFeedback = true; const bool enableFeedback = true;
@ -2703,7 +2702,7 @@ void main() {
}); });
}); });
testWidgetsWithLeakTracking('BottomNavigationBar excludes semantics', (WidgetTester tester) async { testWidgets('BottomNavigationBar excludes semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget( await tester.pumpWidget(
@ -2774,7 +2773,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Material2 - BottomNavigationBar default layout', (WidgetTester tester) async { testWidgets('Material2 - BottomNavigationBar default layout', (WidgetTester tester) async {
final Key icon0 = UniqueKey(); final Key icon0 = UniqueKey();
final Key icon1 = UniqueKey(); final Key icon1 = UniqueKey();
@ -2822,7 +2821,7 @@ void main() {
expect(tester.getRect(find.byKey(icon1)), const Rect.fromLTRB(500.0, 560.0, 700.0, 570.0)); expect(tester.getRect(find.byKey(icon1)), const Rect.fromLTRB(500.0, 560.0, 700.0, 570.0));
}); });
testWidgetsWithLeakTracking('Material3 - BottomNavigationBar default layout', (WidgetTester tester) async { testWidgets('Material3 - BottomNavigationBar default layout', (WidgetTester tester) async {
final Key icon0 = UniqueKey(); final Key icon0 = UniqueKey();
final Key icon1 = UniqueKey(); final Key icon1 = UniqueKey();
const double iconHeight = 10; const double iconHeight = 10;
@ -2889,7 +2888,7 @@ void main() {
expect(tester.getRect(find.byKey(icon1)), Rect.fromLTRB(500.0, iconTop, 700.0, iconTop + iconHeight)); expect(tester.getRect(find.byKey(icon1)), Rect.fromLTRB(500.0, iconTop, 700.0, iconTop + iconHeight));
}, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933 }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
testWidgetsWithLeakTracking('Material2 - BottomNavigationBar centered landscape layout', (WidgetTester tester) async { testWidgets('Material2 - BottomNavigationBar centered landscape layout', (WidgetTester tester) async {
final Key icon0 = UniqueKey(); final Key icon0 = UniqueKey();
final Key icon1 = UniqueKey(); final Key icon1 = UniqueKey();
@ -2935,7 +2934,7 @@ void main() {
expect(tester.getRect(find.byKey(icon1)), const Rect.fromLTRB(450.0, 560.0, 650.0, 570.0)); expect(tester.getRect(find.byKey(icon1)), const Rect.fromLTRB(450.0, 560.0, 650.0, 570.0));
}); });
testWidgetsWithLeakTracking('Material3 - BottomNavigationBar centered landscape layout', (WidgetTester tester) async { testWidgets('Material3 - BottomNavigationBar centered landscape layout', (WidgetTester tester) async {
final Key icon0 = UniqueKey(); final Key icon0 = UniqueKey();
final Key icon1 = UniqueKey(); final Key icon1 = UniqueKey();
const double iconWidth = 200; const double iconWidth = 200;
@ -3008,7 +3007,7 @@ void main() {
expect(tester.getRect(find.byKey(icon1)), Rect.fromLTRB(450.0, iconTop, 650.0, iconTop + iconHeight)); expect(tester.getRect(find.byKey(icon1)), Rect.fromLTRB(450.0, iconTop, 650.0, iconTop + iconHeight));
}, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933 }, skip: kIsWeb && !isCanvasKit); // https://github.com/flutter/flutter/issues/99933
testWidgetsWithLeakTracking('Material2 - BottomNavigationBar linear landscape layout', (WidgetTester tester) async { testWidgets('Material2 - BottomNavigationBar linear landscape layout', (WidgetTester tester) async {
final Key icon0 = UniqueKey(); final Key icon0 = UniqueKey();
final Key icon1 = UniqueKey(); final Key icon1 = UniqueKey();
@ -3049,7 +3048,7 @@ void main() {
expect(tester.getRect(find.byKey(icon1)), const Rect.fromLTRB(504.0, 562.0, 604.0, 582.0)); expect(tester.getRect(find.byKey(icon1)), const Rect.fromLTRB(504.0, 562.0, 604.0, 582.0));
}); });
testWidgetsWithLeakTracking('Material3 - BottomNavigationBar linear landscape layout', (WidgetTester tester) async { testWidgets('Material3 - BottomNavigationBar linear landscape layout', (WidgetTester tester) async {
final Key icon0 = UniqueKey(); final Key icon0 = UniqueKey();
final Key icon1 = UniqueKey(); final Key icon1 = UniqueKey();
const double iconWidth = 100; const double iconWidth = 100;

View File

@ -6,7 +6,6 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'package:vector_math/vector_math_64.dart' show Vector3; import 'package:vector_math/vector_math_64.dart' show Vector3;
@ -53,7 +52,7 @@ void main() {
expect(themeData.mouseCursor, null); expect(themeData.mouseCursor, null);
}); });
testWidgetsWithLeakTracking('Default BottomNavigationBarThemeData debugFillProperties', (WidgetTester tester) async { testWidgets('Default BottomNavigationBarThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const BottomNavigationBarThemeData().debugFillProperties(builder); const BottomNavigationBarThemeData().debugFillProperties(builder);
@ -65,7 +64,7 @@ void main() {
expect(description, <String>[]); expect(description, <String>[]);
}); });
testWidgetsWithLeakTracking('BottomNavigationBarThemeData implements debugFillProperties', (WidgetTester tester) async { testWidgets('BottomNavigationBarThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const BottomNavigationBarThemeData( const BottomNavigationBarThemeData(
backgroundColor: Color(0xfffffff0), backgroundColor: Color(0xfffffff0),
@ -106,7 +105,7 @@ void main() {
expect(description[11], 'mouseCursor: MaterialStateMouseCursor(clickable)'); expect(description[11], 'mouseCursor: MaterialStateMouseCursor(clickable)');
}); });
testWidgetsWithLeakTracking('BottomNavigationBar is themeable', (WidgetTester tester) async { testWidgets('BottomNavigationBar is themeable', (WidgetTester tester) async {
const Color backgroundColor = Color(0xFF000001); const Color backgroundColor = Color(0xFF000001);
const Color selectedItemColor = Color(0xFF000002); const Color selectedItemColor = Color(0xFF000002);
const Color unselectedItemColor = Color(0xFF000003); const Color unselectedItemColor = Color(0xFF000003);
@ -210,7 +209,7 @@ void main() {
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.move); expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.move);
}); });
testWidgetsWithLeakTracking('BottomNavigationBar properties are taken over the theme values', (WidgetTester tester) async { testWidgets('BottomNavigationBar properties are taken over the theme values', (WidgetTester tester) async {
const Color themeBackgroundColor = Color(0xFF000001); const Color themeBackgroundColor = Color(0xFF000001);
const Color themeSelectedItemColor = Color(0xFF000002); const Color themeSelectedItemColor = Color(0xFF000002);
const Color themeUnselectedItemColor = Color(0xFF000003); const Color themeUnselectedItemColor = Color(0xFF000003);
@ -337,7 +336,7 @@ void main() {
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text); expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.text);
}); });
testWidgetsWithLeakTracking('BottomNavigationBarTheme can be used to hide all labels', (WidgetTester tester) async { testWidgets('BottomNavigationBarTheme can be used to hide all labels', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/66738. // Regression test for https://github.com/flutter/flutter/issues/66738.
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -375,7 +374,7 @@ void main() {
expect(tester.widget<Visibility>(findVisibility.at(1)).visible, false); expect(tester.widget<Visibility>(findVisibility.at(1)).visible, false);
}); });
testWidgetsWithLeakTracking('BottomNavigationBarTheme can be used to hide selected labels', (WidgetTester tester) async { testWidgets('BottomNavigationBarTheme can be used to hide selected labels', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/66738. // Regression test for https://github.com/flutter/flutter/issues/66738.
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -413,7 +412,7 @@ void main() {
expect(tester.widget<FadeTransition>(findFadeTransition.at(1)).opacity.value, 1.0); expect(tester.widget<FadeTransition>(findFadeTransition.at(1)).opacity.value, 1.0);
}); });
testWidgetsWithLeakTracking('BottomNavigationBarTheme can be used to hide unselected labels', (WidgetTester tester) async { testWidgets('BottomNavigationBarTheme can be used to hide unselected labels', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData( theme: ThemeData(

View File

@ -7,7 +7,6 @@ import 'dart:ui';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
@ -27,7 +26,7 @@ void main() {
expect(dyDelta1, isNot(moreOrLessEquals(dyDelta2, epsilon: 0.1))); expect(dyDelta1, isNot(moreOrLessEquals(dyDelta2, epsilon: 0.1)));
} }
testWidgetsWithLeakTracking('Throw if enable drag without an animation controller', (WidgetTester tester) async { testWidgets('Throw if enable drag without an animation controller', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/89168 // Regression test for https://github.com/flutter/flutter/issues/89168
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -54,7 +53,7 @@ void main() {
FlutterError.onError = handler; FlutterError.onError = handler;
}); });
testWidgetsWithLeakTracking('Disposing app while bottom sheet is disappearing does not crash', (WidgetTester tester) async { testWidgets('Disposing app while bottom sheet is disappearing does not crash', (WidgetTester tester) async {
late BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget( await tester.pumpWidget(
@ -91,7 +90,7 @@ void main() {
await tester.pumpWidget(Container()); await tester.pumpWidget(Container());
}); });
testWidgetsWithLeakTracking('Swiping down a BottomSheet should dismiss it by default', (WidgetTester tester) async { testWidgets('Swiping down a BottomSheet should dismiss it by default', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
bool showBottomSheetThenCalled = false; bool showBottomSheetThenCalled = false;
@ -126,7 +125,7 @@ void main() {
expect(find.text('BottomSheet'), findsNothing); expect(find.text('BottomSheet'), findsNothing);
}); });
testWidgetsWithLeakTracking('Swiping down a BottomSheet should not dismiss it when enableDrag is false', (WidgetTester tester) async { testWidgets('Swiping down a BottomSheet should not dismiss it when enableDrag is false', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
bool showBottomSheetThenCalled = false; bool showBottomSheetThenCalled = false;
@ -163,7 +162,7 @@ void main() {
expect(find.text('BottomSheet'), findsOneWidget); expect(find.text('BottomSheet'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Swiping down a BottomSheet should dismiss it when enableDrag is true', (WidgetTester tester) async { testWidgets('Swiping down a BottomSheet should dismiss it when enableDrag is true', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
bool showBottomSheetThenCalled = false; bool showBottomSheetThenCalled = false;
@ -200,7 +199,7 @@ void main() {
expect(find.text('BottomSheet'), findsNothing); expect(find.text('BottomSheet'), findsNothing);
}); });
testWidgetsWithLeakTracking('Tapping on a BottomSheet should not trigger a rebuild when enableDrag is true', (WidgetTester tester) async { testWidgets('Tapping on a BottomSheet should not trigger a rebuild when enableDrag is true', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/126833. // Regression test for https://github.com/flutter/flutter/issues/126833.
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
int buildCount = 0; int buildCount = 0;
@ -237,7 +236,7 @@ void main() {
expect(find.text('BottomSheet'), findsOneWidget); expect(find.text('BottomSheet'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Modal BottomSheet builder should only be called once', (WidgetTester tester) async { testWidgets('Modal BottomSheet builder should only be called once', (WidgetTester tester) async {
late BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -268,7 +267,7 @@ void main() {
expect(numBuilderCalls, 1); expect(numBuilderCalls, 1);
}); });
testWidgetsWithLeakTracking('Tapping on a modal BottomSheet should not dismiss it', (WidgetTester tester) async { testWidgets('Tapping on a modal BottomSheet should not dismiss it', (WidgetTester tester) async {
late BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget( await tester.pumpWidget(
@ -304,7 +303,7 @@ void main() {
expect(showBottomSheetThenCalled, isFalse); expect(showBottomSheetThenCalled, isFalse);
}); });
testWidgetsWithLeakTracking('Tapping outside a modal BottomSheet should dismiss it by default', (WidgetTester tester) async { testWidgets('Tapping outside a modal BottomSheet should dismiss it by default', (WidgetTester tester) async {
late BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -338,7 +337,7 @@ void main() {
expect(find.text('BottomSheet'), findsNothing); expect(find.text('BottomSheet'), findsNothing);
}); });
testWidgetsWithLeakTracking('Tapping outside a modal BottomSheet should dismiss it when isDismissible=true', (WidgetTester tester) async { testWidgets('Tapping outside a modal BottomSheet should dismiss it when isDismissible=true', (WidgetTester tester) async {
late BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -372,7 +371,7 @@ void main() {
expect(find.text('BottomSheet'), findsNothing); expect(find.text('BottomSheet'), findsNothing);
}); });
testWidgetsWithLeakTracking('Verify that the BottomSheet animates non-linearly', (WidgetTester tester) async { testWidgets('Verify that the BottomSheet animates non-linearly', (WidgetTester tester) async {
late BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -405,7 +404,7 @@ void main() {
}); });
// Regression test for https://github.com/flutter/flutter/issues/121098 // Regression test for https://github.com/flutter/flutter/issues/121098
testWidgetsWithLeakTracking('Verify that accessibleNavigation has no impact on the BottomSheet animation', (WidgetTester tester) async { testWidgets('Verify that accessibleNavigation has no impact on the BottomSheet animation', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
return MediaQuery( return MediaQuery(
@ -430,7 +429,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Tapping outside a modal BottomSheet should not dismiss it when isDismissible=false', (WidgetTester tester) async { testWidgets('Tapping outside a modal BottomSheet should not dismiss it when isDismissible=false', (WidgetTester tester) async {
late BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget( await tester.pumpWidget(
@ -467,7 +466,7 @@ void main() {
expect(find.text('BottomSheet'), findsOneWidget); expect(find.text('BottomSheet'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Swiping down a modal BottomSheet should dismiss it by default', (WidgetTester tester) async { testWidgets('Swiping down a modal BottomSheet should dismiss it by default', (WidgetTester tester) async {
late BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -502,7 +501,7 @@ void main() {
expect(find.text('BottomSheet'), findsNothing); expect(find.text('BottomSheet'), findsNothing);
}); });
testWidgetsWithLeakTracking('Swiping down a modal BottomSheet should not dismiss it when enableDrag is false', (WidgetTester tester) async { testWidgets('Swiping down a modal BottomSheet should not dismiss it when enableDrag is false', (WidgetTester tester) async {
late BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -538,7 +537,7 @@ void main() {
expect(find.text('BottomSheet'), findsOneWidget); expect(find.text('BottomSheet'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Swiping down a modal BottomSheet should dismiss it when enableDrag is true', (WidgetTester tester) async { testWidgets('Swiping down a modal BottomSheet should dismiss it when enableDrag is true', (WidgetTester tester) async {
late BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -573,7 +572,7 @@ void main() {
expect(find.text('BottomSheet'), findsNothing); expect(find.text('BottomSheet'), findsNothing);
}); });
testWidgetsWithLeakTracking('Modal BottomSheet builder should only be called once', (WidgetTester tester) async { testWidgets('Modal BottomSheet builder should only be called once', (WidgetTester tester) async {
late BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -604,7 +603,7 @@ void main() {
expect(numBuilderCalls, 1); expect(numBuilderCalls, 1);
}); });
testWidgetsWithLeakTracking('Verify that a downwards fling dismisses a persistent BottomSheet', (WidgetTester tester) async { testWidgets('Verify that a downwards fling dismisses a persistent BottomSheet', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
bool showBottomSheetThenCalled = false; bool showBottomSheetThenCalled = false;
@ -661,7 +660,7 @@ void main() {
expect(find.text('BottomSheet'), findsNothing); expect(find.text('BottomSheet'), findsNothing);
}); });
testWidgetsWithLeakTracking('Verify that dragging past the bottom dismisses a persistent BottomSheet', (WidgetTester tester) async { testWidgets('Verify that dragging past the bottom dismisses a persistent BottomSheet', (WidgetTester tester) async {
// This is a regression test for https://github.com/flutter/flutter/issues/5528 // This is a regression test for https://github.com/flutter/flutter/issues/5528
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
@ -691,7 +690,7 @@ void main() {
expect(find.text('BottomSheet'), findsNothing); expect(find.text('BottomSheet'), findsNothing);
}); });
testWidgetsWithLeakTracking('modal BottomSheet has no top MediaQuery', (WidgetTester tester) async { testWidgets('modal BottomSheet has no top MediaQuery', (WidgetTester tester) async {
late BuildContext outerContext; late BuildContext outerContext;
late BuildContext innerContext; late BuildContext innerContext;
@ -742,7 +741,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('modal BottomSheet can insert a SafeArea', (WidgetTester tester) async { testWidgets('modal BottomSheet can insert a SafeArea', (WidgetTester tester) async {
late BuildContext outerContext; late BuildContext outerContext;
late BuildContext innerContext; late BuildContext innerContext;
@ -814,7 +813,7 @@ void main() {
expect(MediaQuery.of(innerContext).padding, const EdgeInsets.fromLTRB(0, 0, 0, 50.0)); expect(MediaQuery.of(innerContext).padding, const EdgeInsets.fromLTRB(0, 0, 0, 50.0));
}); });
testWidgetsWithLeakTracking('modal BottomSheet has semantics', (WidgetTester tester) async { testWidgets('modal BottomSheet has semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
@ -871,7 +870,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Verify that visual properties are passed through', (WidgetTester tester) async { testWidgets('Verify that visual properties are passed through', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
const Color color = Colors.pink; const Color color = Colors.pink;
const double elevation = 9.0; const double elevation = 9.0;
@ -911,7 +910,7 @@ void main() {
expect(modalBarrier.color, barrierColor); expect(modalBarrier.color, barrierColor);
}); });
testWidgetsWithLeakTracking('Material3 - BottomSheet uses fallback values', testWidgets('Material3 - BottomSheet uses fallback values',
(WidgetTester tester) async { (WidgetTester tester) async {
const Color surfaceColor = Colors.pink; const Color surfaceColor = Colors.pink;
const Color surfaceTintColor = Colors.blue; const Color surfaceTintColor = Colors.blue;
@ -951,7 +950,7 @@ void main() {
expect(tester.getSize(finder).width, 640); expect(tester.getSize(finder).width, 640);
}); });
testWidgetsWithLeakTracking('Material3 - BottomSheet has transparent shadow', (WidgetTester tester) async { testWidgets('Material3 - BottomSheet has transparent shadow', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData( theme: ThemeData(
useMaterial3: true, useMaterial3: true,
@ -975,7 +974,7 @@ void main() {
expect(material.shadowColor, Colors.transparent); expect(material.shadowColor, Colors.transparent);
}); });
testWidgetsWithLeakTracking('Material2 - Modal BottomSheet with ScrollController has semantics', (WidgetTester tester) async { testWidgets('Material2 - Modal BottomSheet with ScrollController has semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
@ -1048,7 +1047,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Material3 - Modal BottomSheet with ScrollController has semantics', (WidgetTester tester) async { testWidgets('Material3 - Modal BottomSheet with ScrollController has semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
@ -1125,7 +1124,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Material3 - Modal BottomSheet with drag handle has semantics', (WidgetTester tester) async { testWidgets('Material3 - Modal BottomSheet with drag handle has semantics', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
@ -1194,7 +1193,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Drag handle color can take MaterialStateProperty', (WidgetTester tester) async { testWidgets('Drag handle color can take MaterialStateProperty', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
const Color defaultColor=Colors.blue; const Color defaultColor=Colors.blue;
const Color hoveringColor=Colors.green; const Color hoveringColor=Colors.green;
@ -1256,7 +1255,7 @@ void main() {
expect(boxDecoration.color, hoveringColor); expect(boxDecoration.color, hoveringColor);
}); });
testWidgetsWithLeakTracking('showModalBottomSheet does not use root Navigator by default', (WidgetTester tester) async { testWidgets('showModalBottomSheet does not use root Navigator by default', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( home: Scaffold(
body: Navigator(onGenerateRoute: (RouteSettings settings) => MaterialPageRoute<void>(builder: (_) { body: Navigator(onGenerateRoute: (RouteSettings settings) => MaterialPageRoute<void>(builder: (_) {
@ -1286,7 +1285,7 @@ void main() {
expect(tester.getBottomLeft(find.byType(BottomSheet)).dy, 600 - tabBarHeight); expect(tester.getBottomLeft(find.byType(BottomSheet)).dy, 600 - tabBarHeight);
}); });
testWidgetsWithLeakTracking('showModalBottomSheet uses root Navigator when specified', (WidgetTester tester) async { testWidgets('showModalBottomSheet uses root Navigator when specified', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( home: Scaffold(
body: Navigator(onGenerateRoute: (RouteSettings settings) => MaterialPageRoute<void>(builder: (_) { body: Navigator(onGenerateRoute: (RouteSettings settings) => MaterialPageRoute<void>(builder: (_) {
@ -1315,7 +1314,7 @@ void main() {
expect(tester.getBottomLeft(find.byType(BottomSheet)).dy, 600.0); expect(tester.getBottomLeft(find.byType(BottomSheet)).dy, 600.0);
}); });
testWidgetsWithLeakTracking('Verify that route settings can be set in the showModalBottomSheet', (WidgetTester tester) async { testWidgets('Verify that route settings can be set in the showModalBottomSheet', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
const RouteSettings routeSettings = RouteSettings(name: 'route_name', arguments: 'route_argument'); const RouteSettings routeSettings = RouteSettings(name: 'route_name', arguments: 'route_argument');
@ -1343,7 +1342,7 @@ void main() {
expect(retrievedRouteSettings, routeSettings); expect(retrievedRouteSettings, routeSettings);
}); });
testWidgetsWithLeakTracking('Verify showModalBottomSheet use AnimationController if provided.', (WidgetTester tester) async { testWidgets('Verify showModalBottomSheet use AnimationController if provided.', (WidgetTester tester) async {
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
final AnimationController controller = AnimationController( final AnimationController controller = AnimationController(
vsync: const TestVSync(), vsync: const TestVSync(),
@ -1403,7 +1402,7 @@ void main() {
}); });
// Regression test for https://github.com/flutter/flutter/issues/87592 // Regression test for https://github.com/flutter/flutter/issues/87592
testWidgetsWithLeakTracking('the framework do not dispose the transitionAnimationController provided by user.', (WidgetTester tester) async { testWidgets('the framework do not dispose the transitionAnimationController provided by user.', (WidgetTester tester) async {
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
final AnimationController controller = AnimationController( final AnimationController controller = AnimationController(
vsync: const TestVSync(), vsync: const TestVSync(),
@ -1465,7 +1464,7 @@ void main() {
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
}); });
testWidgetsWithLeakTracking('Verify persistence BottomSheet use AnimationController if provided.', (WidgetTester tester) async { testWidgets('Verify persistence BottomSheet use AnimationController if provided.', (WidgetTester tester) async {
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
const Key tapTargetToClose = Key('tap-target-to-close'); const Key tapTargetToClose = Key('tap-target-to-close');
final AnimationController controller = AnimationController( final AnimationController controller = AnimationController(
@ -1530,7 +1529,7 @@ void main() {
}); });
// Regression test for https://github.com/flutter/flutter/issues/87708 // Regression test for https://github.com/flutter/flutter/issues/87708
testWidgetsWithLeakTracking('Each of the internal animation controllers should be disposed by the framework.', (WidgetTester tester) async { testWidgets('Each of the internal animation controllers should be disposed by the framework.', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
home: Scaffold( home: Scaffold(
@ -1573,7 +1572,7 @@ void main() {
}); });
// Regression test for https://github.com/flutter/flutter/issues/99627 // Regression test for https://github.com/flutter/flutter/issues/99627
testWidgetsWithLeakTracking('The old route entry should be removed when a new sheet popup', (WidgetTester tester) async { testWidgets('The old route entry should be removed when a new sheet popup', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey();
PersistentBottomSheetController? sheetController; PersistentBottomSheetController? sheetController;
@ -1617,7 +1616,7 @@ void main() {
}); });
// Regression test for https://github.com/flutter/flutter/issues/87708 // Regression test for https://github.com/flutter/flutter/issues/87708
testWidgetsWithLeakTracking('The framework does not dispose of the transitionAnimationController provided by user.', (WidgetTester tester) async { testWidgets('The framework does not dispose of the transitionAnimationController provided by user.', (WidgetTester tester) async {
const Key tapTarget = Key('tap-target'); const Key tapTarget = Key('tap-target');
const Key tapTargetToClose = Key('tap-target-to-close'); const Key tapTargetToClose = Key('tap-target-to-close');
final AnimationController controller = AnimationController( final AnimationController controller = AnimationController(
@ -1673,7 +1672,7 @@ void main() {
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
}); });
testWidgetsWithLeakTracking('Calling PersistentBottomSheetController.close does not crash when it is not the current bottom sheet', (WidgetTester tester) async { testWidgets('Calling PersistentBottomSheetController.close does not crash when it is not the current bottom sheet', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/93717 // Regression test for https://github.com/flutter/flutter/issues/93717
PersistentBottomSheetController? sheetController1; PersistentBottomSheetController? sheetController1;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -1725,7 +1724,7 @@ void main() {
expect(find.text('BottomSheet 2'), findsOneWidget); expect(find.text('BottomSheet 2'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('ModalBottomSheetRoute shows BottomSheet correctly', (WidgetTester tester) async { testWidgets('ModalBottomSheetRoute shows BottomSheet correctly', (WidgetTester tester) async {
late BuildContext savedContext; late BuildContext savedContext;
await tester.pumpWidget( await tester.pumpWidget(
@ -1755,7 +1754,7 @@ void main() {
}); });
group('Modal BottomSheet avoids overlapping display features', () { group('Modal BottomSheet avoids overlapping display features', () {
testWidgetsWithLeakTracking('positioning using anchorPoint', (WidgetTester tester) async { testWidgets('positioning using anchorPoint', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
@ -1793,7 +1792,7 @@ void main() {
expect(tester.getBottomRight(find.byType(Placeholder)).dx, 800); expect(tester.getBottomRight(find.byType(Placeholder)).dx, 800);
}); });
testWidgetsWithLeakTracking('positioning using Directionality', (WidgetTester tester) async { testWidgets('positioning using Directionality', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
@ -1833,7 +1832,7 @@ void main() {
expect(tester.getBottomRight(find.byType(Placeholder)).dx, 800); expect(tester.getBottomRight(find.byType(Placeholder)).dx, 800);
}); });
testWidgetsWithLeakTracking('default positioning', (WidgetTester tester) async { testWidgets('default positioning', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
@ -1872,7 +1871,7 @@ void main() {
}); });
group('constraints', () { group('constraints', () {
testWidgetsWithLeakTracking('Material3 - Default constraints are max width 640', (WidgetTester tester) async { testWidgets('Material3 - Default constraints are max width 640', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
theme: ThemeData(useMaterial3: true), theme: ThemeData(useMaterial3: true),
@ -1888,7 +1887,7 @@ void main() {
expect(tester.getSize(find.byType(Placeholder)).width, 640); expect(tester.getSize(find.byType(Placeholder)).width, 640);
}); });
testWidgetsWithLeakTracking('Material2 - No constraints by default for bottomSheet property', (WidgetTester tester) async { testWidgets('Material2 - No constraints by default for bottomSheet property', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
// This test is specific to Material2 because Material3 sets constraints by default for BottomSheet. // This test is specific to Material2 because Material3 sets constraints by default for BottomSheet.
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
@ -1904,7 +1903,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('No constraints by default for showBottomSheet', (WidgetTester tester) async { testWidgets('No constraints by default for showBottomSheet', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
// This test is specific to Material2 because Material3 sets constraints by default for BottomSheet. // This test is specific to Material2 because Material3 sets constraints by default for BottomSheet.
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
@ -1933,7 +1932,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('No constraints by default for showModalBottomSheet', (WidgetTester tester) async { testWidgets('No constraints by default for showModalBottomSheet', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
// This test is specific to Material2 because Material3 sets constraints by default for BottomSheet. // This test is specific to Material2 because Material3 sets constraints by default for BottomSheet.
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
@ -1963,7 +1962,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material3 - Theme constraints used for bottomSheet property', (WidgetTester tester) async { testWidgets('Material3 - Theme constraints used for bottomSheet property', (WidgetTester tester) async {
const double sheetMaxWidth = 80.0; const double sheetMaxWidth = 80.0;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData( theme: ThemeData(
@ -1991,7 +1990,7 @@ void main() {
expect(iconRect.top, bottomSheetRect.top - iconRect.height / 2); expect(iconRect.top, bottomSheetRect.top - iconRect.height / 2);
}); });
testWidgetsWithLeakTracking('Material2 - Theme constraints used for bottomSheet property', (WidgetTester tester) async { testWidgets('Material2 - Theme constraints used for bottomSheet property', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData( theme: ThemeData(
useMaterial3: false, useMaterial3: false,
@ -2019,7 +2018,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Theme constraints used for showBottomSheet', (WidgetTester tester) async { testWidgets('Theme constraints used for showBottomSheet', (WidgetTester tester) async {
const double sheetMaxWidth = 80.0; const double sheetMaxWidth = 80.0;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData( theme: ThemeData(
@ -2053,7 +2052,7 @@ void main() {
expect(bottomSheetRect.width, sheetMaxWidth); expect(bottomSheetRect.width, sheetMaxWidth);
}); });
testWidgetsWithLeakTracking('Theme constraints used for showModalBottomSheet', (WidgetTester tester) async { testWidgets('Theme constraints used for showModalBottomSheet', (WidgetTester tester) async {
const double sheetMaxWidth = 80.0; const double sheetMaxWidth = 80.0;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData( theme: ThemeData(
@ -2088,7 +2087,7 @@ void main() {
expect(bottomSheetRect.width, sheetMaxWidth); expect(bottomSheetRect.width, sheetMaxWidth);
}); });
testWidgetsWithLeakTracking('constraints param overrides theme for showBottomSheet', (WidgetTester tester) async { testWidgets('constraints param overrides theme for showBottomSheet', (WidgetTester tester) async {
const double sheetMaxWidth = 100.0; const double sheetMaxWidth = 100.0;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData( theme: ThemeData(
@ -2123,7 +2122,7 @@ void main() {
expect(bottomSheetRect.width, sheetMaxWidth); expect(bottomSheetRect.width, sheetMaxWidth);
}); });
testWidgetsWithLeakTracking('constraints param overrides theme for showModalBottomSheet', (WidgetTester tester) async { testWidgets('constraints param overrides theme for showModalBottomSheet', (WidgetTester tester) async {
const double sheetMaxWidth = 100.0; const double sheetMaxWidth = 100.0;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData( theme: ThemeData(
@ -2201,20 +2200,20 @@ void main() {
); );
} }
testWidgetsWithLeakTracking('works at 9 / 16', (WidgetTester tester) { testWidgets('works at 9 / 16', (WidgetTester tester) {
return test(tester, false, 9.0 / 16.0); return test(tester, false, 9.0 / 16.0);
}); });
testWidgetsWithLeakTracking('works at 8 / 16', (WidgetTester tester) { testWidgets('works at 8 / 16', (WidgetTester tester) {
return test(tester, false, 8.0 / 16.0); return test(tester, false, 8.0 / 16.0);
}); });
testWidgetsWithLeakTracking('works at isScrollControlled', (WidgetTester tester) { testWidgets('works at isScrollControlled', (WidgetTester tester) {
return test(tester, true, 8.0 / 16.0); return test(tester, true, 8.0 / 16.0);
}); });
}); });
}); });
group('showModalBottomSheet modalBarrierDismissLabel', () { group('showModalBottomSheet modalBarrierDismissLabel', () {
testWidgetsWithLeakTracking('Verify that modalBarrierDismissLabel is used if provided', testWidgets('Verify that modalBarrierDismissLabel is used if provided',
(WidgetTester tester) async { (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
const String customLabel = 'custom label'; const String customLabel = 'custom label';
@ -2240,7 +2239,7 @@ void main() {
expect(modalBarrier.semanticsLabel, customLabel); expect(modalBarrier.semanticsLabel, customLabel);
}); });
testWidgetsWithLeakTracking('Verify that modalBarrierDismissLabel from context is used if barrierLabel is not provided', testWidgets('Verify that modalBarrierDismissLabel from context is used if barrierLabel is not provided',
(WidgetTester tester) async { (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(

View File

@ -5,7 +5,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
test('BottomSheetThemeData copyWith, ==, hashCode basics', () { test('BottomSheetThemeData copyWith, ==, hashCode basics', () {
@ -37,7 +36,7 @@ void main() {
expect(bottomSheetTheme.dragHandleSize, null); expect(bottomSheetTheme.dragHandleSize, null);
}); });
testWidgetsWithLeakTracking('Default BottomSheetThemeData debugFillProperties', (WidgetTester tester) async { testWidgets('Default BottomSheetThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const BottomSheetThemeData().debugFillProperties(builder); const BottomSheetThemeData().debugFillProperties(builder);
@ -49,7 +48,7 @@ void main() {
expect(description, <String>[]); expect(description, <String>[]);
}); });
testWidgetsWithLeakTracking('BottomSheetThemeData implements debugFillProperties', (WidgetTester tester) async { testWidgets('BottomSheetThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const BottomSheetThemeData( const BottomSheetThemeData(
backgroundColor: Color(0xFFFFFFFF), backgroundColor: Color(0xFFFFFFFF),
@ -79,7 +78,7 @@ void main() {
]); ]);
}); });
testWidgetsWithLeakTracking('Material3 - Passing no BottomSheetThemeData returns defaults', (WidgetTester tester) async { testWidgets('Material3 - Passing no BottomSheetThemeData returns defaults', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: true), theme: ThemeData(useMaterial3: true),
home: Scaffold( home: Scaffold(
@ -106,7 +105,7 @@ void main() {
expect(material.clipBehavior, Clip.none); expect(material.clipBehavior, Clip.none);
}); });
testWidgetsWithLeakTracking('Material2 - Passing no BottomSheetThemeData returns defaults', (WidgetTester tester) async { testWidgets('Material2 - Passing no BottomSheetThemeData returns defaults', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
home: Scaffold( home: Scaffold(
@ -131,7 +130,7 @@ void main() {
expect(material.clipBehavior, Clip.none); expect(material.clipBehavior, Clip.none);
}); });
testWidgetsWithLeakTracking('BottomSheet uses values from BottomSheetThemeData', (WidgetTester tester) async { testWidgets('BottomSheet uses values from BottomSheetThemeData', (WidgetTester tester) async {
final BottomSheetThemeData bottomSheetTheme = _bottomSheetTheme(); final BottomSheetThemeData bottomSheetTheme = _bottomSheetTheme();
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -158,7 +157,7 @@ void main() {
expect(material.clipBehavior, bottomSheetTheme.clipBehavior); expect(material.clipBehavior, bottomSheetTheme.clipBehavior);
}); });
testWidgetsWithLeakTracking('BottomSheet widget properties take priority over theme', (WidgetTester tester) async { testWidgets('BottomSheet widget properties take priority over theme', (WidgetTester tester) async {
const Color backgroundColor = Colors.purple; const Color backgroundColor = Colors.purple;
const Color shadowColor = Colors.blue; const Color shadowColor = Colors.blue;
const double elevation = 7.0; const double elevation = 7.0;
@ -197,7 +196,7 @@ void main() {
expect(material.clipBehavior, clipBehavior); expect(material.clipBehavior, clipBehavior);
}); });
testWidgetsWithLeakTracking('Modal bottom sheet-specific parameters are used for modal bottom sheets', (WidgetTester tester) async { testWidgets('Modal bottom sheet-specific parameters are used for modal bottom sheets', (WidgetTester tester) async {
const double modalElevation = 5.0; const double modalElevation = 5.0;
const double persistentElevation = 7.0; const double persistentElevation = 7.0;
const Color modalBackgroundColor = Colors.yellow; const Color modalBackgroundColor = Colors.yellow;
@ -228,7 +227,7 @@ void main() {
expect(modalBarrier.color, modalBarrierColor); expect(modalBarrier.color, modalBarrierColor);
}); });
testWidgetsWithLeakTracking('General bottom sheet parameters take priority over modal bottom sheet-specific parameters for persistent bottom sheets', (WidgetTester tester) async { testWidgets('General bottom sheet parameters take priority over modal bottom sheet-specific parameters for persistent bottom sheets', (WidgetTester tester) async {
const double modalElevation = 5.0; const double modalElevation = 5.0;
const double persistentElevation = 7.0; const double persistentElevation = 7.0;
const Color modalBackgroundColor = Colors.yellow; const Color modalBackgroundColor = Colors.yellow;
@ -254,7 +253,7 @@ void main() {
expect(material.color, persistentBackgroundColor); expect(material.color, persistentBackgroundColor);
}); });
testWidgetsWithLeakTracking("Material3 - Modal bottom sheet-specific parameters don't apply to persistent bottom sheets", (WidgetTester tester) async { testWidgets("Material3 - Modal bottom sheet-specific parameters don't apply to persistent bottom sheets", (WidgetTester tester) async {
const double modalElevation = 5.0; const double modalElevation = 5.0;
const Color modalBackgroundColor = Colors.yellow; const Color modalBackgroundColor = Colors.yellow;
const BottomSheetThemeData bottomSheetTheme = BottomSheetThemeData( const BottomSheetThemeData bottomSheetTheme = BottomSheetThemeData(
@ -277,7 +276,7 @@ void main() {
expect(material.color, theme.colorScheme.surface); expect(material.color, theme.colorScheme.surface);
}); });
testWidgetsWithLeakTracking("Material2 - Modal bottom sheet-specific parameters don't apply to persistent bottom sheets", (WidgetTester tester) async { testWidgets("Material2 - Modal bottom sheet-specific parameters don't apply to persistent bottom sheets", (WidgetTester tester) async {
const double modalElevation = 5.0; const double modalElevation = 5.0;
const Color modalBackgroundColor = Colors.yellow; const Color modalBackgroundColor = Colors.yellow;
const BottomSheetThemeData bottomSheetTheme = BottomSheetThemeData( const BottomSheetThemeData bottomSheetTheme = BottomSheetThemeData(
@ -299,7 +298,7 @@ void main() {
expect(material.color, null); expect(material.color, null);
}); });
testWidgetsWithLeakTracking('Modal bottom sheets respond to theme changes', (WidgetTester tester) async { testWidgets('Modal bottom sheets respond to theme changes', (WidgetTester tester) async {
const double lightElevation = 5.0; const double lightElevation = 5.0;
const double darkElevation = 3.0; const double darkElevation = 3.0;
const Color lightBackgroundColor = Colors.green; const Color lightBackgroundColor = Colors.green;

View File

@ -4,10 +4,9 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
testWidgetsWithLeakTracking('ButtonBar default control smoketest', (WidgetTester tester) async { testWidgets('ButtonBar default control smoketest', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
@ -18,7 +17,7 @@ void main() {
group('alignment', () { group('alignment', () {
testWidgetsWithLeakTracking('default alignment is MainAxisAlignment.end', (WidgetTester tester) async { testWidgets('default alignment is MainAxisAlignment.end', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: ButtonBar( home: ButtonBar(
@ -35,7 +34,7 @@ void main() {
expect(tester.getRect(child).right, 792.0); // bar width - default padding expect(tester.getRect(child).right, 792.0); // bar width - default padding
}); });
testWidgetsWithLeakTracking('ButtonBarTheme.alignment overrides default', (WidgetTester tester) async { testWidgets('ButtonBarTheme.alignment overrides default', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: ButtonBarTheme( home: ButtonBarTheme(
@ -57,7 +56,7 @@ void main() {
expect(tester.getRect(child).right, 405.0); // (bar width - padding) / 2 - 10 / 2 + 10 expect(tester.getRect(child).right, 405.0); // (bar width - padding) / 2 - 10 / 2 + 10
}); });
testWidgetsWithLeakTracking('ButtonBar.alignment overrides ButtonBarTheme.alignment and default', (WidgetTester tester) async { testWidgets('ButtonBar.alignment overrides ButtonBarTheme.alignment and default', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: ButtonBarTheme( home: ButtonBarTheme(
@ -84,7 +83,7 @@ void main() {
group('mainAxisSize', () { group('mainAxisSize', () {
testWidgetsWithLeakTracking('Default mainAxisSize is MainAxisSize.max', (WidgetTester tester) async { testWidgets('Default mainAxisSize is MainAxisSize.max', (WidgetTester tester) async {
const Key buttonBarKey = Key('row'); const Key buttonBarKey = Key('row');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
@ -131,7 +130,7 @@ void main() {
expect(childRect.right, 800.0); expect(childRect.right, 800.0);
}); });
testWidgetsWithLeakTracking('ButtonBarTheme.mainAxisSize overrides default', (WidgetTester tester) async { testWidgets('ButtonBarTheme.mainAxisSize overrides default', (WidgetTester tester) async {
const Key buttonBarKey = Key('row'); const Key buttonBarKey = Key('row');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
@ -186,7 +185,7 @@ void main() {
expect(childRect.left, ((800.0 - buttonBarRect.width) / 2.0) + 200.0); expect(childRect.left, ((800.0 - buttonBarRect.width) / 2.0) + 200.0);
}); });
testWidgetsWithLeakTracking('ButtonBar.mainAxisSize overrides ButtonBarTheme.mainAxisSize and default', (WidgetTester tester) async { testWidgets('ButtonBar.mainAxisSize overrides ButtonBarTheme.mainAxisSize and default', (WidgetTester tester) async {
const Key buttonBarKey = Key('row'); const Key buttonBarKey = Key('row');
const Key child0Key = Key('child0'); const Key child0Key = Key('child0');
const Key child1Key = Key('child1'); const Key child1Key = Key('child1');
@ -241,7 +240,7 @@ void main() {
group('button properties override ButtonTheme', () { group('button properties override ButtonTheme', () {
testWidgetsWithLeakTracking('default button properties override ButtonTheme properties', (WidgetTester tester) async { testWidgets('default button properties override ButtonTheme properties', (WidgetTester tester) async {
late BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -264,7 +263,7 @@ void main() {
expect(buttonTheme.layoutBehavior, equals(ButtonBarLayoutBehavior.padded)); expect(buttonTheme.layoutBehavior, equals(ButtonBarLayoutBehavior.padded));
}); });
testWidgetsWithLeakTracking('ButtonBarTheme button properties override defaults and ButtonTheme properties', (WidgetTester tester) async { testWidgets('ButtonBarTheme button properties override defaults and ButtonTheme properties', (WidgetTester tester) async {
late BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -297,7 +296,7 @@ void main() {
expect(buttonTheme.layoutBehavior, equals(ButtonBarLayoutBehavior.constrained)); expect(buttonTheme.layoutBehavior, equals(ButtonBarLayoutBehavior.constrained));
}); });
testWidgetsWithLeakTracking('ButtonBar button properties override ButtonBarTheme, defaults and ButtonTheme properties', (WidgetTester tester) async { testWidgets('ButtonBar button properties override ButtonBarTheme, defaults and ButtonTheme properties', (WidgetTester tester) async {
late BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -340,7 +339,7 @@ void main() {
group('layoutBehavior', () { group('layoutBehavior', () {
testWidgetsWithLeakTracking('ButtonBar has a min height of 52 when using ButtonBarLayoutBehavior.constrained', (WidgetTester tester) async { testWidgets('ButtonBar has a min height of 52 when using ButtonBarLayoutBehavior.constrained', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const SingleChildScrollView( const SingleChildScrollView(
child: ListBody( child: ListBody(
@ -363,7 +362,7 @@ void main() {
expect(tester.getBottomRight(buttonBar).dy - tester.getTopRight(buttonBar).dy, 52.0); expect(tester.getBottomRight(buttonBar).dy - tester.getTopRight(buttonBar).dy, 52.0);
}); });
testWidgetsWithLeakTracking('ButtonBar has padding applied when using ButtonBarLayoutBehavior.padded', (WidgetTester tester) async { testWidgets('ButtonBar has padding applied when using ButtonBarLayoutBehavior.padded', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const SingleChildScrollView( const SingleChildScrollView(
child: ListBody( child: ListBody(
@ -388,7 +387,7 @@ void main() {
}); });
group("ButtonBar's children wrap when they overflow horizontally", () { group("ButtonBar's children wrap when they overflow horizontally", () {
testWidgetsWithLeakTracking("ButtonBar's children wrap when buttons overflow", (WidgetTester tester) async { testWidgets("ButtonBar's children wrap when buttons overflow", (WidgetTester tester) async {
final Key keyOne = UniqueKey(); final Key keyOne = UniqueKey();
final Key keyTwo = UniqueKey(); final Key keyTwo = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
@ -410,7 +409,7 @@ void main() {
expect(containerOneRect.left, containerTwoRect.left); expect(containerOneRect.left, containerTwoRect.left);
}); });
testWidgetsWithLeakTracking( testWidgets(
"ButtonBar's children overflow defaults - MainAxisAlignment.end", (WidgetTester tester) async { "ButtonBar's children overflow defaults - MainAxisAlignment.end", (WidgetTester tester) async {
final Key keyOne = UniqueKey(); final Key keyOne = UniqueKey();
final Key keyTwo = UniqueKey(); final Key keyTwo = UniqueKey();
@ -438,7 +437,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking("ButtonBar's children overflow - MainAxisAlignment.start", (WidgetTester tester) async { testWidgets("ButtonBar's children overflow - MainAxisAlignment.start", (WidgetTester tester) async {
final Key keyOne = UniqueKey(); final Key keyOne = UniqueKey();
final Key keyTwo = UniqueKey(); final Key keyTwo = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
@ -465,7 +464,7 @@ void main() {
expect(containerOneRect.left, buttonBarRect.left); expect(containerOneRect.left, buttonBarRect.left);
}); });
testWidgetsWithLeakTracking("ButtonBar's children overflow - MainAxisAlignment.center", (WidgetTester tester) async { testWidgets("ButtonBar's children overflow - MainAxisAlignment.center", (WidgetTester tester) async {
final Key keyOne = UniqueKey(); final Key keyOne = UniqueKey();
final Key keyTwo = UniqueKey(); final Key keyTwo = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
@ -492,7 +491,7 @@ void main() {
expect(containerOneRect.center.dx, buttonBarRect.center.dx); expect(containerOneRect.center.dx, buttonBarRect.center.dx);
}); });
testWidgetsWithLeakTracking( testWidgets(
"ButtonBar's children default to MainAxisAlignment.start for horizontal " "ButtonBar's children default to MainAxisAlignment.start for horizontal "
'alignment when overflowing in spaceBetween, spaceAround and spaceEvenly ' 'alignment when overflowing in spaceBetween, spaceAround and spaceEvenly '
'cases when overflowing.', (WidgetTester tester) async { 'cases when overflowing.', (WidgetTester tester) async {
@ -546,7 +545,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
"ButtonBar's children respects verticalDirection when overflowing", "ButtonBar's children respects verticalDirection when overflowing",
(WidgetTester tester) async { (WidgetTester tester) async {
final Key keyOne = UniqueKey(); final Key keyOne = UniqueKey();
@ -575,7 +574,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'ButtonBar has no spacing by default when overflowing', 'ButtonBar has no spacing by default when overflowing',
(WidgetTester tester) async { (WidgetTester tester) async {
final Key keyOne = UniqueKey(); final Key keyOne = UniqueKey();
@ -600,7 +599,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
"ButtonBar's children respects overflowButtonSpacing when overflowing", "ButtonBar's children respects overflowButtonSpacing when overflowing",
(WidgetTester tester) async { (WidgetTester tester) async {
final Key keyOne = UniqueKey(); final Key keyOne = UniqueKey();
@ -629,7 +628,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('_RenderButtonBarRow.constraints does not work before layout', (WidgetTester tester) async { testWidgets('_RenderButtonBarRow.constraints does not work before layout', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp(home: ButtonBar()), const MaterialApp(home: ButtonBar()),
Duration.zero, Duration.zero,

View File

@ -5,7 +5,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
@ -37,7 +36,7 @@ void main() {
expect(const ButtonBarThemeData().hashCode, const ButtonBarThemeData().copyWith().hashCode); expect(const ButtonBarThemeData().hashCode, const ButtonBarThemeData().copyWith().hashCode);
}); });
testWidgetsWithLeakTracking('ButtonBarThemeData lerps correctly', (WidgetTester tester) async { testWidgets('ButtonBarThemeData lerps correctly', (WidgetTester tester) async {
const ButtonBarThemeData barThemePrimary = ButtonBarThemeData( const ButtonBarThemeData barThemePrimary = ButtonBarThemeData(
alignment: MainAxisAlignment.end, alignment: MainAxisAlignment.end,
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@ -73,7 +72,7 @@ void main() {
expect(lerp.overflowDirection, equals(VerticalDirection.up)); expect(lerp.overflowDirection, equals(VerticalDirection.up));
}); });
testWidgetsWithLeakTracking('Default ButtonBarThemeData debugFillProperties', (WidgetTester tester) async { testWidgets('Default ButtonBarThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ButtonBarThemeData().debugFillProperties(builder); const ButtonBarThemeData().debugFillProperties(builder);
@ -85,7 +84,7 @@ void main() {
expect(description, <String>[]); expect(description, <String>[]);
}); });
testWidgetsWithLeakTracking('ButtonBarThemeData implements debugFillProperties', (WidgetTester tester) async { testWidgets('ButtonBarThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ButtonBarThemeData( const ButtonBarThemeData(
alignment: MainAxisAlignment.center, alignment: MainAxisAlignment.center,
@ -117,7 +116,7 @@ void main() {
]); ]);
}); });
testWidgetsWithLeakTracking('ButtonBarTheme.of falls back to ThemeData.buttonBarTheme', (WidgetTester tester) async { testWidgets('ButtonBarTheme.of falls back to ThemeData.buttonBarTheme', (WidgetTester tester) async {
const ButtonBarThemeData buttonBarTheme = ButtonBarThemeData(buttonMinWidth: 42.0); const ButtonBarThemeData buttonBarTheme = ButtonBarThemeData(buttonMinWidth: 42.0);
late BuildContext capturedContext; late BuildContext capturedContext;
await tester.pumpWidget( await tester.pumpWidget(
@ -135,7 +134,7 @@ void main() {
expect(ButtonBarTheme.of(capturedContext).buttonMinWidth, equals(42.0)); expect(ButtonBarTheme.of(capturedContext).buttonMinWidth, equals(42.0));
}); });
testWidgetsWithLeakTracking('ButtonBarTheme overrides ThemeData.buttonBarTheme', (WidgetTester tester) async { testWidgets('ButtonBarTheme overrides ThemeData.buttonBarTheme', (WidgetTester tester) async {
const ButtonBarThemeData defaultBarTheme = ButtonBarThemeData(buttonMinWidth: 42.0); const ButtonBarThemeData defaultBarTheme = ButtonBarThemeData(buttonMinWidth: 42.0);
const ButtonBarThemeData buttonBarTheme = ButtonBarThemeData(buttonMinWidth: 84.0); const ButtonBarThemeData buttonBarTheme = ButtonBarThemeData(buttonMinWidth: 84.0);
late BuildContext capturedContext; late BuildContext capturedContext;

View File

@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
test('ButtonStyle copyWith, merge, ==, hashCode basics', () { test('ButtonStyle copyWith, merge, ==, hashCode basics', () {
@ -45,7 +44,7 @@ void main() {
expect(style.enableFeedback, null); expect(style.enableFeedback, null);
}); });
testWidgetsWithLeakTracking('Default ButtonStyle debugFillProperties', (WidgetTester tester) async { testWidgets('Default ButtonStyle debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ButtonStyle().debugFillProperties(builder); const ButtonStyle().debugFillProperties(builder);
@ -57,7 +56,7 @@ void main() {
expect(description, <String>[]); expect(description, <String>[]);
}); });
testWidgetsWithLeakTracking('ButtonStyle debugFillProperties', (WidgetTester tester) async { testWidgets('ButtonStyle debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ButtonStyle( const ButtonStyle(
textStyle: MaterialStatePropertyAll<TextStyle>(TextStyle(fontSize: 10.0)), textStyle: MaterialStatePropertyAll<TextStyle>(TextStyle(fontSize: 10.0)),
@ -107,7 +106,7 @@ void main() {
]); ]);
}); });
testWidgetsWithLeakTracking('ButtonStyle copyWith, merge', (WidgetTester tester) async { testWidgets('ButtonStyle copyWith, merge', (WidgetTester tester) async {
const MaterialStateProperty<TextStyle> textStyle = MaterialStatePropertyAll<TextStyle>(TextStyle(fontSize: 10)); const MaterialStateProperty<TextStyle> textStyle = MaterialStatePropertyAll<TextStyle>(TextStyle(fontSize: 10));
const MaterialStateProperty<Color> backgroundColor = MaterialStatePropertyAll<Color>(Color(0xfffffff1)); const MaterialStateProperty<Color> backgroundColor = MaterialStatePropertyAll<Color>(Color(0xfffffff1));
const MaterialStateProperty<Color> foregroundColor = MaterialStatePropertyAll<Color>(Color(0xfffffff2)); const MaterialStateProperty<Color> foregroundColor = MaterialStatePropertyAll<Color>(Color(0xfffffff2));

View File

@ -4,7 +4,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
@ -68,7 +67,7 @@ void main() {
expect(theme.colorScheme, const ColorScheme.dark()); expect(theme.colorScheme, const ColorScheme.dark());
}); });
testWidgetsWithLeakTracking('ButtonTheme alignedDropdown', (WidgetTester tester) async { testWidgets('ButtonTheme alignedDropdown', (WidgetTester tester) async {
final Key dropdownKey = UniqueKey(); final Key dropdownKey = UniqueKey();
Widget buildFrame({ required bool alignedDropdown, required TextDirection textDirection }) { Widget buildFrame({ required bool alignedDropdown, required TextDirection textDirection }) {

View File

@ -5,7 +5,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'feedback_tester.dart'; import 'feedback_tester.dart';
@ -77,7 +76,7 @@ void main() {
} }
group('CalendarDatePicker', () { group('CalendarDatePicker', () {
testWidgetsWithLeakTracking('Can select a day', (WidgetTester tester) async { testWidgets('Can select a day', (WidgetTester tester) async {
DateTime? selectedDate; DateTime? selectedDate;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
@ -87,7 +86,7 @@ void main() {
expect(selectedDate, equals(DateTime(2016, DateTime.january, 12))); expect(selectedDate, equals(DateTime(2016, DateTime.january, 12)));
}); });
testWidgetsWithLeakTracking('Can select a day with nothing first selected', (WidgetTester tester) async { testWidgets('Can select a day with nothing first selected', (WidgetTester tester) async {
DateTime? selectedDate; DateTime? selectedDate;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
onDateChanged: (DateTime date) => selectedDate = date, onDateChanged: (DateTime date) => selectedDate = date,
@ -96,7 +95,7 @@ void main() {
expect(selectedDate, equals(DateTime(2016, DateTime.january, 12))); expect(selectedDate, equals(DateTime(2016, DateTime.january, 12)));
}); });
testWidgetsWithLeakTracking('Can select a month', (WidgetTester tester) async { testWidgets('Can select a month', (WidgetTester tester) async {
DateTime? displayedMonth; DateTime? displayedMonth;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
@ -121,7 +120,7 @@ void main() {
expect(displayedMonth, equals(DateTime(2015, DateTime.december))); expect(displayedMonth, equals(DateTime(2015, DateTime.december)));
}); });
testWidgetsWithLeakTracking('Can select a month with nothing first selected', (WidgetTester tester) async { testWidgets('Can select a month with nothing first selected', (WidgetTester tester) async {
DateTime? displayedMonth; DateTime? displayedMonth;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
onDisplayedMonthChanged: (DateTime date) => displayedMonth = date, onDisplayedMonthChanged: (DateTime date) => displayedMonth = date,
@ -145,7 +144,7 @@ void main() {
expect(displayedMonth, equals(DateTime(2015, DateTime.december))); expect(displayedMonth, equals(DateTime(2015, DateTime.december)));
}); });
testWidgetsWithLeakTracking('Can select a year', (WidgetTester tester) async { testWidgets('Can select a year', (WidgetTester tester) async {
DateTime? displayedMonth; DateTime? displayedMonth;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
@ -160,7 +159,7 @@ void main() {
expect(displayedMonth, equals(DateTime(2018))); expect(displayedMonth, equals(DateTime(2018)));
}); });
testWidgetsWithLeakTracking('Can select a year with nothing first selected', (WidgetTester tester) async { testWidgets('Can select a year with nothing first selected', (WidgetTester tester) async {
DateTime? displayedMonth; DateTime? displayedMonth;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
onDisplayedMonthChanged: (DateTime date) => displayedMonth = date, onDisplayedMonthChanged: (DateTime date) => displayedMonth = date,
@ -174,7 +173,7 @@ void main() {
expect(displayedMonth, equals(DateTime(2018))); expect(displayedMonth, equals(DateTime(2018)));
}); });
testWidgetsWithLeakTracking('Selecting date does not change displayed month', (WidgetTester tester) async { testWidgets('Selecting date does not change displayed month', (WidgetTester tester) async {
DateTime? selectedDate; DateTime? selectedDate;
DateTime? displayedMonth; DateTime? displayedMonth;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
@ -197,7 +196,7 @@ void main() {
expect(find.text('31'), findsNothing); expect(find.text('31'), findsNothing);
}); });
testWidgetsWithLeakTracking('Changing year does change selected date', (WidgetTester tester) async { testWidgets('Changing year does change selected date', (WidgetTester tester) async {
DateTime? selectedDate; DateTime? selectedDate;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
@ -212,7 +211,7 @@ void main() {
expect(selectedDate, equals(DateTime(2018, DateTime.january, 4))); expect(selectedDate, equals(DateTime(2018, DateTime.january, 4)));
}); });
testWidgetsWithLeakTracking('Changing year for february 29th', (WidgetTester tester) async { testWidgets('Changing year for february 29th', (WidgetTester tester) async {
DateTime? selectedDate; DateTime? selectedDate;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2020, DateTime.february, 29), initialDate: DateTime(2020, DateTime.february, 29),
@ -231,7 +230,7 @@ void main() {
expect(selectedDate, equals(DateTime(2020, DateTime.february, 28))); expect(selectedDate, equals(DateTime(2020, DateTime.february, 28)));
}); });
testWidgetsWithLeakTracking('Changing year does not change the month', (WidgetTester tester) async { testWidgets('Changing year does not change the month', (WidgetTester tester) async {
DateTime? displayedMonth; DateTime? displayedMonth;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
@ -249,7 +248,7 @@ void main() {
expect(displayedMonth, equals(DateTime(2018, DateTime.march))); expect(displayedMonth, equals(DateTime(2018, DateTime.march)));
}); });
testWidgetsWithLeakTracking('Can select a year and then a day', (WidgetTester tester) async { testWidgets('Can select a year and then a day', (WidgetTester tester) async {
DateTime? selectedDate; DateTime? selectedDate;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
@ -263,7 +262,7 @@ void main() {
expect(selectedDate, equals(DateTime(2017, DateTime.january, 19))); expect(selectedDate, equals(DateTime(2017, DateTime.january, 19)));
}); });
testWidgetsWithLeakTracking('Cannot select a day outside bounds', (WidgetTester tester) async { testWidgets('Cannot select a day outside bounds', (WidgetTester tester) async {
final DateTime validDate = DateTime(2017, DateTime.january, 15); final DateTime validDate = DateTime(2017, DateTime.january, 15);
DateTime? selectedDate; DateTime? selectedDate;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
@ -286,7 +285,7 @@ void main() {
expect(selectedDate, validDate); expect(selectedDate, validDate);
}); });
testWidgetsWithLeakTracking('Cannot navigate to a month outside bounds', (WidgetTester tester) async { testWidgets('Cannot navigate to a month outside bounds', (WidgetTester tester) async {
DateTime? displayedMonth; DateTime? displayedMonth;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
firstDate: DateTime(2016, DateTime.december, 15), firstDate: DateTime(2016, DateTime.december, 15),
@ -310,7 +309,7 @@ void main() {
expect(previousMonthIcon, findsNothing); expect(previousMonthIcon, findsNothing);
}); });
testWidgetsWithLeakTracking('Cannot select disabled year', (WidgetTester tester) async { testWidgets('Cannot select disabled year', (WidgetTester tester) async {
DateTime? displayedMonth; DateTime? displayedMonth;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
firstDate: DateTime(2018, DateTime.june, 9), firstDate: DateTime(2018, DateTime.june, 9),
@ -331,7 +330,7 @@ void main() {
expect(displayedMonth, isNull); expect(displayedMonth, isNull);
}); });
testWidgetsWithLeakTracking('Selecting firstDate year respects firstDate', (WidgetTester tester) async { testWidgets('Selecting firstDate year respects firstDate', (WidgetTester tester) async {
DateTime? selectedDate; DateTime? selectedDate;
DateTime? displayedMonth; DateTime? displayedMonth;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
@ -351,7 +350,7 @@ void main() {
expect(selectedDate, DateTime(2016, DateTime.june, 9)); expect(selectedDate, DateTime(2016, DateTime.june, 9));
}); });
testWidgetsWithLeakTracking('Selecting lastDate year respects lastDate', (WidgetTester tester) async { testWidgets('Selecting lastDate year respects lastDate', (WidgetTester tester) async {
DateTime? selectedDate; DateTime? selectedDate;
DateTime? displayedMonth; DateTime? displayedMonth;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
@ -373,7 +372,7 @@ void main() {
expect(selectedDate, DateTime(2019, DateTime.january, 4)); expect(selectedDate, DateTime(2019, DateTime.january, 4));
}); });
testWidgetsWithLeakTracking('Selecting lastDate year respects lastDate', (WidgetTester tester) async { testWidgets('Selecting lastDate year respects lastDate', (WidgetTester tester) async {
DateTime? selectedDate; DateTime? selectedDate;
DateTime? displayedMonth; DateTime? displayedMonth;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
@ -396,7 +395,7 @@ void main() {
expect(selectedDate, DateTime(2019, DateTime.january, 4)); expect(selectedDate, DateTime(2019, DateTime.january, 4));
}); });
testWidgetsWithLeakTracking('Only predicate days are selectable', (WidgetTester tester) async { testWidgets('Only predicate days are selectable', (WidgetTester tester) async {
DateTime? selectedDate; DateTime? selectedDate;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
firstDate: DateTime(2017, DateTime.january, 10), firstDate: DateTime(2017, DateTime.january, 10),
@ -413,7 +412,7 @@ void main() {
expect(selectedDate, DateTime(2017, DateTime.january, 10)); expect(selectedDate, DateTime(2017, DateTime.january, 10));
}); });
testWidgetsWithLeakTracking('Can select initial calendar picker mode', (WidgetTester tester) async { testWidgets('Can select initial calendar picker mode', (WidgetTester tester) async {
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2014, DateTime.january, 15), initialDate: DateTime(2014, DateTime.january, 15),
initialCalendarMode: DatePickerMode.year, initialCalendarMode: DatePickerMode.year,
@ -425,7 +424,7 @@ void main() {
expect(find.text('January 2018'), findsOneWidget); expect(find.text('January 2018'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Material2 - currentDate is highlighted', (WidgetTester tester) async { testWidgets('Material2 - currentDate is highlighted', (WidgetTester tester) async {
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
useMaterial3: false, useMaterial3: false,
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
@ -443,7 +442,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material3 - currentDate is highlighted', (WidgetTester tester) async { testWidgets('Material3 - currentDate is highlighted', (WidgetTester tester) async {
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
useMaterial3: true, useMaterial3: true,
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
@ -461,7 +460,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material2 - currentDate is highlighted even if it is disabled', (WidgetTester tester) async { testWidgets('Material2 - currentDate is highlighted even if it is disabled', (WidgetTester tester) async {
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
useMaterial3: false, useMaterial3: false,
firstDate: DateTime(2016, 1, 3), firstDate: DateTime(2016, 1, 3),
@ -482,7 +481,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material3 - currentDate is highlighted even if it is disabled', (WidgetTester tester) async { testWidgets('Material3 - currentDate is highlighted even if it is disabled', (WidgetTester tester) async {
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
useMaterial3: true, useMaterial3: true,
firstDate: DateTime(2016, 1, 3), firstDate: DateTime(2016, 1, 3),
@ -503,7 +502,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Selecting date does not switch picker to year selection', (WidgetTester tester) async { testWidgets('Selecting date does not switch picker to year selection', (WidgetTester tester) async {
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2020, DateTime.may, 10), initialDate: DateTime(2020, DateTime.may, 10),
initialCalendarMode: DatePickerMode.year, initialCalendarMode: DatePickerMode.year,
@ -517,7 +516,7 @@ void main() {
expect(find.text('2017'), findsNothing); expect(find.text('2017'), findsNothing);
}); });
testWidgetsWithLeakTracking('Selecting disabled date does not change current selection', (WidgetTester tester) async { testWidgets('Selecting disabled date does not change current selection', (WidgetTester tester) async {
DateTime day(int day) => DateTime(2020, DateTime.may, day); DateTime day(int day) => DateTime(2020, DateTime.may, day);
DateTime selection = day(2); DateTime selection = day(2);
@ -542,7 +541,7 @@ void main() {
}); });
for (final bool useMaterial3 in <bool>[false, true]) { for (final bool useMaterial3 in <bool>[false, true]) {
testWidgetsWithLeakTracking('Updates to initialDate parameter are not reflected in the state (useMaterial3=$useMaterial3)', (WidgetTester tester) async { testWidgets('Updates to initialDate parameter are not reflected in the state (useMaterial3=$useMaterial3)', (WidgetTester tester) async {
final Key pickerKey = UniqueKey(); final Key pickerKey = UniqueKey();
final DateTime initialDate = DateTime(2020, 1, 21); final DateTime initialDate = DateTime(2020, 1, 21);
final DateTime updatedDate = DateTime(1976, 2, 23); final DateTime updatedDate = DateTime(1976, 2, 23);
@ -592,7 +591,7 @@ void main() {
}); });
} }
testWidgetsWithLeakTracking('Updates to initialCalendarMode parameter is not reflected in the state', (WidgetTester tester) async { testWidgets('Updates to initialCalendarMode parameter is not reflected in the state', (WidgetTester tester) async {
final Key pickerKey = UniqueKey(); final Key pickerKey = UniqueKey();
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
@ -619,7 +618,7 @@ void main() {
expect(find.text('2016'), findsOneWidget); // 2016 in year grid expect(find.text('2016'), findsOneWidget); // 2016 in year grid
}); });
testWidgetsWithLeakTracking('Dragging more than half the width should not cause a jump', (WidgetTester tester) async { testWidgets('Dragging more than half the width should not cause a jump', (WidgetTester tester) async {
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
)); ));
@ -641,7 +640,7 @@ void main() {
}); });
group('Keyboard navigation', () { group('Keyboard navigation', () {
testWidgetsWithLeakTracking('Can toggle to year mode', (WidgetTester tester) async { testWidgets('Can toggle to year mode', (WidgetTester tester) async {
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
)); ));
@ -656,7 +655,7 @@ void main() {
expect(find.text('January 2016'), findsOneWidget); expect(find.text('January 2016'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Can navigate next/previous months', (WidgetTester tester) async { testWidgets('Can navigate next/previous months', (WidgetTester tester) async {
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
)); ));
@ -685,7 +684,7 @@ void main() {
expect(find.text('March 2016'), findsOneWidget); expect(find.text('March 2016'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Can navigate date grid with arrow keys', (WidgetTester tester) async { testWidgets('Can navigate date grid with arrow keys', (WidgetTester tester) async {
DateTime? selectedDate; DateTime? selectedDate;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
@ -715,7 +714,7 @@ void main() {
expect(selectedDate, DateTime(2016, DateTime.january, 18)); expect(selectedDate, DateTime(2016, DateTime.january, 18));
}); });
testWidgetsWithLeakTracking('Navigating with arrow keys scrolls months', (WidgetTester tester) async { testWidgets('Navigating with arrow keys scrolls months', (WidgetTester tester) async {
DateTime? selectedDate; DateTime? selectedDate;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
@ -756,7 +755,7 @@ void main() {
expect(selectedDate, DateTime(2015, DateTime.november, 26)); expect(selectedDate, DateTime(2015, DateTime.november, 26));
}); });
testWidgetsWithLeakTracking('RTL text direction reverses the horizontal arrow key navigation', (WidgetTester tester) async { testWidgets('RTL text direction reverses the horizontal arrow key navigation', (WidgetTester tester) async {
DateTime? selectedDate; DateTime? selectedDate;
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
@ -800,7 +799,7 @@ void main() {
feedback.dispose(); feedback.dispose();
}); });
testWidgetsWithLeakTracking('Selecting date vibrates', (WidgetTester tester) async { testWidgets('Selecting date vibrates', (WidgetTester tester) async {
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
)); ));
@ -815,7 +814,7 @@ void main() {
expect(feedback.hapticCount, 3); expect(feedback.hapticCount, 3);
}); });
testWidgetsWithLeakTracking('Tapping unselectable date does not vibrate', (WidgetTester tester) async { testWidgets('Tapping unselectable date does not vibrate', (WidgetTester tester) async {
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2016, DateTime.january, 10), initialDate: DateTime(2016, DateTime.january, 10),
selectableDayPredicate: (DateTime date) => date.day.isEven, selectableDayPredicate: (DateTime date) => date.day.isEven,
@ -831,7 +830,7 @@ void main() {
expect(feedback.hapticCount, 0); expect(feedback.hapticCount, 0);
}); });
testWidgetsWithLeakTracking('Changing modes and year vibrates', (WidgetTester tester) async { testWidgets('Changing modes and year vibrates', (WidgetTester tester) async {
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
initialDate: DateTime(2016, DateTime.january, 15), initialDate: DateTime(2016, DateTime.january, 15),
)); ));
@ -845,7 +844,7 @@ void main() {
}); });
group('Semantics', () { group('Semantics', () {
testWidgetsWithLeakTracking('day mode', (WidgetTester tester) async { testWidgets('day mode', (WidgetTester tester) async {
final SemanticsHandle semantics = tester.ensureSemantics(); final SemanticsHandle semantics = tester.ensureSemantics();
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
@ -1061,7 +1060,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('calendar year mode', (WidgetTester tester) async { testWidgets('calendar year mode', (WidgetTester tester) async {
final SemanticsHandle semantics = tester.ensureSemantics(); final SemanticsHandle semantics = tester.ensureSemantics();
await tester.pumpWidget(calendarDatePicker( await tester.pumpWidget(calendarDatePicker(
@ -1091,12 +1090,12 @@ void main() {
}); });
group('YearPicker', () { group('YearPicker', () {
testWidgetsWithLeakTracking('Current year is visible in year picker', (WidgetTester tester) async { testWidgets('Current year is visible in year picker', (WidgetTester tester) async {
await tester.pumpWidget(yearPicker()); await tester.pumpWidget(yearPicker());
expect(find.text('2016'), findsOneWidget); expect(find.text('2016'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Can select a year', (WidgetTester tester) async { testWidgets('Can select a year', (WidgetTester tester) async {
DateTime? selectedDate; DateTime? selectedDate;
await tester.pumpWidget(yearPicker( await tester.pumpWidget(yearPicker(
onChanged: (DateTime date) => selectedDate = date, onChanged: (DateTime date) => selectedDate = date,
@ -1107,7 +1106,7 @@ void main() {
expect(selectedDate, equals(DateTime(2018))); expect(selectedDate, equals(DateTime(2018)));
}); });
testWidgetsWithLeakTracking('Cannot select disabled year', (WidgetTester tester) async { testWidgets('Cannot select disabled year', (WidgetTester tester) async {
DateTime? selectedYear; DateTime? selectedYear;
await tester.pumpWidget(yearPicker( await tester.pumpWidget(yearPicker(
firstDate: DateTime(2018, DateTime.june, 9), firstDate: DateTime(2018, DateTime.june, 9),
@ -1126,7 +1125,7 @@ void main() {
expect(selectedYear, equals(DateTime(2018, DateTime.july))); expect(selectedYear, equals(DateTime(2018, DateTime.july)));
}); });
testWidgetsWithLeakTracking('Selecting year with no selected month uses earliest month', (WidgetTester tester) async { testWidgets('Selecting year with no selected month uses earliest month', (WidgetTester tester) async {
DateTime? selectedYear; DateTime? selectedYear;
await tester.pumpWidget(yearPicker( await tester.pumpWidget(yearPicker(
firstDate: DateTime(2018, DateTime.june, 9), firstDate: DateTime(2018, DateTime.june, 9),
@ -1145,7 +1144,7 @@ void main() {
expect(selectedYear, equals(DateTime(2019, DateTime.june))); expect(selectedYear, equals(DateTime(2019, DateTime.june)));
}); });
testWidgetsWithLeakTracking('Selecting year with no selected month uses January', (WidgetTester tester) async { testWidgets('Selecting year with no selected month uses January', (WidgetTester tester) async {
DateTime? selectedYear; DateTime? selectedYear;
await tester.pumpWidget(yearPicker( await tester.pumpWidget(yearPicker(
firstDate: DateTime(2018, DateTime.june, 9), firstDate: DateTime(2018, DateTime.june, 9),

View File

@ -5,11 +5,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
void main() { void main() {
testWidgetsWithLeakTracking('Material3 - Card defaults (Elevated card)', (WidgetTester tester) async { testWidgets('Material3 - Card defaults (Elevated card)', (WidgetTester tester) async {
final ThemeData theme = ThemeData(); final ThemeData theme = ThemeData();
final ColorScheme colors = theme.colorScheme; final ColorScheme colors = theme.colorScheme;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -33,7 +32,7 @@ void main() {
)); ));
}); });
testWidgetsWithLeakTracking('Material3 - Card.filled defaults', (WidgetTester tester) async { testWidgets('Material3 - Card.filled defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(); final ThemeData theme = ThemeData();
final ColorScheme colors = theme.colorScheme; final ColorScheme colors = theme.colorScheme;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -57,7 +56,7 @@ void main() {
)); ));
}); });
testWidgetsWithLeakTracking('Material3 - Card.outlined defaults', (WidgetTester tester) async { testWidgets('Material3 - Card.outlined defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(); final ThemeData theme = ThemeData();
final ColorScheme colors = theme.colorScheme; final ColorScheme colors = theme.colorScheme;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -82,7 +81,7 @@ void main() {
)); ));
}); });
testWidgetsWithLeakTracking('Card can take semantic text from multiple children', (WidgetTester tester) async { testWidgets('Card can take semantic text from multiple children', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
@ -150,7 +149,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Card merges children when it is a semanticContainer', (WidgetTester tester) async { testWidgets('Card merges children when it is a semanticContainer', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
debugResetSemanticsIdCounter(); debugResetSemanticsIdCounter();
@ -189,7 +188,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('Card margin', (WidgetTester tester) async { testWidgets('Card margin', (WidgetTester tester) async {
const Key contentsKey = ValueKey<String>('contents'); const Key contentsKey = ValueKey<String>('contents');
await tester.pumpWidget( await tester.pumpWidget(
@ -236,7 +235,7 @@ void main() {
expect(tester.getSize(find.byKey(contentsKey)), const Size(100.0, 100.0)); expect(tester.getSize(find.byKey(contentsKey)), const Size(100.0, 100.0));
}); });
testWidgetsWithLeakTracking('Card clipBehavior property passes through to the Material', (WidgetTester tester) async { testWidgets('Card clipBehavior property passes through to the Material', (WidgetTester tester) async {
await tester.pumpWidget(const Card()); await tester.pumpWidget(const Card());
expect(tester.widget<Material>(find.byType(Material)).clipBehavior, Clip.none); expect(tester.widget<Material>(find.byType(Material)).clipBehavior, Clip.none);
@ -244,7 +243,7 @@ void main() {
expect(tester.widget<Material>(find.byType(Material)).clipBehavior, Clip.antiAlias); expect(tester.widget<Material>(find.byType(Material)).clipBehavior, Clip.antiAlias);
}); });
testWidgetsWithLeakTracking('Card clipBehavior property defers to theme when null', (WidgetTester tester) async { testWidgets('Card clipBehavior property defers to theme when null', (WidgetTester tester) async {
await tester.pumpWidget(Builder(builder: (BuildContext context) { await tester.pumpWidget(Builder(builder: (BuildContext context) {
final ThemeData themeData = Theme.of(context); final ThemeData themeData = Theme.of(context);
return Theme( return Theme(
@ -259,7 +258,7 @@ void main() {
expect(tester.widget<Material>(find.byType(Material)).clipBehavior, Clip.antiAliasWithSaveLayer); expect(tester.widget<Material>(find.byType(Material)).clipBehavior, Clip.antiAliasWithSaveLayer);
}); });
testWidgetsWithLeakTracking('Card shadowColor', (WidgetTester tester) async { testWidgets('Card shadowColor', (WidgetTester tester) async {
Material getCardMaterial(WidgetTester tester) { Material getCardMaterial(WidgetTester tester) {
return tester.widget<Material>( return tester.widget<Material>(
find.descendant( find.descendant(

View File

@ -9,7 +9,6 @@ library;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
test('CardTheme copyWith, ==, hashCode basics', () { test('CardTheme copyWith, ==, hashCode basics', () {
@ -23,7 +22,7 @@ void main() {
expect(identical(CardTheme.lerp(theme, theme, 0.5), theme), true); expect(identical(CardTheme.lerp(theme, theme, 0.5), theme), true);
}); });
testWidgetsWithLeakTracking('Material3 - Passing no CardTheme returns defaults', (WidgetTester tester) async { testWidgets('Material3 - Passing no CardTheme returns defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: theme, theme: theme,
@ -46,7 +45,7 @@ void main() {
)); ));
}); });
testWidgetsWithLeakTracking('Card uses values from CardTheme', (WidgetTester tester) async { testWidgets('Card uses values from CardTheme', (WidgetTester tester) async {
final CardTheme cardTheme = _cardTheme(); final CardTheme cardTheme = _cardTheme();
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -68,7 +67,7 @@ void main() {
expect(material.shape, cardTheme.shape); expect(material.shape, cardTheme.shape);
}); });
testWidgetsWithLeakTracking('Card widget properties take priority over theme', (WidgetTester tester) async { testWidgets('Card widget properties take priority over theme', (WidgetTester tester) async {
const Clip clip = Clip.hardEdge; const Clip clip = Clip.hardEdge;
const Color color = Colors.orange; const Color color = Colors.orange;
const Color shadowColor = Colors.pink; const Color shadowColor = Colors.pink;
@ -103,7 +102,7 @@ void main() {
expect(material.shape, shape); expect(material.shape, shape);
}); });
testWidgetsWithLeakTracking('CardTheme properties take priority over ThemeData properties', (WidgetTester tester) async { testWidgets('CardTheme properties take priority over ThemeData properties', (WidgetTester tester) async {
final CardTheme cardTheme = _cardTheme(); final CardTheme cardTheme = _cardTheme();
final ThemeData themeData = _themeData().copyWith(cardTheme: cardTheme); final ThemeData themeData = _themeData().copyWith(cardTheme: cardTheme);
@ -118,7 +117,7 @@ void main() {
expect(material.color, cardTheme.color); expect(material.color, cardTheme.color);
}); });
testWidgetsWithLeakTracking('Material3 - ThemeData properties are used when no CardTheme is set', (WidgetTester tester) async { testWidgets('Material3 - ThemeData properties are used when no CardTheme is set', (WidgetTester tester) async {
final ThemeData themeData = ThemeData(useMaterial3: true); final ThemeData themeData = ThemeData(useMaterial3: true);
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -132,7 +131,7 @@ void main() {
expect(material.color, themeData.colorScheme.surface); expect(material.color, themeData.colorScheme.surface);
}); });
testWidgetsWithLeakTracking('Material3 - CardTheme customizes shape', (WidgetTester tester) async { testWidgets('Material3 - CardTheme customizes shape', (WidgetTester tester) async {
const CardTheme cardTheme = CardTheme( const CardTheme cardTheme = CardTheme(
color: Colors.white, color: Colors.white,
shape: BeveledRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(7))), shape: BeveledRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(7))),
@ -166,7 +165,7 @@ void main() {
// support is deprecated and the APIs are removed, these tests // support is deprecated and the APIs are removed, these tests
// can be deleted. // can be deleted.
testWidgetsWithLeakTracking('Material2 - ThemeData properties are used when no CardTheme is set', (WidgetTester tester) async { testWidgets('Material2 - ThemeData properties are used when no CardTheme is set', (WidgetTester tester) async {
final ThemeData themeData = ThemeData(useMaterial3: false); final ThemeData themeData = ThemeData(useMaterial3: false);
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -180,7 +179,7 @@ void main() {
expect(material.color, themeData.cardColor); expect(material.color, themeData.cardColor);
}); });
testWidgetsWithLeakTracking('Material2 - Passing no CardTheme returns defaults', (WidgetTester tester) async { testWidgets('Material2 - Passing no CardTheme returns defaults', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
theme: ThemeData(useMaterial3: false), theme: ThemeData(useMaterial3: false),
home: const Scaffold( home: const Scaffold(
@ -202,7 +201,7 @@ void main() {
)); ));
}); });
testWidgetsWithLeakTracking('Material2 - CardTheme customizes shape', (WidgetTester tester) async { testWidgets('Material2 - CardTheme customizes shape', (WidgetTester tester) async {
const CardTheme cardTheme = CardTheme( const CardTheme cardTheme = CardTheme(
color: Colors.white, color: Colors.white,
shape: BeveledRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(7))), shape: BeveledRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(7))),

View File

@ -8,7 +8,6 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'feedback_tester.dart'; import 'feedback_tester.dart';
Widget wrap({ required Widget child }) { Widget wrap({ required Widget child }) {
@ -22,7 +21,7 @@ Widget wrap({ required Widget child }) {
} }
void main() { void main() {
testWidgetsWithLeakTracking('CheckboxListTile control test', (WidgetTester tester) async { testWidgets('CheckboxListTile control test', (WidgetTester tester) async {
final List<dynamic> log = <dynamic>[]; final List<dynamic> log = <dynamic>[];
await tester.pumpWidget(wrap( await tester.pumpWidget(wrap(
child: CheckboxListTile( child: CheckboxListTile(
@ -37,7 +36,7 @@ void main() {
expect(log, equals(<dynamic>[false, '-', false])); expect(log, equals(<dynamic>[false, '-', false]));
}); });
testWidgetsWithLeakTracking('Material2 - CheckboxListTile checkColor test', (WidgetTester tester) async { testWidgets('Material2 - CheckboxListTile checkColor test', (WidgetTester tester) async {
const Color checkBoxBorderColor = Color(0xff2196f3); const Color checkBoxBorderColor = Color(0xff2196f3);
Color checkBoxCheckColor = const Color(0xffFFFFFF); Color checkBoxCheckColor = const Color(0xffFFFFFF);
@ -69,7 +68,7 @@ void main() {
expect(getCheckboxListTileRenderer(), paints..path(color: checkBoxBorderColor)..path(color: checkBoxCheckColor)); expect(getCheckboxListTileRenderer(), paints..path(color: checkBoxBorderColor)..path(color: checkBoxCheckColor));
}); });
testWidgetsWithLeakTracking('Material3 - CheckboxListTile checkColor test', (WidgetTester tester) async { testWidgets('Material3 - CheckboxListTile checkColor test', (WidgetTester tester) async {
const Color checkBoxBorderColor = Color(0xff6750a4); const Color checkBoxBorderColor = Color(0xff6750a4);
Color checkBoxCheckColor = const Color(0xffFFFFFF); Color checkBoxCheckColor = const Color(0xffFFFFFF);
@ -101,7 +100,7 @@ void main() {
expect(getCheckboxListTileRenderer(), paints..path(color: checkBoxBorderColor)..path(color: checkBoxCheckColor)); expect(getCheckboxListTileRenderer(), paints..path(color: checkBoxBorderColor)..path(color: checkBoxCheckColor));
}); });
testWidgetsWithLeakTracking('CheckboxListTile activeColor test', (WidgetTester tester) async { testWidgets('CheckboxListTile activeColor test', (WidgetTester tester) async {
Widget buildFrame(Color? themeColor, Color? activeColor) { Widget buildFrame(Color? themeColor, Color? activeColor) {
return wrap( return wrap(
child: Theme( child: Theme(
@ -133,7 +132,7 @@ void main() {
expect(getCheckboxListTileRenderer(), paints..path(color: const Color(0xFFFFFFFF))); expect(getCheckboxListTileRenderer(), paints..path(color: const Color(0xFFFFFFFF)));
}); });
testWidgetsWithLeakTracking('CheckboxListTile can autofocus unless disabled.', (WidgetTester tester) async { testWidgets('CheckboxListTile can autofocus unless disabled.', (WidgetTester tester) async {
final GlobalKey childKey = GlobalKey(); final GlobalKey childKey = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
@ -165,7 +164,7 @@ void main() {
expect(Focus.maybeOf(childKey.currentContext!)!.hasPrimaryFocus, isFalse); expect(Focus.maybeOf(childKey.currentContext!)!.hasPrimaryFocus, isFalse);
}); });
testWidgetsWithLeakTracking('CheckboxListTile contentPadding test', (WidgetTester tester) async { testWidgets('CheckboxListTile contentPadding test', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
child: const Center( child: const Center(
@ -195,7 +194,7 @@ void main() {
expect(paddingRect.bottom, tallerWidget.bottom + remainingHeight / 2 + 2); expect(paddingRect.bottom, tallerWidget.bottom + remainingHeight / 2 + 2);
}); });
testWidgetsWithLeakTracking('CheckboxListTile tristate test', (WidgetTester tester) async { testWidgets('CheckboxListTile tristate test', (WidgetTester tester) async {
bool? value = false; bool? value = false;
bool tristate = false; bool tristate = false;
@ -273,7 +272,7 @@ void main() {
expect(value, false); expect(value, false);
}); });
testWidgetsWithLeakTracking('CheckboxListTile respects shape', (WidgetTester tester) async { testWidgets('CheckboxListTile respects shape', (WidgetTester tester) async {
const ShapeBorder shapeBorder = RoundedRectangleBorder( const ShapeBorder shapeBorder = RoundedRectangleBorder(
borderRadius: BorderRadius.horizontal(right: Radius.circular(100)), borderRadius: BorderRadius.horizontal(right: Radius.circular(100)),
); );
@ -290,7 +289,7 @@ void main() {
expect(tester.widget<InkWell>(find.byType(InkWell)).customBorder, shapeBorder); expect(tester.widget<InkWell>(find.byType(InkWell)).customBorder, shapeBorder);
}); });
testWidgetsWithLeakTracking('CheckboxListTile respects tileColor', (WidgetTester tester) async { testWidgets('CheckboxListTile respects tileColor', (WidgetTester tester) async {
final Color tileColor = Colors.red.shade500; final Color tileColor = Colors.red.shade500;
await tester.pumpWidget( await tester.pumpWidget(
@ -309,7 +308,7 @@ void main() {
expect(find.byType(Material), paints..rect(color: tileColor)); expect(find.byType(Material), paints..rect(color: tileColor));
}); });
testWidgetsWithLeakTracking('CheckboxListTile respects selectedTileColor', (WidgetTester tester) async { testWidgets('CheckboxListTile respects selectedTileColor', (WidgetTester tester) async {
final Color selectedTileColor = Colors.green.shade500; final Color selectedTileColor = Colors.green.shade500;
await tester.pumpWidget( await tester.pumpWidget(
@ -329,7 +328,7 @@ void main() {
expect(find.byType(Material), paints..rect(color: selectedTileColor)); expect(find.byType(Material), paints..rect(color: selectedTileColor));
}); });
testWidgetsWithLeakTracking('CheckboxListTile selected item text Color', (WidgetTester tester) async { testWidgets('CheckboxListTile selected item text Color', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/pull/76908 // Regression test for https://github.com/flutter/flutter/pull/76908
const Color activeColor = Color(0xff00ff00); const Color activeColor = Color(0xff00ff00);
@ -368,7 +367,7 @@ void main() {
expect(textColor('title'), activeColor); expect(textColor('title'), activeColor);
}); });
testWidgetsWithLeakTracking('CheckboxListTile respects checkbox shape and side', (WidgetTester tester) async { testWidgets('CheckboxListTile respects checkbox shape and side', (WidgetTester tester) async {
Widget buildApp(BorderSide side, OutlinedBorder shape) { Widget buildApp(BorderSide side, OutlinedBorder shape) {
return MaterialApp( return MaterialApp(
home: Material( home: Material(
@ -422,7 +421,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('CheckboxListTile respects visualDensity', (WidgetTester tester) async { testWidgets('CheckboxListTile respects visualDensity', (WidgetTester tester) async {
const Key key = Key('test'); const Key key = Key('test');
Future<void> buildTest(VisualDensity visualDensity) async { Future<void> buildTest(VisualDensity visualDensity) async {
return tester.pumpWidget( return tester.pumpWidget(
@ -446,7 +445,7 @@ void main() {
expect(box.size, equals(const Size(800, 56))); expect(box.size, equals(const Size(800, 56)));
}); });
testWidgetsWithLeakTracking('CheckboxListTile respects focusNode', (WidgetTester tester) async { testWidgets('CheckboxListTile respects focusNode', (WidgetTester tester) async {
final GlobalKey childKey = GlobalKey(); final GlobalKey childKey = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
@ -468,7 +467,7 @@ void main() {
expect(tileNode.hasPrimaryFocus, isTrue); expect(tileNode.hasPrimaryFocus, isTrue);
}); });
testWidgetsWithLeakTracking('CheckboxListTile onFocusChange callback', (WidgetTester tester) async { testWidgets('CheckboxListTile onFocusChange callback', (WidgetTester tester) async {
final FocusNode node = FocusNode(debugLabel: 'CheckboxListTile onFocusChange'); final FocusNode node = FocusNode(debugLabel: 'CheckboxListTile onFocusChange');
bool gotFocus = false; bool gotFocus = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -499,7 +498,7 @@ void main() {
node.dispose(); node.dispose();
}); });
testWidgetsWithLeakTracking('CheckboxListTile can be disabled', (WidgetTester tester) async { testWidgets('CheckboxListTile can be disabled', (WidgetTester tester) async {
bool? value = false; bool? value = false;
bool enabled = true; bool enabled = true;
@ -540,7 +539,7 @@ void main() {
expect(tester.widget<Checkbox>(checkbox).value, true); expect(tester.widget<Checkbox>(checkbox).value, true);
}); });
testWidgetsWithLeakTracking('CheckboxListTile respects mouseCursor when hovered', (WidgetTester tester) async { testWidgets('CheckboxListTile respects mouseCursor when hovered', (WidgetTester tester) async {
// Test Checkbox() constructor // Test Checkbox() constructor
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
@ -611,7 +610,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('CheckboxListTile respects fillColor in enabled/disabled states', (WidgetTester tester) async { testWidgets('CheckboxListTile respects fillColor in enabled/disabled states', (WidgetTester tester) async {
const Color activeEnabledFillColor = Color(0xFF000001); const Color activeEnabledFillColor = Color(0xFF000001);
const Color activeDisabledFillColor = Color(0xFF000002); const Color activeDisabledFillColor = Color(0xFF000002);
@ -647,7 +646,7 @@ void main() {
expect(getCheckboxRenderer(), paints..path(color: activeDisabledFillColor)); expect(getCheckboxRenderer(), paints..path(color: activeDisabledFillColor));
}); });
testWidgetsWithLeakTracking('CheckboxListTile respects fillColor in hovered state', (WidgetTester tester) async { testWidgets('CheckboxListTile respects fillColor in hovered state', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
const Color hoveredFillColor = Color(0xFF000001); const Color hoveredFillColor = Color(0xFF000001);
@ -691,7 +690,7 @@ void main() {
expect(getCheckboxRenderer(), paints..path(color: hoveredFillColor)); expect(getCheckboxRenderer(), paints..path(color: hoveredFillColor));
}); });
testWidgetsWithLeakTracking('CheckboxListTile respects hoverColor', (WidgetTester tester) async { testWidgets('CheckboxListTile respects hoverColor', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
bool? value = true; bool? value = true;
Widget buildApp({bool enabled = true}) { Widget buildApp({bool enabled = true}) {
@ -743,7 +742,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material2 - CheckboxListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async { testWidgets('Material2 - CheckboxListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
const Color fillColor = Color(0xFF000000); const Color fillColor = Color(0xFF000000);
@ -866,7 +865,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Material3 - CheckboxListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async { testWidgets('Material3 - CheckboxListTile respects overlayColor in active/pressed/hovered states', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
const Color fillColor = Color(0xFF000000); const Color fillColor = Color(0xFF000000);
@ -996,7 +995,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('CheckboxListTile respects splashRadius', (WidgetTester tester) async { testWidgets('CheckboxListTile respects splashRadius', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
const double splashRadius = 30; const double splashRadius = 30;
Widget buildApp() { Widget buildApp() {
@ -1025,7 +1024,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('CheckboxListTile respects materialTapTargetSize', (WidgetTester tester) async { testWidgets('CheckboxListTile respects materialTapTargetSize', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
child: CheckboxListTile( child: CheckboxListTile(
@ -1051,7 +1050,7 @@ void main() {
expect(tester.getSize(find.byType(Checkbox)), const Size(48.0, 48.0)); expect(tester.getSize(find.byType(Checkbox)), const Size(48.0, 48.0));
}); });
testWidgetsWithLeakTracking('Material3 - CheckboxListTile respects isError', (WidgetTester tester) async { testWidgets('Material3 - CheckboxListTile respects isError', (WidgetTester tester) async {
final ThemeData themeData = ThemeData(useMaterial3: true); final ThemeData themeData = ThemeData(useMaterial3: true);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
bool? value = true; bool? value = true;
@ -1099,7 +1098,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('CheckboxListTile.adaptive shows the correct checkbox platform widget', (WidgetTester tester) async { testWidgets('CheckboxListTile.adaptive shows the correct checkbox platform widget', (WidgetTester tester) async {
Widget buildApp(TargetPlatform platform) { Widget buildApp(TargetPlatform platform) {
return MaterialApp( return MaterialApp(
theme: ThemeData(platform: platform), theme: ThemeData(platform: platform),
@ -1142,7 +1141,7 @@ void main() {
feedback.dispose(); feedback.dispose();
}); });
testWidgetsWithLeakTracking('CheckboxListTile respects enableFeedback', (WidgetTester tester) async { testWidgets('CheckboxListTile respects enableFeedback', (WidgetTester tester) async {
Future<void> buildTest(bool enableFeedback) async { Future<void> buildTest(bool enableFeedback) async {
return tester.pumpWidget( return tester.pumpWidget(
wrap( wrap(
@ -1171,7 +1170,7 @@ void main() {
}); });
}); });
testWidgetsWithLeakTracking('CheckboxListTile has proper semantics', (WidgetTester tester) async { testWidgets('CheckboxListTile has proper semantics', (WidgetTester tester) async {
final List<dynamic> log = <dynamic>[]; final List<dynamic> log = <dynamic>[];
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(wrap( await tester.pumpWidget(wrap(

View File

@ -11,7 +11,6 @@ import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter/src/gestures/constants.dart'; import 'package:flutter/src/gestures/constants.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
@ -21,7 +20,7 @@ void main() {
debugResetSemanticsIdCounter(); debugResetSemanticsIdCounter();
}); });
testWidgetsWithLeakTracking('Checkbox size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { testWidgets('Checkbox size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
Theme( Theme(
data: theme.copyWith(materialTapTargetSize: MaterialTapTargetSize.padded), data: theme.copyWith(materialTapTargetSize: MaterialTapTargetSize.padded),
@ -61,7 +60,7 @@ void main() {
expect(tester.getSize(find.byType(Checkbox)), const Size(40.0, 40.0)); expect(tester.getSize(find.byType(Checkbox)), const Size(40.0, 40.0));
}); });
testWidgetsWithLeakTracking('Checkbox semantics', (WidgetTester tester) async { testWidgets('Checkbox semantics', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(Theme( await tester.pumpWidget(Theme(
@ -219,7 +218,7 @@ void main() {
handle.dispose(); handle.dispose();
}); });
testWidgetsWithLeakTracking('Can wrap Checkbox with Semantics', (WidgetTester tester) async { testWidgets('Can wrap Checkbox with Semantics', (WidgetTester tester) async {
final SemanticsHandle handle = tester.ensureSemantics(); final SemanticsHandle handle = tester.ensureSemantics();
await tester.pumpWidget(Theme( await tester.pumpWidget(Theme(
@ -248,7 +247,7 @@ void main() {
handle.dispose(); handle.dispose();
}); });
testWidgetsWithLeakTracking('Checkbox tristate: true', (WidgetTester tester) async { testWidgets('Checkbox tristate: true', (WidgetTester tester) async {
bool? checkBoxValue; bool? checkBoxValue;
await tester.pumpWidget( await tester.pumpWidget(
@ -295,7 +294,7 @@ void main() {
expect(checkBoxValue, null); expect(checkBoxValue, null);
}); });
testWidgetsWithLeakTracking('has semantics for tristate', (WidgetTester tester) async { testWidgets('has semantics for tristate', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester); final SemanticsTester semantics = SemanticsTester(tester);
await tester.pumpWidget( await tester.pumpWidget(
Theme( Theme(
@ -371,7 +370,7 @@ void main() {
semantics.dispose(); semantics.dispose();
}); });
testWidgetsWithLeakTracking('has semantic events', (WidgetTester tester) async { testWidgets('has semantic events', (WidgetTester tester) async {
dynamic semanticEvent; dynamic semanticEvent;
bool? checkboxValue = false; bool? checkboxValue = false;
tester.binding.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, (dynamic message) async { tester.binding.defaultBinaryMessenger.setMockDecodedMessageHandler<dynamic>(SystemChannels.accessibility, (dynamic message) async {
@ -414,7 +413,7 @@ void main() {
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgetsWithLeakTracking('Material2 - Checkbox tristate rendering, programmatic transitions', (WidgetTester tester) async { testWidgets('Material2 - Checkbox tristate rendering, programmatic transitions', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: false); final ThemeData theme = ThemeData(useMaterial3: false);
Widget buildFrame(bool? checkboxValue) { Widget buildFrame(bool? checkboxValue) {
return Theme( return Theme(
@ -474,7 +473,7 @@ void main() {
expect(getCheckboxRenderer(), paints..line()); // null is rendered as a line (a "dash") expect(getCheckboxRenderer(), paints..line()); // null is rendered as a line (a "dash")
}); });
testWidgetsWithLeakTracking('Material3 - Checkbox tristate rendering, programmatic transitions', (WidgetTester tester) async { testWidgets('Material3 - Checkbox tristate rendering, programmatic transitions', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
Widget buildFrame(bool? checkboxValue) { Widget buildFrame(bool? checkboxValue) {
return Theme( return Theme(
@ -534,7 +533,7 @@ void main() {
expect(getCheckboxRenderer(), paints..line()); // null is rendered as a line (a "dash") expect(getCheckboxRenderer(), paints..line()); // null is rendered as a line (a "dash")
}); });
testWidgetsWithLeakTracking('Material2 - Checkbox color rendering', (WidgetTester tester) async { testWidgets('Material2 - Checkbox color rendering', (WidgetTester tester) async {
ThemeData theme = ThemeData(useMaterial3: false); ThemeData theme = ThemeData(useMaterial3: false);
const Color borderColor = Color(0xff2196f3); const Color borderColor = Color(0xff2196f3);
Color checkColor = const Color(0xffFFFFFF); Color checkColor = const Color(0xffFFFFFF);
@ -589,7 +588,7 @@ void main() {
expect(getCheckboxRenderer(), paints..path(color: activeColor)); expect(getCheckboxRenderer(), paints..path(color: activeColor));
}); });
testWidgetsWithLeakTracking('Material3 - Checkbox color rendering', (WidgetTester tester) async { testWidgets('Material3 - Checkbox color rendering', (WidgetTester tester) async {
ThemeData theme = ThemeData(useMaterial3: true); ThemeData theme = ThemeData(useMaterial3: true);
const Color borderColor = Color(0xFF6750A4); const Color borderColor = Color(0xFF6750A4);
Color checkColor = const Color(0xffFFFFFF); Color checkColor = const Color(0xffFFFFFF);
@ -642,7 +641,7 @@ void main() {
expect(getCheckboxRenderer(), paints..path(color: activeColor)); expect(getCheckboxRenderer(), paints..path(color: activeColor));
}); });
testWidgetsWithLeakTracking('Material2 - Checkbox is focusable and has correct focus color', (WidgetTester tester) async { testWidgets('Material2 - Checkbox is focusable and has correct focus color', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox'); final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
@ -713,7 +712,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material3 - Checkbox is focusable and has correct focus color', (WidgetTester tester) async { testWidgets('Material3 - Checkbox is focusable and has correct focus color', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox'); final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
@ -785,7 +784,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Checkbox with splash radius set', (WidgetTester tester) async { testWidgets('Checkbox with splash radius set', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
const double splashRadius = 30; const double splashRadius = 30;
Widget buildApp() { Widget buildApp() {
@ -814,7 +813,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Checkbox starts the splash in center, even when tap is on the corner', (WidgetTester tester) async { testWidgets('Checkbox starts the splash in center, even when tap is on the corner', (WidgetTester tester) async {
Widget buildApp() { Widget buildApp() {
return MaterialApp( return MaterialApp(
theme: theme, theme: theme,
@ -850,7 +849,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Material2 - Checkbox can be hovered and has correct hover color', (WidgetTester tester) async { testWidgets('Material2 - Checkbox can be hovered and has correct hover color', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
bool? value = true; bool? value = true;
final ThemeData theme = ThemeData(useMaterial3: false); final ThemeData theme = ThemeData(useMaterial3: false);
@ -907,7 +906,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material3 - Checkbox can be hovered and has correct hover color', (WidgetTester tester) async { testWidgets('Material3 - Checkbox can be hovered and has correct hover color', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
bool? value = true; bool? value = true;
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
@ -964,7 +963,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Checkbox can be toggled by keyboard shortcuts', (WidgetTester tester) async { testWidgets('Checkbox can be toggled by keyboard shortcuts', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
bool? value = true; bool? value = true;
Widget buildApp({bool enabled = true}) { Widget buildApp({bool enabled = true}) {
@ -1005,7 +1004,7 @@ void main() {
expect(value, isTrue); expect(value, isTrue);
}); });
testWidgetsWithLeakTracking('Checkbox responds to density changes.', (WidgetTester tester) async { testWidgets('Checkbox responds to density changes.', (WidgetTester tester) async {
const Key key = Key('test'); const Key key = Key('test');
Future<void> buildTest(VisualDensity visualDensity) async { Future<void> buildTest(VisualDensity visualDensity) async {
return tester.pumpWidget( return tester.pumpWidget(
@ -1043,7 +1042,7 @@ void main() {
expect(box.size, equals(const Size(60, 36))); expect(box.size, equals(const Size(60, 36)));
}); });
testWidgetsWithLeakTracking('Checkbox stops hover animation when removed from the tree.', (WidgetTester tester) async { testWidgets('Checkbox stops hover animation when removed from the tree.', (WidgetTester tester) async {
const Key checkboxKey = Key('checkbox'); const Key checkboxKey = Key('checkbox');
bool? checkboxVal = true; bool? checkboxVal = true;
@ -1097,7 +1096,7 @@ void main() {
}); });
testWidgetsWithLeakTracking('Checkbox changes mouse cursor when hovered', (WidgetTester tester) async { testWidgets('Checkbox changes mouse cursor when hovered', (WidgetTester tester) async {
// Test Checkbox() constructor // Test Checkbox() constructor
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -1202,7 +1201,7 @@ void main() {
}); });
testWidgetsWithLeakTracking('Checkbox fill color resolves in enabled/disabled states', (WidgetTester tester) async { testWidgets('Checkbox fill color resolves in enabled/disabled states', (WidgetTester tester) async {
const Color activeEnabledFillColor = Color(0xFF000001); const Color activeEnabledFillColor = Color(0xFF000001);
const Color activeDisabledFillColor = Color(0xFF000002); const Color activeDisabledFillColor = Color(0xFF000002);
@ -1246,7 +1245,7 @@ void main() {
expect(getCheckboxRenderer(), paints..path(color: activeDisabledFillColor)); expect(getCheckboxRenderer(), paints..path(color: activeDisabledFillColor));
}); });
testWidgetsWithLeakTracking('Checkbox fill color resolves in hovered/focused states', (WidgetTester tester) async { testWidgets('Checkbox fill color resolves in hovered/focused states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'checkbox'); final FocusNode focusNode = FocusNode(debugLabel: 'checkbox');
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
@ -1304,7 +1303,7 @@ void main() {
expect(getCheckboxRenderer(), paints..path(color: hoveredFillColor)); expect(getCheckboxRenderer(), paints..path(color: hoveredFillColor));
}); });
testWidgetsWithLeakTracking('Checkbox respects shape and side', (WidgetTester tester) async { testWidgets('Checkbox respects shape and side', (WidgetTester tester) async {
const RoundedRectangleBorder roundedRectangleBorder = const RoundedRectangleBorder roundedRectangleBorder =
RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(5))); RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(5)));
@ -1347,7 +1346,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material2 - Checkbox default overlay color in active/pressed/focused/hovered states', (WidgetTester tester) async { testWidgets('Material2 - Checkbox default overlay color in active/pressed/focused/hovered states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox'); final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
@ -1420,7 +1419,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Material3 - Checkbox default overlay color in active/pressed/focused/hovered states', (WidgetTester tester) async { testWidgets('Material3 - Checkbox default overlay color in active/pressed/focused/hovered states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox'); final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
@ -1491,7 +1490,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Checkbox overlay color resolves in active/pressed/focused/hovered states', (WidgetTester tester) async { testWidgets('Checkbox overlay color resolves in active/pressed/focused/hovered states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox'); final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
@ -1635,7 +1634,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Tristate Checkbox overlay color resolves in pressed active/inactive states', (WidgetTester tester) async { testWidgets('Tristate Checkbox overlay color resolves in pressed active/inactive states', (WidgetTester tester) async {
const Color activePressedOverlayColor = Color(0xFF000001); const Color activePressedOverlayColor = Color(0xFF000001);
const Color inactivePressedOverlayColor = Color(0xFF000002); const Color inactivePressedOverlayColor = Color(0xFF000002);
@ -1742,7 +1741,7 @@ void main() {
await gesture.up(); await gesture.up();
}); });
testWidgetsWithLeakTracking('Do not crash when widget disappears while pointer is down', (WidgetTester tester) async { testWidgets('Do not crash when widget disappears while pointer is down', (WidgetTester tester) async {
Widget buildCheckbox(bool show) { Widget buildCheckbox(bool show) {
return MaterialApp( return MaterialApp(
theme: theme, theme: theme,
@ -1766,7 +1765,7 @@ void main() {
await gesture.up(); await gesture.up();
}); });
testWidgetsWithLeakTracking('Checkbox BorderSide side only applies when unselected in M2', (WidgetTester tester) async { testWidgets('Checkbox BorderSide side only applies when unselected in M2', (WidgetTester tester) async {
const Color borderColor = Color(0xfff44336); const Color borderColor = Color(0xfff44336);
const Color activeColor = Color(0xff123456); const Color activeColor = Color(0xff123456);
const BorderSide side = BorderSide( const BorderSide side = BorderSide(
@ -1830,7 +1829,7 @@ void main() {
expect(getCheckboxRenderer(), paints..path(color: activeColor)); // checkbox fill expect(getCheckboxRenderer(), paints..path(color: activeColor)); // checkbox fill
}); });
testWidgetsWithLeakTracking('Material2 - Checkbox MaterialStateBorderSide applies unconditionally', (WidgetTester tester) async { testWidgets('Material2 - Checkbox MaterialStateBorderSide applies unconditionally', (WidgetTester tester) async {
const Color borderColor = Color(0xfff44336); const Color borderColor = Color(0xfff44336);
const BorderSide side = BorderSide( const BorderSide side = BorderSide(
width: 4, width: 4,
@ -1884,7 +1883,7 @@ void main() {
expectBorder(); expectBorder();
}); });
testWidgetsWithLeakTracking('Material3 - Checkbox MaterialStateBorderSide applies unconditionally', (WidgetTester tester) async { testWidgets('Material3 - Checkbox MaterialStateBorderSide applies unconditionally', (WidgetTester tester) async {
const Color borderColor = Color(0xfff44336); const Color borderColor = Color(0xfff44336);
const BorderSide side = BorderSide( const BorderSide side = BorderSide(
width: 4, width: 4,
@ -1938,7 +1937,7 @@ void main() {
expectBorder(); expectBorder();
}); });
testWidgetsWithLeakTracking('disabled checkbox shows tooltip', (WidgetTester tester) async { testWidgets('disabled checkbox shows tooltip', (WidgetTester tester) async {
const String longPressTooltip = 'long press tooltip'; const String longPressTooltip = 'long press tooltip';
const String tapTooltip = 'tap tooltip'; const String tapTooltip = 'tap tooltip';
await tester.pumpWidget( await tester.pumpWidget(
@ -1992,7 +1991,7 @@ void main() {
expect(find.text(tapTooltip), findsOneWidget); expect(find.text(tapTooltip), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Material3 - Checkbox has default error color when isError is set to true', (WidgetTester tester) async { testWidgets('Material3 - Checkbox has default error color when isError is set to true', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox'); final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
final ThemeData themeData = ThemeData(useMaterial3: true); final ThemeData themeData = ThemeData(useMaterial3: true);
@ -2065,7 +2064,7 @@ void main() {
await tester.pump(); await tester.pump();
}); });
testWidgetsWithLeakTracking('Material3 - Checkbox MaterialStateBorderSide applies in error states', (WidgetTester tester) async { testWidgets('Material3 - Checkbox MaterialStateBorderSide applies in error states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox'); final FocusNode focusNode = FocusNode(debugLabel: 'Checkbox');
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
final ThemeData themeData = ThemeData(useMaterial3: true); final ThemeData themeData = ThemeData(useMaterial3: true);
@ -2145,7 +2144,7 @@ void main() {
await tester.pump(); await tester.pump();
}); });
testWidgetsWithLeakTracking('Material3 - Checkbox has correct default shape', (WidgetTester tester) async { testWidgets('Material3 - Checkbox has correct default shape', (WidgetTester tester) async {
final ThemeData themeData = ThemeData(useMaterial3: true); final ThemeData themeData = ThemeData(useMaterial3: true);
Widget buildApp() { Widget buildApp() {
@ -2179,7 +2178,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Checkbox.adaptive shows the correct platform widget', (WidgetTester tester) async { testWidgets('Checkbox.adaptive shows the correct platform widget', (WidgetTester tester) async {
Widget buildApp(TargetPlatform platform) { Widget buildApp(TargetPlatform platform) {
return MaterialApp( return MaterialApp(
theme: ThemeData(platform: platform), theme: ThemeData(platform: platform),
@ -2211,7 +2210,7 @@ void main() {
} }
}); });
testWidgetsWithLeakTracking('Material2 - Checkbox respects fillColor when it is unchecked', (WidgetTester tester) async { testWidgets('Material2 - Checkbox respects fillColor when it is unchecked', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: false); final ThemeData theme = ThemeData(useMaterial3: false);
const Color activeBackgroundColor = Color(0xff123456); const Color activeBackgroundColor = Color(0xff123456);
const Color inactiveBackgroundColor = Color(0xff654321); const Color inactiveBackgroundColor = Color(0xff654321);
@ -2264,7 +2263,7 @@ void main() {
expect(getCheckboxRenderer(), paints..path(color: inactiveBackgroundColor)); expect(getCheckboxRenderer(), paints..path(color: inactiveBackgroundColor));
}); });
testWidgetsWithLeakTracking('Material3 - Checkbox respects fillColor when it is unchecked', (WidgetTester tester) async { testWidgets('Material3 - Checkbox respects fillColor when it is unchecked', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
const Color activeBackgroundColor = Color(0xff123456); const Color activeBackgroundColor = Color(0xff123456);
const Color inactiveBackgroundColor = Color(0xff654321); const Color inactiveBackgroundColor = Color(0xff654321);

View File

@ -6,7 +6,6 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() { void main() {
test('CheckboxThemeData copyWith, ==, hashCode basics', () { test('CheckboxThemeData copyWith, ==, hashCode basics', () {
@ -40,7 +39,7 @@ void main() {
expect(theme.data.visualDensity, null); expect(theme.data.visualDensity, null);
}); });
testWidgetsWithLeakTracking('Default CheckboxThemeData debugFillProperties', (WidgetTester tester) async { testWidgets('Default CheckboxThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const CheckboxThemeData().debugFillProperties(builder); const CheckboxThemeData().debugFillProperties(builder);
@ -52,7 +51,7 @@ void main() {
expect(description, <String>[]); expect(description, <String>[]);
}); });
testWidgetsWithLeakTracking('CheckboxThemeData implements debugFillProperties', (WidgetTester tester) async { testWidgets('CheckboxThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const CheckboxThemeData( const CheckboxThemeData(
mouseCursor: MaterialStatePropertyAll<MouseCursor?>(SystemMouseCursors.click), mouseCursor: MaterialStatePropertyAll<MouseCursor?>(SystemMouseCursors.click),
@ -83,7 +82,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Checkbox is themeable', (WidgetTester tester) async { testWidgets('Checkbox is themeable', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
const MouseCursor mouseCursor = SystemMouseCursors.text; const MouseCursor mouseCursor = SystemMouseCursors.text;
@ -165,7 +164,7 @@ void main() {
expect(_getCheckboxMaterial(tester), paints..path(color: selectedFillColor)..path(color: focusedCheckColor)); expect(_getCheckboxMaterial(tester), paints..path(color: selectedFillColor)..path(color: focusedCheckColor));
}); });
testWidgetsWithLeakTracking('Checkbox properties are taken over the theme values', (WidgetTester tester) async { testWidgets('Checkbox properties are taken over the theme values', (WidgetTester tester) async {
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
const MouseCursor themeMouseCursor = SystemMouseCursors.click; const MouseCursor themeMouseCursor = SystemMouseCursors.click;
@ -263,7 +262,7 @@ void main() {
expect(_getCheckboxMaterial(tester), paints..circle(color: focusColor, radius: splashRadius)); expect(_getCheckboxMaterial(tester), paints..circle(color: focusColor, radius: splashRadius));
}); });
testWidgetsWithLeakTracking('Checkbox activeColor property is taken over the theme', (WidgetTester tester) async { testWidgets('Checkbox activeColor property is taken over the theme', (WidgetTester tester) async {
const Color themeSelectedFillColor = Color(0xfffffff1); const Color themeSelectedFillColor = Color(0xfffffff1);
const Color themeDefaultFillColor = Color(0xfffffff0); const Color themeDefaultFillColor = Color(0xfffffff0);
const Color selectedFillColor = Color(0xfffffff6); const Color selectedFillColor = Color(0xfffffff6);
@ -301,7 +300,7 @@ void main() {
expect(_getCheckboxMaterial(tester), paints..path(color: selectedFillColor)); expect(_getCheckboxMaterial(tester), paints..path(color: selectedFillColor));
}); });
testWidgetsWithLeakTracking('Checkbox theme overlay color resolves in active/pressed states', (WidgetTester tester) async { testWidgets('Checkbox theme overlay color resolves in active/pressed states', (WidgetTester tester) async {
const Color activePressedOverlayColor = Color(0xFF000001); const Color activePressedOverlayColor = Color(0xFF000001);
const Color inactivePressedOverlayColor = Color(0xFF000002); const Color inactivePressedOverlayColor = Color(0xFF000002);
@ -367,7 +366,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Local CheckboxTheme can override global CheckboxTheme', (WidgetTester tester) async { testWidgets('Local CheckboxTheme can override global CheckboxTheme', (WidgetTester tester) async {
const Color globalThemeFillColor = Color(0xfffffff1); const Color globalThemeFillColor = Color(0xfffffff1);
const Color globalThemeCheckColor = Color(0xff000000); const Color globalThemeCheckColor = Color(0xff000000);
const Color localThemeFillColor = Color(0xffff0000); const Color localThemeFillColor = Color(0xffff0000);

View File

@ -12,7 +12,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../widgets/semantics_tester.dart'; import '../widgets/semantics_tester.dart';
import 'feedback_tester.dart'; import 'feedback_tester.dart';
@ -220,7 +219,7 @@ Finder findTooltipContainer(String tooltipText) {
} }
void main() { void main() {
testWidgetsWithLeakTracking('M2 Chip defaults', (WidgetTester tester) async { testWidgets('M2 Chip defaults', (WidgetTester tester) async {
late TextTheme textTheme; late TextTheme textTheme;
Widget buildFrame(Brightness brightness) { Widget buildFrame(Brightness brightness) {
@ -297,7 +296,7 @@ void main() {
expect(labelStyle.wordSpacing, textTheme.bodyLarge?.wordSpacing); expect(labelStyle.wordSpacing, textTheme.bodyLarge?.wordSpacing);
}); });
testWidgetsWithLeakTracking('M3 Chip defaults', (WidgetTester tester) async { testWidgets('M3 Chip defaults', (WidgetTester tester) async {
late TextTheme textTheme; late TextTheme textTheme;
final ThemeData lightTheme = ThemeData.light(useMaterial3: true); final ThemeData lightTheme = ThemeData.light(useMaterial3: true);
final ThemeData darkTheme = ThemeData.dark(useMaterial3: true); final ThemeData darkTheme = ThemeData.dark(useMaterial3: true);
@ -378,7 +377,7 @@ void main() {
expect(labelStyle.wordSpacing, textTheme.labelLarge?.wordSpacing); expect(labelStyle.wordSpacing, textTheme.labelLarge?.wordSpacing);
}); });
testWidgetsWithLeakTracking('Chip control test', (WidgetTester tester) async { testWidgets('Chip control test', (WidgetTester tester) async {
final FeedbackTester feedback = FeedbackTester(); final FeedbackTester feedback = FeedbackTester();
final List<String> deletedChipLabels = <String>[]; final List<String> deletedChipLabels = <String>[];
await tester.pumpWidget( await tester.pumpWidget(
@ -427,7 +426,7 @@ void main() {
feedback.dispose(); feedback.dispose();
}); });
testWidgetsWithLeakTracking( testWidgets(
'Chip does not constrain size of label widget if it does not exceed ' 'Chip does not constrain size of label widget if it does not exceed '
'the available space', 'the available space',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -463,7 +462,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'Chip constrains the size of the label widget when it exceeds the ' 'Chip constrains the size of the label widget when it exceeds the '
'available space', 'available space',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -471,7 +470,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'Chip constrains the size of the label widget when it exceeds the ' 'Chip constrains the size of the label widget when it exceeds the '
'available space and the avatar is present', 'available space and the avatar is present',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -482,7 +481,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'Chip constrains the size of the label widget when it exceeds the ' 'Chip constrains the size of the label widget when it exceeds the '
'available space and the delete icon is present', 'available space and the delete icon is present',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -493,7 +492,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'Chip constrains the size of the label widget when it exceeds the ' 'Chip constrains the size of the label widget when it exceeds the '
'available space and both avatar and delete icons are present', 'available space and both avatar and delete icons are present',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -505,7 +504,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking( testWidgets(
'Chip constrains the avatar, label, and delete icons to the bounds of ' 'Chip constrains the avatar, label, and delete icons to the bounds of '
'the chip when it exceeds the available space', 'the chip when it exceeds the available space',
(WidgetTester tester) async { (WidgetTester tester) async {
@ -580,7 +579,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('Chip in row works ok', (WidgetTester tester) async { testWidgets('Chip in row works ok', (WidgetTester tester) async {
const TextStyle style = TextStyle(fontSize: 10.0); const TextStyle style = TextStyle(fontSize: 10.0);
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
@ -618,7 +617,7 @@ void main() {
expect(tester.getSize(find.byType(Chip)), const Size(800.0, 48.0)); expect(tester.getSize(find.byType(Chip)), const Size(800.0, 48.0));
}); });
testWidgetsWithLeakTracking('Chip responds to materialTapTargetSize', (WidgetTester tester) async { testWidgets('Chip responds to materialTapTargetSize', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
useMaterial3: false, useMaterial3: false,
@ -641,7 +640,7 @@ void main() {
}, },
); );
testWidgetsWithLeakTracking('Delete button tap target is the right proportion of the chip', (WidgetTester tester) async { testWidgets('Delete button tap target is the right proportion of the chip', (WidgetTester tester) async {
final UniqueKey deleteKey = UniqueKey(); final UniqueKey deleteKey = UniqueKey();
bool calledDelete = false; bool calledDelete = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -703,7 +702,7 @@ void main() {
expect(calledDelete, isFalse); expect(calledDelete, isFalse);
}); });
testWidgetsWithLeakTracking('Chip elements are ordered horizontally for locale', (WidgetTester tester) async { testWidgets('Chip elements are ordered horizontally for locale', (WidgetTester tester) async {
final UniqueKey iconKey = UniqueKey(); final UniqueKey iconKey = UniqueKey();
late final OverlayEntry entry; late final OverlayEntry entry;
addTearDown(() => entry..remove()..dispose()); addTearDown(() => entry..remove()..dispose());
@ -740,7 +739,7 @@ void main() {
expect(tester.getCenter(find.text('ABC')).dx, lessThan(tester.getCenter(find.byKey(iconKey)).dx)); expect(tester.getCenter(find.text('ABC')).dx, lessThan(tester.getCenter(find.byKey(iconKey)).dx));
}); });
testWidgetsWithLeakTracking('Chip responds to textScaleFactor', (WidgetTester tester) async { testWidgets('Chip responds to textScaleFactor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
useMaterial3: false, useMaterial3: false,
@ -817,7 +816,7 @@ void main() {
expect(tester.getSize(find.byType(Chip).last), const Size(132.0, 48.0)); expect(tester.getSize(find.byType(Chip).last), const Size(132.0, 48.0));
}); });
testWidgetsWithLeakTracking('Labels can be non-text widgets', (WidgetTester tester) async { testWidgets('Labels can be non-text widgets', (WidgetTester tester) async {
final Key keyA = GlobalKey(); final Key keyA = GlobalKey();
final Key keyB = GlobalKey(); final Key keyB = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
@ -844,7 +843,7 @@ void main() {
expect(tester.getSize(find.byType(Chip).last), const Size(58.0, 48.0)); expect(tester.getSize(find.byType(Chip).last), const Size(58.0, 48.0));
}); });
testWidgetsWithLeakTracking('Avatars can be non-circle avatar widgets', (WidgetTester tester) async { testWidgets('Avatars can be non-circle avatar widgets', (WidgetTester tester) async {
final Key keyA = GlobalKey(); final Key keyA = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
@ -862,7 +861,7 @@ void main() {
expect(tester.getSize(find.byKey(keyA)), equals(const Size(20.0, 20.0))); expect(tester.getSize(find.byKey(keyA)), equals(const Size(20.0, 20.0)));
}); });
testWidgetsWithLeakTracking('Delete icons can be non-icon widgets', (WidgetTester tester) async { testWidgets('Delete icons can be non-icon widgets', (WidgetTester tester) async {
final Key keyA = GlobalKey(); final Key keyA = GlobalKey();
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
@ -881,7 +880,7 @@ void main() {
expect(tester.getSize(find.byKey(keyA)), equals(const Size(20.0, 20.0))); expect(tester.getSize(find.byKey(keyA)), equals(const Size(20.0, 20.0)));
}); });
testWidgetsWithLeakTracking('Chip padding - LTR', (WidgetTester tester) async { testWidgets('Chip padding - LTR', (WidgetTester tester) async {
final GlobalKey keyA = GlobalKey(); final GlobalKey keyA = GlobalKey();
final GlobalKey keyB = GlobalKey(); final GlobalKey keyB = GlobalKey();
@ -920,7 +919,7 @@ void main() {
expect(tester.getBottomRight(find.byType(Icon)), const Offset(457.0, 309.0)); expect(tester.getBottomRight(find.byType(Icon)), const Offset(457.0, 309.0));
}); });
testWidgetsWithLeakTracking('Chip padding - RTL', (WidgetTester tester) async { testWidgets('Chip padding - RTL', (WidgetTester tester) async {
final GlobalKey keyA = GlobalKey(); final GlobalKey keyA = GlobalKey();
final GlobalKey keyB = GlobalKey(); final GlobalKey keyB = GlobalKey();
@ -962,7 +961,7 @@ void main() {
expect(tester.getBottomRight(find.byType(Icon)), const Offset(361.0, 309.0)); expect(tester.getBottomRight(find.byType(Icon)), const Offset(361.0, 309.0));
}); });
testWidgetsWithLeakTracking('Avatar drawer works as expected on RawChip', (WidgetTester tester) async { testWidgets('Avatar drawer works as expected on RawChip', (WidgetTester tester) async {
final GlobalKey labelKey = GlobalKey(); final GlobalKey labelKey = GlobalKey();
Future<void> pushChip({ Widget? avatar }) async { Future<void> pushChip({ Widget? avatar }) async {
return tester.pumpWidget( return tester.pumpWidget(
@ -1075,7 +1074,7 @@ void main() {
expect(find.byKey(avatarKey), findsNothing); expect(find.byKey(avatarKey), findsNothing);
}); });
testWidgetsWithLeakTracking('Delete button drawer works as expected on RawChip', (WidgetTester tester) async { testWidgets('Delete button drawer works as expected on RawChip', (WidgetTester tester) async {
const Key labelKey = Key('label'); const Key labelKey = Key('label');
const Key deleteButtonKey = Key('delete'); const Key deleteButtonKey = Key('delete');
bool wasDeleted = false; bool wasDeleted = false;
@ -1192,7 +1191,7 @@ void main() {
expect(find.byKey(deleteButtonKey), findsNothing); expect(find.byKey(deleteButtonKey), findsNothing);
}); });
testWidgetsWithLeakTracking('Delete button takes up at most half of the chip', (WidgetTester tester) async { testWidgets('Delete button takes up at most half of the chip', (WidgetTester tester) async {
final UniqueKey chipKey = UniqueKey(); final UniqueKey chipKey = UniqueKey();
bool chipPressed = false; bool chipPressed = false;
bool deletePressed = false; bool deletePressed = false;
@ -1228,7 +1227,7 @@ void main() {
expect(deletePressed, isTrue); expect(deletePressed, isTrue);
}); });
testWidgetsWithLeakTracking('Chip creates centered, unique ripple when label is tapped', (WidgetTester tester) async { testWidgets('Chip creates centered, unique ripple when label is tapped', (WidgetTester tester) async {
final UniqueKey labelKey = UniqueKey(); final UniqueKey labelKey = UniqueKey();
final UniqueKey deleteButtonKey = UniqueKey(); final UniqueKey deleteButtonKey = UniqueKey();
@ -1278,7 +1277,7 @@ void main() {
await gesture.up(); await gesture.up();
}); });
testWidgetsWithLeakTracking('Delete button is focusable', (WidgetTester tester) async { testWidgets('Delete button is focusable', (WidgetTester tester) async {
final GlobalKey labelKey = GlobalKey(); final GlobalKey labelKey = GlobalKey();
final GlobalKey deleteButtonKey = GlobalKey(); final GlobalKey deleteButtonKey = GlobalKey();
@ -1311,7 +1310,7 @@ void main() {
expect(Focus.of(labelKey.currentContext!).hasPrimaryFocus, isTrue); expect(Focus.of(labelKey.currentContext!).hasPrimaryFocus, isTrue);
}); });
testWidgetsWithLeakTracking('Delete button creates non-centered, unique ripple when tapped', (WidgetTester tester) async { testWidgets('Delete button creates non-centered, unique ripple when tapped', (WidgetTester tester) async {
final UniqueKey labelKey = UniqueKey(); final UniqueKey labelKey = UniqueKey();
final UniqueKey deleteButtonKey = UniqueKey(); final UniqueKey deleteButtonKey = UniqueKey();
@ -1365,7 +1364,7 @@ void main() {
await gesture.up(); await gesture.up();
}); });
testWidgetsWithLeakTracking('Delete button in a chip with null onPressed creates ripple when tapped', (WidgetTester tester) async { testWidgets('Delete button in a chip with null onPressed creates ripple when tapped', (WidgetTester tester) async {
final UniqueKey labelKey = UniqueKey(); final UniqueKey labelKey = UniqueKey();
final UniqueKey deleteButtonKey = UniqueKey(); final UniqueKey deleteButtonKey = UniqueKey();
@ -1420,7 +1419,7 @@ void main() {
await gesture.up(); await gesture.up();
}); });
testWidgetsWithLeakTracking('RTL delete button responds to tap on the left of the chip', (WidgetTester tester) async { testWidgets('RTL delete button responds to tap on the left of the chip', (WidgetTester tester) async {
// Creates an RTL chip with a delete button. // Creates an RTL chip with a delete button.
final UniqueKey labelKey = UniqueKey(); final UniqueKey labelKey = UniqueKey();
final UniqueKey deleteButtonKey = UniqueKey(); final UniqueKey deleteButtonKey = UniqueKey();
@ -1450,7 +1449,7 @@ void main() {
await gesture.up(); await gesture.up();
}); });
testWidgetsWithLeakTracking('Chip without delete button creates correct ripple', (WidgetTester tester) async { testWidgets('Chip without delete button creates correct ripple', (WidgetTester tester) async {
// Creates a chip with a delete button. // Creates a chip with a delete button.
final UniqueKey labelKey = UniqueKey(); final UniqueKey labelKey = UniqueKey();
@ -1505,7 +1504,7 @@ void main() {
await gesture.up(); await gesture.up();
}); });
testWidgetsWithLeakTracking('Selection with avatar works as expected on RawChip', (WidgetTester tester) async { testWidgets('Selection with avatar works as expected on RawChip', (WidgetTester tester) async {
bool selected = false; bool selected = false;
final UniqueKey labelKey = UniqueKey(); final UniqueKey labelKey = UniqueKey();
Future<void> pushChip({ Widget? avatar, bool selectable = false }) async { Future<void> pushChip({ Widget? avatar, bool selectable = false }) async {
@ -1586,7 +1585,7 @@ void main() {
expect(getDeleteDrawerProgress(tester), equals(0.0)); expect(getDeleteDrawerProgress(tester), equals(0.0));
}); });
testWidgetsWithLeakTracking('Selection without avatar works as expected on RawChip', (WidgetTester tester) async { testWidgets('Selection without avatar works as expected on RawChip', (WidgetTester tester) async {
bool selected = false; bool selected = false;
final UniqueKey labelKey = UniqueKey(); final UniqueKey labelKey = UniqueKey();
Future<void> pushChip({ bool selectable = false }) async { Future<void> pushChip({ bool selectable = false }) async {
@ -1660,7 +1659,7 @@ void main() {
expect(getDeleteDrawerProgress(tester), equals(0.0)); expect(getDeleteDrawerProgress(tester), equals(0.0));
}); });
testWidgetsWithLeakTracking('Activation works as expected on RawChip', (WidgetTester tester) async { testWidgets('Activation works as expected on RawChip', (WidgetTester tester) async {
bool selected = false; bool selected = false;
final UniqueKey labelKey = UniqueKey(); final UniqueKey labelKey = UniqueKey();
Future<void> pushChip({ Widget? avatar, bool selectable = false }) async { Future<void> pushChip({ Widget? avatar, bool selectable = false }) async {
@ -1717,7 +1716,7 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
}); });
testWidgetsWithLeakTracking('Chip uses ThemeData chip theme if present', (WidgetTester tester) async { testWidgets('Chip uses ThemeData chip theme if present', (WidgetTester tester) async {
final ThemeData theme = ThemeData( final ThemeData theme = ThemeData(
useMaterial3: false, useMaterial3: false,
platform: TargetPlatform.android, platform: TargetPlatform.android,
@ -1748,7 +1747,7 @@ void main() {
expect(materialBox, paints..rrect(color: chipTheme.disabledColor)); expect(materialBox, paints..rrect(color: chipTheme.disabledColor));
}); });
testWidgetsWithLeakTracking('Chip merges ChipThemeData label style with the provided label style', (WidgetTester tester) async { testWidgets('Chip merges ChipThemeData label style with the provided label style', (WidgetTester tester) async {
// The font family should be preserved even if the chip overrides some label style properties // The font family should be preserved even if the chip overrides some label style properties
final ThemeData theme = ThemeData( final ThemeData theme = ThemeData(
fontFamily: 'MyFont', fontFamily: 'MyFont',
@ -1774,7 +1773,7 @@ void main() {
expect(labelStyle.fontWeight, FontWeight.w200); expect(labelStyle.fontWeight, FontWeight.w200);
}); });
testWidgetsWithLeakTracking('ChipTheme labelStyle with inherit:true', (WidgetTester tester) async { testWidgets('ChipTheme labelStyle with inherit:true', (WidgetTester tester) async {
Widget buildChip() { Widget buildChip() {
return wrapForChip( return wrapForChip(
child: Theme( child: Theme(
@ -1794,7 +1793,7 @@ void main() {
expect(labelStyle.height, 4); expect(labelStyle.height, 4);
}); });
testWidgetsWithLeakTracking('Chip does not merge inherit:false label style with the theme label style', (WidgetTester tester) async { testWidgets('Chip does not merge inherit:false label style with the theme label style', (WidgetTester tester) async {
Widget buildChip() { Widget buildChip() {
return wrapForChip( return wrapForChip(
child: Theme( child: Theme(
@ -1818,7 +1817,7 @@ void main() {
expect(labelStyle.fontWeight, FontWeight.w200); expect(labelStyle.fontWeight, FontWeight.w200);
}); });
testWidgetsWithLeakTracking('Chip size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { testWidgets('Chip size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async {
final Key key1 = UniqueKey(); final Key key1 = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
@ -1854,7 +1853,7 @@ void main() {
expect(tester.getSize(find.byKey(key2)), const Size(80.0, 32.0)); expect(tester.getSize(find.byKey(key2)), const Size(80.0, 32.0));
}); });
testWidgetsWithLeakTracking('Chip uses the right theme colors for the right components', (WidgetTester tester) async { testWidgets('Chip uses the right theme colors for the right components', (WidgetTester tester) async {
final ThemeData themeData = ThemeData( final ThemeData themeData = ThemeData(
platform: TargetPlatform.android, platform: TargetPlatform.android,
primarySwatch: Colors.blue, primarySwatch: Colors.blue,
@ -1978,7 +1977,7 @@ void main() {
}); });
group('Chip semantics', () { group('Chip semantics', () {
testWidgetsWithLeakTracking('label only', (WidgetTester tester) async { testWidgets('label only', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
await tester.pumpWidget(const MaterialApp( await tester.pumpWidget(const MaterialApp(
@ -2026,7 +2025,7 @@ void main() {
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgetsWithLeakTracking('delete', (WidgetTester tester) async { testWidgets('delete', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -2086,7 +2085,7 @@ void main() {
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgetsWithLeakTracking('with onPressed', (WidgetTester tester) async { testWidgets('with onPressed', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -2140,7 +2139,7 @@ void main() {
}); });
testWidgetsWithLeakTracking('with onSelected', (WidgetTester tester) async { testWidgets('with onSelected', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
bool selected = false; bool selected = false;
@ -2250,7 +2249,7 @@ void main() {
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgetsWithLeakTracking('disabled', (WidgetTester tester) async { testWidgets('disabled', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -2302,7 +2301,7 @@ void main() {
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgetsWithLeakTracking('tapEnabled explicitly false', (WidgetTester tester) async { testWidgets('tapEnabled explicitly false', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
await tester.pumpWidget(const MaterialApp( await tester.pumpWidget(const MaterialApp(
@ -2350,7 +2349,7 @@ void main() {
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgetsWithLeakTracking('enabled when tapEnabled and canTap', (WidgetTester tester) async { testWidgets('enabled when tapEnabled and canTap', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
// These settings make a Chip which can be tapped, both in general and at this moment. // These settings make a Chip which can be tapped, both in general and at this moment.
@ -2404,7 +2403,7 @@ void main() {
semanticsTester.dispose(); semanticsTester.dispose();
}); });
testWidgetsWithLeakTracking('disabled when tapEnabled but not canTap', (WidgetTester tester) async { testWidgets('disabled when tapEnabled but not canTap', (WidgetTester tester) async {
final SemanticsTester semanticsTester = SemanticsTester(tester); final SemanticsTester semanticsTester = SemanticsTester(tester);
// These settings make a Chip which _could_ be tapped, but not currently (ensures `canTap == false`). // These settings make a Chip which _could_ be tapped, but not currently (ensures `canTap == false`).
await tester.pumpWidget(const MaterialApp( await tester.pumpWidget(const MaterialApp(
@ -2454,7 +2453,7 @@ void main() {
}); });
}); });
testWidgetsWithLeakTracking('can be tapped outside of chip delete icon', (WidgetTester tester) async { testWidgets('can be tapped outside of chip delete icon', (WidgetTester tester) async {
bool deleted = false; bool deleted = false;
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
@ -2480,7 +2479,7 @@ void main() {
expect(deleted, true); expect(deleted, true);
}); });
testWidgetsWithLeakTracking('Chips can be tapped', (WidgetTester tester) async { testWidgets('Chips can be tapped', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: Material( home: Material(
@ -2495,7 +2494,7 @@ void main() {
expect(tester.takeException(), null); expect(tester.takeException(), null);
}); });
testWidgetsWithLeakTracking('Chip elevation and shadow color work correctly', (WidgetTester tester) async { testWidgets('Chip elevation and shadow color work correctly', (WidgetTester tester) async {
final ThemeData theme = ThemeData( final ThemeData theme = ThemeData(
useMaterial3: false, useMaterial3: false,
platform: TargetPlatform.android, platform: TargetPlatform.android,
@ -2546,7 +2545,7 @@ void main() {
expect(material.shadowColor, Colors.blue); expect(material.shadowColor, Colors.blue);
}); });
testWidgetsWithLeakTracking('can be tapped outside of chip body', (WidgetTester tester) async { testWidgets('can be tapped outside of chip body', (WidgetTester tester) async {
bool pressed = false; bool pressed = false;
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
@ -2571,7 +2570,7 @@ void main() {
expect(pressed, true); expect(pressed, true);
}); });
testWidgetsWithLeakTracking('is hitTestable', (WidgetTester tester) async { testWidgets('is hitTestable', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
child: InputChip( child: InputChip(
@ -2592,7 +2591,7 @@ void main() {
expect(materials.last.clipBehavior, clipBehavior); expect(materials.last.clipBehavior, clipBehavior);
} }
testWidgetsWithLeakTracking('Chip clipBehavior properly passes through to the Material', (WidgetTester tester) async { testWidgets('Chip clipBehavior properly passes through to the Material', (WidgetTester tester) async {
const Text label = Text('label'); const Text label = Text('label');
await tester.pumpWidget(wrapForChip(child: const Chip(label: label))); await tester.pumpWidget(wrapForChip(child: const Chip(label: label)));
checkChipMaterialClipBehavior(tester, Clip.none); checkChipMaterialClipBehavior(tester, Clip.none);
@ -2601,7 +2600,7 @@ void main() {
checkChipMaterialClipBehavior(tester, Clip.antiAlias); checkChipMaterialClipBehavior(tester, Clip.antiAlias);
}); });
testWidgetsWithLeakTracking('selected chip and avatar draw darkened layer within avatar circle', (WidgetTester tester) async { testWidgets('selected chip and avatar draw darkened layer within avatar circle', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
useMaterial3: false, useMaterial3: false,
@ -2629,7 +2628,7 @@ void main() {
])); ]));
}); });
testWidgetsWithLeakTracking('Chips should use InkWell instead of InkResponse.', (WidgetTester tester) async { testWidgets('Chips should use InkWell instead of InkResponse.', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/28646 // Regression test for https://github.com/flutter/flutter/issues/28646
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -2644,7 +2643,7 @@ void main() {
expect(find.byType(InkWell), findsOneWidget); expect(find.byType(InkWell), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Chip uses stateful color for text color in different states', (WidgetTester tester) async { testWidgets('Chip uses stateful color for text color in different states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
@ -2733,7 +2732,7 @@ void main() {
expect(textColor(), disabledColor); expect(textColor(), disabledColor);
}); });
testWidgetsWithLeakTracking('Chip uses stateful border side color in different states', (WidgetTester tester) async { testWidgets('Chip uses stateful border side color in different states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
@ -2814,7 +2813,7 @@ void main() {
expect(find.byType(RawChip), paints..rrect()..rrect(color: disabledColor)); expect(find.byType(RawChip), paints..rrect()..rrect(color: disabledColor));
}); });
testWidgetsWithLeakTracking('Chip uses stateful border side color from resolveWith', (WidgetTester tester) async { testWidgets('Chip uses stateful border side color from resolveWith', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
@ -2896,7 +2895,7 @@ void main() {
}); });
testWidgetsWithLeakTracking('Chip uses stateful nullable border side color from resolveWith', (WidgetTester tester) async { testWidgets('Chip uses stateful nullable border side color from resolveWith', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
@ -2986,7 +2985,7 @@ void main() {
expect(find.byType(RawChip), paints..rrect()..rrect(color: disabledColor)); expect(find.byType(RawChip), paints..rrect()..rrect(color: disabledColor));
}); });
testWidgetsWithLeakTracking('Chip uses stateful shape in different states', (WidgetTester tester) async { testWidgets('Chip uses stateful shape in different states', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
OutlinedBorder? getShape(Set<MaterialState> states) { OutlinedBorder? getShape(Set<MaterialState> states) {
@ -3058,7 +3057,7 @@ void main() {
expect(getMaterial(tester).shape, isA<BeveledRectangleBorder>()); expect(getMaterial(tester).shape, isA<BeveledRectangleBorder>());
}); });
testWidgetsWithLeakTracking('Chip defers to theme, if shape and side resolves to null', (WidgetTester tester) async { testWidgets('Chip defers to theme, if shape and side resolves to null', (WidgetTester tester) async {
const OutlinedBorder themeShape = StadiumBorder(); const OutlinedBorder themeShape = StadiumBorder();
const OutlinedBorder selectedShape = RoundedRectangleBorder(); const OutlinedBorder selectedShape = RoundedRectangleBorder();
const BorderSide themeBorderSide = BorderSide(color: Color(0x00000001)); const BorderSide themeBorderSide = BorderSide(color: Color(0x00000001));
@ -3110,7 +3109,7 @@ void main() {
expect(find.byType(RawChip), paints..rect()..drrect(color: selectedBorderSide.color)); expect(find.byType(RawChip), paints..rect()..drrect(color: selectedBorderSide.color));
}); });
testWidgetsWithLeakTracking('Chip responds to density changes.', (WidgetTester tester) async { testWidgets('Chip responds to density changes.', (WidgetTester tester) async {
const Key key = Key('test'); const Key key = Key('test');
const Key textKey = Key('test text'); const Key textKey = Key('test text');
const Key iconKey = Key('test icon'); const Key iconKey = Key('test icon');
@ -3216,7 +3215,7 @@ void main() {
expect(box.size, equals(const Size(128, 24.0 + 16.0))); expect(box.size, equals(const Size(128, 24.0 + 16.0)));
}); });
testWidgetsWithLeakTracking('Chip delete button tooltip is disabled if deleteButtonTooltipMessage is empty', (WidgetTester tester) async { testWidgets('Chip delete button tooltip is disabled if deleteButtonTooltipMessage is empty', (WidgetTester tester) async {
final UniqueKey deleteButtonKey = UniqueKey(); final UniqueKey deleteButtonKey = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
chipWithOptionalDeleteButton( chipWithOptionalDeleteButton(
@ -3241,7 +3240,7 @@ void main() {
expect(findTooltipContainer(''), findsNothing); expect(findTooltipContainer(''), findsNothing);
}); });
testWidgetsWithLeakTracking('Disabling delete button tooltip does not disable chip tooltip', (WidgetTester tester) async { testWidgets('Disabling delete button tooltip does not disable chip tooltip', (WidgetTester tester) async {
final UniqueKey deleteButtonKey = UniqueKey(); final UniqueKey deleteButtonKey = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
chipWithOptionalDeleteButton( chipWithOptionalDeleteButton(
@ -3269,7 +3268,7 @@ void main() {
expect(findTooltipContainer('Chip Tooltip'), findsOneWidget); expect(findTooltipContainer('Chip Tooltip'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('Triggering delete button tooltip does not trigger Chip tooltip', (WidgetTester tester) async { testWidgets('Triggering delete button tooltip does not trigger Chip tooltip', (WidgetTester tester) async {
final UniqueKey deleteButtonKey = UniqueKey(); final UniqueKey deleteButtonKey = UniqueKey();
await tester.pumpWidget( await tester.pumpWidget(
chipWithOptionalDeleteButton( chipWithOptionalDeleteButton(
@ -3296,7 +3295,7 @@ void main() {
expect(findTooltipContainer('Delete'), findsOneWidget); expect(findTooltipContainer('Delete'), findsOneWidget);
}); });
testWidgetsWithLeakTracking('intrinsicHeight implementation meets constraints', (WidgetTester tester) async { testWidgets('intrinsicHeight implementation meets constraints', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/49478. // Regression test for https://github.com/flutter/flutter/issues/49478.
await tester.pumpWidget(wrapForChip( await tester.pumpWidget(wrapForChip(
child: const Chip( child: const Chip(
@ -3308,7 +3307,7 @@ void main() {
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
}); });
testWidgetsWithLeakTracking('Chip background color and shape are drawn on Ink', (WidgetTester tester) async { testWidgets('Chip background color and shape are drawn on Ink', (WidgetTester tester) async {
const Color backgroundColor = Color(0xff00ff00); const Color backgroundColor = Color(0xff00ff00);
const OutlinedBorder shape = ContinuousRectangleBorder(); const OutlinedBorder shape = ContinuousRectangleBorder();
@ -3330,7 +3329,7 @@ void main() {
expect(decoration.shape, shape); expect(decoration.shape, shape);
}); });
testWidgetsWithLeakTracking('Chip highlight color is drawn on top of the backgroundColor', (WidgetTester tester) async { testWidgets('Chip highlight color is drawn on top of the backgroundColor', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(debugLabel: 'RawChip'); final FocusNode focusNode = FocusNode(debugLabel: 'RawChip');
addTearDown(focusNode.dispose); addTearDown(focusNode.dispose);
tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional; tester.binding.focusManager.highlightStrategy = FocusHighlightStrategy.alwaysTraditional;
@ -3359,7 +3358,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('RawChip.color resolves material states', (WidgetTester tester) async { testWidgets('RawChip.color resolves material states', (WidgetTester tester) async {
const Color disabledSelectedColor = Color(0xffffff00); const Color disabledSelectedColor = Color(0xffffff00);
const Color disabledColor = Color(0xff00ff00); const Color disabledColor = Color(0xff00ff00);
const Color backgroundColor = Color(0xff0000ff); const Color backgroundColor = Color(0xff0000ff);
@ -3415,7 +3414,7 @@ void main() {
expect(getMaterialBox(tester), paints..rrect(color: disabledSelectedColor)); expect(getMaterialBox(tester), paints..rrect(color: disabledSelectedColor));
}); });
testWidgetsWithLeakTracking('RawChip uses provided state color properties', (WidgetTester tester) async { testWidgets('RawChip uses provided state color properties', (WidgetTester tester) async {
const Color disabledColor = Color(0xff00ff00); const Color disabledColor = Color(0xff00ff00);
const Color backgroundColor = Color(0xff0000ff); const Color backgroundColor = Color(0xff0000ff);
const Color selectedColor = Color(0xffff0000); const Color selectedColor = Color(0xffff0000);
@ -3454,7 +3453,7 @@ void main() {
expect(getMaterialBox(tester), paints..rrect(color: selectedColor)); expect(getMaterialBox(tester), paints..rrect(color: selectedColor));
}); });
testWidgetsWithLeakTracking('Delete button tap target area does not include label', (WidgetTester tester) async { testWidgets('Delete button tap target area does not include label', (WidgetTester tester) async {
bool calledDelete = false; bool calledDelete = false;
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
@ -3497,7 +3496,7 @@ void main() {
}); });
// This is a regression test for https://github.com/flutter/flutter/pull/133615. // This is a regression test for https://github.com/flutter/flutter/pull/133615.
testWidgetsWithLeakTracking('Material3 - Custom shape without provided side uses default side', (WidgetTester tester) async { testWidgets('Material3 - Custom shape without provided side uses default side', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
await tester.pumpWidget( await tester.pumpWidget(
MaterialApp( MaterialApp(
@ -3521,7 +3520,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking("Material3 - RawChip.shape's side is used when provided", (WidgetTester tester) async { testWidgets("Material3 - RawChip.shape's side is used when provided", (WidgetTester tester) async {
Widget buildChip({ OutlinedBorder? shape, BorderSide? side }) { Widget buildChip({ OutlinedBorder? shape, BorderSide? side }) {
return MaterialApp( return MaterialApp(
theme: ThemeData(useMaterial3: true), theme: ThemeData(useMaterial3: true),
@ -3575,7 +3574,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material3 - Chip.iconTheme respects default iconTheme.size', (WidgetTester tester) async { testWidgets('Material3 - Chip.iconTheme respects default iconTheme.size', (WidgetTester tester) async {
Widget buildChip({ IconThemeData? iconTheme }) { Widget buildChip({ IconThemeData? iconTheme }) {
return MaterialApp( return MaterialApp(
theme: ThemeData(useMaterial3: true), theme: ThemeData(useMaterial3: true),
@ -3610,7 +3609,7 @@ void main() {
}); });
// This is a regression test for https://github.com/flutter/flutter/issues/138287. // This is a regression test for https://github.com/flutter/flutter/issues/138287.
testWidgetsWithLeakTracking("Enabling and disabling Chip with Tooltip doesn't throw an exception", (WidgetTester tester) async { testWidgets("Enabling and disabling Chip with Tooltip doesn't throw an exception", (WidgetTester tester) async {
bool isEnabled = true; bool isEnabled = true;
await tester.pumpWidget(MaterialApp( await tester.pumpWidget(MaterialApp(
@ -3658,7 +3657,7 @@ void main() {
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
}); });
testWidgetsWithLeakTracking('Delete button is visible RawChip is disabled', (WidgetTester tester) async { testWidgets('Delete button is visible RawChip is disabled', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
wrapForChip( wrapForChip(
child: RawChip( child: RawChip(
@ -3678,7 +3677,7 @@ void main() {
// support is deprecated and the APIs are removed, these tests // support is deprecated and the APIs are removed, these tests
// can be deleted. // can be deleted.
testWidgetsWithLeakTracking('M2 Chip defaults', (WidgetTester tester) async { testWidgets('M2 Chip defaults', (WidgetTester tester) async {
late TextTheme textTheme; late TextTheme textTheme;
Widget buildFrame(Brightness brightness) { Widget buildFrame(Brightness brightness) {
@ -3755,7 +3754,7 @@ void main() {
expect(labelStyle.wordSpacing, textTheme.bodyLarge?.wordSpacing); expect(labelStyle.wordSpacing, textTheme.bodyLarge?.wordSpacing);
}); });
testWidgetsWithLeakTracking('Chip uses the right theme colors for the right components', (WidgetTester tester) async { testWidgets('Chip uses the right theme colors for the right components', (WidgetTester tester) async {
final ThemeData themeData = ThemeData( final ThemeData themeData = ThemeData(
platform: TargetPlatform.android, platform: TargetPlatform.android,
primarySwatch: Colors.blue, primarySwatch: Colors.blue,

View File

@ -6,7 +6,6 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
RenderBox getMaterialBox(WidgetTester tester) { RenderBox getMaterialBox(WidgetTester tester) {
return tester.firstRenderObject<RenderBox>( return tester.firstRenderObject<RenderBox>(
@ -82,7 +81,7 @@ void main() {
expect(themeData.iconTheme, null); expect(themeData.iconTheme, null);
}); });
testWidgetsWithLeakTracking('Default ChipThemeData debugFillProperties', (WidgetTester tester) async { testWidgets('Default ChipThemeData debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ChipThemeData().debugFillProperties(builder); const ChipThemeData().debugFillProperties(builder);
@ -94,7 +93,7 @@ void main() {
expect(description, <String>[]); expect(description, <String>[]);
}); });
testWidgetsWithLeakTracking('ChipThemeData implements debugFillProperties', (WidgetTester tester) async { testWidgets('ChipThemeData implements debugFillProperties', (WidgetTester tester) async {
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
const ChipThemeData( const ChipThemeData(
color: MaterialStatePropertyAll<Color>(Color(0xfffffff0)), color: MaterialStatePropertyAll<Color>(Color(0xfffffff0)),
@ -150,7 +149,7 @@ void main() {
])); ]));
}); });
testWidgetsWithLeakTracking('Material3 - Chip uses ThemeData chip theme', (WidgetTester tester) async { testWidgets('Material3 - Chip uses ThemeData chip theme', (WidgetTester tester) async {
const ChipThemeData chipTheme = ChipThemeData( const ChipThemeData chipTheme = ChipThemeData(
backgroundColor: Color(0xff112233), backgroundColor: Color(0xff112233),
elevation: 4, elevation: 4,
@ -192,7 +191,7 @@ void main() {
expect(getIconData(tester).color, chipTheme.iconTheme!.color); expect(getIconData(tester).color, chipTheme.iconTheme!.color);
}); });
testWidgetsWithLeakTracking('Material2 - Chip uses ThemeData chip theme', (WidgetTester tester) async { testWidgets('Material2 - Chip uses ThemeData chip theme', (WidgetTester tester) async {
const ChipThemeData chipTheme = ChipThemeData( const ChipThemeData chipTheme = ChipThemeData(
backgroundColor: Color(0xff112233), backgroundColor: Color(0xff112233),
elevation: 4, elevation: 4,
@ -230,7 +229,7 @@ void main() {
expect(getIconData(tester).color, chipTheme.iconTheme!.color); expect(getIconData(tester).color, chipTheme.iconTheme!.color);
}); });
testWidgetsWithLeakTracking('Material3 - Chip uses local ChipTheme', (WidgetTester tester) async { testWidgets('Material3 - Chip uses local ChipTheme', (WidgetTester tester) async {
const ChipThemeData chipTheme = ChipThemeData( const ChipThemeData chipTheme = ChipThemeData(
backgroundColor: Color(0xff112233), backgroundColor: Color(0xff112233),
elevation: 4, elevation: 4,
@ -279,7 +278,7 @@ void main() {
expect(getIconData(tester).color, chipTheme.iconTheme!.color); expect(getIconData(tester).color, chipTheme.iconTheme!.color);
}); });
testWidgetsWithLeakTracking('Material2 - Chip uses local ChipTheme', (WidgetTester tester) async { testWidgets('Material2 - Chip uses local ChipTheme', (WidgetTester tester) async {
const ChipThemeData chipTheme = ChipThemeData( const ChipThemeData chipTheme = ChipThemeData(
backgroundColor: Color(0xff112233), backgroundColor: Color(0xff112233),
elevation: 4, elevation: 4,
@ -324,7 +323,7 @@ void main() {
expect(getIconData(tester).color, chipTheme.iconTheme!.color); expect(getIconData(tester).color, chipTheme.iconTheme!.color);
}); });
testWidgetsWithLeakTracking('Chip properties overrides ChipTheme', (WidgetTester tester) async { testWidgets('Chip properties overrides ChipTheme', (WidgetTester tester) async {
const ChipThemeData chipTheme = ChipThemeData( const ChipThemeData chipTheme = ChipThemeData(
backgroundColor: Color(0xff112233), backgroundColor: Color(0xff112233),
elevation: 4, elevation: 4,
@ -381,7 +380,7 @@ void main() {
expect(getIconData(tester).color, iconTheme.color); expect(getIconData(tester).color, iconTheme.color);
}); });
testWidgetsWithLeakTracking('Material3 - Chip uses constructor parameters', (WidgetTester tester) async { testWidgets('Material3 - Chip uses constructor parameters', (WidgetTester tester) async {
const Color backgroundColor = Color(0xff332211); const Color backgroundColor = Color(0xff332211);
const double elevation = 3; const double elevation = 3;
const double fontSize = 32; const double fontSize = 32;
@ -426,7 +425,7 @@ void main() {
expect(getIconData(tester).color, iconTheme.color); expect(getIconData(tester).color, iconTheme.color);
}); });
testWidgetsWithLeakTracking('Material2 - Chip uses constructor parameters', (WidgetTester tester) async { testWidgets('Material2 - Chip uses constructor parameters', (WidgetTester tester) async {
const Color backgroundColor = Color(0xff332211); const Color backgroundColor = Color(0xff332211);
const double elevation = 3; const double elevation = 3;
const double fontSize = 32; const double fontSize = 32;
@ -471,7 +470,7 @@ void main() {
expect(getIconData(tester).color, iconTheme.color); expect(getIconData(tester).color, iconTheme.color);
}); });
testWidgetsWithLeakTracking('ChipTheme.fromDefaults', (WidgetTester tester) async { testWidgets('ChipTheme.fromDefaults', (WidgetTester tester) async {
const TextStyle labelStyle = TextStyle(); const TextStyle labelStyle = TextStyle();
ChipThemeData chipTheme = ChipThemeData.fromDefaults( ChipThemeData chipTheme = ChipThemeData.fromDefaults(
brightness: Brightness.light, brightness: Brightness.light,
@ -523,7 +522,7 @@ void main() {
expect(chipTheme.pressElevation, 8.0); expect(chipTheme.pressElevation, 8.0);
}); });
testWidgetsWithLeakTracking('ChipThemeData generates correct opacities for defaults', (WidgetTester tester) async { testWidgets('ChipThemeData generates correct opacities for defaults', (WidgetTester tester) async {
const Color customColor1 = Color(0xcafefeed); const Color customColor1 = Color(0xcafefeed);
const Color customColor2 = Color(0xdeadbeef); const Color customColor2 = Color(0xdeadbeef);
final TextStyle customStyle = ThemeData.fallback().textTheme.bodyLarge!.copyWith(color: customColor2); final TextStyle customStyle = ThemeData.fallback().textTheme.bodyLarge!.copyWith(color: customColor2);
@ -586,7 +585,7 @@ void main() {
expect(customTheme.brightness, equals(Brightness.light)); expect(customTheme.brightness, equals(Brightness.light));
}); });
testWidgetsWithLeakTracking('ChipThemeData lerps correctly', (WidgetTester tester) async { testWidgets('ChipThemeData lerps correctly', (WidgetTester tester) async {
final ChipThemeData chipThemeBlack = ChipThemeData.fromDefaults( final ChipThemeData chipThemeBlack = ChipThemeData.fromDefaults(
secondaryColor: Colors.black, secondaryColor: Colors.black,
brightness: Brightness.dark, brightness: Brightness.dark,
@ -734,7 +733,7 @@ void main() {
expect(lerp.iconTheme, isNull); expect(lerp.iconTheme, isNull);
}); });
testWidgetsWithLeakTracking('Chip uses stateful color from chip theme', (WidgetTester tester) async { testWidgets('Chip uses stateful color from chip theme', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
const Color pressedColor = Color(0x00000001); const Color pressedColor = Color(0x00000001);
@ -832,7 +831,7 @@ void main() {
focusNode.dispose(); focusNode.dispose();
}); });
testWidgetsWithLeakTracking('Chip uses stateful border side from resolveWith pattern', (WidgetTester tester) async { testWidgets('Chip uses stateful border side from resolveWith pattern', (WidgetTester tester) async {
const Color selectedColor = Color(0x00000001); const Color selectedColor = Color(0x00000001);
const Color defaultColor = Color(0x00000002); const Color defaultColor = Color(0x00000002);
@ -873,7 +872,7 @@ void main() {
expect(find.byType(RawChip), paints..rrect()..rrect(color: selectedColor)); expect(find.byType(RawChip), paints..rrect()..rrect(color: selectedColor));
}); });
testWidgetsWithLeakTracking('Chip uses stateful border side from chip theme', (WidgetTester tester) async { testWidgets('Chip uses stateful border side from chip theme', (WidgetTester tester) async {
const Color selectedColor = Color(0x00000001); const Color selectedColor = Color(0x00000001);
const Color defaultColor = Color(0x00000002); const Color defaultColor = Color(0x00000002);
@ -915,7 +914,7 @@ void main() {
expect(find.byType(RawChip), paints..rrect()..rrect(color: selectedColor)); expect(find.byType(RawChip), paints..rrect()..rrect(color: selectedColor));
}); });
testWidgetsWithLeakTracking('Chip uses stateful shape from chip theme', (WidgetTester tester) async { testWidgets('Chip uses stateful shape from chip theme', (WidgetTester tester) async {
OutlinedBorder? getShape(Set<MaterialState> states) { OutlinedBorder? getShape(Set<MaterialState> states) {
if (states.contains(MaterialState.selected)) { if (states.contains(MaterialState.selected)) {
return const RoundedRectangleBorder(); return const RoundedRectangleBorder();
@ -955,7 +954,7 @@ void main() {
expect(getMaterial(tester).shape, isA<RoundedRectangleBorder>()); expect(getMaterial(tester).shape, isA<RoundedRectangleBorder>());
}); });
testWidgetsWithLeakTracking('RawChip uses material state color from ChipTheme', (WidgetTester tester) async { testWidgets('RawChip uses material state color from ChipTheme', (WidgetTester tester) async {
const Color disabledSelectedColor = Color(0xffffff00); const Color disabledSelectedColor = Color(0xffffff00);
const Color disabledColor = Color(0xff00ff00); const Color disabledColor = Color(0xff00ff00);
const Color backgroundColor = Color(0xff0000ff); const Color backgroundColor = Color(0xff0000ff);
@ -1019,7 +1018,7 @@ void main() {
expect(getMaterialBox(tester), paints..rrect(color: disabledSelectedColor)); expect(getMaterialBox(tester), paints..rrect(color: disabledSelectedColor));
}); });
testWidgetsWithLeakTracking('RawChip uses state colors from ChipTheme', (WidgetTester tester) async { testWidgets('RawChip uses state colors from ChipTheme', (WidgetTester tester) async {
const ChipThemeData chipTheme = ChipThemeData( const ChipThemeData chipTheme = ChipThemeData(
disabledColor: Color(0xadfefafe), disabledColor: Color(0xadfefafe),
backgroundColor: Color(0xcafefeed), backgroundColor: Color(0xcafefeed),
@ -1061,7 +1060,7 @@ void main() {
}); });
// This is a regression test for https://github.com/flutter/flutter/issues/119163. // This is a regression test for https://github.com/flutter/flutter/issues/119163.
testWidgetsWithLeakTracking('RawChip respects checkmark properties from ChipTheme', (WidgetTester tester) async { testWidgets('RawChip respects checkmark properties from ChipTheme', (WidgetTester tester) async {
Widget buildRawChip({ChipThemeData? chipTheme}) { Widget buildRawChip({ChipThemeData? chipTheme}) {
return MaterialApp( return MaterialApp(
theme: ThemeData.light(useMaterial3: false).copyWith( theme: ThemeData.light(useMaterial3: false).copyWith(
@ -1117,7 +1116,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking("Material3 - RawChip.shape's side is used when provided", (WidgetTester tester) async { testWidgets("Material3 - RawChip.shape's side is used when provided", (WidgetTester tester) async {
Widget buildChip({ OutlinedBorder? shape, BorderSide? side }) { Widget buildChip({ OutlinedBorder? shape, BorderSide? side }) {
return MaterialApp( return MaterialApp(
theme: ThemeData( theme: ThemeData(
@ -1175,7 +1174,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('Material3 - ChipThemeData.iconTheme respects default iconTheme.size', (WidgetTester tester) async { testWidgets('Material3 - ChipThemeData.iconTheme respects default iconTheme.size', (WidgetTester tester) async {
Widget buildChip({ IconThemeData? iconTheme }) { Widget buildChip({ IconThemeData? iconTheme }) {
return MaterialApp( return MaterialApp(
theme: ThemeData(useMaterial3: true, chipTheme: ChipThemeData(iconTheme: iconTheme)), theme: ThemeData(useMaterial3: true, chipTheme: ChipThemeData(iconTheme: iconTheme)),

View File

@ -4,7 +4,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
RenderBox getMaterialBox(WidgetTester tester, Finder type) { RenderBox getMaterialBox(WidgetTester tester, Finder type) {
return tester.firstRenderObject<RenderBox>( return tester.firstRenderObject<RenderBox>(
@ -73,7 +72,7 @@ void checkChipMaterialClipBehavior(WidgetTester tester, Clip clipBehavior) {
} }
void main() { void main() {
testWidgetsWithLeakTracking('ChoiceChip defaults', (WidgetTester tester) async { testWidgets('ChoiceChip defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
const String label = 'choice chip'; const String label = 'choice chip';
@ -208,7 +207,7 @@ void main() {
expect(decoration.color, theme.colorScheme.onSurface.withOpacity(0.12)); expect(decoration.color, theme.colorScheme.onSurface.withOpacity(0.12));
}); });
testWidgetsWithLeakTracking('ChoiceChip.elevated defaults', (WidgetTester tester) async { testWidgets('ChoiceChip.elevated defaults', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: true); final ThemeData theme = ThemeData(useMaterial3: true);
const String label = 'choice chip'; const String label = 'choice chip';
@ -343,7 +342,7 @@ void main() {
expect(decoration.color, theme.colorScheme.onSurface.withOpacity(0.12)); expect(decoration.color, theme.colorScheme.onSurface.withOpacity(0.12));
}); });
testWidgetsWithLeakTracking('ChoiceChip.color resolves material states', (WidgetTester tester) async { testWidgets('ChoiceChip.color resolves material states', (WidgetTester tester) async {
const Color disabledSelectedColor = Color(0xffffff00); const Color disabledSelectedColor = Color(0xffffff00);
const Color disabledColor = Color(0xff00ff00); const Color disabledColor = Color(0xff00ff00);
const Color backgroundColor = Color(0xff0000ff); const Color backgroundColor = Color(0xff0000ff);
@ -442,7 +441,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('ChoiceChip uses provided state color properties', (WidgetTester tester) async { testWidgets('ChoiceChip uses provided state color properties', (WidgetTester tester) async {
const Color disabledColor = Color(0xff00ff00); const Color disabledColor = Color(0xff00ff00);
const Color backgroundColor = Color(0xff0000ff); const Color backgroundColor = Color(0xff0000ff);
const Color selectedColor = Color(0xffff0000); const Color selectedColor = Color(0xffff0000);
@ -517,7 +516,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('ChoiceChip can be tapped', (WidgetTester tester) async { testWidgets('ChoiceChip can be tapped', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: Material( home: Material(
@ -533,7 +532,7 @@ void main() {
expect(tester.takeException(), null); expect(tester.takeException(), null);
}); });
testWidgetsWithLeakTracking('ChoiceChip clipBehavior properly passes through to the Material', (WidgetTester tester) async { testWidgets('ChoiceChip clipBehavior properly passes through to the Material', (WidgetTester tester) async {
const Text label = Text('label'); const Text label = Text('label');
await tester.pumpWidget(wrapForChip(child: const ChoiceChip(label: label, selected: false))); await tester.pumpWidget(wrapForChip(child: const ChoiceChip(label: label, selected: false)));
checkChipMaterialClipBehavior(tester, Clip.none); checkChipMaterialClipBehavior(tester, Clip.none);
@ -542,7 +541,7 @@ void main() {
checkChipMaterialClipBehavior(tester, Clip.antiAlias); checkChipMaterialClipBehavior(tester, Clip.antiAlias);
}); });
testWidgetsWithLeakTracking('ChoiceChip passes iconTheme property to RawChip', (WidgetTester tester) async { testWidgets('ChoiceChip passes iconTheme property to RawChip', (WidgetTester tester) async {
const IconThemeData iconTheme = IconThemeData(color: Colors.red); const IconThemeData iconTheme = IconThemeData(color: Colors.red);
await tester.pumpWidget(wrapForChip( await tester.pumpWidget(wrapForChip(
child: const ChoiceChip( child: const ChoiceChip(
@ -554,7 +553,7 @@ void main() {
expect(rawChip.iconTheme, iconTheme); expect(rawChip.iconTheme, iconTheme);
}); });
testWidgetsWithLeakTracking('ChoiceChip passes showCheckmark from ChipTheme to RawChip', (WidgetTester tester) async { testWidgets('ChoiceChip passes showCheckmark from ChipTheme to RawChip', (WidgetTester tester) async {
const bool showCheckmark = false; const bool showCheckmark = false;
await tester.pumpWidget(wrapForChip( await tester.pumpWidget(wrapForChip(
child: const ChipTheme( child: const ChipTheme(
@ -570,7 +569,7 @@ void main() {
expect(rawChip.showCheckmark, showCheckmark); expect(rawChip.showCheckmark, showCheckmark);
}); });
testWidgetsWithLeakTracking('ChoiceChip passes checkmark properties to RawChip', (WidgetTester tester) async { testWidgets('ChoiceChip passes checkmark properties to RawChip', (WidgetTester tester) async {
const bool showCheckmark = false; const bool showCheckmark = false;
const Color checkmarkColor = Color(0xff0000ff); const Color checkmarkColor = Color(0xff0000ff);
await tester.pumpWidget(wrapForChip( await tester.pumpWidget(wrapForChip(
@ -585,7 +584,7 @@ void main() {
expect(rawChip.checkmarkColor, checkmarkColor); expect(rawChip.checkmarkColor, checkmarkColor);
}); });
testWidgetsWithLeakTracking('ChoiceChip uses provided iconTheme', (WidgetTester tester) async { testWidgets('ChoiceChip uses provided iconTheme', (WidgetTester tester) async {
Widget buildChip({ IconThemeData? iconTheme }) { Widget buildChip({ IconThemeData? iconTheme }) {
return MaterialApp( return MaterialApp(
home: Material( home: Material(
@ -616,7 +615,7 @@ void main() {
// support is deprecated and the APIs are removed, these tests // support is deprecated and the APIs are removed, these tests
// can be deleted. // can be deleted.
testWidgetsWithLeakTracking('ChoiceChip defaults', (WidgetTester tester) async { testWidgets('ChoiceChip defaults', (WidgetTester tester) async {
Widget buildFrame(Brightness brightness) { Widget buildFrame(Brightness brightness) {
return MaterialApp( return MaterialApp(
theme: ThemeData(useMaterial3: false, brightness: brightness), theme: ThemeData(useMaterial3: false, brightness: brightness),

View File

@ -12,12 +12,11 @@ import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../image_data.dart'; import '../image_data.dart';
import '../painting/mocks_for_image_cache.dart'; import '../painting/mocks_for_image_cache.dart';
void main() { void main() {
testWidgetsWithLeakTracking('CircleAvatar with dark background color', (WidgetTester tester) async { testWidgets('CircleAvatar with dark background color', (WidgetTester tester) async {
final Color backgroundColor = Colors.blue.shade900; final Color backgroundColor = Colors.blue.shade900;
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
@ -39,7 +38,7 @@ void main() {
expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorLight)); expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorLight));
}); });
testWidgetsWithLeakTracking('CircleAvatar with light background color', (WidgetTester tester) async { testWidgets('CircleAvatar with light background color', (WidgetTester tester) async {
final Color backgroundColor = Colors.blue.shade100; final Color backgroundColor = Colors.blue.shade100;
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
@ -61,7 +60,7 @@ void main() {
expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorDark)); expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorDark));
}); });
testWidgetsWithLeakTracking('CircleAvatar with image background', (WidgetTester tester) async { testWidgets('CircleAvatar with image background', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
child: CircleAvatar( child: CircleAvatar(
@ -78,7 +77,7 @@ void main() {
expect(decoration.image!.fit, equals(BoxFit.cover)); expect(decoration.image!.fit, equals(BoxFit.cover));
}); });
testWidgetsWithLeakTracking('CircleAvatar with image foreground', (WidgetTester tester) async { testWidgets('CircleAvatar with image foreground', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
child: CircleAvatar( child: CircleAvatar(
@ -95,7 +94,7 @@ void main() {
expect(decoration.image!.fit, equals(BoxFit.cover)); expect(decoration.image!.fit, equals(BoxFit.cover));
}); });
testWidgetsWithLeakTracking('CircleAvatar backgroundImage is used as a fallback for foregroundImage', (WidgetTester tester) async { testWidgets('CircleAvatar backgroundImage is used as a fallback for foregroundImage', (WidgetTester tester) async {
final ErrorImageProvider errorImage = ErrorImageProvider(); final ErrorImageProvider errorImage = ErrorImageProvider();
bool caughtForegroundImageError = false; bool caughtForegroundImageError = false;
await tester.pumpWidget( await tester.pumpWidget(
@ -123,7 +122,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('CircleAvatar with foreground color', (WidgetTester tester) async { testWidgets('CircleAvatar with foreground color', (WidgetTester tester) async {
final Color foregroundColor = Colors.red.shade100; final Color foregroundColor = Colors.red.shade100;
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
@ -146,7 +145,7 @@ void main() {
expect(paragraph.text.style!.color, equals(foregroundColor)); expect(paragraph.text.style!.color, equals(foregroundColor));
}); });
testWidgetsWithLeakTracking('Material3 - CircleAvatar default colors', (WidgetTester tester) async { testWidgets('Material3 - CircleAvatar default colors', (WidgetTester tester) async {
final ThemeData theme = ThemeData(); final ThemeData theme = ThemeData();
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
@ -168,7 +167,7 @@ void main() {
expect(paragraph.text.style!.color, equals(theme.colorScheme.onPrimaryContainer)); expect(paragraph.text.style!.color, equals(theme.colorScheme.onPrimaryContainer));
}); });
testWidgetsWithLeakTracking('CircleAvatar text does not expand with textScaleFactor', (WidgetTester tester) async { testWidgets('CircleAvatar text does not expand with textScaleFactor', (WidgetTester tester) async {
final Color foregroundColor = Colors.red.shade100; final Color foregroundColor = Colors.red.shade100;
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
@ -212,7 +211,7 @@ void main() {
expect(tester.getSize(find.text('Z')), equals(const Size(16.0, 16.0))); expect(tester.getSize(find.text('Z')), equals(const Size(16.0, 16.0)));
}); });
testWidgetsWithLeakTracking('CircleAvatar respects minRadius', (WidgetTester tester) async { testWidgets('CircleAvatar respects minRadius', (WidgetTester tester) async {
final Color backgroundColor = Colors.blue.shade900; final Color backgroundColor = Colors.blue.shade900;
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
@ -236,7 +235,7 @@ void main() {
expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorLight)); expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorLight));
}); });
testWidgetsWithLeakTracking('CircleAvatar respects maxRadius', (WidgetTester tester) async { testWidgets('CircleAvatar respects maxRadius', (WidgetTester tester) async {
final Color backgroundColor = Colors.blue.shade900; final Color backgroundColor = Colors.blue.shade900;
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
@ -258,7 +257,7 @@ void main() {
expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorLight)); expect(paragraph.text.style!.color, equals(ThemeData.fallback().primaryColorLight));
}); });
testWidgetsWithLeakTracking('CircleAvatar respects setting both minRadius and maxRadius', (WidgetTester tester) async { testWidgets('CircleAvatar respects setting both minRadius and maxRadius', (WidgetTester tester) async {
final Color backgroundColor = Colors.blue.shade900; final Color backgroundColor = Colors.blue.shade900;
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
@ -286,7 +285,7 @@ void main() {
// support is deprecated and the APIs are removed, these tests // support is deprecated and the APIs are removed, these tests
// can be deleted. // can be deleted.
testWidgetsWithLeakTracking('Material2 - CircleAvatar default colors with light theme', (WidgetTester tester) async { testWidgets('Material2 - CircleAvatar default colors with light theme', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: false, primaryColor: Colors.grey.shade100); final ThemeData theme = ThemeData(useMaterial3: false, primaryColor: Colors.grey.shade100);
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(
@ -308,7 +307,7 @@ void main() {
expect(paragraph.text.style!.color, equals(theme.primaryTextTheme.titleLarge!.color)); expect(paragraph.text.style!.color, equals(theme.primaryTextTheme.titleLarge!.color));
}); });
testWidgetsWithLeakTracking('Material2 - CircleAvatar default colors with dark theme', (WidgetTester tester) async { testWidgets('Material2 - CircleAvatar default colors with dark theme', (WidgetTester tester) async {
final ThemeData theme = ThemeData(useMaterial3: false, primaryColor: Colors.grey.shade800); final ThemeData theme = ThemeData(useMaterial3: false, primaryColor: Colors.grey.shade800);
await tester.pumpWidget( await tester.pumpWidget(
wrap( wrap(

View File

@ -6,7 +6,6 @@ import 'dart:typed_data';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import '../image_data.dart'; import '../image_data.dart';
@ -444,7 +443,7 @@ void main() {
); );
}); });
testWidgetsWithLeakTracking('generated scheme "on" colors meet a11y contrast guidelines', (WidgetTester tester) async { testWidgets('generated scheme "on" colors meet a11y contrast guidelines', (WidgetTester tester) async {
final ColorScheme colors = ColorScheme.fromSeed(seedColor: Colors.teal); final ColorScheme colors = ColorScheme.fromSeed(seedColor: Colors.teal);
Widget label(String text, Color textColor, Color background) { Widget label(String text, Color textColor, Color background) {

Some files were not shown because too many files have changed in this diff Show More