Unverified Commit 8e7fce98 authored by Binni Goel's avatar Binni Goel Committed by GitHub

[leak-tracking] Add more leak tracking in test/painting #3 (#136170)

parent e1b420cd
...@@ -7,6 +7,7 @@ import 'dart:ui' as ui; ...@@ -7,6 +7,7 @@ import 'dart:ui' as 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';
class TestCanvas implements Canvas { class TestCanvas implements Canvas {
final List<Invocation> invocations = <Invocation>[]; final List<Invocation> invocations = <Invocation>[];
...@@ -160,7 +161,7 @@ void main() { ...@@ -160,7 +161,7 @@ void main() {
expect(command.positionalArguments[2], equals(const Rect.fromLTRB(20.0, 40.0, 860.0, 840.0))); 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; late ImageSizeInfo imageSizeInfo;
int count = 0; int count = 0;
debugOnPaintImage = (ImageSizeInfo info) { debugOnPaintImage = (ImageSizeInfo info) {
...@@ -199,7 +200,7 @@ void main() { ...@@ -199,7 +200,7 @@ void main() {
debugOnPaintImage = null; 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; late ImageSizeInfo imageSizeInfo;
int count = 0; int count = 0;
debugOnPaintImage = (ImageSizeInfo info) { debugOnPaintImage = (ImageSizeInfo info) {
...@@ -242,7 +243,7 @@ void main() { ...@@ -242,7 +243,7 @@ void main() {
debugOnPaintImage = null; 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; late ImageSizeInfo imageSizeInfo;
int count = 0; int count = 0;
debugOnPaintImage = (ImageSizeInfo info) { debugOnPaintImage = (ImageSizeInfo info) {
......
...@@ -7,6 +7,7 @@ library; ...@@ -7,6 +7,7 @@ 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() {
Future<void> testBorder(WidgetTester tester, String name, StarBorder border, Future<void> testBorder(WidgetTester tester, String name, StarBorder border,
...@@ -114,12 +115,12 @@ void main() { ...@@ -114,12 +115,12 @@ void main() {
expect(copy, isNot(equals(copy.copyWith(squash: 0.0)))); 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_star', const StarBorder());
await testBorder(tester, 'basic_polygon', const StarBorder.polygon()); 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_6', const StarBorder(points: 6));
await testBorder(tester, 'points_2', const StarBorder(points: 2)); await testBorder(tester, 'points_2', const StarBorder(points: 2));
await testBorder(tester, 'inner_radius_0', const StarBorder(innerRadiusRatio: 0.0)); await testBorder(tester, 'inner_radius_0', const StarBorder(innerRadiusRatio: 0.0));
...@@ -144,7 +145,7 @@ void main() { ...@@ -144,7 +145,7 @@ void main() {
await testBorder(tester, 'side_align_outside', const StarBorder(side: BorderSide(color: Color(0xffff0000), strokeAlign: BorderSide.strokeAlignOutside))); 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_6', const StarBorder.polygon(sides: 6));
await testBorder(tester, 'poly_sides_2', const StarBorder.polygon(sides: 2)); await testBorder(tester, 'poly_sides_2', const StarBorder.polygon(sides: 2));
await testBorder(tester, 'poly_point_rounding_20', const StarBorder.polygon(pointRounding: 0.2)); await testBorder(tester, 'poly_point_rounding_20', const StarBorder.polygon(pointRounding: 0.2));
...@@ -163,7 +164,7 @@ void main() { ...@@ -163,7 +164,7 @@ void main() {
await testBorder(tester, 'poly_side_align_outside', const StarBorder.polygon(side: BorderSide(color: Color(0xffff0000), strokeAlign: BorderSide.strokeAlignOutside))); 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( await tester.pumpWidget(
Directionality( Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -191,7 +192,7 @@ void main() { ...@@ -191,7 +192,7 @@ void main() {
expect(tester.takeException(), isNull); 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 StarBorder from = StarBorder();
const ShapeBorder otherBorder = StarBorder( const ShapeBorder otherBorder = StarBorder(
points: 6, points: 6,
...@@ -208,7 +209,7 @@ void main() { ...@@ -208,7 +209,7 @@ void main() {
await testBorder(tester, 'from_star_border_100', from, lerpFrom: otherBorder, lerpAmount: 1.0); 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 StarBorder from = StarBorder();
const ShapeBorder otherBorder = CircleBorder(); const ShapeBorder otherBorder = CircleBorder();
const ShapeBorder eccentricCircle = CircleBorder(eccentricity: 0.6); const ShapeBorder eccentricCircle = CircleBorder(eccentricity: 0.6);
...@@ -226,7 +227,7 @@ void main() { ...@@ -226,7 +227,7 @@ void main() {
await testBorder(tester, 'from_eccentric_circle_border_100', from, lerpFrom: eccentricCircle, lerpAmount: 1.0); 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 StarBorder from = StarBorder();
const RoundedRectangleBorder rectangleBorder = RoundedRectangleBorder(); const RoundedRectangleBorder rectangleBorder = RoundedRectangleBorder();
await testBorder(tester, 'to_rect_border_20', from, lerpTo: rectangleBorder, lerpAmount: 0.2); await testBorder(tester, 'to_rect_border_20', from, lerpTo: rectangleBorder, lerpAmount: 0.2);
...@@ -250,7 +251,7 @@ void main() { ...@@ -250,7 +251,7 @@ void main() {
await testBorder(tester, 'from_rrect_border_100', from, lerpFrom: roundedRectBorder, lerpAmount: 1.0); 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 StarBorder from = StarBorder();
const StadiumBorder stadiumBorder = StadiumBorder(); const StadiumBorder stadiumBorder = StadiumBorder();
......
...@@ -10,6 +10,7 @@ import 'package:flutter/material.dart'; ...@@ -10,6 +10,7 @@ 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';
Future<void> verifyMarkedNeedsLayoutDuringTransientCallbacksPhase(WidgetTester tester, RenderObject renderObject) async { Future<void> verifyMarkedNeedsLayoutDuringTransientCallbacksPhase(WidgetTester tester, RenderObject renderObject) async {
assert(!renderObject.debugNeedsLayout); assert(!renderObject.debugNeedsLayout);
...@@ -36,7 +37,7 @@ Future<void> verifyMarkedNeedsLayoutDuringTransientCallbacksPhase(WidgetTester t ...@@ -36,7 +37,7 @@ Future<void> verifyMarkedNeedsLayoutDuringTransientCallbacksPhase(WidgetTester t
} }
void main() { 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( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: Text('text widget'), home: Text('text widget'),
...@@ -46,7 +47,7 @@ void main() { ...@@ -46,7 +47,7 @@ void main() {
await verifyMarkedNeedsLayoutDuringTransientCallbacksPhase(tester, renderObject); await verifyMarkedNeedsLayoutDuringTransientCallbacksPhase(tester, renderObject);
}); });
testWidgets( testWidgetsWithLeakTracking(
'Safe to query a RelayoutWhenSystemFontsChangeMixin for text layout after system fonts changes', 'Safe to query a RelayoutWhenSystemFontsChangeMixin for text layout after system fonts changes',
(WidgetTester tester) async { (WidgetTester tester) async {
final _RenderCustomRelayoutWhenSystemFontsChange child = _RenderCustomRelayoutWhenSystemFontsChange(); final _RenderCustomRelayoutWhenSystemFontsChange child = _RenderCustomRelayoutWhenSystemFontsChange();
...@@ -68,7 +69,7 @@ void main() { ...@@ -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( await tester.pumpWidget(
const MaterialApp( const MaterialApp(
home: SelectableText('text widget'), home: SelectableText('text widget'),
...@@ -79,7 +80,7 @@ void main() { ...@@ -79,7 +80,7 @@ void main() {
await verifyMarkedNeedsLayoutDuringTransientCallbacksPhase(tester, state.renderEditable); 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( await tester.pumpWidget(
const Banner( const Banner(
message: 'message', message: 'message',
...@@ -100,7 +101,7 @@ void main() { ...@@ -100,7 +101,7 @@ void main() {
expect(renderObject.debugNeedsPaint, isTrue); 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( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoDatePicker( home: CupertinoDatePicker(
...@@ -126,7 +127,7 @@ void main() { ...@@ -126,7 +127,7 @@ void main() {
expect(element.dirty, isTrue); expect(element.dirty, isTrue);
}, skip: isBrowser); // TODO(yjbanov): cupertino does not work on the Web yet: https://github.com/flutter/flutter/issues/41920 }, 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( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoDatePicker( home: CupertinoDatePicker(
...@@ -154,7 +155,7 @@ void main() { ...@@ -154,7 +155,7 @@ void main() {
expect(element.dirty, isTrue); expect(element.dirty, isTrue);
}, skip: isBrowser); // TODO(yjbanov): cupertino does not work on the Web yet: https://github.com/flutter/flutter/issues/41920 }, 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( await tester.pumpWidget(
CupertinoApp( CupertinoApp(
home: CupertinoTimerPicker( home: CupertinoTimerPicker(
...@@ -189,7 +190,7 @@ void main() { ...@@ -189,7 +190,7 @@ void main() {
expect(element.dirty, isTrue); expect(element.dirty, isTrue);
}, skip: isBrowser); // TODO(yjbanov): cupertino does not work on the Web yet: https://github.com/flutter/flutter/issues/41920 }, 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( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Material( home: Material(
...@@ -212,7 +213,7 @@ void main() { ...@@ -212,7 +213,7 @@ void main() {
await verifyMarkedNeedsLayoutDuringTransientCallbacksPhase(tester, renderObject); 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( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Material( home: Material(
...@@ -228,7 +229,7 @@ void main() { ...@@ -228,7 +229,7 @@ void main() {
await verifyMarkedNeedsLayoutDuringTransientCallbacksPhase(tester, renderObject); 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( await tester.pumpWidget(
MaterialApp( MaterialApp(
home: Material( home: Material(
......
...@@ -8,6 +8,7 @@ import 'package:flutter/gestures.dart'; ...@@ -8,6 +8,7 @@ import 'package:flutter/gestures.dart';
import 'package:flutter/rendering.dart'; import 'package:flutter/rendering.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() {
test('TextSpan equals', () { test('TextSpan equals', () {
...@@ -327,7 +328,7 @@ void main() { ...@@ -327,7 +328,7 @@ void main() {
expect(indexInTree(const TextSpan(text: 'foobar')), null); expect(indexInTree(const TextSpan(text: 'foobar')), null);
}); });
testWidgets('handles mouse cursor', (WidgetTester tester) async { testWidgetsWithLeakTracking('handles mouse cursor', (WidgetTester tester) async {
await tester.pumpWidget( await tester.pumpWidget(
const Directionality( const Directionality(
textDirection: TextDirection.ltr, textDirection: TextDirection.ltr,
...@@ -364,7 +365,7 @@ void main() { ...@@ -364,7 +365,7 @@ void main() {
expect(RendererBinding.instance.mouseTracker.debugDeviceActiveCursor(1), SystemMouseCursors.basic); 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>[]; final List<PointerEvent> logEvents = <PointerEvent>[];
await tester.pumpWidget( await tester.pumpWidget(
Directionality( Directionality(
...@@ -409,7 +410,7 @@ void main() { ...@@ -409,7 +410,7 @@ void main() {
expect(logEvents[1], isA<PointerExitEvent>()); 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( const TextSpan span = TextSpan(
text: 'aaaaa', text: 'aaaaa',
spellOut: true, spellOut: true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment