Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3f5aadef authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Convert VtsHalAudioControlV1_0TargetTest to parameterized gtest" into...

Merge "Convert VtsHalAudioControlV1_0TargetTest to parameterized gtest" into rvc-dev am: cebc5743 am: 83eab545 am: 7ed8fac8

Change-Id: Ib7f60c04c3084cab151a8a15285866df82759dbc
parents 3c5fdad7 7ed8fac8
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -25,5 +25,8 @@ cc_test {
    static_libs: [
        "android.hardware.automotive.audiocontrol@1.0",
    ],
    test_suites: ["general-tests"],
    test_suites: [
        "general-tests",
        "vts",
    ],
}
+15 −27
Original line number Diff line number Diff line
@@ -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 {
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);
 No newline at end of file