mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Convert VtsHalAudioControlV1_0TargetTest to parameterized gtest
Bug: 150383827 Bug: 150381814 Test: atest VtsHalAudioControlV1_0TargetTest Change-Id: I900f6a540c44d13f5f8a8882b573fa5669c1732f
This commit is contained in:
@@ -25,5 +25,8 @@ cc_test {
|
||||
static_libs: [
|
||||
"android.hardware.automotive.audiocontrol@1.0",
|
||||
],
|
||||
test_suites: ["general-tests"],
|
||||
test_suites: [
|
||||
"general-tests",
|
||||
"vts",
|
||||
],
|
||||
}
|
||||
|
||||
@@ -25,11 +25,12 @@
|
||||
#include <utils/Errors.h>
|
||||
#include <utils/StrongPointer.h>
|
||||
|
||||
#include <android/hardware/automotive/audiocontrol/1.0/types.h>
|
||||
#include <android/hardware/automotive/audiocontrol/1.0/IAudioControl.h>
|
||||
#include <android/hardware/automotive/audiocontrol/1.0/types.h>
|
||||
#include <android/log.h>
|
||||
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
|
||||
using namespace ::android::hardware::automotive::audiocontrol::V1_0;
|
||||
using ::android::hardware::Return;
|
||||
@@ -40,30 +41,12 @@ using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::sp;
|
||||
|
||||
|
||||
// Boiler plate for test harness
|
||||
class CarAudioControlHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
// get the test environment singleton
|
||||
static CarAudioControlHidlEnvironment* Instance() {
|
||||
static CarAudioControlHidlEnvironment* instance = new CarAudioControlHidlEnvironment;
|
||||
return instance;
|
||||
}
|
||||
|
||||
virtual void registerTestServices() override { registerTestService<IAudioControl>(); }
|
||||
private:
|
||||
CarAudioControlHidlEnvironment() {}
|
||||
};
|
||||
|
||||
|
||||
// The main test class for the automotive AudioControl HAL
|
||||
class CarAudioControlHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
public:
|
||||
class CarAudioControlHidlTest : public ::testing::TestWithParam<std::string> {
|
||||
public:
|
||||
virtual void SetUp() override {
|
||||
// Make sure we can connect to the driver
|
||||
pAudioControl = ::testing::VtsHalHidlTargetTestBase::getService<IAudioControl>(
|
||||
CarAudioControlHidlEnvironment::Instance()->
|
||||
getServiceName<IAudioControl>());
|
||||
pAudioControl = IAudioControl::getService(GetParam());
|
||||
ASSERT_NE(pAudioControl.get(), nullptr);
|
||||
}
|
||||
|
||||
@@ -82,7 +65,7 @@ public:
|
||||
* fader actually works. The only thing we can do is exercise the HAL and if the HAL crashes,
|
||||
* we _might_ get a test failure if that breaks the connection to the driver.
|
||||
*/
|
||||
TEST_F(CarAudioControlHidlTest, FaderExercise) {
|
||||
TEST_P(CarAudioControlHidlTest, FaderExercise) {
|
||||
ALOGI("Fader exercise test (silent)");
|
||||
|
||||
// Set the fader all the way to the back
|
||||
@@ -104,7 +87,7 @@ TEST_F(CarAudioControlHidlTest, FaderExercise) {
|
||||
/*
|
||||
* Balance exercise test.
|
||||
*/
|
||||
TEST_F(CarAudioControlHidlTest, BalanceExercise) {
|
||||
TEST_P(CarAudioControlHidlTest, BalanceExercise) {
|
||||
ALOGI("Balance exercise test (silent)");
|
||||
|
||||
// Set the balance all the way to the left
|
||||
@@ -126,7 +109,7 @@ TEST_F(CarAudioControlHidlTest, BalanceExercise) {
|
||||
/*
|
||||
* Context mapping test.
|
||||
*/
|
||||
TEST_F(CarAudioControlHidlTest, ContextMapping) {
|
||||
TEST_P(CarAudioControlHidlTest, ContextMapping) {
|
||||
ALOGI("Context mapping test");
|
||||
|
||||
int bus = -1;
|
||||
@@ -156,3 +139,8 @@ TEST_F(CarAudioControlHidlTest, ContextMapping) {
|
||||
bus = pAudioControl->getBusForContext((ContextNumber)~0);
|
||||
EXPECT_EQ(bus, -1);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
PerInstance, CarAudioControlHidlTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IAudioControl::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
Reference in New Issue
Block a user