Merge changes from topic "upstream-vts-v6"
* changes: audio: Run VTS tests for streams of non-primary modules for HAL V6 audio: Run VTS tests for non-primary modules for HAL V6 audio: Parametrize core VTS tests audio: Parametrize effect VTS tests for V6.0
This commit is contained in:
commit
460be58661
14 changed files with 1086 additions and 371 deletions
|
@ -260,7 +260,8 @@ interface IDevice {
|
|||
/**
|
||||
* Returns an array with available microphones in device.
|
||||
*
|
||||
* @return retval INVALID_STATE if the call is not successful,
|
||||
* @return retval NOT_SUPPORTED if there are no microphones on this device
|
||||
* INVALID_STATE if the call is not successful,
|
||||
* OK otherwise.
|
||||
*
|
||||
* @return microphones array with microphones info
|
||||
|
|
|
@ -123,9 +123,11 @@ interface IStream {
|
|||
* equivalent to getting AUDIO_PARAMETER_STREAM_SUP_FORMATS on the legacy
|
||||
* HAL.
|
||||
*
|
||||
* @return retval operation completion status.
|
||||
* @return formats supported audio formats.
|
||||
* Must be non empty if retval is OK.
|
||||
*/
|
||||
getSupportedFormats() generates (vec<AudioFormat> formats);
|
||||
getSupportedFormats() generates (Result retval, vec<AudioFormat> formats);
|
||||
|
||||
/**
|
||||
* Sets the audio format of the stream. Calling this method is equivalent to
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
#include <functional>
|
||||
#include <list>
|
||||
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace audio {
|
||||
|
@ -34,18 +31,20 @@ namespace utility {
|
|||
* 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 Environment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
class EnvironmentTearDown {
|
||||
public:
|
||||
using TearDownFunc = std::function<void()>;
|
||||
void registerTearDown(TearDownFunc&& tearDown) { tearDowns.push_front(std::move(tearDown)); }
|
||||
|
||||
private:
|
||||
void HidlTearDown() override {
|
||||
protected:
|
||||
void executeAllTearDowns() {
|
||||
// Call the tear downs in reverse order of insertion
|
||||
for (auto& tearDown : tearDowns) {
|
||||
tearDown();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::list<TearDownFunc> tearDowns;
|
||||
};
|
||||
|
||||
|
|
|
@ -175,8 +175,17 @@ Return<void> Stream::getSupportedFormats(getSupportedFormats_cb _hidl_cb) {
|
|||
for (size_t i = 0; i < halFormats.size(); ++i) {
|
||||
formats[i] = AudioFormat(halFormats[i]);
|
||||
}
|
||||
// Legacy get_parameter does not return a status_t, thus can not advertise of failure.
|
||||
// Note that the method must not return an empty list if this capability is supported.
|
||||
if (formats.size() == 0) {
|
||||
result = Result::NOT_SUPPORTED;
|
||||
}
|
||||
}
|
||||
#if MAJOR_VERSION <= 5
|
||||
_hidl_cb(formats);
|
||||
#elif MAJOR_VERSION >= 6
|
||||
_hidl_cb(result, formats);
|
||||
#endif
|
||||
return Void();
|
||||
}
|
||||
|
||||
|
|
|
@ -60,19 +60,20 @@ TEST_IO_STREAM(SetConnectedState,
|
|||
"deconnection",
|
||||
testConnectedState(stream.get()))
|
||||
|
||||
TEST_IO_STREAM(GetHwAvSync, "Get hardware sync can not fail", ASSERT_IS_OK(device->getHwAvSync()));
|
||||
TEST_IO_STREAM(GetHwAvSync, "Get hardware sync can not fail",
|
||||
ASSERT_IS_OK(getDevice()->getHwAvSync()));
|
||||
|
||||
TEST_F(AudioPrimaryHidlTest, setMode) {
|
||||
TEST_P(AudioPrimaryHidlTest, setMode) {
|
||||
doc::test("Make sure setMode always succeeds if mode is valid and fails otherwise");
|
||||
// Test Invalid values
|
||||
for (AudioMode mode : {AudioMode::INVALID, AudioMode::CURRENT, AudioMode::CNT}) {
|
||||
SCOPED_TRACE("mode=" + toString(mode));
|
||||
ASSERT_RESULT(Result::INVALID_ARGUMENTS, device->setMode(mode));
|
||||
ASSERT_RESULT(Result::INVALID_ARGUMENTS, getDevice()->setMode(mode));
|
||||
}
|
||||
// Test valid values
|
||||
for (AudioMode mode : {AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION, AudioMode::RINGTONE,
|
||||
AudioMode::NORMAL /* Make sure to leave the test in normal mode */}) {
|
||||
SCOPED_TRACE("mode=" + toString(mode));
|
||||
ASSERT_OK(device->setMode(mode));
|
||||
ASSERT_OK(getDevice()->setMode(mode));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* 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
|
|
@ -16,28 +16,18 @@
|
|||
|
||||
#include "AudioPrimaryHidlHalTest.h"
|
||||
|
||||
static void waitForDeviceDestruction() {
|
||||
// FIXME: there is no way to know when the remote IDevice is being destroyed
|
||||
// Binder does not support testing if an object is alive, thus
|
||||
// wait for 100ms to let the binder destruction propagates and
|
||||
// the remote device has the time to be destroyed.
|
||||
// flushCommand makes sure all local command are sent, thus should reduce
|
||||
// the latency between local and remote destruction.
|
||||
IPCThreadState::self()->flushCommands();
|
||||
usleep(100 * 1000);
|
||||
}
|
||||
|
||||
TEST_F(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) {
|
||||
TEST_P(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) {
|
||||
doc::test("Calling openDevice(\"primary\") should return the primary device.");
|
||||
if (getDeviceName() != DeviceManager::kPrimaryDevice) {
|
||||
GTEST_SKIP() << "No primary device on this factory"; // returns
|
||||
}
|
||||
|
||||
struct WaitExecutor {
|
||||
~WaitExecutor() { waitForDeviceDestruction(); }
|
||||
~WaitExecutor() { DeviceManager::waitForInstanceDestruction(); }
|
||||
} waitExecutor; // Make sure we wait for the device destruction on exiting from the test.
|
||||
Result result;
|
||||
sp<IDevice> baseDevice;
|
||||
ASSERT_OK(devicesFactory->openDevice("primary", returnIn(result, baseDevice)));
|
||||
if (result != Result::OK && isPrimaryDeviceOptional()) {
|
||||
GTEST_SKIP() << "No primary device on this factory"; // returns
|
||||
}
|
||||
ASSERT_OK(getDevicesFactory()->openDevice("primary", returnIn(result, baseDevice)));
|
||||
ASSERT_OK(result);
|
||||
ASSERT_TRUE(baseDevice != nullptr);
|
||||
|
||||
|
@ -50,10 +40,13 @@ TEST_F(AudioHidlTest, OpenPrimaryDeviceUsingGetDevice) {
|
|||
/////////////////////////// get(Active)Microphones ///////////////////////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
TEST_F(AudioPrimaryHidlTest, GetMicrophonesTest) {
|
||||
TEST_P(AudioHidlDeviceTest, GetMicrophonesTest) {
|
||||
doc::test("Make sure getMicrophones always succeeds");
|
||||
hidl_vec<MicrophoneInfo> microphones;
|
||||
ASSERT_OK(device->getMicrophones(returnIn(res, microphones)));
|
||||
ASSERT_OK(getDevice()->getMicrophones(returnIn(res, microphones)));
|
||||
if (res == Result::NOT_SUPPORTED) {
|
||||
GTEST_SKIP() << "getMicrophones is not supported"; // returns
|
||||
}
|
||||
ASSERT_OK(res);
|
||||
if (microphones.size() > 0) {
|
||||
// When there is microphone on the phone, try to open an input stream
|
||||
|
@ -75,15 +68,15 @@ TEST_F(AudioPrimaryHidlTest, GetMicrophonesTest) {
|
|||
}
|
||||
sp<IStreamIn> stream;
|
||||
AudioConfig suggestedConfig{};
|
||||
ASSERT_OK(device->openInputStream(ioHandle, microphone.deviceAddress, config, flags,
|
||||
initMetadata,
|
||||
returnIn(res, stream, suggestedConfig)));
|
||||
ASSERT_OK(getDevice()->openInputStream(ioHandle, microphone.deviceAddress, config,
|
||||
flags, initMetadata,
|
||||
returnIn(res, stream, suggestedConfig)));
|
||||
if (res != Result::OK) {
|
||||
ASSERT_TRUE(stream == nullptr);
|
||||
AudioConfig suggestedConfigRetry{};
|
||||
ASSERT_OK(device->openInputStream(ioHandle, microphone.deviceAddress,
|
||||
suggestedConfig, flags, initMetadata,
|
||||
returnIn(res, stream, suggestedConfigRetry)));
|
||||
ASSERT_OK(getDevice()->openInputStream(
|
||||
ioHandle, microphone.deviceAddress, suggestedConfig, flags, initMetadata,
|
||||
returnIn(res, stream, suggestedConfigRetry)));
|
||||
}
|
||||
ASSERT_OK(res);
|
||||
hidl_vec<MicrophoneInfo> activeMicrophones;
|
||||
|
@ -131,7 +124,7 @@ TEST_F(AudioPrimaryHidlTest, GetMicrophonesTest) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(AudioPrimaryHidlTest, SetConnectedState) {
|
||||
TEST_P(AudioHidlDeviceTest, SetConnectedState) {
|
||||
doc::test("Check that the HAL can be notified of device connection and deconnection");
|
||||
using AD = AudioDevice;
|
||||
for (auto deviceType : {AD::OUT_HDMI, AD::OUT_WIRED_HEADPHONE, AD::IN_USB_HEADSET}) {
|
||||
|
@ -140,7 +133,7 @@ TEST_F(AudioPrimaryHidlTest, SetConnectedState) {
|
|||
SCOPED_TRACE("state=" + ::testing::PrintToString(state));
|
||||
DeviceAddress address = {};
|
||||
address.device = deviceType;
|
||||
auto ret = device->setConnectedState(address, state);
|
||||
auto ret = getDevice()->setConnectedState(address, state);
|
||||
ASSERT_TRUE(ret.isOk());
|
||||
if (ret == Result::NOT_SUPPORTED) {
|
||||
doc::partialTest("setConnectedState is not supported");
|
||||
|
@ -153,9 +146,7 @@ TEST_F(AudioPrimaryHidlTest, SetConnectedState) {
|
|||
// Because there is no way of knowing if the devices were connected before
|
||||
// calling setConnectedState, there is no way to restore the HAL to its
|
||||
// initial state. To workaround this, destroy the HAL at the end of this test.
|
||||
device.clear();
|
||||
waitForDeviceDestruction();
|
||||
ASSERT_NO_FATAL_FAILURE(initPrimaryDevice());
|
||||
ASSERT_TRUE(resetDevice());
|
||||
}
|
||||
|
||||
static void testGetDevices(IStream* stream, AudioDevice expectedDevice) {
|
||||
|
@ -181,9 +172,10 @@ static void testSetDevices(IStream* stream, const DeviceAddress& address) {
|
|||
DeviceAddress otherAddress = address;
|
||||
otherAddress.device = (address.device & AudioDevice::BIT_IN) == 0 ? AudioDevice::OUT_SPEAKER
|
||||
: AudioDevice::IN_BUILTIN_MIC;
|
||||
EXPECT_OK(stream->setDevices({otherAddress}));
|
||||
EXPECT_RESULT(okOrNotSupported, stream->setDevices({otherAddress}));
|
||||
|
||||
ASSERT_OK(stream->setDevices({address})); // Go back to the original value
|
||||
ASSERT_RESULT(okOrNotSupported,
|
||||
stream->setDevices({address})); // Go back to the original value
|
||||
}
|
||||
|
||||
TEST_IO_STREAM(SetDevices, "Check that the stream can be rerouted to SPEAKER or BUILTIN_MIC",
|
||||
|
@ -199,7 +191,7 @@ static void checkGetHwAVSync(IDevice* device) {
|
|||
}
|
||||
ASSERT_OK(res);
|
||||
}
|
||||
TEST_IO_STREAM(GetHwAvSync, "Get hardware sync can not fail", checkGetHwAVSync(device.get()));
|
||||
TEST_IO_STREAM(GetHwAvSync, "Get hardware sync can not fail", checkGetHwAVSync(getDevice().get()));
|
||||
|
||||
TEST_P(InputStreamTest, updateSinkMetadata) {
|
||||
doc::test("The HAL should not crash on metadata change");
|
||||
|
@ -259,58 +251,58 @@ TEST_P(OutputStreamTest, updateSourceMetadata) {
|
|||
ASSERT_OK(stream->updateSourceMetadata(initMetadata));
|
||||
}
|
||||
|
||||
TEST_F(AudioPrimaryHidlTest, setMode) {
|
||||
TEST_P(AudioPrimaryHidlTest, setMode) {
|
||||
doc::test("Make sure setMode always succeeds if mode is valid and fails otherwise");
|
||||
// Test Invalid values
|
||||
for (int mode : {-2, -1, int(AudioMode::IN_COMMUNICATION) + 1}) {
|
||||
ASSERT_RESULT(Result::INVALID_ARGUMENTS, device->setMode(AudioMode(mode)))
|
||||
<< "mode=" << mode;
|
||||
ASSERT_RESULT(Result::INVALID_ARGUMENTS, getDevice()->setMode(AudioMode(mode)))
|
||||
<< "mode=" << mode;
|
||||
}
|
||||
// Test valid values
|
||||
for (AudioMode mode : {AudioMode::IN_CALL, AudioMode::IN_COMMUNICATION, AudioMode::RINGTONE,
|
||||
AudioMode::NORMAL /* Make sure to leave the test in normal mode */}) {
|
||||
ASSERT_OK(device->setMode(mode)) << "mode=" << toString(mode);
|
||||
ASSERT_OK(getDevice()->setMode(mode)) << "mode=" << toString(mode);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(AudioPrimaryHidlTest, setBtHfpSampleRate) {
|
||||
TEST_P(AudioPrimaryHidlTest, setBtHfpSampleRate) {
|
||||
doc::test(
|
||||
"Make sure setBtHfpSampleRate either succeeds or "
|
||||
"indicates that it is not supported at all, or that the provided value is invalid");
|
||||
for (auto samplingRate : {8000, 16000, 22050, 24000}) {
|
||||
ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, device->setBtHfpSampleRate(samplingRate));
|
||||
ASSERT_RESULT(okOrNotSupportedOrInvalidArgs, getDevice()->setBtHfpSampleRate(samplingRate));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(AudioPrimaryHidlTest, setBtHfpVolume) {
|
||||
TEST_P(AudioPrimaryHidlTest, setBtHfpVolume) {
|
||||
doc::test(
|
||||
"Make sure setBtHfpVolume is either not supported or "
|
||||
"only succeed if volume is in [0,1]");
|
||||
auto ret = device->setBtHfpVolume(0.0);
|
||||
auto ret = getDevice()->setBtHfpVolume(0.0);
|
||||
ASSERT_TRUE(ret.isOk());
|
||||
if (ret == Result::NOT_SUPPORTED) {
|
||||
doc::partialTest("setBtHfpVolume is not supported");
|
||||
return;
|
||||
}
|
||||
testUnitaryGain([](float volume) { return device->setBtHfpVolume(volume); });
|
||||
testUnitaryGain([this](float volume) { return getDevice()->setBtHfpVolume(volume); });
|
||||
}
|
||||
|
||||
TEST_F(AudioPrimaryHidlTest, setBtScoHeadsetDebugName) {
|
||||
TEST_P(AudioPrimaryHidlTest, setBtScoHeadsetDebugName) {
|
||||
doc::test(
|
||||
"Make sure setBtScoHeadsetDebugName either succeeds or "
|
||||
"indicates that it is not supported");
|
||||
ASSERT_RESULT(okOrNotSupported, device->setBtScoHeadsetDebugName("test"));
|
||||
ASSERT_RESULT(okOrNotSupported, getDevice()->setBtScoHeadsetDebugName("test"));
|
||||
}
|
||||
|
||||
TEST_F(AudioPrimaryHidlTest, updateRotation) {
|
||||
TEST_P(AudioPrimaryHidlTest, updateRotation) {
|
||||
doc::test("Check that the hal can receive the current rotation");
|
||||
for (Rotation rotation : {Rotation::DEG_0, Rotation::DEG_90, Rotation::DEG_180,
|
||||
Rotation::DEG_270, Rotation::DEG_0}) {
|
||||
ASSERT_RESULT(okOrNotSupported, device->updateRotation(rotation));
|
||||
ASSERT_RESULT(okOrNotSupported, getDevice()->updateRotation(rotation));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(BoolAccessorPrimaryHidlTest, setGetBtHfpEnabled) {
|
||||
TEST_P(BoolAccessorPrimaryHidlTest, setGetBtHfpEnabled) {
|
||||
doc::test("Query and set the BT HFP state");
|
||||
testAccessors<OPTIONAL>("BtHfpEnabled", Initial{false, OPTIONAL}, {true},
|
||||
&IPrimaryDevice::setBtHfpEnabled, &IPrimaryDevice::getBtHfpEnabled);
|
||||
|
|
|
@ -75,11 +75,18 @@ struct GetSupported {
|
|||
return res;
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 5
|
||||
static Result formats(IStream* stream, hidl_vec<AudioFormat>& capabilities) {
|
||||
EXPECT_OK(stream->getSupportedFormats(returnIn(capabilities)));
|
||||
// TODO: this should be an optional function
|
||||
return Result::OK;
|
||||
}
|
||||
#elif MAJOR_VERSION >= 6
|
||||
static Result formats(IStream* stream, hidl_vec<AudioFormat>& capabilities) {
|
||||
Result res;
|
||||
EXPECT_OK(stream->getSupportedFormats(returnIn(res, capabilities)));
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
|
|
@ -16,3 +16,131 @@
|
|||
|
||||
// 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;
|
||||
for (const auto& device : getDeviceParameters()) {
|
||||
auto module =
|
||||
getCachedPolicyConfig().getModuleFromName(std::get<PARAM_DEVICE_NAME>(device));
|
||||
for (const auto& ioProfile : module->getOutputProfiles()) {
|
||||
for (const auto& profile : ioProfile->getAudioProfiles()) {
|
||||
const auto& channels = profile->getChannels();
|
||||
const auto& sampleRates = profile->getSampleRates();
|
||||
auto configs = ConfigHelper::combineAudioConfig(
|
||||
vector<audio_channel_mask_t>(channels.begin(), channels.end()),
|
||||
vector<uint32_t>(sampleRates.begin(), sampleRates.end()),
|
||||
profile->getFormat());
|
||||
auto flags = ioProfile->getFlags();
|
||||
for (auto& config : configs) {
|
||||
// Some combinations of flags declared in the config file require special
|
||||
// treatment.
|
||||
bool special = false;
|
||||
if (flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
|
||||
config.offloadInfo.sampleRateHz = config.sampleRateHz;
|
||||
config.offloadInfo.channelMask = config.channelMask;
|
||||
config.offloadInfo.format = config.format;
|
||||
config.offloadInfo.streamType = AudioStreamType::MUSIC;
|
||||
config.offloadInfo.bitRatePerSecond = 320;
|
||||
config.offloadInfo.durationMicroseconds = -1;
|
||||
config.offloadInfo.bitWidth = 16;
|
||||
config.offloadInfo.bufferSize = 256; // arbitrary value
|
||||
config.offloadInfo.usage = AudioUsage::MEDIA;
|
||||
result.emplace_back(
|
||||
device, config,
|
||||
AudioOutputFlag(AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD));
|
||||
special = true;
|
||||
}
|
||||
if ((flags & AUDIO_OUTPUT_FLAG_DIRECT) &&
|
||||
!(flags & AUDIO_OUTPUT_FLAG_HW_AV_SYNC)) {
|
||||
result.emplace_back(device, config,
|
||||
AudioOutputFlag(AUDIO_OUTPUT_FLAG_DIRECT));
|
||||
special = true;
|
||||
}
|
||||
if (flags & AUDIO_OUTPUT_FLAG_PRIMARY) { // ignore the flag
|
||||
flags &= ~AUDIO_OUTPUT_FLAG_PRIMARY;
|
||||
}
|
||||
if (!special) {
|
||||
result.emplace_back(device, config, AudioOutputFlag(flags));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}();
|
||||
return parameters;
|
||||
}
|
||||
|
||||
const std::vector<DeviceConfigParameter>& getInputDeviceConfigParameters() {
|
||||
static std::vector<DeviceConfigParameter> parameters = [] {
|
||||
std::vector<DeviceConfigParameter> result;
|
||||
for (const auto& device : getDeviceParameters()) {
|
||||
auto module =
|
||||
getCachedPolicyConfig().getModuleFromName(std::get<PARAM_DEVICE_NAME>(device));
|
||||
for (const auto& ioProfile : module->getInputProfiles()) {
|
||||
for (const auto& profile : ioProfile->getAudioProfiles()) {
|
||||
const auto& channels = profile->getChannels();
|
||||
const auto& sampleRates = profile->getSampleRates();
|
||||
auto configs = ConfigHelper::combineAudioConfig(
|
||||
vector<audio_channel_mask_t>(channels.begin(), channels.end()),
|
||||
vector<uint32_t>(sampleRates.begin(), sampleRates.end()),
|
||||
profile->getFormat());
|
||||
for (const auto& config : configs) {
|
||||
result.emplace_back(device, config, AudioInputFlag(ioProfile->getFlags()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}();
|
||||
return parameters;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* 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_6_0_ENVIRONMENT_TEARDOWN_H
|
||||
#define ANDROID_HARDWARE_AUDIO_CORE_6_0_ENVIRONMENT_TEARDOWN_H
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "utility/EnvironmentTearDown.h"
|
||||
|
||||
class Environment : public ::android::hardware::audio::common::test::utility::EnvironmentTearDown,
|
||||
public ::testing::Environment {
|
||||
public:
|
||||
void init(int* /*argc*/, char** /*argv*/) {} // emulate VtsHalHidlTargetTestEnvBase
|
||||
private:
|
||||
void TearDown() override { executeAllTearDowns(); }
|
||||
};
|
||||
|
||||
// FIXME: Will be removed while making getDeviceParameters to use the config
|
||||
static constexpr const char* kDefaultServiceName = "default";
|
||||
|
||||
#endif // ANDROID_HARDWARE_AUDIO_CORE_6_0_ENVIRONMENT_TEARDOWN_H
|
File diff suppressed because it is too large
Load diff
120
audio/core/all-versions/vts/functional/ConfigHelper.h
Normal file
120
audio/core/all-versions/vts/functional/ConfigHelper.h
Normal file
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Code in this file uses 'getCachedPolicyConfig'
|
||||
#ifndef AUDIO_PRIMARY_HIDL_HAL_TEST
|
||||
#error Must be included from AudioPrimaryHidlTest.h
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//////////////// Required and recommended audio format support ///////////////
|
||||
// From:
|
||||
// https://source.android.com/compatibility/android-cdd.html#5_4_audio_recording
|
||||
// From:
|
||||
// https://source.android.com/compatibility/android-cdd.html#5_5_audio_playback
|
||||
/////////// TODO: move to the beginning of the file for easier update ////////
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
struct ConfigHelper {
|
||||
// for retro compatibility only test the primary device IN_BUILTIN_MIC
|
||||
// FIXME: in the next audio HAL version, test all available devices
|
||||
static bool primaryHasMic() {
|
||||
auto& policyConfig = getCachedPolicyConfig();
|
||||
if (policyConfig.getStatus() != OK || policyConfig.getPrimaryModule() == nullptr) {
|
||||
return true; // Could not get the information, run all tests
|
||||
}
|
||||
auto getMic = [](auto& devs) {
|
||||
return devs.getDevice(AUDIO_DEVICE_IN_BUILTIN_MIC, {}, AUDIO_FORMAT_DEFAULT);
|
||||
};
|
||||
auto primaryMic = getMic(policyConfig.getPrimaryModule()->getDeclaredDevices());
|
||||
auto availableMic = getMic(policyConfig.getAvailableInputDevices());
|
||||
|
||||
return primaryMic != nullptr && primaryMic->equals(availableMic);
|
||||
}
|
||||
|
||||
// Cache result ?
|
||||
static const vector<AudioConfig> getRequiredSupportPlaybackAudioConfig() {
|
||||
return combineAudioConfig({AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO},
|
||||
{8000, 11025, 16000, 22050, 32000, 44100},
|
||||
{AudioFormat::PCM_16_BIT});
|
||||
}
|
||||
|
||||
static const vector<AudioConfig> getRecommendedSupportPlaybackAudioConfig() {
|
||||
return combineAudioConfig({AudioChannelMask::OUT_STEREO, AudioChannelMask::OUT_MONO},
|
||||
{24000, 48000}, {AudioFormat::PCM_16_BIT});
|
||||
}
|
||||
|
||||
static const vector<AudioConfig> getSupportedPlaybackAudioConfig() {
|
||||
// TODO: retrieve audio config supported by the platform
|
||||
// as declared in the policy configuration
|
||||
return {};
|
||||
}
|
||||
|
||||
static const vector<AudioConfig> getRequiredSupportCaptureAudioConfig() {
|
||||
if (!primaryHasMic()) return {};
|
||||
return combineAudioConfig({AudioChannelMask::IN_MONO}, {8000, 11025, 16000, 44100},
|
||||
{AudioFormat::PCM_16_BIT});
|
||||
}
|
||||
static const vector<AudioConfig> getRecommendedSupportCaptureAudioConfig() {
|
||||
if (!primaryHasMic()) return {};
|
||||
return combineAudioConfig({AudioChannelMask::IN_STEREO}, {22050, 48000},
|
||||
{AudioFormat::PCM_16_BIT});
|
||||
}
|
||||
static const vector<AudioConfig> getSupportedCaptureAudioConfig() {
|
||||
// TODO: retrieve audio config supported by the platform
|
||||
// as declared in the policy configuration
|
||||
return {};
|
||||
}
|
||||
|
||||
static vector<AudioConfig> combineAudioConfig(vector<audio_channel_mask_t> channelMasks,
|
||||
vector<uint32_t> sampleRates,
|
||||
audio_format_t format) {
|
||||
vector<AudioConfig> configs;
|
||||
configs.reserve(channelMasks.size() * sampleRates.size());
|
||||
for (auto channelMask : channelMasks) {
|
||||
for (auto sampleRate : sampleRates) {
|
||||
AudioConfig config{};
|
||||
// leave offloadInfo to 0
|
||||
config.channelMask = EnumBitfield<AudioChannelMask>(channelMask);
|
||||
config.sampleRateHz = sampleRate;
|
||||
config.format = AudioFormat(format);
|
||||
configs.push_back(config);
|
||||
}
|
||||
}
|
||||
return configs;
|
||||
}
|
||||
|
||||
static vector<AudioConfig> combineAudioConfig(vector<AudioChannelMask> channelMasks,
|
||||
vector<uint32_t> sampleRates,
|
||||
vector<AudioFormat> formats) {
|
||||
vector<AudioConfig> configs;
|
||||
configs.reserve(channelMasks.size() * sampleRates.size() * formats.size());
|
||||
for (auto channelMask : channelMasks) {
|
||||
for (auto sampleRate : sampleRates) {
|
||||
for (auto format : formats) {
|
||||
AudioConfig config{};
|
||||
// leave offloadInfo to 0
|
||||
config.channelMask = mkEnumBitfield(channelMask);
|
||||
config.sampleRateHz = sampleRate;
|
||||
config.format = format;
|
||||
// FIXME: leave frameCount to 0 ?
|
||||
configs.push_back(config);
|
||||
}
|
||||
}
|
||||
}
|
||||
return configs;
|
||||
}
|
||||
};
|
143
audio/core/all-versions/vts/functional/DeviceManager.h
Normal file
143
audio/core/all-versions/vts/functional/DeviceManager.h
Normal file
|
@ -0,0 +1,143 @@
|
|||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// Code in this file uses 'environment'
|
||||
#ifndef AUDIO_PRIMARY_HIDL_HAL_TEST
|
||||
#error Must be included from AudioPrimaryHidlTest.h
|
||||
#endif
|
||||
|
||||
template <class Derived, class Key, class Interface>
|
||||
class InterfaceManager {
|
||||
public:
|
||||
sp<Interface> get(const Key& name) {
|
||||
auto existing = instances.find(name);
|
||||
if (existing != instances.end()) return existing->second;
|
||||
auto [inserted, _] = instances.emplace(name, Derived::createInterfaceInstance(name));
|
||||
if (inserted->second) {
|
||||
environment->registerTearDown([name]() { (void)Derived::getInstance().reset(name); });
|
||||
}
|
||||
return inserted->second;
|
||||
}
|
||||
|
||||
// The test must check that reset was successful. Reset failure means that the test code
|
||||
// is holding a strong reference to the device.
|
||||
bool reset(const Key& name) __attribute__((warn_unused_result)) {
|
||||
auto iter = instances.find(name);
|
||||
if (iter == instances.end()) return true;
|
||||
::android::wp<Interface> weak = iter->second;
|
||||
instances.erase(iter);
|
||||
if (weak.promote() != nullptr) return false;
|
||||
waitForInstanceDestruction();
|
||||
return true;
|
||||
}
|
||||
|
||||
static void waitForInstanceDestruction() {
|
||||
// FIXME: there is no way to know when the remote IDevice is being destroyed
|
||||
// Binder does not support testing if an object is alive, thus
|
||||
// wait for 100ms to let the binder destruction propagates and
|
||||
// the remote device has the time to be destroyed.
|
||||
// flushCommand makes sure all local command are sent, thus should reduce
|
||||
// the latency between local and remote destruction.
|
||||
IPCThreadState::self()->flushCommands();
|
||||
usleep(100 * 1000);
|
||||
}
|
||||
|
||||
protected:
|
||||
std::map<Key, sp<Interface>> instances;
|
||||
};
|
||||
|
||||
class DevicesFactoryManager
|
||||
: public InterfaceManager<DevicesFactoryManager, std::string, IDevicesFactory> {
|
||||
public:
|
||||
static DevicesFactoryManager& getInstance() {
|
||||
static DevicesFactoryManager instance;
|
||||
return instance;
|
||||
}
|
||||
static sp<IDevicesFactory> createInterfaceInstance(const std::string& name) {
|
||||
#if MAJOR_VERSION <= 5
|
||||
return ::testing::VtsHalHidlTargetTestBase::getService<IDevicesFactory>(name);
|
||||
#elif MAJOR_VERSION >= 6
|
||||
return IDevicesFactory::getService(name);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
using FactoryAndDevice = std::tuple<std::string, std::string>;
|
||||
class DeviceManager : public InterfaceManager<DeviceManager, FactoryAndDevice, IDevice> {
|
||||
public:
|
||||
static DeviceManager& getInstance() {
|
||||
static DeviceManager instance;
|
||||
return instance;
|
||||
}
|
||||
static sp<IDevice> createInterfaceInstance(const FactoryAndDevice& factoryAndDevice) {
|
||||
auto [factoryName, name] = factoryAndDevice;
|
||||
sp<IDevicesFactory> factory = DevicesFactoryManager::getInstance().get(factoryName);
|
||||
return name == kPrimaryDevice ? openPrimaryDevice(factory) : openDevice(factory, name);
|
||||
}
|
||||
using InterfaceManager::reset;
|
||||
|
||||
static constexpr const char* kPrimaryDevice = "primary";
|
||||
|
||||
sp<IDevice> get(const std::string& factoryName, const std::string& name) {
|
||||
return InterfaceManager::get(std::make_tuple(factoryName, name));
|
||||
}
|
||||
sp<IPrimaryDevice> getPrimary(const std::string& factoryName) {
|
||||
sp<IDevice> device = get(factoryName, kPrimaryDevice);
|
||||
return device != nullptr ? IPrimaryDevice::castFrom(device) : nullptr;
|
||||
}
|
||||
bool reset(const std::string& factoryName, const std::string& name)
|
||||
__attribute__((warn_unused_result)) {
|
||||
return InterfaceManager::reset(std::make_tuple(factoryName, name));
|
||||
}
|
||||
bool resetPrimary(const std::string& factoryName) __attribute__((warn_unused_result)) {
|
||||
return reset(factoryName, kPrimaryDevice);
|
||||
}
|
||||
|
||||
private:
|
||||
static sp<IDevice> openDevice(const sp<IDevicesFactory>& factory, const std::string& name) {
|
||||
if (factory == nullptr) return nullptr;
|
||||
sp<IDevice> device;
|
||||
#if MAJOR_VERSION >= 4
|
||||
Result result;
|
||||
auto ret = factory->openDevice(name, returnIn(result, device));
|
||||
if (!ret.isOk() || result != Result::OK || device == nullptr) {
|
||||
ALOGW("Device %s can not be opened, transaction: %s, result %d, device %p",
|
||||
name.c_str(), ret.description().c_str(), result, device.get());
|
||||
return nullptr;
|
||||
}
|
||||
#else
|
||||
(void)name;
|
||||
#endif
|
||||
return device;
|
||||
}
|
||||
|
||||
static sp<IDevice> openPrimaryDevice(const sp<IDevicesFactory>& factory) {
|
||||
if (factory == nullptr) return nullptr;
|
||||
Result result;
|
||||
sp<IDevice> device;
|
||||
#if MAJOR_VERSION == 2
|
||||
auto ret = factory->openDevice(IDevicesFactory::Device::PRIMARY, returnIn(result, device));
|
||||
#elif MAJOR_VERSION >= 4
|
||||
auto ret = factory->openPrimaryDevice(returnIn(result, device));
|
||||
#endif
|
||||
if (!ret.isOk() || result != Result::OK || device == nullptr) {
|
||||
ALOGW("Primary device can not be opened, transaction: %s, result %d, device %p",
|
||||
ret.description().c_str(), result, device.get());
|
||||
return nullptr;
|
||||
}
|
||||
return device;
|
||||
}
|
||||
};
|
|
@ -28,8 +28,14 @@
|
|||
|
||||
#include <common/all-versions/VersionUtils.h>
|
||||
|
||||
#if MAJOR_VERSION <= 5
|
||||
#include <VtsHalHidlTargetTestBase.h>
|
||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
||||
#elif MAJOR_VERSION >= 6
|
||||
#include <gtest/gtest.h>
|
||||
#include <hidl/GtestPrinter.h>
|
||||
#include <hidl/ServiceManagement.h>
|
||||
#endif
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::hardware::hidl_handle;
|
||||
|
@ -49,6 +55,11 @@ using namespace ::android::hardware::audio::effect::CPP_VERSION;
|
|||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(*(a)))
|
||||
#endif
|
||||
|
||||
#if MAJOR_VERSION <= 5
|
||||
// For HAL versions 2..5 Vts Environment and Test base classes are used.
|
||||
// The tests are non-parametrized.
|
||||
#define EFFECT_TEST TEST_F
|
||||
|
||||
// Test environment for Audio Effects Factory HIDL HAL.
|
||||
class AudioEffectsFactoryHidlEnvironment : public ::testing::VtsHalHidlTargetTestEnvBase {
|
||||
public:
|
||||
|
@ -71,6 +82,18 @@ class AudioEffectsFactoryHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
|||
ASSERT_NE(effectsFactory, nullptr);
|
||||
}
|
||||
|
||||
#elif MAJOR_VERSION >= 6
|
||||
// For HAL version 6 and above, standard GTest Environment and Test base classes are used.
|
||||
// The tests are parametrized by the IEffectsFactory instance name.
|
||||
#define EFFECT_TEST TEST_P
|
||||
|
||||
class AudioEffectsFactoryHidlTest : public ::testing::TestWithParam<std::string> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
effectsFactory = IEffectsFactory::getService(GetParam());
|
||||
ASSERT_NE(effectsFactory, nullptr);
|
||||
}
|
||||
#endif // The rest of the AudioEffectsFactoryHidlTest class definition is the same.
|
||||
void TearDown() override { effectsFactory.clear(); }
|
||||
|
||||
protected:
|
||||
|
@ -81,7 +104,7 @@ class AudioEffectsFactoryHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
|||
sp<IEffectsFactory> effectsFactory;
|
||||
};
|
||||
|
||||
TEST_F(AudioEffectsFactoryHidlTest, EnumerateEffects) {
|
||||
EFFECT_TEST(AudioEffectsFactoryHidlTest, EnumerateEffects) {
|
||||
description("Verify that EnumerateEffects returns at least one effect");
|
||||
Result retval = Result::NOT_INITIALIZED;
|
||||
size_t effectCount = 0;
|
||||
|
@ -95,7 +118,7 @@ TEST_F(AudioEffectsFactoryHidlTest, EnumerateEffects) {
|
|||
EXPECT_GT(effectCount, 0u);
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectsFactoryHidlTest, CreateEffect) {
|
||||
EFFECT_TEST(AudioEffectsFactoryHidlTest, CreateEffect) {
|
||||
description("Verify that an effect can be created via CreateEffect");
|
||||
bool gotEffect = false;
|
||||
Uuid effectUuid;
|
||||
|
@ -123,7 +146,7 @@ TEST_F(AudioEffectsFactoryHidlTest, CreateEffect) {
|
|||
EXPECT_NE(nullptr, effect.get());
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectsFactoryHidlTest, GetDescriptor) {
|
||||
EFFECT_TEST(AudioEffectsFactoryHidlTest, GetDescriptor) {
|
||||
description(
|
||||
"Verify that effects factory can provide an effect descriptor via "
|
||||
"GetDescriptor");
|
||||
|
@ -146,7 +169,7 @@ TEST_F(AudioEffectsFactoryHidlTest, GetDescriptor) {
|
|||
EXPECT_TRUE(ret.isOk());
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectsFactoryHidlTest, DebugDumpInvalidArgument) {
|
||||
EFFECT_TEST(AudioEffectsFactoryHidlTest, DebugDumpInvalidArgument) {
|
||||
description("Verify that debugDump doesn't crash on invalid arguments");
|
||||
#if MAJOR_VERSION == 2
|
||||
Return<void> ret = effectsFactory->debugDump(hidl_handle());
|
||||
|
@ -168,10 +191,17 @@ static const Uuid LOUDNESS_ENHANCER_EFFECT_TYPE = {
|
|||
std::array<uint8_t, 6>{{0x11, 0x26, 0x0e, 0xb6, 0x3c, 0xf1}}};
|
||||
|
||||
// The main test class for Audio Effect HIDL HAL.
|
||||
#if MAJOR_VERSION <= 5
|
||||
class AudioEffectHidlTest : public ::testing::VtsHalHidlTargetTestBase {
|
||||
public:
|
||||
void SetUp() override {
|
||||
effectsFactory = ::testing::VtsHalHidlTargetTestBase::getService<IEffectsFactory>();
|
||||
#elif MAJOR_VERSION >= 6
|
||||
class AudioEffectHidlTest : public ::testing::TestWithParam<std::string> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
effectsFactory = IEffectsFactory::getService(GetParam());
|
||||
#endif
|
||||
ASSERT_NE(nullptr, effectsFactory.get());
|
||||
|
||||
findAndCreateEffect(getEffectType());
|
||||
|
@ -250,14 +280,14 @@ void AudioEffectHidlTest::getChannelCount(uint32_t* channelCount) {
|
|||
static_cast<audio_channel_mask_t>(currentConfig.outputCfg.channels));
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, Close) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, Close) {
|
||||
description("Verify that an effect can be closed");
|
||||
Return<Result> ret = effect->close();
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
EXPECT_EQ(Result::OK, ret);
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, GetDescriptor) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, GetDescriptor) {
|
||||
description("Verify that an effect can return its own descriptor via GetDescriptor");
|
||||
Result retval = Result::NOT_INITIALIZED;
|
||||
Uuid actualType;
|
||||
|
@ -272,7 +302,7 @@ TEST_F(AudioEffectHidlTest, GetDescriptor) {
|
|||
EXPECT_EQ(getEffectType(), actualType);
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, GetSetConfig) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, GetSetConfig) {
|
||||
description(
|
||||
"Verify that it is possible to manipulate effect config via Get / "
|
||||
"SetConfig");
|
||||
|
@ -291,26 +321,26 @@ TEST_F(AudioEffectHidlTest, GetSetConfig) {
|
|||
EXPECT_EQ(Result::OK, ret2);
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, GetConfigReverse) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, GetConfigReverse) {
|
||||
description("Verify that GetConfigReverse does not crash");
|
||||
Return<void> ret = effect->getConfigReverse([&](Result, const EffectConfig&) {});
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, GetSupportedAuxChannelsConfigs) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, GetSupportedAuxChannelsConfigs) {
|
||||
description("Verify that GetSupportedAuxChannelsConfigs does not crash");
|
||||
Return<void> ret = effect->getSupportedAuxChannelsConfigs(
|
||||
0, [&](Result, const hidl_vec<EffectAuxChannelsConfig>&) {});
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, GetAuxChannelsConfig) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, GetAuxChannelsConfig) {
|
||||
description("Verify that GetAuxChannelsConfig does not crash");
|
||||
Return<void> ret = effect->getAuxChannelsConfig([&](Result, const EffectAuxChannelsConfig&) {});
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, SetAuxChannelsConfig) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, SetAuxChannelsConfig) {
|
||||
description("Verify that SetAuxChannelsConfig does not crash");
|
||||
Return<Result> ret = effect->setAuxChannelsConfig(EffectAuxChannelsConfig());
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
|
@ -349,7 +379,7 @@ inline bool operator==(const EffectConfig& lhs, const EffectConfig& rhs) {
|
|||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
TEST_F(AudioEffectHidlTest, Reset) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, Reset) {
|
||||
description("Verify that Reset preserves effect configuration");
|
||||
Result retval = Result::NOT_INITIALIZED;
|
||||
EffectConfig originalConfig;
|
||||
|
@ -374,7 +404,7 @@ TEST_F(AudioEffectHidlTest, Reset) {
|
|||
EXPECT_EQ(originalConfig, configAfterReset);
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, DisableEnableDisable) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, DisableEnableDisable) {
|
||||
description("Verify Disable -> Enable -> Disable sequence for an effect");
|
||||
Return<Result> ret = effect->disable();
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
|
@ -387,14 +417,14 @@ TEST_F(AudioEffectHidlTest, DisableEnableDisable) {
|
|||
EXPECT_EQ(Result::OK, ret);
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, SetDevice) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, SetDevice) {
|
||||
description("Verify that SetDevice works for an output chain effect");
|
||||
Return<Result> ret = effect->setDevice(mkEnumBitfield(AudioDevice::OUT_SPEAKER));
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
EXPECT_EQ(Result::OK, ret);
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, SetAndGetVolume) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, SetAndGetVolume) {
|
||||
description("Verify that SetAndGetVolume method works for an effect");
|
||||
uint32_t channelCount;
|
||||
getChannelCount(&channelCount);
|
||||
|
@ -410,7 +440,7 @@ TEST_F(AudioEffectHidlTest, SetAndGetVolume) {
|
|||
EXPECT_EQ(Result::OK, retval);
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, VolumeChangeNotification) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, VolumeChangeNotification) {
|
||||
description("Verify that effect accepts VolumeChangeNotification");
|
||||
uint32_t channelCount;
|
||||
getChannelCount(&channelCount);
|
||||
|
@ -424,32 +454,32 @@ TEST_F(AudioEffectHidlTest, VolumeChangeNotification) {
|
|||
EXPECT_EQ(Result::OK, ret);
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, SetAudioMode) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, SetAudioMode) {
|
||||
description("Verify that SetAudioMode works for an effect");
|
||||
Return<Result> ret = effect->setAudioMode(AudioMode::NORMAL);
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
EXPECT_EQ(Result::OK, ret);
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, SetConfigReverse) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, SetConfigReverse) {
|
||||
description("Verify that SetConfigReverse does not crash");
|
||||
Return<Result> ret = effect->setConfigReverse(EffectConfig(), nullptr, nullptr);
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, SetInputDevice) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, SetInputDevice) {
|
||||
description("Verify that SetInputDevice does not crash");
|
||||
Return<Result> ret = effect->setInputDevice(mkEnumBitfield(AudioDevice::IN_BUILTIN_MIC));
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, SetAudioSource) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, SetAudioSource) {
|
||||
description("Verify that SetAudioSource does not crash");
|
||||
Return<Result> ret = effect->setAudioSource(AudioSource::MIC);
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, Offload) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, Offload) {
|
||||
description("Verify that calling Offload method does not crash");
|
||||
EffectOffloadParameter offloadParam;
|
||||
offloadParam.isOffload = false;
|
||||
|
@ -458,7 +488,7 @@ TEST_F(AudioEffectHidlTest, Offload) {
|
|||
EXPECT_TRUE(ret.isOk());
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, PrepareForProcessing) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, PrepareForProcessing) {
|
||||
description("Verify that PrepareForProcessing method works for an effect");
|
||||
Result retval = Result::NOT_INITIALIZED;
|
||||
Return<void> ret = effect->prepareForProcessing(
|
||||
|
@ -467,7 +497,7 @@ TEST_F(AudioEffectHidlTest, PrepareForProcessing) {
|
|||
EXPECT_EQ(Result::OK, retval);
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, SetProcessBuffers) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, SetProcessBuffers) {
|
||||
description("Verify that SetProcessBuffers works for an effect");
|
||||
sp<IAllocator> ashmem = IAllocator::getService("ashmem");
|
||||
ASSERT_NE(nullptr, ashmem.get());
|
||||
|
@ -486,41 +516,41 @@ TEST_F(AudioEffectHidlTest, SetProcessBuffers) {
|
|||
EXPECT_EQ(Result::OK, ret2);
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, Command) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, Command) {
|
||||
description("Verify that Command does not crash");
|
||||
Return<void> ret =
|
||||
effect->command(0, hidl_vec<uint8_t>(), 0, [&](int32_t, const hidl_vec<uint8_t>&) {});
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, SetParameter) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, SetParameter) {
|
||||
description("Verify that SetParameter does not crash");
|
||||
Return<Result> ret = effect->setParameter(hidl_vec<uint8_t>(), hidl_vec<uint8_t>());
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, GetParameter) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, GetParameter) {
|
||||
description("Verify that GetParameter does not crash");
|
||||
Return<void> ret =
|
||||
effect->getParameter(hidl_vec<uint8_t>(), 0, [&](Result, const hidl_vec<uint8_t>&) {});
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, GetSupportedConfigsForFeature) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, GetSupportedConfigsForFeature) {
|
||||
description("Verify that GetSupportedConfigsForFeature does not crash");
|
||||
Return<void> ret = effect->getSupportedConfigsForFeature(
|
||||
0, 0, 0, [&](Result, uint32_t, const hidl_vec<uint8_t>&) {});
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, GetCurrentConfigForFeature) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, GetCurrentConfigForFeature) {
|
||||
description("Verify that GetCurrentConfigForFeature does not crash");
|
||||
Return<void> ret =
|
||||
effect->getCurrentConfigForFeature(0, 0, [&](Result, const hidl_vec<uint8_t>&) {});
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
}
|
||||
|
||||
TEST_F(AudioEffectHidlTest, SetCurrentConfigForFeature) {
|
||||
EFFECT_TEST(AudioEffectHidlTest, SetCurrentConfigForFeature) {
|
||||
description("Verify that SetCurrentConfigForFeature does not crash");
|
||||
Return<Result> ret = effect->setCurrentConfigForFeature(0, hidl_vec<uint8_t>());
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
|
@ -606,21 +636,21 @@ void EqualizerAudioEffectHidlTest::getPresetCount(size_t* count) {
|
|||
ASSERT_EQ(Result::OK, retval);
|
||||
}
|
||||
|
||||
TEST_F(EqualizerAudioEffectHidlTest, GetNumBands) {
|
||||
EFFECT_TEST(EqualizerAudioEffectHidlTest, GetNumBands) {
|
||||
description("Verify that Equalizer effect reports at least one band");
|
||||
uint16_t numBands = 0;
|
||||
getNumBands(&numBands);
|
||||
EXPECT_GT(numBands, 0);
|
||||
}
|
||||
|
||||
TEST_F(EqualizerAudioEffectHidlTest, GetLevelRange) {
|
||||
EFFECT_TEST(EqualizerAudioEffectHidlTest, GetLevelRange) {
|
||||
description("Verify that Equalizer effect reports adequate band level range");
|
||||
int16_t minLevel = 0x7fff, maxLevel = 0;
|
||||
getLevelRange(&minLevel, &maxLevel);
|
||||
EXPECT_GT(maxLevel, minLevel);
|
||||
}
|
||||
|
||||
TEST_F(EqualizerAudioEffectHidlTest, GetSetBandLevel) {
|
||||
EFFECT_TEST(EqualizerAudioEffectHidlTest, GetSetBandLevel) {
|
||||
description("Verify that manipulating band levels works for Equalizer effect");
|
||||
uint16_t numBands = 0;
|
||||
getNumBands(&numBands);
|
||||
|
@ -649,7 +679,7 @@ TEST_F(EqualizerAudioEffectHidlTest, GetSetBandLevel) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(EqualizerAudioEffectHidlTest, GetBandCenterFrequencyAndRange) {
|
||||
EFFECT_TEST(EqualizerAudioEffectHidlTest, GetBandCenterFrequencyAndRange) {
|
||||
description("Verify that Equalizer effect reports adequate band frequency range");
|
||||
uint16_t numBands = 0;
|
||||
getNumBands(&numBands);
|
||||
|
@ -664,7 +694,7 @@ TEST_F(EqualizerAudioEffectHidlTest, GetBandCenterFrequencyAndRange) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(EqualizerAudioEffectHidlTest, GetBandForFrequency) {
|
||||
EFFECT_TEST(EqualizerAudioEffectHidlTest, GetBandForFrequency) {
|
||||
description("Verify that Equalizer effect supports GetBandForFrequency correctly");
|
||||
uint16_t numBands = 0;
|
||||
getNumBands(&numBands);
|
||||
|
@ -693,14 +723,14 @@ TEST_F(EqualizerAudioEffectHidlTest, GetBandForFrequency) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(EqualizerAudioEffectHidlTest, GetPresetNames) {
|
||||
EFFECT_TEST(EqualizerAudioEffectHidlTest, GetPresetNames) {
|
||||
description("Verify that Equalizer effect reports at least one preset");
|
||||
size_t presetCount;
|
||||
getPresetCount(&presetCount);
|
||||
EXPECT_GT(presetCount, 0u);
|
||||
}
|
||||
|
||||
TEST_F(EqualizerAudioEffectHidlTest, GetSetCurrentPreset) {
|
||||
EFFECT_TEST(EqualizerAudioEffectHidlTest, GetSetCurrentPreset) {
|
||||
description("Verify that manipulating the current preset for Equalizer effect");
|
||||
size_t presetCount;
|
||||
getPresetCount(&presetCount);
|
||||
|
@ -723,7 +753,7 @@ TEST_F(EqualizerAudioEffectHidlTest, GetSetCurrentPreset) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_F(EqualizerAudioEffectHidlTest, GetSetAllProperties) {
|
||||
EFFECT_TEST(EqualizerAudioEffectHidlTest, GetSetAllProperties) {
|
||||
description(
|
||||
"Verify that setting band levels and presets works via Get / "
|
||||
"SetAllProperties for Equalizer effect");
|
||||
|
@ -787,7 +817,7 @@ class LoudnessEnhancerAudioEffectHidlTest : public AudioEffectHidlTest {
|
|||
sp<ILoudnessEnhancerEffect> enhancer;
|
||||
};
|
||||
|
||||
TEST_F(LoudnessEnhancerAudioEffectHidlTest, GetSetTargetGain) {
|
||||
EFFECT_TEST(LoudnessEnhancerAudioEffectHidlTest, GetSetTargetGain) {
|
||||
description(
|
||||
"Verify that manipulating the target gain works for Loudness Enhancer "
|
||||
"effect");
|
||||
|
@ -808,6 +838,7 @@ TEST_F(LoudnessEnhancerAudioEffectHidlTest, GetSetTargetGain) {
|
|||
EXPECT_EQ(gain, actualGain);
|
||||
}
|
||||
|
||||
#if MAJOR_VERSION <= 5
|
||||
int main(int argc, char** argv) {
|
||||
::testing::AddGlobalTestEnvironment(AudioEffectsFactoryHidlEnvironment::Instance());
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
|
@ -816,3 +847,17 @@ int main(int argc, char** argv) {
|
|||
LOG(INFO) << "Test result = " << status;
|
||||
return status;
|
||||
}
|
||||
#elif MAJOR_VERSION >= 6
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
EffectsFactory, AudioEffectsFactoryHidlTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IEffectsFactory::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Equalizer, EqualizerAudioEffectHidlTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IEffectsFactory::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
LoudnessEnhancer, LoudnessEnhancerAudioEffectHidlTest,
|
||||
testing::ValuesIn(android::hardware::getAllHalInstanceNames(IEffectsFactory::descriptor)),
|
||||
android::hardware::PrintInstanceNameToString);
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue