Skip to content

Commit

Permalink
Dispose layers in test. (#134802)
Browse files Browse the repository at this point in the history
  • Loading branch information
polina-c authored Sep 15, 2023
1 parent ec47148 commit f629dc8
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/flutter/test/material/material_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1078,7 +1078,7 @@ void main() {
});
});

testWidgets('InkFeature skips painting if intermediate node skips', (WidgetTester tester) async {
testWidgetsWithLeakTracking('InkFeature skips painting if intermediate node skips', (WidgetTester tester) async {
final GlobalKey sizedBoxKey = GlobalKey();
final GlobalKey materialKey = GlobalKey();
await tester.pumpWidget(Material(
Expand All @@ -1096,8 +1096,11 @@ void main() {
controller.addInkFeature(tracker);
expect(tracker.paintCount, 0);

final ContainerLayer layer1 = ContainerLayer();
addTearDown(layer1.dispose);

// Force a repaint. Since it's offstage, the ink feature should not get painted.
materialKey.currentContext!.findRenderObject()!.paint(PaintingContext(ContainerLayer(), Rect.largest), Offset.zero);
materialKey.currentContext!.findRenderObject()!.paint(PaintingContext(layer1, Rect.largest), Offset.zero);
expect(tracker.paintCount, 0);

await tester.pumpWidget(Material(
Expand All @@ -1111,8 +1114,11 @@ void main() {
// now onstage.
expect(tracker.paintCount, 1);

final ContainerLayer layer2 = ContainerLayer();
addTearDown(layer2.dispose);

// Force a repaint again. This time, it gets repainted because it is onstage.
materialKey.currentContext!.findRenderObject()!.paint(PaintingContext(ContainerLayer(), Rect.largest), Offset.zero);
materialKey.currentContext!.findRenderObject()!.paint(PaintingContext(layer2, Rect.largest), Offset.zero);
expect(tracker.paintCount, 2);
});

Expand Down

0 comments on commit f629dc8

Please sign in to comment.