Skip to content

Commit

Permalink
[leak-tracking] Add leak tracking in test/painting #1 (flutter#136167)
Browse files Browse the repository at this point in the history
  • Loading branch information
droidbg authored Oct 9, 2023
1 parent 3df6078 commit 67170b1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
8 changes: 4 additions & 4 deletions packages/flutter/test/painting/_network_image_test_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/painting/_network_image_web.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
import 'package:web/web.dart' as web;

import '../image_data.dart';
import '_test_http_request.dart';

void runTests() {
tearDown(() {
debugRestoreHttpRequestFactory();
});

testWidgets('loads an image from the network with headers',
testWidgetsWithLeakTracking('loads an image from the network with headers',
(WidgetTester tester) async {
final TestHttpRequest testHttpRequest = TestHttpRequest()
..status = 200
Expand All @@ -42,7 +42,7 @@ void runTests() {
assert(mapEquals(testHttpRequest.responseHeaders, headers), true);
});

testWidgets('loads an image from the network with unsuccessful HTTP code',
testWidgetsWithLeakTracking('loads an image from the network with unsuccessful HTTP code',
(WidgetTester tester) async {
final TestHttpRequest testHttpRequest = TestHttpRequest()
..status = 404
Expand All @@ -67,7 +67,7 @@ void runTests() {
expect((tester.takeException() as web.ProgressEvent).type, 'test error');
});

testWidgets('loads an image from the network with empty response',
testWidgetsWithLeakTracking('loads an image from the network with empty response',
(WidgetTester tester) async {
final TestHttpRequest testHttpRequest = TestHttpRequest()
..status = 200
Expand Down
3 changes: 2 additions & 1 deletion packages/flutter/test/painting/binding_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import 'package:flutter/scheduler.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';

Future<void> main() async {
final ui.Image image = await createTestImage();

testWidgets('didHaveMemoryPressure clears imageCache', (WidgetTester tester) async {
testWidgetsWithLeakTracking('didHaveMemoryPressure clears imageCache', (WidgetTester tester) async {
imageCache.putIfAbsent(1, () => OneFrameImageStreamCompleter(
Future<ImageInfo>.value(ImageInfo(
image: image,
Expand Down
3 changes: 2 additions & 1 deletion packages/flutter/test/painting/border_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import 'package:flutter/widgets.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 @@ -316,7 +317,7 @@ void main() {
expect(nonUniformBorderDirectional.dimensions, const EdgeInsetsDirectional.fromSTEB(5, 5, 0, 20));
});

testWidgets('Non-Uniform Border variations', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Non-Uniform Border variations', (WidgetTester tester) async {

Widget buildWidget({ required BoxBorder border, BorderRadius? borderRadius, BoxShape boxShape = BoxShape.rectangle}) {
return Directionality(
Expand Down
17 changes: 9 additions & 8 deletions packages/flutter/test/painting/box_painter_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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() {
tearDown(() {
Expand Down Expand Up @@ -160,7 +161,7 @@ void main() {
expect(const BoxShadow(blurRadius: 4.0, blurStyle: BlurStyle.solid).toString(), equals('BoxShadow(Color(0xff000000), Offset(0.0, 0.0), 4.0, 0.0, BlurStyle.solid)'));
});

testWidgets('BoxShadow BoxStyle.solid', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BoxShadow BoxStyle.solid', (WidgetTester tester) async {
final Key key = UniqueKey();
debugDisableShadows = false;
await tester.pumpWidget(
Expand Down Expand Up @@ -192,7 +193,7 @@ void main() {
debugDisableShadows = true;
});

testWidgets('BoxShadow BoxStyle.outer', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BoxShadow BoxStyle.outer', (WidgetTester tester) async {
final Key key = UniqueKey();
debugDisableShadows = false;
await tester.pumpWidget(
Expand Down Expand Up @@ -224,7 +225,7 @@ void main() {
debugDisableShadows = true;
});

testWidgets('BoxShadow BoxStyle.inner', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BoxShadow BoxStyle.inner', (WidgetTester tester) async {
final Key key = UniqueKey();
debugDisableShadows = false;
await tester.pumpWidget(
Expand Down Expand Up @@ -256,7 +257,7 @@ void main() {
debugDisableShadows = true;
});

testWidgets('BoxShadow BoxStyle.normal', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BoxShadow BoxStyle.normal', (WidgetTester tester) async {
final Key key = UniqueKey();
debugDisableShadows = false;
await tester.pumpWidget(
Expand Down Expand Up @@ -288,7 +289,7 @@ void main() {
debugDisableShadows = true;
});

testWidgets('BoxShadow BoxStyle.normal.wide_radius', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BoxShadow BoxStyle.normal.wide_radius', (WidgetTester tester) async {
final Key key = UniqueKey();
debugDisableShadows = false;
await tester.pumpWidget(
Expand Down Expand Up @@ -321,7 +322,7 @@ void main() {
debugDisableShadows = true;
});

testWidgets('BoxShadow BoxStyle.outer.wide_radius', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BoxShadow BoxStyle.outer.wide_radius', (WidgetTester tester) async {
final Key key = UniqueKey();
debugDisableShadows = false;
await tester.pumpWidget(
Expand Down Expand Up @@ -354,7 +355,7 @@ void main() {
debugDisableShadows = true;
});

testWidgets('BoxShadow BoxStyle.solid.wide_radius', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BoxShadow BoxStyle.solid.wide_radius', (WidgetTester tester) async {
final Key key = UniqueKey();
debugDisableShadows = false;
await tester.pumpWidget(
Expand Down Expand Up @@ -386,7 +387,7 @@ void main() {
debugDisableShadows = true;
});

testWidgets('BoxShadow BoxStyle.inner.wide_radius', (WidgetTester tester) async {
testWidgetsWithLeakTracking('BoxShadow BoxStyle.inner.wide_radius', (WidgetTester tester) async {
final Key key = UniqueKey();
debugDisableShadows = false;
await tester.pumpWidget(
Expand Down
3 changes: 2 additions & 1 deletion packages/flutter/test/painting/flutter_logo_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ library;

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() {
// Here and below, see: https://github.com/dart-lang/sdk/issues/26980
Expand Down Expand Up @@ -85,7 +86,7 @@ void main() {
);
});

testWidgets('Flutter Logo golden test', (WidgetTester tester) async {
testWidgetsWithLeakTracking('Flutter Logo golden test', (WidgetTester tester) async {
final Key logo = UniqueKey();
await tester.pumpWidget(Container(
key: logo,
Expand Down

0 comments on commit 67170b1

Please sign in to comment.