Merge "Add two tests for Stable AIDL composer3 as a start of tests."
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/OWNERS b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/OWNERS
index 1bfad7d..d95d98d 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/OWNERS
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/OWNERS
@@ -4,6 +4,3 @@
adyabr@google.com
alecmouri@google.com
ramindani@google.com
-
-# VTS team
-include platform/hardware/interfaces:/OWNERS
\ No newline at end of file
diff --git a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp
index ce4eed6..d892681 100644
--- a/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp
+++ b/graphics/composer/aidl/android/hardware/graphics/composer3/vts/functional/VtsHalGraphicsComposer3_TargetTest.cpp
@@ -3,6 +3,8 @@
#include <aidl/Vintf.h>
#include <aidl/android/hardware/graphics/composer3/IComposer.h>
#include <android-base/properties.h>
+#include <android/binder_manager.h>
+#include <android/binder_process.h>
#include <binder/ProcessState.h>
#include <gtest/gtest.h>
#include <string>
@@ -11,15 +13,77 @@
#undef LOG_TAG
#define LOG_TAG "VtsHalGraphicsComposer3_TargetTest"
+typedef uint64_t DisplayId;
+
namespace aidl::android::hardware::graphics::composer3::vts {
namespace {
+class VtsDisplay {
+ public:
+ VtsDisplay(DisplayId displayId, int32_t displayWidth, int32_t displayHeight)
+ : mDisplayId(displayId), mDisplayWidth(displayWidth), mDisplayHeight(displayHeight) {}
+
+ DisplayId get() const { return mDisplayId; }
+
+ void setDimensions(int32_t displayWidth, int32_t displayHeight) {
+ mDisplayWidth = displayWidth;
+ mDisplayHeight = displayHeight;
+ }
+
+ private:
+ const DisplayId mDisplayId;
+ int32_t mDisplayWidth;
+ int32_t mDisplayHeight;
+};
+
class GraphicsComposerAidlTest : public ::testing::TestWithParam<std::string> {
- // TODO(b/201796346) setup composer client and use it to send data and generate commands.
+ protected:
+ void SetUp() override {
+ std::string name = GetParam();
+ ndk::SpAIBinder binder(AServiceManager_waitForService(name.c_str()));
+ ASSERT_NE(binder, nullptr);
+ ASSERT_NO_FATAL_FAILURE(mComposer = IComposer::fromBinder(binder));
+ ASSERT_NE(mComposer, nullptr);
+ ASSERT_NO_FATAL_FAILURE(mComposer->createClient(&mComposerClient));
+ mInvalidDisplayId = GetInvalidDisplayId();
+ }
+
+ // returns an invalid display id (one that has not been registered to a
+ // display. Currently assuming that a device will never have close to
+ // std::numeric_limit<uint64_t>::max() displays registered while running tests
+ DisplayId GetInvalidDisplayId() {
+ uint64_t id = std::numeric_limits<uint64_t>::max();
+ while (id > 0) {
+ if (std::none_of(mDisplays.begin(), mDisplays.end(),
+ [&](const VtsDisplay& display) { return id == display.get(); })) {
+ return id;
+ }
+ id--;
+ }
+
+ return 0;
+ }
+
+ std::shared_ptr<IComposer> mComposer;
+ std::shared_ptr<IComposerClient> mComposerClient{};
+ DisplayId mInvalidDisplayId;
+ std::vector<VtsDisplay>
+ mDisplays; // TODO(b/202401906) populate all the displays available for test.
};
TEST_P(GraphicsComposerAidlTest, getDisplayCapabilitiesBadDisplay) {
- // TODO(b/201797681) update with actual test instead of a place holder
+ std::vector<DisplayCapability> capabilities;
+ const auto error = mComposerClient->getDisplayCapabilities(mInvalidDisplayId, &capabilities);
+ EXPECT_EQ(IComposerClient::EX_BAD_DISPLAY, error.getServiceSpecificError());
+}
+
+TEST_P(GraphicsComposerAidlTest, getDisplayCapabilities) {
+ for (const auto& display : mDisplays) {
+ std::vector<DisplayCapability> capabilities;
+ const auto error = mComposerClient->getDisplayCapabilities(display.get(), &capabilities);
+
+ EXPECT_NE(IComposerClient::EX_BAD_DISPLAY, error.getServiceSpecificError());
+ }
}
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsComposerAidlTest);
@@ -39,4 +103,4 @@
return -1;
}
return RUN_ALL_TESTS();
-}
\ No newline at end of file
+}