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

Commit 06ad24a7 authored by Dan Shi's avatar Dan Shi Committed by Automerger Merge Worker
Browse files

Merge "Convert VtsHalAudioV*_0TargetTest to parameterized gtest" am:...

Merge "Convert VtsHalAudioV*_0TargetTest to parameterized gtest" am: 1b03269e am: e904793d am: daa29997

Change-Id: I456498c011274f0d3df978e5cefa77cb46db9545
parents 275a522d daa29997
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
//
// 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.
//

filegroup {
    name: "audio_policy_configuration_V2_0",
    srcs: ["audio_policy_configuration.xsd"],
}
+0 −58
Original line number Diff line number Diff line
/*
 * 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_AUDIO_COMMON_TEST_UTILITY_ENVIRONMENT_TEARDOWN_H
#define ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_ENVIRONMENT_TEARDOWN_H

#include <functional>
#include <list>

namespace android {
namespace hardware {
namespace audio {
namespace common {
namespace test {
namespace utility {

/** Register callback for static object destruction
 * Avoid destroying static objects after main return.
 * Post main return destruction leads to incorrect gtest timing measurements as
 * well as harder debuging if anything goes wrong during destruction. */
class EnvironmentTearDown {
  public:
    using TearDownFunc = std::function<void()>;
    void registerTearDown(TearDownFunc&& tearDown) { tearDowns.push_front(std::move(tearDown)); }

  protected:
    void executeAllTearDowns() {
        // Call the tear downs in reverse order of insertion
        for (auto& tearDown : tearDowns) {
            tearDown();
        }
    }

  private:
    std::list<TearDownFunc> tearDowns;
};

}  // namespace utility
}  // namespace test
}  // namespace common
}  // namespace audio
}  // namespace hardware
}  // namespace android

#endif  // ANDROID_HARDWARE_AUDIO_COMMON_TEST_UTILITY_ENVIRONMENT_TEARDOWN_H
+8 −5
Original line number Diff line number Diff line
@@ -18,8 +18,11 @@ cc_defaults {

    export_include_dirs: ["include"],

    shared_libs: [
    static_libs: [
        "libaudiofoundation",
    ],

    shared_libs: [
        "libbase",
        "libcutils",
        "libfmq",
@@ -52,7 +55,7 @@ cc_library_shared {
        "-DMAJOR_VERSION=2",
        "-DMINOR_VERSION=0",
        "-include common/all-versions/VersionMacro.h",
    ]
    ],
}

cc_library_shared {
@@ -68,7 +71,7 @@ cc_library_shared {
        "-DMAJOR_VERSION=4",
        "-DMINOR_VERSION=0",
        "-include common/all-versions/VersionMacro.h",
    ]
    ],
}

cc_library_shared {
@@ -83,7 +86,7 @@ cc_library_shared {
        "-DMAJOR_VERSION=5",
        "-DMINOR_VERSION=0",
        "-include common/all-versions/VersionMacro.h",
    ]
    ],
}

cc_library_shared {
@@ -98,5 +101,5 @@ cc_library_shared {
        "-DMAJOR_VERSION=6",
        "-DMINOR_VERSION=0",
        "-include common/all-versions/VersionMacro.h",
    ]
    ],
}
+0 −34
Original line number Diff line number Diff line
/*
 * Copyright (C) 2019 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_AUDIO_CORE_2_0_ENVIRONMENT_TEARDOWN_H
#define ANDROID_HARDWARE_AUDIO_CORE_2_0_ENVIRONMENT_TEARDOWN_H

#include <VtsHalHidlTargetTestEnvBase.h>
#include <gtest/gtest.h>

#include "utility/EnvironmentTearDown.h"

class Environment : public ::android::hardware::audio::common::test::utility::EnvironmentTearDown,
                    public ::testing::VtsHalHidlTargetTestEnvBase {
  private:
    void HidlTearDown() override {
        executeAllTearDowns();
        VtsHalHidlTargetTestEnvBase::HidlTearDown();
    }
};

#endif  // ANDROID_HARDWARE_AUDIO_CORE_2_0_ENVIRONMENT_TEARDOWN_H
+0 −48
Original line number Diff line number Diff line
@@ -17,54 +17,6 @@
// pull in all the <= 5.0 tests
#include "5.0/AudioPrimaryHidlHalTest.cpp"

const std::vector<DeviceParameter>& getDeviceParametersForFactoryTests() {
    static std::vector<DeviceParameter> parameters = [] {
        std::vector<DeviceParameter> result;
        const auto factories =
                ::android::hardware::getAllHalInstanceNames(IDevicesFactory::descriptor);
        for (const auto& factoryName : factories) {
            result.emplace_back(factoryName,
                                DeviceManager::getInstance().getPrimary(factoryName) != nullptr
                                        ? DeviceManager::kPrimaryDevice
                                        : "");
        }
        return result;
    }();
    return parameters;
}

const std::vector<DeviceParameter>& getDeviceParametersForPrimaryDeviceTests() {
    static std::vector<DeviceParameter> parameters = [] {
        std::vector<DeviceParameter> result;
        const auto primary = std::find_if(
                getDeviceParameters().begin(), getDeviceParameters().end(), [](const auto& elem) {
                    return std::get<PARAM_DEVICE_NAME>(elem) == DeviceManager::kPrimaryDevice;
                });
        if (primary != getDeviceParameters().end()) result.push_back(*primary);
        return result;
    }();
    return parameters;
}

const std::vector<DeviceParameter>& getDeviceParameters() {
    static std::vector<DeviceParameter> parameters = [] {
        std::vector<DeviceParameter> result;
        const auto factories =
                ::android::hardware::getAllHalInstanceNames(IDevicesFactory::descriptor);
        const auto devices = getCachedPolicyConfig().getModulesWithDevicesNames();
        result.reserve(devices.size());
        for (const auto& factoryName : factories) {
            for (const auto& deviceName : devices) {
                if (DeviceManager::getInstance().get(factoryName, deviceName) != nullptr) {
                    result.emplace_back(factoryName, deviceName);
                }
            }
        }
        return result;
    }();
    return parameters;
}

const std::vector<DeviceConfigParameter>& getOutputDeviceConfigParameters() {
    static std::vector<DeviceConfigParameter> parameters = [] {
        std::vector<DeviceConfigParameter> result;
Loading