From 4efe8608f7f2105a09d9fd563dfd26130e7d0a30 Mon Sep 17 00:00:00 2001 From: Kriti Dang Date: Tue, 3 May 2022 16:55:59 +0200 Subject: [PATCH] Vts test for verifying that there are no duplicates in getDisplayconfigs Test: atest VtsHalGraphicsComposer3_TargetTest Test: atest VtsHalGraphicsComposerV2_4TargetTest Bug: 176086656 Change-Id: I51dd4774b3c990e6db2cb9ee71d14f74dc3effb0 --- .../VtsHalGraphicsComposerV2_4TargetTest.cpp | 33 +++++++++++++++++ .../VtsHalGraphicsComposer3_TargetTest.cpp | 35 +++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/graphics/composer/2.4/vts/functional/VtsHalGraphicsComposerV2_4TargetTest.cpp b/graphics/composer/2.4/vts/functional/VtsHalGraphicsComposerV2_4TargetTest.cpp index fa294ff259..35225d9a03 100644 --- a/graphics/composer/2.4/vts/functional/VtsHalGraphicsComposerV2_4TargetTest.cpp +++ b/graphics/composer/2.4/vts/functional/VtsHalGraphicsComposerV2_4TargetTest.cpp @@ -737,6 +737,39 @@ TEST_P(GraphicsComposerHidlTest, getLayerGenericMetadataKeys) { } } +/* + * Test that no two display configs are exactly the same. + */ +TEST_P(GraphicsComposerHidlTest, GetDisplayConfigNoRepetitions) { + for (const auto& display : mDisplays) { + std::vector configs = mComposerClient->getDisplayConfigs(display.get()); + for (int i = 0; i < configs.size(); i++) { + for (int j = i + 1; j < configs.size(); j++) { + const int32_t width1 = mComposerClient->getDisplayAttribute_2_4( + display.get(), configs[i], IComposerClient::Attribute::WIDTH); + const int32_t height1 = mComposerClient->getDisplayAttribute_2_4( + display.get(), configs[i], IComposerClient::Attribute::HEIGHT); + const int32_t vsyncPeriod1 = mComposerClient->getDisplayAttribute_2_4( + display.get(), configs[i], IComposerClient::Attribute::VSYNC_PERIOD); + const int32_t group1 = mComposerClient->getDisplayAttribute_2_4( + display.get(), configs[i], IComposerClient::Attribute::CONFIG_GROUP); + + const int32_t width2 = mComposerClient->getDisplayAttribute_2_4( + display.get(), configs[j], IComposerClient::Attribute::WIDTH); + const int32_t height2 = mComposerClient->getDisplayAttribute_2_4( + display.get(), configs[j], IComposerClient::Attribute::HEIGHT); + const int32_t vsyncPeriod2 = mComposerClient->getDisplayAttribute_2_4( + display.get(), configs[j], IComposerClient::Attribute::VSYNC_PERIOD); + const int32_t group2 = mComposerClient->getDisplayAttribute_2_4( + display.get(), configs[j], IComposerClient::Attribute::CONFIG_GROUP); + + ASSERT_FALSE(width1 == width2 && height1 == height2 && + vsyncPeriod1 == vsyncPeriod2 && group1 == group2); + } + } + } +} + } // namespace } // namespace vts } // namespace V2_4 diff --git a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp index 759bfecca3..ece1fd3742 100644 --- a/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp +++ b/graphics/composer/aidl/vts/VtsHalGraphicsComposer3_TargetTest.cpp @@ -2122,6 +2122,41 @@ TEST_P(GraphicsComposerAidlCommandTest, SetIdleTimerEnabled_Timeout_2) { EXPECT_TRUE(mComposerClient->setPowerMode(getPrimaryDisplayId(), PowerMode::OFF).isOk()); } +/* + * Test that no two display configs are exactly the same. + */ +TEST_P(GraphicsComposerAidlTest, GetDisplayConfigNoRepetitions) { + for (const auto& display : mDisplays) { + const auto& [status, configs] = mComposerClient->getDisplayConfigs(display.getDisplayId()); + for (std::vector::size_type i = 0; i < configs.size(); i++) { + for (std::vector::size_type j = i + 1; j < configs.size(); j++) { + const auto& [widthStatus1, width1] = mComposerClient->getDisplayAttribute( + display.getDisplayId(), configs[i], DisplayAttribute::WIDTH); + const auto& [heightStatus1, height1] = mComposerClient->getDisplayAttribute( + display.getDisplayId(), configs[i], DisplayAttribute::HEIGHT); + const auto& [vsyncPeriodStatus1, vsyncPeriod1] = + mComposerClient->getDisplayAttribute(display.getDisplayId(), configs[i], + DisplayAttribute::VSYNC_PERIOD); + const auto& [groupStatus1, group1] = mComposerClient->getDisplayAttribute( + display.getDisplayId(), configs[i], DisplayAttribute::CONFIG_GROUP); + + const auto& [widthStatus2, width2] = mComposerClient->getDisplayAttribute( + display.getDisplayId(), configs[j], DisplayAttribute::WIDTH); + const auto& [heightStatus2, height2] = mComposerClient->getDisplayAttribute( + display.getDisplayId(), configs[j], DisplayAttribute::HEIGHT); + const auto& [vsyncPeriodStatus2, vsyncPeriod2] = + mComposerClient->getDisplayAttribute(display.getDisplayId(), configs[j], + DisplayAttribute::VSYNC_PERIOD); + const auto& [groupStatus2, group2] = mComposerClient->getDisplayAttribute( + display.getDisplayId(), configs[j], DisplayAttribute::CONFIG_GROUP); + + ASSERT_FALSE(width1 == width2 && height1 == height2 && + vsyncPeriod1 == vsyncPeriod2 && group1 == group2); + } + } + } +} + GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(GraphicsComposerAidlCommandTest); INSTANTIATE_TEST_SUITE_P( PerInstance, GraphicsComposerAidlCommandTest,