mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-02 10:05:19 +00:00
Merge "composer: add TestCommandReader to 2.4"
This commit is contained in:
committed by
Android (Google) Code Review
commit
722fab775f
@@ -29,63 +29,68 @@ void TestCommandReader::parse() {
|
||||
mErrors.clear();
|
||||
mCompositionChanges.clear();
|
||||
while (!isEmpty()) {
|
||||
IComposerClient::Command command;
|
||||
int32_t command;
|
||||
uint16_t length;
|
||||
ASSERT_TRUE(beginCommand(&command, &length));
|
||||
|
||||
switch (command) {
|
||||
case IComposerClient::Command::SELECT_DISPLAY:
|
||||
ASSERT_EQ(2, length);
|
||||
read64(); // display
|
||||
break;
|
||||
case IComposerClient::Command::SET_ERROR: {
|
||||
ASSERT_EQ(2, length);
|
||||
auto loc = read();
|
||||
auto err = readSigned();
|
||||
std::pair<uint32_t, uint32_t> error(loc, err);
|
||||
mErrors.push_back(error);
|
||||
} break;
|
||||
case IComposerClient::Command::SET_CHANGED_COMPOSITION_TYPES:
|
||||
ASSERT_EQ(0, length % 3);
|
||||
for (uint16_t count = 0; count < length / 3; ++count) {
|
||||
uint64_t layerId = read64();
|
||||
uint32_t composition = read();
|
||||
|
||||
std::pair<uint64_t, uint32_t> compositionChange(layerId, composition);
|
||||
mCompositionChanges.push_back(compositionChange);
|
||||
}
|
||||
break;
|
||||
case IComposerClient::Command::SET_DISPLAY_REQUESTS:
|
||||
ASSERT_EQ(1, length % 3);
|
||||
read(); // displayRequests, ignored for now
|
||||
for (uint16_t count = 0; count < (length - 1) / 3; ++count) {
|
||||
read64(); // layer
|
||||
// silently eat requests to clear the client target, since we won't be testing
|
||||
// client composition anyway
|
||||
ASSERT_EQ(1u, read());
|
||||
}
|
||||
break;
|
||||
case IComposerClient::Command::SET_PRESENT_FENCE:
|
||||
ASSERT_EQ(1, length);
|
||||
close(readFence());
|
||||
break;
|
||||
case IComposerClient::Command::SET_RELEASE_FENCES:
|
||||
ASSERT_EQ(0, length % 3);
|
||||
for (uint16_t count = 0; count < length / 3; ++count) {
|
||||
read64();
|
||||
close(readFence());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
GTEST_FAIL() << "unexpected return command " << std::hex
|
||||
<< static_cast<int>(command);
|
||||
break;
|
||||
}
|
||||
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);
|
||||
read64(); // display
|
||||
break;
|
||||
case IComposerClient::Command::SET_ERROR: {
|
||||
ASSERT_EQ(2, length);
|
||||
auto loc = read();
|
||||
auto err = readSigned();
|
||||
std::pair<uint32_t, uint32_t> error(loc, err);
|
||||
mErrors.push_back(error);
|
||||
} break;
|
||||
case IComposerClient::Command::SET_CHANGED_COMPOSITION_TYPES:
|
||||
ASSERT_EQ(0, length % 3);
|
||||
for (uint16_t count = 0; count < length / 3; ++count) {
|
||||
uint64_t layerId = read64();
|
||||
uint32_t composition = read();
|
||||
|
||||
std::pair<uint64_t, uint32_t> compositionChange(layerId, composition);
|
||||
mCompositionChanges.push_back(compositionChange);
|
||||
}
|
||||
break;
|
||||
case IComposerClient::Command::SET_DISPLAY_REQUESTS:
|
||||
ASSERT_EQ(1, length % 3);
|
||||
read(); // displayRequests, ignored for now
|
||||
for (uint16_t count = 0; count < (length - 1) / 3; ++count) {
|
||||
read64(); // layer
|
||||
// silently eat requests to clear the client target, since we won't be testing
|
||||
// client composition anyway
|
||||
ASSERT_EQ(1u, read());
|
||||
}
|
||||
break;
|
||||
case IComposerClient::Command::SET_PRESENT_FENCE:
|
||||
ASSERT_EQ(1, length);
|
||||
close(readFence());
|
||||
break;
|
||||
case IComposerClient::Command::SET_RELEASE_FENCES:
|
||||
ASSERT_EQ(0, length % 3);
|
||||
for (uint16_t count = 0; count < length / 3; ++count) {
|
||||
read64();
|
||||
close(readFence());
|
||||
}
|
||||
break;
|
||||
default:
|
||||
GTEST_FAIL() << "unexpected return command " << std::hex << static_cast<int>(command);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace vts
|
||||
} // namespace V2_1
|
||||
} // namespace composer
|
||||
|
||||
@@ -29,12 +29,16 @@ namespace vts {
|
||||
// returned.
|
||||
class TestCommandReader : public CommandReaderBase {
|
||||
public:
|
||||
// Parse all commands in the return command queue. Call GTEST_FAIL() for
|
||||
// unexpected errors or commands.
|
||||
void parse();
|
||||
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;
|
||||
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
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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
graphics/composer/2.4/utils/vts/TestCommandReader.cpp
Normal file
38
graphics/composer/2.4/utils/vts/TestCommandReader.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* 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
|
||||
@@ -22,6 +22,7 @@
|
||||
#include <android/hardware/graphics/composer/2.4/IComposer.h>
|
||||
#include <android/hardware/graphics/composer/2.4/IComposerClient.h>
|
||||
#include <composer-vts/2.3/ComposerVts.h>
|
||||
#include <composer-vts/2.4/TestCommandReader.h>
|
||||
#include <utils/StrongPointer.h>
|
||||
|
||||
namespace android {
|
||||
@@ -92,6 +93,8 @@ class ComposerClient : public V2_3::vts::ComposerClient {
|
||||
|
||||
Error setContentType(Display display, IComposerClient::ContentType contentType);
|
||||
|
||||
void execute(TestCommandReader* reader, CommandWriterBase* writer);
|
||||
|
||||
Error getLayerGenericMetadataKeys(
|
||||
std::vector<IComposerClient::LayerGenericMetadataKey>* outKeys);
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <composer-command-buffer/2.4/ComposerCommandBuffer.h>
|
||||
#include <composer-vts/2.1/TestCommandReader.h>
|
||||
|
||||
namespace android::hardware::graphics::composer::V2_4::vts {
|
||||
|
||||
// A command parser that checks that no error nor unexpected commands are
|
||||
// returned.
|
||||
class TestCommandReader
|
||||
: public android::hardware::graphics::composer::V2_1::vts::TestCommandReader {
|
||||
protected:
|
||||
void parseSingleCommand(int32_t commandRaw, uint16_t length) override;
|
||||
};
|
||||
|
||||
} // namespace android::hardware::graphics::composer::V2_4::vts
|
||||
@@ -23,9 +23,9 @@
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/graphics/mapper/2.0/IMapper.h>
|
||||
#include <composer-command-buffer/2.4/ComposerCommandBuffer.h>
|
||||
#include <composer-vts/2.1/TestCommandReader.h>
|
||||
#include <composer-vts/2.4/ComposerVts.h>
|
||||
#include <composer-vts/2.4/GraphicsComposerCallback.h>
|
||||
#include <composer-vts/2.4/TestCommandReader.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
@@ -77,7 +77,7 @@ class GraphicsComposerHidlTest : public ::testing::TestWithParam<std::string> {
|
||||
mComposerCallback->setVsyncAllowed(false);
|
||||
|
||||
mWriter = std::make_unique<CommandWriterBase>(1024);
|
||||
mReader = std::make_unique<V2_1::vts::TestCommandReader>();
|
||||
mReader = std::make_unique<TestCommandReader>();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
@@ -153,7 +153,7 @@ class GraphicsComposerHidlTest : public ::testing::TestWithParam<std::string> {
|
||||
Display mPrimaryDisplay;
|
||||
Display mInvalidDisplayId;
|
||||
std::unique_ptr<CommandWriterBase> mWriter;
|
||||
std::unique_ptr<V2_1::vts::TestCommandReader> mReader;
|
||||
std::unique_ptr<TestCommandReader> mReader;
|
||||
|
||||
private:
|
||||
Display waitForFirstDisplay() {
|
||||
@@ -184,7 +184,7 @@ class GraphicsComposerHidlCommandTest : public GraphicsComposerHidlTest {
|
||||
mPrimaryDisplay, activeConfig, IComposerClient::Attribute::HEIGHT);
|
||||
|
||||
mWriter = std::make_unique<CommandWriterBase>(1024);
|
||||
mReader = std::make_unique<V2_1::vts::TestCommandReader>();
|
||||
mReader = std::make_unique<TestCommandReader>();
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
@@ -211,7 +211,7 @@ class GraphicsComposerHidlCommandTest : public GraphicsComposerHidlTest {
|
||||
int64_t newPeriodNanos);
|
||||
|
||||
std::unique_ptr<CommandWriterBase> mWriter;
|
||||
std::unique_ptr<V2_1::vts::TestCommandReader> mReader;
|
||||
std::unique_ptr<TestCommandReader> mReader;
|
||||
int32_t mDisplayWidth;
|
||||
int32_t mDisplayHeight;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user