Skip to content

Commit eec3f06

Browse files
authored
TestClipPaintingContext should dispose ContainerLayer (#135949)
1 parent 7d01663 commit eec3f06

File tree

3 files changed

+16
-23
lines changed

3 files changed

+16
-23
lines changed

packages/flutter/test/rendering/rendering_tester.dart

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,11 @@ class FakeTicker implements Ticker {
381381
}
382382

383383
class TestClipPaintingContext extends PaintingContext {
384-
TestClipPaintingContext() : super(ContainerLayer(), Rect.zero);
384+
TestClipPaintingContext() : this._(ContainerLayer());
385+
386+
TestClipPaintingContext._(this._containerLayer) : super(_containerLayer, Rect.zero);
387+
388+
final ContainerLayer _containerLayer;
385389

386390
@override
387391
ClipRectLayer? pushClipRect(
@@ -397,6 +401,11 @@ class TestClipPaintingContext extends PaintingContext {
397401
}
398402

399403
Clip clipBehavior = Clip.none;
404+
405+
@mustCallSuper
406+
void dispose() {
407+
_containerLayer.dispose();
408+
}
400409
}
401410

402411
class TestPushLayerPaintingContext extends PaintingContext {

packages/flutter/test/widgets/grid_view_test.dart

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -664,16 +664,8 @@ void main() {
664664
final TestClipPaintingContext context = TestClipPaintingContext();
665665
renderObject.paint(context, Offset.zero);
666666
expect(context.clipBehavior, equals(Clip.none));
667-
},
668-
leakTrackingTestConfig: const LeakTrackingTestConfig(
669-
// TODO(ksokolovskyi): remove after fixing
670-
notDisposedAllowList: <String, int?> {
671-
// https://github.com/flutter/flutter/issues/134575
672-
'OffsetLayer': 1,
673-
// https://github.com/flutter/flutter/issues/134572
674-
'ContainerLayer': 1,
675-
},
676-
));
667+
context.dispose();
668+
});
677669

678670
testWidgetsWithLeakTracking('GridView respects clipBehavior', (WidgetTester tester) async {
679671
await tester.pumpWidget(
@@ -739,12 +731,8 @@ void main() {
739731
// 4th, check that a non-default clip behavior can be sent to the painting context.
740732
renderObject.paint(context, Offset.zero);
741733
expect(context.clipBehavior, equals(Clip.antiAlias));
742-
},
743-
leakTrackingTestConfig: const LeakTrackingTestConfig(
744-
// TODO(ksokolovskyi): remove after fixing
745-
// https://github.com/flutter/flutter/issues/134572
746-
notDisposedAllowList: <String, int?> {'ContainerLayer': 1},
747-
));
734+
context.dispose();
735+
});
748736

749737
testWidgetsWithLeakTracking('GridView.builder respects clipBehavior', (WidgetTester tester) async {
750738
await tester.pumpWidget(

packages/flutter/test/widgets/list_view_test.dart

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -730,12 +730,8 @@ void main() {
730730
// 4th, check that a non-default clip behavior can be sent to the painting context.
731731
renderObject.paint(context, Offset.zero);
732732
expect(context.clipBehavior, equals(Clip.antiAlias));
733-
},
734-
leakTrackingTestConfig: const LeakTrackingTestConfig(
735-
// TODO(ksokolovskyi): remove after fixing
736-
// https://github.com/flutter/flutter/issues/134572
737-
notDisposedAllowList: <String, int?> {'ContainerLayer': 1},
738-
));
733+
context.dispose();
734+
});
739735

740736
testWidgetsWithLeakTracking('ListView.builder respects clipBehavior', (WidgetTester tester) async {
741737
await tester.pumpWidget(

0 commit comments

Comments
 (0)