From 310e04ccf47c176c7c1541ae11697684b51e3cf3 Mon Sep 17 00:00:00 2001 From: Melody Hsu Date: Fri, 19 Apr 2024 19:22:01 +0000 Subject: Inject legacy layer in metadata tests Fixes metadata CommitTests by adding a legacy layer wherever a RequestedLayerState is created. Bug: b/330785038 Test: atest CommitTest Change-Id: I282b8c9d78e127359636c1859ce26576b8f3a2a6 --- .../surfaceflinger/tests/unittests/CommitTest.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/services/surfaceflinger/tests/unittests/CommitTest.cpp b/services/surfaceflinger/tests/unittests/CommitTest.cpp index 80c166441a..7f29418252 100644 --- a/services/surfaceflinger/tests/unittests/CommitTest.cpp +++ b/services/surfaceflinger/tests/unittests/CommitTest.cpp @@ -94,13 +94,15 @@ TEST_F(CommitTest, metadataNotIncluded) { // Create a parent layer with metadata and a child layer without. Metadata should not // be included in the child layer when the flag is not set. std::unordered_map> metadata = {{1, {'a', 'b'}}}; - auto parent = std::make_unique( - createArgs(1, LayerMetadata(metadata), UNASSIGNED_LAYER_ID)); + auto parentArgs = createArgs(1, LayerMetadata(metadata), UNASSIGNED_LAYER_ID); + auto parent = std::make_unique(parentArgs); mFlinger.addLayer(parent); + mFlinger.injectLegacyLayer(sp::make(parentArgs)); - auto child = - std::make_unique(createArgs(11, LayerMetadata(), 1)); + auto childArgs = createArgs(11, LayerMetadata(), 1); + auto child = std::make_unique(childArgs); mFlinger.addLayer(child); + mFlinger.injectLegacyLayer(sp::make(childArgs)); bool unused; bool mustComposite = mFlinger.updateLayerSnapshots(VsyncId{1}, /*frameTimeNs=*/0, @@ -136,13 +138,15 @@ TEST_F(CommitTest, metadataIsIncluded) { // Create a parent layer with metadata and a child layer without. Metadata from the // parent should be included in the child layer when the flag is set. std::unordered_map> metadata = {{1, {'a', 'b'}}}; - auto parent = std::make_unique( - createArgs(1, LayerMetadata(metadata), UNASSIGNED_LAYER_ID)); + auto parentArgs = createArgs(1, LayerMetadata(metadata), UNASSIGNED_LAYER_ID); + auto parent = std::make_unique(parentArgs); mFlinger.addLayer(parent); + mFlinger.injectLegacyLayer(sp::make(parentArgs)); - auto child = - std::make_unique(createArgs(11, LayerMetadata(), 1)); + auto childArgs = createArgs(11, LayerMetadata(), 1); + auto child = std::make_unique(childArgs); mFlinger.addLayer(child); + mFlinger.injectLegacyLayer(sp::make(childArgs)); bool unused; bool mustComposite = mFlinger.updateLayerSnapshots(VsyncId{1}, /*frameTimeNs=*/0, -- cgit v1.2.3-59-g8ed1b