test: Fix memory leak in transitions test (#146747)

This commit is contained in:
Valentin Vignal 2024-04-15 23:52:18 +08:00 committed by GitHub
parent 63634c25ad
commit 0099d1a96a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5,6 +5,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:leak_tracker_flutter_testing/leak_tracker_flutter_testing.dart';
void main() {
testWidgets('toString control test', (WidgetTester tester) async {
@ -95,12 +96,18 @@ void main() {
expect(actualDecoration.boxShadow, null);
});
testWidgets('animations work with curves test', (WidgetTester tester) async {
final Animation<Decoration> curvedDecorationAnimation =
decorationTween.animate(CurvedAnimation(
testWidgets(
'animations work with curves test',
// TODO(polina-c): remove when fixed https://github.com/flutter/flutter/issues/145600 [leak-tracking-opt-in]
experimentalLeakTesting: LeakTesting.settings.withTracked(classes: const <String>['CurvedAnimation']),
(WidgetTester tester) async {
final CurvedAnimation animation = CurvedAnimation(
parent: controller,
curve: Curves.easeOut,
));
);
addTearDown(animation.dispose);
final Animation<Decoration> curvedDecorationAnimation =
decorationTween.animate(animation);
final DecoratedBoxTransition transitionUnderTest = DecoratedBoxTransition(
decoration: curvedDecorationAnimation,
@ -141,7 +148,8 @@ void main() {
expect(actualDecoration.boxShadow![0].spreadRadius, moreOrLessEquals(1.2, epsilon: 0.1));
// Scaling a shadow doesn't change the color.
expect(actualDecoration.boxShadow![0].color, const Color(0x66000000));
});
},
);
});
testWidgets('AlignTransition animates', (WidgetTester tester) async {