Skip to content

Commit

Permalink
Cover more test/widgets tests with leak tracking (#134387)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksokolovskyi authored Sep 13, 2023
1 parent 083ac65 commit 7d0c9b7
Show file tree
Hide file tree
Showing 15 changed files with 1,209 additions and 1,070 deletions.
8 changes: 4 additions & 4 deletions packages/flutter/test/widgets/app_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ void main() {
expect(find.text('popped'), findsOneWidget);
},
leakTrackingTestConfig: const LeakTrackingTestConfig(
// TODO(someone): remove after fixing
// TODO(ksokolovskyi): remove after fixing
// https://github.com/flutter/flutter/issues/134205
notDisposedAllowList: <String, int?> {'_RestorableRouteInformation': 1},
));
Expand Down Expand Up @@ -338,7 +338,7 @@ void main() {
expect(find.text('popped'), findsOneWidget);
},
leakTrackingTestConfig: const LeakTrackingTestConfig(
// TODO(someone): remove after fixing
// TODO(ksokolovskyi): remove after fixing
// https://github.com/flutter/flutter/issues/134205
notDisposedAllowList: <String, int?> {'_RestorableRouteInformation': 1},
));
Expand Down Expand Up @@ -434,7 +434,7 @@ void main() {
expect(find.text('popped'), findsOneWidget);
},
leakTrackingTestConfig: const LeakTrackingTestConfig(
// TODO(someone): remove after fixing
// TODO(ksokolovskyi): remove after fixing
// https://github.com/flutter/flutter/issues/134205
notDisposedAllowList: <String, int?> {'_RestorableRouteInformation': 1},
));
Expand All @@ -455,7 +455,7 @@ void main() {
expect(find.text('/'), findsOneWidget);
},
leakTrackingTestConfig: const LeakTrackingTestConfig(
// TODO(someone): remove after fixing
// TODO(ksokolovskyi): remove after fixing
// https://github.com/flutter/flutter/issues/134205
notDisposedAllowList: <String, int?> {'_RestorableRouteInformation': 1},
));
Expand Down
132 changes: 68 additions & 64 deletions packages/flutter/test/widgets/draggable_test.dart

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions packages/flutter/test/widgets/drawer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import 'package:flutter/gestures.dart' show DragStartBehavior;
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';

import 'semantics_tester.dart';

void main() {

testWidgets('Drawer control test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer control test', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
late BuildContext savedContext;
await tester.pumpWidget(
Expand Down Expand Up @@ -44,7 +45,7 @@ void main() {
expect(find.text('drawer'), findsNothing);
});

testWidgets('Drawer tap test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer tap test', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
await tester.pumpWidget(
MaterialApp(
Expand Down Expand Up @@ -76,7 +77,7 @@ void main() {
expect(find.text('drawer'), findsNothing);
});

testWidgets('Drawer hover test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer hover test', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
final List<String> logs = <String>[];
final TestGesture gesture = await tester.createGesture(kind: PointerDeviceKind.mouse);
Expand Down Expand Up @@ -146,7 +147,7 @@ void main() {
logs.clear();
});

testWidgets('Drawer drag cancel resume (LTR)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer drag cancel resume (LTR)', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
await tester.pumpWidget(
MaterialApp(
Expand Down Expand Up @@ -197,7 +198,7 @@ void main() {
await gesture.up();
});

testWidgets('Drawer drag cancel resume (RTL)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer drag cancel resume (RTL)', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
await tester.pumpWidget(
MaterialApp(
Expand Down Expand Up @@ -251,7 +252,7 @@ void main() {
await gesture.up();
});

testWidgets('Drawer navigator back button', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer navigator back button', (WidgetTester tester) async {
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();
bool buttonPressed = false;

Expand Down Expand Up @@ -299,7 +300,7 @@ void main() {
expect(buttonPressed, equals(true));
});

testWidgets('Dismissible ModalBarrier includes button in semantic tree', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Dismissible ModalBarrier includes button in semantic tree', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();

Expand All @@ -326,7 +327,7 @@ void main() {
semantics.dispose();
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS, TargetPlatform.macOS }));

testWidgets('Dismissible ModalBarrier is hidden on Android (back button is used to dismiss)', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Dismissible ModalBarrier is hidden on Android (back button is used to dismiss)', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();

Expand Down Expand Up @@ -354,7 +355,7 @@ void main() {
semantics.dispose();
}, variant: TargetPlatformVariant.only(TargetPlatform.android));

testWidgets('Drawer contains route semantics flags', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Drawer contains route semantics flags', (WidgetTester tester) async {
final SemanticsTester semantics = SemanticsTester(tester);
final GlobalKey<ScaffoldState> scaffoldKey = GlobalKey<ScaffoldState>();

Expand Down
15 changes: 11 additions & 4 deletions packages/flutter/test/widgets/dual_transition_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';

void main() {
testWidgets('runs animations', (WidgetTester tester) async {
testWidgetsWithLeakTracking('runs animations', (WidgetTester tester) async {
final AnimationController controller = AnimationController(
vsync: const TestVSync(),
duration: const Duration(milliseconds: 300),
);
addTearDown(controller.dispose);

await tester.pumpWidget(Center(
child: DualTransitionBuilder(
Expand Down Expand Up @@ -74,11 +76,12 @@ void main() {
expect(_getOpacity(tester), 1.0);
});

testWidgets('keeps state', (WidgetTester tester) async {
testWidgetsWithLeakTracking('keeps state', (WidgetTester tester) async {
final AnimationController controller = AnimationController(
vsync: const TestVSync(),
duration: const Duration(milliseconds: 300),
);
addTearDown(controller.dispose);

await tester.pumpWidget(Directionality(
textDirection: TextDirection.ltr,
Expand Down Expand Up @@ -138,11 +141,13 @@ void main() {
expect(state, same(tester.state(find.byType(_StatefulTestWidget))));
});

testWidgets('does not jump when interrupted - forward', (WidgetTester tester) async {
testWidgetsWithLeakTracking('does not jump when interrupted - forward', (WidgetTester tester) async {
final AnimationController controller = AnimationController(
vsync: const TestVSync(),
duration: const Duration(milliseconds: 300),
);
addTearDown(controller.dispose);

await tester.pumpWidget(Center(
child: DualTransitionBuilder(
animation: controller,
Expand Down Expand Up @@ -202,12 +207,14 @@ void main() {
expect(_getOpacity(tester), 1.0);
});

testWidgets('does not jump when interrupted - reverse', (WidgetTester tester) async {
testWidgetsWithLeakTracking('does not jump when interrupted - reverse', (WidgetTester tester) async {
final AnimationController controller = AnimationController(
value: 1.0,
vsync: const TestVSync(),
duration: const Duration(milliseconds: 300),
);
addTearDown(controller.dispose);

await tester.pumpWidget(Center(
child: DualTransitionBuilder(
animation: controller,
Expand Down
Loading

0 comments on commit 7d0c9b7

Please sign in to comment.