mirror of
https://github.com/flutter/flutter
synced 2024-08-25 02:46:31 +00:00
Fix leaks in tests. (#142677)
This commit is contained in:
parent
e91f530b01
commit
fdf05c90bf
|
@ -14,6 +14,12 @@ void main() {
|
|||
|
||||
late ui.Image testImage;
|
||||
|
||||
ui.Image cloneImage() {
|
||||
final ui.Image clone = testImage.clone();
|
||||
addTearDown(clone.dispose);
|
||||
return clone;
|
||||
}
|
||||
|
||||
setUpAll(() async {
|
||||
testImage = await createTestImage(width: 10, height: 10);
|
||||
});
|
||||
|
@ -34,10 +40,7 @@ void main() {
|
|||
return Scrollable.of(find.byType(TestWidget).evaluate().first).position;
|
||||
}
|
||||
|
||||
testWidgets('ScrollAwareImageProvider does not delay if widget is not in scrollable',
|
||||
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
|
||||
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('ScrollAwareImageProvider does not delay if widget is not in scrollable', (WidgetTester tester) async {
|
||||
final GlobalKey<TestWidgetState> key = GlobalKey<TestWidgetState>();
|
||||
await tester.pumpWidget(TestWidget(key));
|
||||
|
||||
|
@ -65,10 +68,7 @@ void main() {
|
|||
expect(imageCache.currentSize, 1);
|
||||
});
|
||||
|
||||
testWidgets('ScrollAwareImageProvider does not delay if in scrollable that is not scrolling',
|
||||
// TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
|
||||
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('ScrollAwareImageProvider does not delay if in scrollable that is not scrolling', (WidgetTester tester) async {
|
||||
final GlobalKey<TestWidgetState> key = GlobalKey<TestWidgetState>();
|
||||
await tester.pumpWidget(Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
|
@ -105,10 +105,7 @@ void main() {
|
|||
expect(findPhysics<RecordingPhysics>(tester).velocities, <double>[0]);
|
||||
});
|
||||
|
||||
testWidgets('ScrollAwareImageProvider does not delay if in scrollable that is scrolling slowly',
|
||||
// TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
|
||||
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('ScrollAwareImageProvider does not delay if in scrollable that is scrolling slowly', (WidgetTester tester) async {
|
||||
final List<GlobalKey<TestWidgetState>> keys = <GlobalKey<TestWidgetState>>[];
|
||||
final ScrollController scrollController = ScrollController();
|
||||
addTearDown(scrollController.dispose);
|
||||
|
@ -167,10 +164,7 @@ void main() {
|
|||
expect(imageCache.currentSize, 1);
|
||||
});
|
||||
|
||||
testWidgets('ScrollAwareImageProvider delays if in scrollable that is scrolling fast',
|
||||
// TODO(polina-c): make sure images are disposed, https://github.com/flutter/flutter/issues/141388 [leaks-to-clean]
|
||||
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('ScrollAwareImageProvider delays if in scrollable that is scrolling fast', (WidgetTester tester) async {
|
||||
final List<GlobalKey<TestWidgetState>> keys = <GlobalKey<TestWidgetState>>[];
|
||||
final ScrollController scrollController = ScrollController();
|
||||
addTearDown(scrollController.dispose);
|
||||
|
@ -239,10 +233,7 @@ void main() {
|
|||
expect(imageCache.currentSize, 1);
|
||||
});
|
||||
|
||||
testWidgets('ScrollAwareImageProvider delays if in scrollable that is scrolling fast and fizzles if disposed',
|
||||
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
|
||||
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('ScrollAwareImageProvider delays if in scrollable that is scrolling fast and fizzles if disposed', (WidgetTester tester) async {
|
||||
final List<GlobalKey<TestWidgetState>> keys = <GlobalKey<TestWidgetState>>[];
|
||||
final ScrollController scrollController = ScrollController();
|
||||
addTearDown(scrollController.dispose);
|
||||
|
@ -261,7 +252,7 @@ void main() {
|
|||
|
||||
final DisposableBuildContext context = DisposableBuildContext(keys.last.currentState!);
|
||||
addTearDown(context.dispose);
|
||||
final TestImageProvider testImageProvider = TestImageProvider(testImage.clone());
|
||||
final TestImageProvider testImageProvider = TestImageProvider(cloneImage());
|
||||
final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>(
|
||||
context: context,
|
||||
imageProvider: testImageProvider,
|
||||
|
@ -313,10 +304,7 @@ void main() {
|
|||
expect(imageCache.currentSize, 0);
|
||||
});
|
||||
|
||||
testWidgets('ScrollAwareImageProvider resolves from ImageCache and does not set completer twice',
|
||||
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
|
||||
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
|
||||
(WidgetTester tester) async {
|
||||
testWidgets('ScrollAwareImageProvider resolves from ImageCache and does not set completer twice', (WidgetTester tester) async {
|
||||
final GlobalKey<TestWidgetState> key = GlobalKey<TestWidgetState>();
|
||||
final ScrollController scrollController = ScrollController();
|
||||
addTearDown(scrollController.dispose);
|
||||
|
@ -331,7 +319,7 @@ void main() {
|
|||
|
||||
final DisposableBuildContext context = DisposableBuildContext(key.currentState!);
|
||||
addTearDown(context.dispose);
|
||||
final TestImageProvider testImageProvider = TestImageProvider(testImage.clone());
|
||||
final TestImageProvider testImageProvider = TestImageProvider(cloneImage());
|
||||
final ScrollAwareImageProvider<TestImageProvider> imageProvider = ScrollAwareImageProvider<TestImageProvider>(
|
||||
context: context,
|
||||
imageProvider: testImageProvider,
|
||||
|
@ -367,7 +355,6 @@ void main() {
|
|||
});
|
||||
|
||||
testWidgets('ScrollAwareImageProvider does not block LRU updates to image cache',
|
||||
// TODO(polina-c): clean up leaks, https://github.com/flutter/flutter/issues/134787 [leaks-to-clean]
|
||||
experimentalLeakTesting: LeakTesting.settings.withIgnoredAll(),
|
||||
(WidgetTester tester) async {
|
||||
final int oldSize = imageCache.maximumSize;
|
||||
|
|
Loading…
Reference in a new issue