Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 422b81cb authored by Vishnu Nair's avatar Vishnu Nair
Browse files

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
parent 834336a3
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -362,6 +362,7 @@ LayerSnapshot LayerSnapshotBuilder::getRootSnapshot() {
    snapshot.gameMode = gui::GameMode::Unsupported;
    snapshot.gameMode = gui::GameMode::Unsupported;
    snapshot.frameRate = {};
    snapshot.frameRate = {};
    snapshot.fixedTransformHint = ui::Transform::ROT_INVALID;
    snapshot.fixedTransformHint = ui::Transform::ROT_INVALID;
    snapshot.ignoreLocalTransform = false;
    return snapshot;
    return snapshot;
}
}


+20 −2
Original line number Original line Diff line number Diff line
@@ -19,6 +19,7 @@
#pragma clang diagnostic ignored "-Wconversion"
#pragma clang diagnostic ignored "-Wconversion"


#include <android-base/properties.h>
#include <android-base/properties.h>
#include <common/FlagManager.h>
#include <private/android_filesystem_config.h>
#include <private/android_filesystem_config.h>
#include "LayerTransactionTest.h"
#include "LayerTransactionTest.h"
#include "utils/TransactionUtils.h"
#include "utils/TransactionUtils.h"
@@ -78,6 +79,10 @@ TEST_F(MirrorLayerTest, MirrorColorLayer) {
            .show(mirrorLayer)
            .show(mirrorLayer)
            .apply();
            .apply();


    if (FlagManager::getInstance().detached_mirror()) {
        Transaction().setPosition(mirrorLayer, 550, 550).apply();
    }

    {
    {
        SCOPED_TRACE("Initial Mirror");
        SCOPED_TRACE("Initial Mirror");
        auto shot = screenshot();
        auto shot = screenshot();
@@ -172,6 +177,9 @@ TEST_F(MirrorLayerTest, MirrorBufferLayer) {
            .show(mirrorLayer)
            .show(mirrorLayer)
            .apply();
            .apply();


    if (FlagManager::getInstance().detached_mirror()) {
        Transaction().setPosition(mirrorLayer, 550, 550).apply();
    }
    {
    {
        SCOPED_TRACE("Initial Mirror BufferQueueLayer");
        SCOPED_TRACE("Initial Mirror BufferQueueLayer");
        auto shot = screenshot();
        auto shot = screenshot();
@@ -263,6 +271,9 @@ TEST_F(MirrorLayerTest, InitialMirrorState) {
            .setLayer(mirrorLayer, INT32_MAX - 1)
            .setLayer(mirrorLayer, INT32_MAX - 1)
            .apply();
            .apply();


    if (FlagManager::getInstance().detached_mirror()) {
        Transaction().setPosition(mirrorLayer, 550, 550).apply();
    }
    {
    {
        SCOPED_TRACE("Offscreen Mirror");
        SCOPED_TRACE("Offscreen Mirror");
        auto shot = screenshot();
        auto shot = screenshot();
@@ -313,8 +324,15 @@ TEST_F(MirrorLayerTest, OffscreenMirrorScreenshot) {
        ASSERT_NE(mirrorLayer, nullptr);
        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.
    // 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");
        SCOPED_TRACE("Offscreen Mirror");
@@ -331,7 +349,7 @@ TEST_F(MirrorLayerTest, OffscreenMirrorScreenshot) {
        SCOPED_TRACE("Capture Mirror");
        SCOPED_TRACE("Capture Mirror");
        // Capture just the mirror layer and child.
        // Capture just the mirror layer and child.
        LayerCaptureArgs captureArgs;
        LayerCaptureArgs captureArgs;
        captureArgs.layerHandle = mirrorLayer->getHandle();
        captureArgs.layerHandle = mirrorParent->getHandle();
        captureArgs.sourceCrop = childBounds;
        captureArgs.sourceCrop = childBounds;
        std::unique_ptr<ScreenCapture> shot;
        std::unique_ptr<ScreenCapture> shot;
        ScreenCapture::captureLayers(&shot, captureArgs);
        ScreenCapture::captureLayers(&shot, captureArgs);