Visitar URL original
Cover more test/widgets tests with leak tracking #8 by ksokolovskyi · Pull Request #135045 · flutter/flutter · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Update more test/widget tests
  • Loading branch information
ksokolovskyi committed Sep 19, 2023
commit 989121ed75141a23cf754d4cc67df39d687cbc3c
3 changes: 2 additions & 1 deletion packages/flutter/test/widgets/scroll_interaction_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

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

void main() {
testWidgets('Scroll flings twice in a row does not crash', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Scroll flings twice in a row does not crash', (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
Expand Down
11 changes: 6 additions & 5 deletions packages/flutter/test/widgets/scroll_notification_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
import 'package:flutter/gestures.dart';
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('ScrollMetricsNotification test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ScrollMetricsNotification test', (WidgetTester tester) async {
final List<Notification> events = <Notification>[];
Widget buildFrame(double height) {
return NotificationListener<Notification>(
Expand Down Expand Up @@ -62,7 +63,7 @@ void main() {
expect(events.length, 0);
});

testWidgets('Scroll notification basics', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Scroll notification basics', (WidgetTester tester) async {
late ScrollNotification notification;

await tester.pumpWidget(NotificationListener<ScrollNotification>(
Expand Down Expand Up @@ -103,7 +104,7 @@ void main() {
expect(end.dragDetails!.velocity, equals(Velocity.zero));
});

testWidgets('Scroll notification depth', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Scroll notification depth', (WidgetTester tester) async {
final List<Type> depth0Types = <Type>[];
final List<Type> depth1Types = <Type>[];
final List<int> depth0Values = <int>[];
Expand Down Expand Up @@ -158,7 +159,7 @@ void main() {
expect(depth1Values, equals(<int>[1, 1, 1, 1, 1]));
});

testWidgets('ScrollNotifications bubble past Scaffold Material', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ScrollNotifications bubble past Scaffold Material', (WidgetTester tester) async {
final List<Type> notificationTypes = <Type>[];

await tester.pumpWidget(
Expand Down Expand Up @@ -206,7 +207,7 @@ void main() {
expect(notificationTypes, equals(types));
});

testWidgets('ScrollNotificationObserver', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ScrollNotificationObserver', (WidgetTester tester) async {
late ScrollNotificationObserverState observer;
ScrollNotification? notification;

Expand Down
3 changes: 2 additions & 1 deletion packages/flutter/test/widgets/scroll_physics_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';

class TestScrollPhysics extends ScrollPhysics {
const TestScrollPhysics({
Expand Down Expand Up @@ -339,7 +340,7 @@ FlutterError
}
});

testWidgets('PageScrollPhysics work with NestedScrollView', (WidgetTester tester) async {
testWidgetsWithLeakTracking('PageScrollPhysics work with NestedScrollView', (WidgetTester tester) async {
// Regression test for: https://github.com/flutter/flutter/issues/47850
await tester.pumpWidget(Material(
child: Directionality(
Expand Down
16 changes: 12 additions & 4 deletions packages/flutter/test/widgets/scroll_position_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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

ScrollController _controller = ScrollController(
initialScrollOffset: 110.0,
Expand Down Expand Up @@ -140,7 +141,7 @@ Future<void> performTest(WidgetTester tester, bool maintainState) async {
}

void main() {
testWidgets("ScrollPosition jumpTo() doesn't call notifyListeners twice", (WidgetTester tester) async {
testWidgetsWithLeakTracking("ScrollPosition jumpTo() doesn't call notifyListeners twice", (WidgetTester tester) async {
int count = 0;
await tester.pumpWidget(MaterialApp(
home: ListView.builder(
Expand All @@ -159,15 +160,22 @@ void main() {
expect(count, 1);
});

testWidgets('whether we remember our scroll position', (WidgetTester tester) async {
testWidgetsWithLeakTracking('whether we remember our scroll position', (WidgetTester tester) async {
await performTest(tester, true);
await performTest(tester, false);
});

testWidgets('scroll alignment is honored by ensureVisible', (WidgetTester tester) async {
testWidgetsWithLeakTracking('scroll alignment is honored by ensureVisible', (WidgetTester tester) async {
final List<int> items = List<int>.generate(11, (int index) => index).toList();
final List<FocusNode> nodes = List<FocusNode>.generate(11, (int index) => FocusNode(debugLabel: 'Item ${index + 1}')).toList();
addTearDown(() {
for (final FocusNode node in nodes) {
node.dispose();
}
});
final ScrollController controller = ScrollController();
addTearDown(controller.dispose);

await tester.pumpWidget(
MaterialApp(
home: ListView(
Expand Down Expand Up @@ -226,7 +234,7 @@ void main() {
expect(controller.position.pixels, equals(0.0));
});

testWidgets('jumpTo recommends deferred loading', (WidgetTester tester) async {
testWidgetsWithLeakTracking('jumpTo recommends deferred loading', (WidgetTester tester) async {
int loadedWithDeferral = 0;
int buildCount = 0;
const double height = 500;
Expand Down
Loading