Test cover painting for memory leaks (#136696)

This commit is contained in:
Binni Goel
2023-10-21 09:41:47 +05:30
committed by GitHub
parent 6db6a5a1b5
commit 2ec771aa9c
2 changed files with 9 additions and 5 deletions

View File

@@ -14,9 +14,10 @@ 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';
void main() {
testWidgets('ImageDecoration.lerp', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ImageDecoration.lerp', (WidgetTester tester) async {
final MemoryImage green = MemoryImage(Uint8List.fromList(<int>[
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x25, 0xdb, 0x56,
@@ -159,6 +160,7 @@ void main() {
if (!kIsWeb) { // TODO(ianh): https://github.com/flutter/flutter/issues/130610
final ui.Image image = (await tester.binding.runAsync<ui.Image>(() => captureImage(find.byType(Wrap).evaluate().single)))!;
addTearDown(() => image.dispose());
final Uint8List bytes = (await tester.binding.runAsync<ByteData?>(() => image.toByteData(format: ui.ImageByteFormat.rawStraightRgba)))!.buffer.asUint8List();
expect(image.width, 792);
expect(image.height, 48);
@@ -189,7 +191,7 @@ void main() {
}
}, skip: kIsWeb); // TODO(ianh): https://github.com/flutter/flutter/issues/130612, https://github.com/flutter/flutter/issues/130609
testWidgets('ImageDecoration.lerp', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ImageDecoration.lerp', (WidgetTester tester) async {
final MemoryImage cmyk = MemoryImage(Uint8List.fromList(<int>[
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x02, 0x03, 0x00, 0x00, 0x00, 0xd4, 0x9f, 0x76,
@@ -355,6 +357,7 @@ void main() {
if (!kIsWeb) { // TODO(ianh): https://github.com/flutter/flutter/issues/130610
final ui.Image image = (await tester.binding.runAsync<ui.Image>(() => captureImage(find.byType(Wrap).evaluate().single)))!;
addTearDown(() => image.dispose());
final Uint8List bytes = (await tester.binding.runAsync<ByteData?>(() => image.toByteData(format: ui.ImageByteFormat.rawStraightRgba)))!.buffer.asUint8List();
expect(image.width, 24 * 24);
expect(image.height, 1 * 24);
@@ -406,7 +409,7 @@ void main() {
}
}, skip: kIsWeb); // TODO(ianh): https://github.com/flutter/flutter/issues/130612, https://github.com/flutter/flutter/issues/130609
testWidgets('ImageDecoration.lerp with colored background', (WidgetTester tester) async {
testWidgetsWithLeakTracking('ImageDecoration.lerp with colored background', (WidgetTester tester) async {
final MemoryImage cmyk = MemoryImage(Uint8List.fromList(<int>[
0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00, 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x04, 0x02, 0x03, 0x00, 0x00, 0x00, 0xd4, 0x9f, 0x76,

View File

@@ -11,6 +11,7 @@ import 'dart:math' as math;
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('LinearGradient scale test', () {
@@ -881,7 +882,7 @@ void main() {
group('Gradients - 45 degrees', () {
for (final Gradient gradient in gradients45) {
testWidgets('$gradient', (WidgetTester tester) async {
testWidgetsWithLeakTracking('$gradient', (WidgetTester tester) async {
await runTest(tester, gradient, 45);
});
}
@@ -889,7 +890,7 @@ void main() {
group('Gradients - 90 degrees', () {
for (final Gradient gradient in gradients90) {
testWidgets('$gradient', (WidgetTester tester) async {
testWidgetsWithLeakTracking('$gradient', (WidgetTester tester) async {
await runTest(tester, gradient, 90);
});
}