Unverified Commit 2ec771aa authored by Binni Goel's avatar Binni Goel Committed by GitHub

Test cover painting for memory leaks (#136696)

parent 6db6a5a1
......@@ -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,
......
......@@ -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);
});
}
......
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