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

Commit 722fab77 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "composer: add TestCommandReader to 2.4"

parents 127f33b7 f6820b2b
Loading
Loading
Loading
Loading
+54 −49
Original line number Diff line number Diff line
@@ -29,10 +29,19 @@ void TestCommandReader::parse() {
    mErrors.clear();
    mCompositionChanges.clear();
    while (!isEmpty()) {
        IComposerClient::Command command;
        int32_t command;
        uint16_t length;
        ASSERT_TRUE(beginCommand(&command, &length));

        parseSingleCommand(command, length);

        endCommand();
    }
}

void TestCommandReader::parseSingleCommand(int32_t commandRaw, uint16_t length) {
    IComposerClient::Command command = static_cast<IComposerClient::Command>(commandRaw);

    switch (command) {
        case IComposerClient::Command::SELECT_DISPLAY:
            ASSERT_EQ(2, length);
@@ -77,13 +86,9 @@ void TestCommandReader::parse() {
            }
            break;
        default:
                GTEST_FAIL() << "unexpected return command " << std::hex
                             << static_cast<int>(command);
            GTEST_FAIL() << "unexpected return command " << std::hex << static_cast<int>(command);
            break;
    }

        endCommand();
    }
}

}  // namespace vts
+9 −5
Original line number Diff line number Diff line
@@ -29,12 +29,16 @@ namespace vts {
// returned.
class TestCommandReader : public CommandReaderBase {
   public:
     virtual ~TestCommandReader() = default;
     // Parse all commands in the return command queue.  Call GTEST_FAIL() for
     // unexpected errors or commands.
     void parse();

     std::vector<std::pair<uint32_t, uint32_t>> mErrors;
     std::vector<std::pair<uint64_t, uint32_t>> mCompositionChanges;

   protected:
     virtual void parseSingleCommand(int32_t commandRaw, uint16_t length);
};

}  // namespace vts
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ cc_library_static {
    srcs: [
        "ComposerVts.cpp",
        "GraphicsComposerCallback.cpp",
        "TestCommandReader.cpp",
    ],
    static_libs: [
        "android.hardware.graphics.composer@2.1",
@@ -33,6 +34,7 @@ cc_library_static {
        "android.hardware.graphics.composer@2.1-command-buffer",
        "android.hardware.graphics.composer@2.2-command-buffer",
        "android.hardware.graphics.composer@2.3-command-buffer",
        "android.hardware.graphics.composer@2.4-command-buffer",
    ],
    cflags: [
        "-O0",
+32 −0
Original line number Diff line number Diff line
@@ -132,6 +132,38 @@ Error ComposerClient::getLayerGenericMetadataKeys(
    return error;
}

void ComposerClient::execute(TestCommandReader* reader, CommandWriterBase* writer) {
    bool queueChanged = false;
    uint32_t commandLength = 0;
    hidl_vec<hidl_handle> commandHandles;
    ASSERT_TRUE(writer->writeQueue(&queueChanged, &commandLength, &commandHandles));

    if (queueChanged) {
        auto ret = mClient->setInputCommandQueue(*writer->getMQDescriptor());
        ASSERT_EQ(V2_1::Error::NONE, ret);
    }

    mClient->executeCommands_2_3(
            commandLength, commandHandles,
            [&](const auto& tmpError, const auto& tmpOutQueueChanged, const auto& tmpOutLength,
                const auto& tmpOutHandles) {
                ASSERT_EQ(V2_1::Error::NONE, tmpError);

                if (tmpOutQueueChanged) {
                    mClient->getOutputCommandQueue(
                            [&](const auto& tmpError, const auto& tmpDescriptor) {
                                ASSERT_EQ(V2_3::Error::NONE, tmpError);
                                reader->setMQDescriptor(tmpDescriptor);
                            });
                }

                ASSERT_TRUE(reader->readQueue(tmpOutLength, tmpOutHandles));
                reader->parse();
            });
    reader->reset();
    writer->reset();
}

}  // namespace vts
}  // namespace V2_4
}  // namespace composer
+38 −0
Original line number Diff line number Diff line
/*
 * Copyright 2020 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include <composer-vts/2.4/TestCommandReader.h>

#include <gtest/gtest.h>

namespace android::hardware::graphics::composer::V2_4::vts {

void TestCommandReader::parseSingleCommand(int32_t commandRaw, uint16_t length) {
    IComposerClient::Command command = static_cast<IComposerClient::Command>(commandRaw);

    switch (command) {
        case IComposerClient::Command::SET_CLIENT_TARGET_PROPERTY:
            ASSERT_EQ(2, length);
            read();
            close(readFence());
            break;
        default:
            return android::hardware::graphics::composer::V2_1::vts::TestCommandReader::
                    parseSingleCommand(commandRaw, length);
    }
}

}  // namespace android::hardware::graphics::composer::V2_4::vts
Loading