Skip to content

Commit

Permalink
TestClipPaintingContext should dispose ContainerLayer (#135949)
Browse files Browse the repository at this point in the history
  • Loading branch information
polina-c authored Oct 10, 2023
1 parent 7d01663 commit eec3f06
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
11 changes: 10 additions & 1 deletion packages/flutter/test/rendering/rendering_tester.dart
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,11 @@ class FakeTicker implements Ticker {
}

class TestClipPaintingContext extends PaintingContext {
TestClipPaintingContext() : super(ContainerLayer(), Rect.zero);
TestClipPaintingContext() : this._(ContainerLayer());

TestClipPaintingContext._(this._containerLayer) : super(_containerLayer, Rect.zero);

final ContainerLayer _containerLayer;

@override
ClipRectLayer? pushClipRect(
Expand All @@ -397,6 +401,11 @@ class TestClipPaintingContext extends PaintingContext {
}

Clip clipBehavior = Clip.none;

@mustCallSuper
void dispose() {
_containerLayer.dispose();
}
}

class TestPushLayerPaintingContext extends PaintingContext {
Expand Down
20 changes: 4 additions & 16 deletions packages/flutter/test/widgets/grid_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -664,16 +664,8 @@ void main() {
final TestClipPaintingContext context = TestClipPaintingContext();
renderObject.paint(context, Offset.zero);
expect(context.clipBehavior, equals(Clip.none));
},
leakTrackingTestConfig: const LeakTrackingTestConfig(
// TODO(ksokolovskyi): remove after fixing
notDisposedAllowList: <String, int?> {
// https://github.com/flutter/flutter/issues/134575
'OffsetLayer': 1,
// https://github.com/flutter/flutter/issues/134572
'ContainerLayer': 1,
},
));
context.dispose();
});

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

testWidgetsWithLeakTracking('GridView.builder respects clipBehavior', (WidgetTester tester) async {
await tester.pumpWidget(
Expand Down
8 changes: 2 additions & 6 deletions packages/flutter/test/widgets/list_view_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -730,12 +730,8 @@ void main() {
// 4th, check that a non-default clip behavior can be sent to the painting context.
renderObject.paint(context, Offset.zero);
expect(context.clipBehavior, equals(Clip.antiAlias));
},
leakTrackingTestConfig: const LeakTrackingTestConfig(
// TODO(ksokolovskyi): remove after fixing
// https://github.com/flutter/flutter/issues/134572
notDisposedAllowList: <String, int?> {'ContainerLayer': 1},
));
context.dispose();
});

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

0 comments on commit eec3f06

Please sign in to comment.