Skip to content

Commit 4f4fdbf

Browse files
authored
fix "TREE INCONSISTENT" noise in compositing_test.dart (flutter#16995)
1 parent cb3237e commit 4f4fdbf

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

lib/web_ui/lib/src/engine/surface/picture.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,11 @@ abstract class PersistedPicture extends PersistedLeafSurface {
356356

357357
EngineCanvas _canvas;
358358

359+
/// Returns the canvas used by this picture layer.
360+
///
361+
/// Useful for tests.
362+
EngineCanvas get debugCanvas => _canvas;
363+
359364
final double dx;
360365
final double dy;
361366
final EnginePicture picture;
@@ -624,7 +629,7 @@ abstract class PersistedPicture extends PersistedLeafSurface {
624629
super.debugValidate(validationErrors);
625630

626631
if (picture.recordingCanvas.didDraw) {
627-
if (_canvas == null) {
632+
if (debugCanvas == null) {
628633
validationErrors
629634
.add('$runtimeType has non-trivial picture but it has null canvas');
630635
}

lib/web_ui/test/compositing_test.dart

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void main() {
151151

152152
scene2.preroll();
153153
scene2.update(scene1);
154-
commitScene(scene1);
154+
commitScene(scene2);
155155
expect(picture.retainCount, 1);
156156
expect(picture.buildCount, 1);
157157
expect(picture.updateCount, 0);
@@ -169,7 +169,7 @@ void main() {
169169

170170
scene3.preroll();
171171
scene3.update(scene2);
172-
commitScene(scene1);
172+
commitScene(scene3);
173173
expect(picture.retainCount, 2);
174174
expect(picture.buildCount, 1);
175175
expect(picture.updateCount, 0);
@@ -271,6 +271,13 @@ class MockPersistedPicture extends PersistedPicture {
271271
int updateCount = 0;
272272
int applyPaintCount = 0;
273273

274+
final BitmapCanvas _fakeCanvas = BitmapCanvas(const Rect.fromLTRB(0, 0, 10, 10));
275+
276+
@override
277+
EngineCanvas get debugCanvas {
278+
return _fakeCanvas;
279+
}
280+
274281
@override
275282
double matchForUpdate(PersistedPicture existingSurface) {
276283
return identical(existingSurface.picture, picture) ? 0.0 : 1.0;

0 commit comments

Comments
 (0)