Update mirror layer tests to support detach mirror flag

We changed mirroring behavior to ignore the local transforms
to support cases like mirroring a freeform window.
This cl fixes the tests to update the position of the mirrored
layer if the flag is set.

Bug: 337845753
Test: presubmit

Change-Id: I28294c36afb4d9f0de2e6c6017332617315f0c4d
diff --git a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
index e40c79c..f2497d4 100644
--- a/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
+++ b/services/surfaceflinger/FrontEnd/LayerSnapshotBuilder.cpp
@@ -362,6 +362,7 @@
     snapshot.gameMode = gui::GameMode::Unsupported;
     snapshot.frameRate = {};
     snapshot.fixedTransformHint = ui::Transform::ROT_INVALID;
+    snapshot.ignoreLocalTransform = false;
     return snapshot;
 }
 
diff --git a/services/surfaceflinger/tests/MirrorLayer_test.cpp b/services/surfaceflinger/tests/MirrorLayer_test.cpp
index 0ea0824..d97d433 100644
--- a/services/surfaceflinger/tests/MirrorLayer_test.cpp
+++ b/services/surfaceflinger/tests/MirrorLayer_test.cpp
@@ -19,6 +19,7 @@
 #pragma clang diagnostic ignored "-Wconversion"
 
 #include <android-base/properties.h>
+#include <common/FlagManager.h>
 #include <private/android_filesystem_config.h>
 #include "LayerTransactionTest.h"
 #include "utils/TransactionUtils.h"
@@ -78,6 +79,10 @@
             .show(mirrorLayer)
             .apply();
 
+    if (FlagManager::getInstance().detached_mirror()) {
+        Transaction().setPosition(mirrorLayer, 550, 550).apply();
+    }
+
     {
         SCOPED_TRACE("Initial Mirror");
         auto shot = screenshot();
@@ -172,6 +177,9 @@
             .show(mirrorLayer)
             .apply();
 
+    if (FlagManager::getInstance().detached_mirror()) {
+        Transaction().setPosition(mirrorLayer, 550, 550).apply();
+    }
     {
         SCOPED_TRACE("Initial Mirror BufferQueueLayer");
         auto shot = screenshot();
@@ -263,6 +271,9 @@
             .setLayer(mirrorLayer, INT32_MAX - 1)
             .apply();
 
+    if (FlagManager::getInstance().detached_mirror()) {
+        Transaction().setPosition(mirrorLayer, 550, 550).apply();
+    }
     {
         SCOPED_TRACE("Offscreen Mirror");
         auto shot = screenshot();
@@ -313,8 +324,15 @@
         ASSERT_NE(mirrorLayer, nullptr);
     }
 
+    sp<SurfaceControl> mirrorParent =
+            createLayer("Grandchild layer", 50, 50, ISurfaceComposerClient::eFXSurfaceBufferState);
+
     // Show the mirror layer, but don't reparent to a layer on screen.
-    Transaction().show(mirrorLayer).apply();
+    Transaction().reparent(mirrorLayer, mirrorParent).show(mirrorLayer).apply();
+
+    if (FlagManager::getInstance().detached_mirror()) {
+        Transaction().setPosition(mirrorLayer, 50, 50).apply();
+    }
 
     {
         SCOPED_TRACE("Offscreen Mirror");
@@ -331,7 +349,7 @@
         SCOPED_TRACE("Capture Mirror");
         // Capture just the mirror layer and child.
         LayerCaptureArgs captureArgs;
-        captureArgs.layerHandle = mirrorLayer->getHandle();
+        captureArgs.layerHandle = mirrorParent->getHandle();
         captureArgs.sourceCrop = childBounds;
         std::unique_ptr<ScreenCapture> shot;
         ScreenCapture::captureLayers(&shot, captureArgs);