Skip to content

Commit

Permalink
[leak-tracking] Add more leak tracking in test/painting #3 (flutter#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
droidbg authored Nov 3, 2023
1 parent e1b420c commit 8e7fce9
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 24 deletions.
7 changes: 4 additions & 3 deletions packages/flutter/test/painting/paint_image_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'dart:ui' as ui;
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 TestCanvas implements Canvas {
final List<Invocation> invocations = <Invocation>[];
Expand Down Expand Up @@ -160,7 +161,7 @@ void main() {
expect(command.positionalArguments[2], equals(const Rect.fromLTRB(20.0, 40.0, 860.0, 840.0)));
});

testWidgets('Reports Image painting', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Reports Image painting', (WidgetTester tester) async {
late ImageSizeInfo imageSizeInfo;
int count = 0;
debugOnPaintImage = (ImageSizeInfo info) {
Expand Down Expand Up @@ -199,7 +200,7 @@ void main() {
debugOnPaintImage = null;
});

testWidgets('Reports Image painting - change per frame', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Reports Image painting - change per frame', (WidgetTester tester) async {
late ImageSizeInfo imageSizeInfo;
int count = 0;
debugOnPaintImage = (ImageSizeInfo info) {
Expand Down Expand Up @@ -242,7 +243,7 @@ void main() {
debugOnPaintImage = null;
});

testWidgets('Reports Image painting - no debug label', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Reports Image painting - no debug label', (WidgetTester tester) async {
late ImageSizeInfo imageSizeInfo;
int count = 0;
debugOnPaintImage = (ImageSizeInfo info) {
Expand Down
17 changes: 9 additions & 8 deletions packages/flutter/test/painting/star_border_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ library;

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() {
Future<void> testBorder(WidgetTester tester, String name, StarBorder border,
Expand Down Expand Up @@ -114,12 +115,12 @@ void main() {
expect(copy, isNot(equals(copy.copyWith(squash: 0.0))));
});

testWidgets('StarBorder basic geometry', (WidgetTester tester) async {
testWidgetsWithLeakTracking('StarBorder basic geometry', (WidgetTester tester) async {
await testBorder(tester, 'basic_star', const StarBorder());
await testBorder(tester, 'basic_polygon', const StarBorder.polygon());
});

testWidgets('StarBorder parameters', (WidgetTester tester) async {
testWidgetsWithLeakTracking('StarBorder parameters', (WidgetTester tester) async {
await testBorder(tester, 'points_6', const StarBorder(points: 6));
await testBorder(tester, 'points_2', const StarBorder(points: 2));
await testBorder(tester, 'inner_radius_0', const StarBorder(innerRadiusRatio: 0.0));
Expand All @@ -144,7 +145,7 @@ void main() {
await testBorder(tester, 'side_align_outside', const StarBorder(side: BorderSide(color: Color(0xffff0000), strokeAlign: BorderSide.strokeAlignOutside)));
});

testWidgets('StarBorder.polygon parameters', (WidgetTester tester) async {
testWidgetsWithLeakTracking('StarBorder.polygon parameters', (WidgetTester tester) async {
await testBorder(tester, 'poly_sides_6', const StarBorder.polygon(sides: 6));
await testBorder(tester, 'poly_sides_2', const StarBorder.polygon(sides: 2));
await testBorder(tester, 'poly_point_rounding_20', const StarBorder.polygon(pointRounding: 0.2));
Expand All @@ -163,7 +164,7 @@ void main() {
await testBorder(tester, 'poly_side_align_outside', const StarBorder.polygon(side: BorderSide(color: Color(0xffff0000), strokeAlign: BorderSide.strokeAlignOutside)));
});

testWidgets("StarBorder doesn't try to scale an infinite scale matrix", (WidgetTester tester) async {
testWidgetsWithLeakTracking("StarBorder doesn't try to scale an infinite scale matrix", (WidgetTester tester) async {
await tester.pumpWidget(
Directionality(
textDirection: TextDirection.ltr,
Expand Down Expand Up @@ -191,7 +192,7 @@ void main() {
expect(tester.takeException(), isNull);
});

testWidgets('StarBorder lerped with StarBorder', (WidgetTester tester) async {
testWidgetsWithLeakTracking('StarBorder lerped with StarBorder', (WidgetTester tester) async {
const StarBorder from = StarBorder();
const ShapeBorder otherBorder = StarBorder(
points: 6,
Expand All @@ -208,7 +209,7 @@ void main() {
await testBorder(tester, 'from_star_border_100', from, lerpFrom: otherBorder, lerpAmount: 1.0);
});

testWidgets('StarBorder lerped with CircleBorder', (WidgetTester tester) async {
testWidgetsWithLeakTracking('StarBorder lerped with CircleBorder', (WidgetTester tester) async {
const StarBorder from = StarBorder();
const ShapeBorder otherBorder = CircleBorder();
const ShapeBorder eccentricCircle = CircleBorder(eccentricity: 0.6);
Expand All @@ -226,7 +227,7 @@ void main() {
await testBorder(tester, 'from_eccentric_circle_border_100', from, lerpFrom: eccentricCircle, lerpAmount: 1.0);
});

testWidgets('StarBorder lerped with RoundedRectangleBorder', (WidgetTester tester) async {
testWidgetsWithLeakTracking('StarBorder lerped with RoundedRectangleBorder', (WidgetTester tester) async {
const StarBorder from = StarBorder();
const RoundedRectangleBorder rectangleBorder = RoundedRectangleBorder();
await testBorder(tester, 'to_rect_border_20', from, lerpTo: rectangleBorder, lerpAmount: 0.2);
Expand All @@ -250,7 +251,7 @@ void main() {
await testBorder(tester, 'from_rrect_border_100', from, lerpFrom: roundedRectBorder, lerpAmount: 1.0);
});

testWidgets('StarBorder lerped with StadiumBorder', (WidgetTester tester) async {
testWidgetsWithLeakTracking('StarBorder lerped with StadiumBorder', (WidgetTester tester) async {
const StarBorder from = StarBorder();
const StadiumBorder stadiumBorder = StadiumBorder();

Expand Down
21 changes: 11 additions & 10 deletions packages/flutter/test/painting/system_fonts_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';

Future<void> verifyMarkedNeedsLayoutDuringTransientCallbacksPhase(WidgetTester tester, RenderObject renderObject) async {
assert(!renderObject.debugNeedsLayout);
Expand All @@ -36,7 +37,7 @@ Future<void> verifyMarkedNeedsLayoutDuringTransientCallbacksPhase(WidgetTester t
}

void main() {
testWidgets('RenderParagraph relayout upon system fonts changes', (WidgetTester tester) async {
testWidgetsWithLeakTracking('RenderParagraph relayout upon system fonts changes', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: Text('text widget'),
Expand All @@ -46,7 +47,7 @@ void main() {
await verifyMarkedNeedsLayoutDuringTransientCallbacksPhase(tester, renderObject);
});

testWidgets(
testWidgetsWithLeakTracking(
'Safe to query a RelayoutWhenSystemFontsChangeMixin for text layout after system fonts changes',
(WidgetTester tester) async {
final _RenderCustomRelayoutWhenSystemFontsChange child = _RenderCustomRelayoutWhenSystemFontsChange();
Expand All @@ -68,7 +69,7 @@ void main() {
},
);

testWidgets('RenderEditable relayout upon system fonts changes', (WidgetTester tester) async {
testWidgetsWithLeakTracking('RenderEditable relayout upon system fonts changes', (WidgetTester tester) async {
await tester.pumpWidget(
const MaterialApp(
home: SelectableText('text widget'),
Expand All @@ -79,7 +80,7 @@ void main() {
await verifyMarkedNeedsLayoutDuringTransientCallbacksPhase(tester, state.renderEditable);
});

testWidgets('Banner repaint upon system fonts changes', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Banner repaint upon system fonts changes', (WidgetTester tester) async {
await tester.pumpWidget(
const Banner(
message: 'message',
Expand All @@ -100,7 +101,7 @@ void main() {
expect(renderObject.debugNeedsPaint, isTrue);
});

testWidgets('CupertinoDatePicker reset cache upon system fonts change - date time mode', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CupertinoDatePicker reset cache upon system fonts change - date time mode', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: CupertinoDatePicker(
Expand All @@ -126,7 +127,7 @@ void main() {
expect(element.dirty, isTrue);
}, skip: isBrowser); // TODO(yjbanov): cupertino does not work on the Web yet: https://github.com/flutter/flutter/issues/41920

testWidgets('CupertinoDatePicker reset cache upon system fonts change - date mode', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CupertinoDatePicker reset cache upon system fonts change - date mode', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: CupertinoDatePicker(
Expand Down Expand Up @@ -154,7 +155,7 @@ void main() {
expect(element.dirty, isTrue);
}, skip: isBrowser); // TODO(yjbanov): cupertino does not work on the Web yet: https://github.com/flutter/flutter/issues/41920

testWidgets('CupertinoDatePicker reset cache upon system fonts change - time mode', (WidgetTester tester) async {
testWidgetsWithLeakTracking('CupertinoDatePicker reset cache upon system fonts change - time mode', (WidgetTester tester) async {
await tester.pumpWidget(
CupertinoApp(
home: CupertinoTimerPicker(
Expand Down Expand Up @@ -189,7 +190,7 @@ void main() {
expect(element.dirty, isTrue);
}, skip: isBrowser); // TODO(yjbanov): cupertino does not work on the Web yet: https://github.com/flutter/flutter/issues/41920

testWidgets('RangeSlider relayout upon system fonts changes', (WidgetTester tester) async {
testWidgetsWithLeakTracking('RangeSlider relayout upon system fonts changes', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
Expand All @@ -212,7 +213,7 @@ void main() {
await verifyMarkedNeedsLayoutDuringTransientCallbacksPhase(tester, renderObject);
});

testWidgets('Slider relayout upon system fonts changes', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Slider relayout upon system fonts changes', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
Expand All @@ -228,7 +229,7 @@ void main() {
await verifyMarkedNeedsLayoutDuringTransientCallbacksPhase(tester, renderObject);
});

testWidgets('TimePicker relayout upon system fonts changes', (WidgetTester tester) async {
testWidgetsWithLeakTracking('TimePicker relayout upon system fonts changes', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Material(
Expand Down
7 changes: 4 additions & 3 deletions packages/flutter/test/painting/text_span_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart';
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() {
test('TextSpan equals', () {
Expand Down Expand Up @@ -327,7 +328,7 @@ void main() {
expect(indexInTree(const TextSpan(text: 'foobar')), null);
});

testWidgets('handles mouse cursor', (WidgetTester tester) async {
testWidgetsWithLeakTracking('handles mouse cursor', (WidgetTester tester) async {
await tester.pumpWidget(
const Directionality(
textDirection: TextDirection.ltr,
Expand Down Expand Up @@ -364,7 +365,7 @@ void main() {
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic);
});

testWidgets('handles onEnter and onExit', (WidgetTester tester) async {
testWidgetsWithLeakTracking('handles onEnter and onExit', (WidgetTester tester) async {
final List<PointerEvent> logEvents = <PointerEvent>[];
await tester.pumpWidget(
Directionality(
Expand Down Expand Up @@ -409,7 +410,7 @@ void main() {
expect(logEvents[1], isA<PointerExitEvent>());
});

testWidgets('TextSpan can compute StringAttributes', (WidgetTester tester) async {
testWidgetsWithLeakTracking('TextSpan can compute StringAttributes', (WidgetTester tester) async {
const TextSpan span = TextSpan(
text: 'aaaaa',
spellOut: true,
Expand Down

0 comments on commit 8e7fce9

Please sign in to comment.