Unverified Commit 67170b12 authored by droidbg's avatar droidbg Committed by GitHub

[leak-tracking] Add leak tracking in test/painting #1 (#136167)

parent 3df6078b
......@@ -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
......@@ -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
......@@ -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
......
......@@ -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,
......
......@@ -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>[];
......@@ -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(
......
......@@ -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(() {
......@@ -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(
......@@ -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(
......@@ -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(
......@@ -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(
......@@ -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(
......@@ -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(
......@@ -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(
......@@ -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(
......
......@@ -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
......@@ -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,
......
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