mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
[vts-core] add VtsHalConfigstoreV1_0TargetTest to vts-core
Convert VtsHalConfigstoreV1_0TargetTest to be parameterized test and add it to vts-core Bug: 142397658 Test: $atest VtsHalConfigstoreV1_0TargetTest Change-Id: If65ce7afbe23eca95f62c6b231abf78d9ada616e
This commit is contained in:
@@ -19,6 +19,6 @@ cc_test {
|
||||
defaults: ["VtsHalTargetTestDefaults"],
|
||||
srcs: ["VtsHalConfigstoreV1_0TargetTest.cpp"],
|
||||
static_libs: ["android.hardware.configstore@1.0"],
|
||||
test_suites: ["general-tests"],
|
||||
test_suites: ["general-tests", "vts-core"],
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,12 @@
|
||||
|
||||
#define LOG_TAG "ConfigstoreHidlHalTest"
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/configstore/1.0/ISurfaceFlingerConfigs.h>
|
||||
#include <android/hardware/configstore/1.0/types.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
#include <unistd.h>
|
||||
|
||||
using ::android::hardware::configstore::V1_0::ISurfaceFlingerConfigs;
|
||||
@@ -35,25 +36,12 @@ using ::android::sp;
|
||||
#define ASSERT_OK(ret) ASSERT_TRUE(ret.isOk())
|
||||
#define EXPECT_OK(ret) EXPECT_TRUE(ret.isOk())
|
||||
|
||||
// Test environment for Configstore HIDL HAL.
|
||||
class ConfigstoreHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
// get the test environment singleton
|
||||
static ConfigstoreHidlEnvironment* Instance() {
|
||||
static ConfigstoreHidlEnvironment* instance = new ConfigstoreHidlEnvironment;
|
||||
return instance;
|
||||
}
|
||||
|
||||
virtual void registerTestServices() override { registerTestService<ISurfaceFlingerConfigs>(); }
|
||||
};
|
||||
|
||||
class ConfigstoreHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
class ConfigstoreHidlTest : public ::testing::TestWithParam<std::string> {
|
||||
public:
|
||||
sp<ISurfaceFlingerConfigs> sfConfigs;
|
||||
|
||||
virtual void SetUp() override {
|
||||
sfConfigs = ::testing::VtsHalHidlTargetTestBase::getService<ISurfaceFlingerConfigs>(
|
||||
ConfigstoreHidlEnvironment::Instance()->getServiceName<ISurfaceFlingerConfigs>());
|
||||
sfConfigs = ISurfaceFlingerConfigs::getService(GetParam());
|
||||
ASSERT_NE(sfConfigs, nullptr);
|
||||
}
|
||||
|
||||
@@ -63,7 +51,7 @@ class ConfigstoreHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
/**
|
||||
* Ensure all ISurfaceFlingerConfigs.hal function calls are successful.
|
||||
*/
|
||||
TEST_F(ConfigstoreHidlTest, TestFunctionCalls) {
|
||||
TEST_P(ConfigstoreHidlTest, TestFunctionCalls) {
|
||||
bool tmp;
|
||||
|
||||
Return<void> status = sfConfigs->vsyncEventPhaseOffsetNs(
|
||||
@@ -118,7 +106,7 @@ TEST_F(ConfigstoreHidlTest, TestFunctionCalls) {
|
||||
/**
|
||||
* Ensure repeated call to the same function returns the same result.
|
||||
*/
|
||||
TEST_F(ConfigstoreHidlTest, TestSameReturnValue) {
|
||||
TEST_P(ConfigstoreHidlTest, TestSameReturnValue) {
|
||||
int64_t original_ret;
|
||||
Return<void> status = sfConfigs->vsyncEventPhaseOffsetNs(
|
||||
[&original_ret](OptionalInt64 arg) { original_ret = arg.value; });
|
||||
@@ -135,7 +123,7 @@ TEST_F(ConfigstoreHidlTest, TestSameReturnValue) {
|
||||
* Make sure the constrains of hasWideColorDisplay, hasHDRDisplay
|
||||
* are enforced.
|
||||
*/
|
||||
TEST_F(ConfigstoreHidlTest, TestColorConstrainsBasic) {
|
||||
TEST_P(ConfigstoreHidlTest, TestColorConstrainsBasic) {
|
||||
bool hasWideColorDisplay;
|
||||
bool hasHDRDisplay;
|
||||
|
||||
@@ -152,11 +140,7 @@ TEST_F(ConfigstoreHidlTest, TestColorConstrainsBasic) {
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
::testing::AddGlobalTestEnvironment(ConfigstoreHidlEnvironment::Instance());
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
ConfigstoreHidlEnvironment::Instance()->init(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
LOG(INFO) << "Test result = " << status;
|
||||
return status;
|
||||
}
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
PerInstance, ConfigstoreHidlTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(ISurfaceFlingerConfigs::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
|
||||
Reference in New Issue
Block a user