mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Merge "Convert VtsHalBroadcastradioV1_0/1TargetTest to parameterized gtest" into rvc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
a2d2482aa1
@@ -22,5 +22,8 @@ cc_test {
|
||||
"android.hardware.broadcastradio@1.0",
|
||||
"android.hardware.broadcastradio@vts-utils-lib",
|
||||
],
|
||||
test_suites: ["general-tests"],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
"vts",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -15,11 +15,13 @@
|
||||
*/
|
||||
|
||||
#define LOG_TAG "BroadcastRadioHidlHalTest"
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <cutils/native_handle.h>
|
||||
#include <cutils/properties.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
#include <utils/threads.h>
|
||||
|
||||
#include <android/hardware/broadcastradio/1.0/IBroadcastRadio.h>
|
||||
@@ -27,28 +29,28 @@
|
||||
#include <android/hardware/broadcastradio/1.0/ITuner.h>
|
||||
#include <android/hardware/broadcastradio/1.0/ITunerCallback.h>
|
||||
#include <android/hardware/broadcastradio/1.0/types.h>
|
||||
#include <broadcastradio-vts-utils/environment-utils.h>
|
||||
#include <broadcastradio-vts-utils/hal-1.x-enum-utils.h>
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::Mutex;
|
||||
using ::android::Condition;
|
||||
using ::android::Mutex;
|
||||
using ::android::sp;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::broadcastradio::V1_0::IBroadcastRadioFactory;
|
||||
using ::android::hardware::broadcastradio::V1_0::IBroadcastRadio;
|
||||
using ::android::hardware::broadcastradio::V1_0::ITuner;
|
||||
using ::android::hardware::broadcastradio::V1_0::ITunerCallback;
|
||||
using ::android::hardware::broadcastradio::V1_0::Result;
|
||||
using ::android::hardware::broadcastradio::V1_0::Class;
|
||||
using ::android::hardware::broadcastradio::V1_0::Properties;
|
||||
using ::android::hardware::broadcastradio::V1_0::Band;
|
||||
using ::android::hardware::broadcastradio::V1_0::BandConfig;
|
||||
using ::android::hardware::broadcastradio::V1_0::Class;
|
||||
using ::android::hardware::broadcastradio::V1_0::Direction;
|
||||
using ::android::hardware::broadcastradio::V1_0::ProgramInfo;
|
||||
using ::android::hardware::broadcastradio::V1_0::IBroadcastRadio;
|
||||
using ::android::hardware::broadcastradio::V1_0::IBroadcastRadioFactory;
|
||||
using ::android::hardware::broadcastradio::V1_0::ITuner;
|
||||
using ::android::hardware::broadcastradio::V1_0::ITunerCallback;
|
||||
using ::android::hardware::broadcastradio::V1_0::MetaData;
|
||||
using ::android::hardware::broadcastradio::V1_0::MetadataKey;
|
||||
using ::android::hardware::broadcastradio::V1_0::MetadataType;
|
||||
using ::android::hardware::broadcastradio::vts::BroadcastRadioHidlEnvironment;
|
||||
using ::android::hardware::broadcastradio::V1_0::ProgramInfo;
|
||||
using ::android::hardware::broadcastradio::V1_0::Properties;
|
||||
using ::android::hardware::broadcastradio::V1_0::Result;
|
||||
using ::android::hardware::broadcastradio::V1_0::vts::RadioClassFromString;
|
||||
|
||||
#define RETURN_IF_SKIPPED \
|
||||
if (skipped) { \
|
||||
@@ -56,19 +58,19 @@ using ::android::hardware::broadcastradio::vts::BroadcastRadioHidlEnvironment;
|
||||
return; \
|
||||
}
|
||||
|
||||
static BroadcastRadioHidlEnvironment<IBroadcastRadioFactory>* gEnv = nullptr;
|
||||
// The main test class for Broadcast Radio HIDL HAL.
|
||||
class BroadcastRadioHidlTest : public ::testing::VtsHalHidlTargetTestBase,
|
||||
public ::testing::WithParamInterface<Class> {
|
||||
protected:
|
||||
class BroadcastRadioHidlTest
|
||||
: public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
|
||||
protected:
|
||||
virtual void SetUp() override {
|
||||
ASSERT_EQ(nullptr, mRadio.get());
|
||||
|
||||
radioClass = GetParam();
|
||||
radioClass = RadioClassFromString(std::get<1>(GetParam()));
|
||||
|
||||
skipped = false;
|
||||
|
||||
sp<IBroadcastRadioFactory> factory =
|
||||
getService<IBroadcastRadioFactory>(gEnv->getServiceName<IBroadcastRadioFactory>());
|
||||
IBroadcastRadioFactory::getService(std::get<0>(GetParam()));
|
||||
ASSERT_NE(nullptr, factory.get());
|
||||
|
||||
Result connectResult;
|
||||
@@ -727,16 +729,8 @@ TEST_P(BroadcastRadioHidlTest, IbImagesOnly) {
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
BroadcastRadioHidlTestCases,
|
||||
BroadcastRadioHidlTest,
|
||||
::testing::Values(Class::AM_FM, Class::SAT, Class::DT));
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
gEnv = new BroadcastRadioHidlEnvironment<IBroadcastRadioFactory>;
|
||||
::testing::AddGlobalTestEnvironment(gEnv);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
gEnv->init(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
ALOGI("Test result = %d", status);
|
||||
return status;
|
||||
}
|
||||
PerInstance, BroadcastRadioHidlTest,
|
||||
testing::Combine(testing::ValuesIn(android::hardware::getAllHalInstanceNames(
|
||||
IBroadcastRadioFactory::descriptor)),
|
||||
::testing::Values("AM_FM", "SAT", "DT")),
|
||||
android::hardware::PrintInstanceTupleNameToString<>);
|
||||
@@ -25,5 +25,8 @@ cc_test {
|
||||
"android.hardware.broadcastradio@vts-utils-lib",
|
||||
"libgmock",
|
||||
],
|
||||
test_suites: ["general-tests"],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
"vts",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
#define LOG_TAG "broadcastradio.vts"
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android/hardware/broadcastradio/1.1/IBroadcastRadio.h>
|
||||
#include <android/hardware/broadcastradio/1.1/IBroadcastRadioFactory.h>
|
||||
@@ -25,13 +24,16 @@
|
||||
#include <android/hardware/broadcastradio/1.1/types.h>
|
||||
#include <broadcastradio-utils-1x/Utils.h>
|
||||
#include <broadcastradio-vts-utils/call-barrier.h>
|
||||
#include <broadcastradio-vts-utils/environment-utils.h>
|
||||
#include <broadcastradio-vts-utils/hal-1.x-enum-utils.h>
|
||||
#include <broadcastradio-vts-utils/mock-timeout.h>
|
||||
#include <broadcastradio-vts-utils/pointer-utils.h>
|
||||
#include <cutils/native_handle.h>
|
||||
#include <cutils/properties.h>
|
||||
#include <gmock/gmock.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
#include <utils/threads.h>
|
||||
|
||||
#include <chrono>
|
||||
@@ -51,6 +53,7 @@ using testing::DoAll;
|
||||
using testing::Invoke;
|
||||
using testing::SaveArg;
|
||||
|
||||
using broadcastradio::V1_0::vts::RadioClassFromString;
|
||||
using broadcastradio::vts::CallBarrier;
|
||||
using V1_0::BandConfig;
|
||||
using V1_0::Class;
|
||||
@@ -59,7 +62,6 @@ using V1_0::MetadataKey;
|
||||
using V1_0::MetadataType;
|
||||
|
||||
using broadcastradio::vts::clearAndWait;
|
||||
using broadcastradio::vts::BroadcastRadioHidlEnvironment;
|
||||
|
||||
static constexpr auto kConfigTimeout = 10s;
|
||||
static constexpr auto kConnectModuleTimeout = 1s;
|
||||
@@ -93,11 +95,9 @@ struct TunerCallbackMock : public ITunerCallback {
|
||||
MOCK_TIMEOUT_METHOD1(currentProgramInfoChanged, Return<void>(const ProgramInfo&));
|
||||
};
|
||||
|
||||
static BroadcastRadioHidlEnvironment<IBroadcastRadioFactory>* gEnv = nullptr;
|
||||
|
||||
class BroadcastRadioHalTest : public ::testing::VtsHalHidlTargetTestBase,
|
||||
public ::testing::WithParamInterface<Class> {
|
||||
protected:
|
||||
class BroadcastRadioHalTest
|
||||
: public ::testing::TestWithParam<std::tuple<std::string, std::string>> {
|
||||
protected:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
@@ -120,11 +120,10 @@ class BroadcastRadioHalTest : public ::testing::VtsHalHidlTargetTestBase,
|
||||
};
|
||||
|
||||
void BroadcastRadioHalTest::SetUp() {
|
||||
radioClass = GetParam();
|
||||
radioClass = RadioClassFromString(std::get<1>(GetParam()));
|
||||
|
||||
// lookup HIDL service
|
||||
auto factory =
|
||||
getService<IBroadcastRadioFactory>(gEnv->getServiceName<IBroadcastRadioFactory>());
|
||||
auto factory = IBroadcastRadioFactory::getService(std::get<0>(GetParam()));
|
||||
ASSERT_NE(nullptr, factory.get());
|
||||
|
||||
// connect radio module
|
||||
@@ -601,24 +600,15 @@ TEST_P(BroadcastRadioHalTest, VerifyIdentifiersFormat) {
|
||||
} while (nextBand());
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(BroadcastRadioHalTestCases, BroadcastRadioHalTest,
|
||||
::testing::Values(Class::AM_FM, Class::SAT, Class::DT));
|
||||
INSTANTIATE_TEST_CASE_P(
|
||||
PerInstance, BroadcastRadioHalTest,
|
||||
testing::Combine(testing::ValuesIn(android::hardware::getAllHalInstanceNames(
|
||||
IBroadcastRadioFactory::descriptor)),
|
||||
::testing::Values("AM_FM", "SAT", "DT")),
|
||||
android::hardware::PrintInstanceTupleNameToString<>);
|
||||
|
||||
} // namespace vts
|
||||
} // namespace V1_1
|
||||
} // namespace broadcastradio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
using android::hardware::broadcastradio::V1_1::vts::gEnv;
|
||||
using android::hardware::broadcastradio::V1_1::IBroadcastRadioFactory;
|
||||
using android::hardware::broadcastradio::vts::BroadcastRadioHidlEnvironment;
|
||||
gEnv = new BroadcastRadioHidlEnvironment<IBroadcastRadioFactory>;
|
||||
::testing::AddGlobalTestEnvironment(gEnv);
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
gEnv->init(&argc, argv);
|
||||
int status = RUN_ALL_TESTS();
|
||||
ALOGI("Test result = %d", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 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.
|
||||
*/
|
||||
#ifndef ANDROID_HARDWARE_BROADCASTRADIO_VTS_ENVIRONMENT_UTILS
|
||||
#define ANDROID_HARDWARE_BROADCASTRADIO_VTS_ENVIRONMENT_UTILS
|
||||
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace broadcastradio {
|
||||
namespace vts {
|
||||
|
||||
// Test environment for BroadcastRadio HIDL HAL.
|
||||
template <typename... T>
|
||||
class BroadcastRadioHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
virtual void registerTestServices() override {
|
||||
using expander = int[];
|
||||
(void)expander{0, (registerTestService<T>(), 0)...};
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace vts
|
||||
} // namespace broadcastradio
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_BROADCASTRADIO_VTS_ENVIRONMENT_UTILS
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 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
|
||||
|
||||
namespace android::hardware::broadcastradio::V1_0::vts {
|
||||
|
||||
using android::hardware::broadcastradio::V1_0::Class;
|
||||
|
||||
/**
|
||||
* Convert a string of Class name to its enum value. Fail the test if the enum
|
||||
* value is not found.
|
||||
*
|
||||
* @param className string value of a Class enum.
|
||||
* @return Class enum that matches the string value.
|
||||
*/
|
||||
Class RadioClassFromString(std::string className) {
|
||||
if (className == "AM_FM") return Class::AM_FM;
|
||||
if (className == "SAT") return Class::SAT;
|
||||
if (className == "DT") return Class::DT;
|
||||
// Fail the test run.
|
||||
CHECK(false) << "Class name not found: " << className;
|
||||
// Return some arbitrary enum.
|
||||
return Class::AM_FM;
|
||||
}
|
||||
} // namespace android::hardware::broadcastradio::V1_0::vts
|
||||
Reference in New Issue
Block a user