Skip to content

Commit

Permalink
fix "TREE INCONSISTENT" noise in compositing_test.dart (flutter#16995)
Browse files Browse the repository at this point in the history
  • Loading branch information
yjbanov authored Mar 9, 2020
1 parent cb3237e commit 4f4fdbf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/web_ui/lib/src/engine/surface/picture.dart
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,11 @@ abstract class PersistedPicture extends PersistedLeafSurface {

EngineCanvas _canvas;

/// Returns the canvas used by this picture layer.
///
/// Useful for tests.
EngineCanvas get debugCanvas => _canvas;

final double dx;
final double dy;
final EnginePicture picture;
Expand Down Expand Up @@ -624,7 +629,7 @@ abstract class PersistedPicture extends PersistedLeafSurface {
super.debugValidate(validationErrors);

if (picture.recordingCanvas.didDraw) {
if (_canvas == null) {
if (debugCanvas == null) {
validationErrors
.add('$runtimeType has non-trivial picture but it has null canvas');
}
Expand Down
11 changes: 9 additions & 2 deletions lib/web_ui/test/compositing_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void main() {

scene2.preroll();
scene2.update(scene1);
commitScene(scene1);
commitScene(scene2);
expect(picture.retainCount, 1);
expect(picture.buildCount, 1);
expect(picture.updateCount, 0);
Expand All @@ -169,7 +169,7 @@ void main() {

scene3.preroll();
scene3.update(scene2);
commitScene(scene1);
commitScene(scene3);
expect(picture.retainCount, 2);
expect(picture.buildCount, 1);
expect(picture.updateCount, 0);
Expand Down Expand Up @@ -271,6 +271,13 @@ class MockPersistedPicture extends PersistedPicture {
int updateCount = 0;
int applyPaintCount = 0;

final BitmapCanvas _fakeCanvas = BitmapCanvas(const Rect.fromLTRB(0, 0, 10, 10));

@override
EngineCanvas get debugCanvas {
return _fakeCanvas;
}

@override
double matchForUpdate(PersistedPicture existingSurface) {
return identical(existingSurface.picture, picture) ? 0.0 : 1.0;
Expand Down

0 comments on commit 4f4fdbf

Please sign in to comment.