mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "Convert VtsHalBluetoothAudioV2_0TargetTest to be parameterized test"
This commit is contained in:
@@ -9,4 +9,5 @@ cc_test {
|
|||||||
shared_libs: [
|
shared_libs: [
|
||||||
"libfmq",
|
"libfmq",
|
||||||
],
|
],
|
||||||
|
test_suites: ["general-tests", "vts-core"],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,12 +21,13 @@
|
|||||||
#include <android/hardware/bluetooth/audio/2.0/IBluetoothAudioProvider.h>
|
#include <android/hardware/bluetooth/audio/2.0/IBluetoothAudioProvider.h>
|
||||||
#include <android/hardware/bluetooth/audio/2.0/IBluetoothAudioProvidersFactory.h>
|
#include <android/hardware/bluetooth/audio/2.0/IBluetoothAudioProvidersFactory.h>
|
||||||
#include <fmq/MessageQueue.h>
|
#include <fmq/MessageQueue.h>
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <hidl/GtestPrinter.h>
|
||||||
#include <hidl/MQDescriptor.h>
|
#include <hidl/MQDescriptor.h>
|
||||||
|
#include <hidl/ServiceManagement.h>
|
||||||
#include <utils/Log.h>
|
#include <utils/Log.h>
|
||||||
|
|
||||||
#include <VtsHalHidlTargetCallbackBase.h>
|
#include <VtsHalHidlTargetCallbackBase.h>
|
||||||
#include <VtsHalHidlTargetTestBase.h>
|
|
||||||
#include <VtsHalHidlTargetTestEnvBase.h>
|
|
||||||
|
|
||||||
using ::android::sp;
|
using ::android::sp;
|
||||||
using ::android::hardware::hidl_vec;
|
using ::android::hardware::hidl_vec;
|
||||||
@@ -105,34 +106,13 @@ std::vector<T> ExtractValuesFromBitmask(T bitmasks, uint32_t bitfield,
|
|||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
// Test environment for Bluetooth Audio HAL.
|
|
||||||
class BluetoothAudioHidlEnvironment
|
|
||||||
: public ::testing::VtsHalHidlTargetTestEnvBase {
|
|
||||||
public:
|
|
||||||
// get the test environment singleton
|
|
||||||
static BluetoothAudioHidlEnvironment* Instance() {
|
|
||||||
static BluetoothAudioHidlEnvironment* instance =
|
|
||||||
new BluetoothAudioHidlEnvironment;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual void registerTestServices() override {
|
|
||||||
registerTestService<IBluetoothAudioProvidersFactory>();
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
BluetoothAudioHidlEnvironment() {}
|
|
||||||
};
|
|
||||||
|
|
||||||
// The base test class for Bluetooth Audio HAL.
|
// The base test class for Bluetooth Audio HAL.
|
||||||
class BluetoothAudioProvidersFactoryHidlTest
|
class BluetoothAudioProvidersFactoryHidlTest
|
||||||
: public ::testing::VtsHalHidlTargetTestBase {
|
: public ::testing::TestWithParam<std::string> {
|
||||||
public:
|
public:
|
||||||
virtual void SetUp() override {
|
virtual void SetUp() override {
|
||||||
providers_factory_ = ::testing::VtsHalHidlTargetTestBase::getService<
|
providers_factory_ =
|
||||||
IBluetoothAudioProvidersFactory>(
|
IBluetoothAudioProvidersFactory::getService(GetParam());
|
||||||
BluetoothAudioHidlEnvironment::Instance()
|
|
||||||
->getServiceName<IBluetoothAudioProvidersFactory>());
|
|
||||||
ASSERT_NE(providers_factory_, nullptr);
|
ASSERT_NE(providers_factory_, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -300,13 +280,13 @@ class BluetoothAudioProvidersFactoryHidlTest
|
|||||||
/**
|
/**
|
||||||
* Test whether we can get the FactoryService from HIDL
|
* Test whether we can get the FactoryService from HIDL
|
||||||
*/
|
*/
|
||||||
TEST_F(BluetoothAudioProvidersFactoryHidlTest, GetProvidersFactoryService) {}
|
TEST_P(BluetoothAudioProvidersFactoryHidlTest, GetProvidersFactoryService) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether we can open a provider for each provider returned by
|
* Test whether we can open a provider for each provider returned by
|
||||||
* getProviderCapabilities() with non-empty capabalities
|
* getProviderCapabilities() with non-empty capabalities
|
||||||
*/
|
*/
|
||||||
TEST_F(BluetoothAudioProvidersFactoryHidlTest,
|
TEST_P(BluetoothAudioProvidersFactoryHidlTest,
|
||||||
OpenProviderAndCheckCapabilitiesBySession) {
|
OpenProviderAndCheckCapabilitiesBySession) {
|
||||||
for (auto session_type : session_types_) {
|
for (auto session_type : session_types_) {
|
||||||
GetProviderCapabilitiesHelper(session_type);
|
GetProviderCapabilitiesHelper(session_type);
|
||||||
@@ -341,14 +321,14 @@ class BluetoothAudioProviderA2dpSoftwareHidlTest
|
|||||||
/**
|
/**
|
||||||
* Test whether we can open a provider of type
|
* Test whether we can open a provider of type
|
||||||
*/
|
*/
|
||||||
TEST_F(BluetoothAudioProviderA2dpSoftwareHidlTest, OpenA2dpSoftwareProvider) {}
|
TEST_P(BluetoothAudioProviderA2dpSoftwareHidlTest, OpenA2dpSoftwareProvider) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether each provider of type
|
* Test whether each provider of type
|
||||||
* SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH can be started and stopped with
|
* SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH can be started and stopped with
|
||||||
* different PCM config
|
* different PCM config
|
||||||
*/
|
*/
|
||||||
TEST_F(BluetoothAudioProviderA2dpSoftwareHidlTest,
|
TEST_P(BluetoothAudioProviderA2dpSoftwareHidlTest,
|
||||||
StartAndEndA2dpSoftwareSessionWithPossiblePcmConfig) {
|
StartAndEndA2dpSoftwareSessionWithPossiblePcmConfig) {
|
||||||
bool is_codec_config_valid;
|
bool is_codec_config_valid;
|
||||||
std::unique_ptr<DataMQ> tempDataMQ;
|
std::unique_ptr<DataMQ> tempDataMQ;
|
||||||
@@ -616,14 +596,14 @@ class BluetoothAudioProviderA2dpHardwareHidlTest
|
|||||||
/**
|
/**
|
||||||
* Test whether we can open a provider of type
|
* Test whether we can open a provider of type
|
||||||
*/
|
*/
|
||||||
TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest, OpenA2dpHardwareProvider) {}
|
TEST_P(BluetoothAudioProviderA2dpHardwareHidlTest, OpenA2dpHardwareProvider) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test whether each provider of type
|
* Test whether each provider of type
|
||||||
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
|
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
|
||||||
* SBC hardware encoding config
|
* SBC hardware encoding config
|
||||||
*/
|
*/
|
||||||
TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest,
|
TEST_P(BluetoothAudioProviderA2dpHardwareHidlTest,
|
||||||
StartAndEndA2dpSbcHardwareSession) {
|
StartAndEndA2dpSbcHardwareSession) {
|
||||||
if (!IsOffloadSupported()) {
|
if (!IsOffloadSupported()) {
|
||||||
return;
|
return;
|
||||||
@@ -658,7 +638,7 @@ TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest,
|
|||||||
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
|
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
|
||||||
* AAC hardware encoding config
|
* AAC hardware encoding config
|
||||||
*/
|
*/
|
||||||
TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest,
|
TEST_P(BluetoothAudioProviderA2dpHardwareHidlTest,
|
||||||
StartAndEndA2dpAacHardwareSession) {
|
StartAndEndA2dpAacHardwareSession) {
|
||||||
if (!IsOffloadSupported()) {
|
if (!IsOffloadSupported()) {
|
||||||
return;
|
return;
|
||||||
@@ -693,7 +673,7 @@ TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest,
|
|||||||
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
|
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
|
||||||
* LDAC hardware encoding config
|
* LDAC hardware encoding config
|
||||||
*/
|
*/
|
||||||
TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest,
|
TEST_P(BluetoothAudioProviderA2dpHardwareHidlTest,
|
||||||
StartAndEndA2dpLdacHardwareSession) {
|
StartAndEndA2dpLdacHardwareSession) {
|
||||||
if (!IsOffloadSupported()) {
|
if (!IsOffloadSupported()) {
|
||||||
return;
|
return;
|
||||||
@@ -728,7 +708,7 @@ TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest,
|
|||||||
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
|
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
|
||||||
* AptX hardware encoding config
|
* AptX hardware encoding config
|
||||||
*/
|
*/
|
||||||
TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest,
|
TEST_P(BluetoothAudioProviderA2dpHardwareHidlTest,
|
||||||
StartAndEndA2dpAptxHardwareSession) {
|
StartAndEndA2dpAptxHardwareSession) {
|
||||||
if (!IsOffloadSupported()) {
|
if (!IsOffloadSupported()) {
|
||||||
return;
|
return;
|
||||||
@@ -767,7 +747,7 @@ TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest,
|
|||||||
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
|
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
|
||||||
* an invalid codec config
|
* an invalid codec config
|
||||||
*/
|
*/
|
||||||
TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest,
|
TEST_P(BluetoothAudioProviderA2dpHardwareHidlTest,
|
||||||
StartAndEndA2dpHardwareSessionInvalidCodecConfig) {
|
StartAndEndA2dpHardwareSessionInvalidCodecConfig) {
|
||||||
if (!IsOffloadSupported()) {
|
if (!IsOffloadSupported()) {
|
||||||
return;
|
return;
|
||||||
@@ -857,7 +837,7 @@ class BluetoothAudioProviderHearingAidSoftwareHidlTest
|
|||||||
* SessionType::HEARING_AID_HARDWARE_ENCODING_DATAPATH can be started and
|
* SessionType::HEARING_AID_HARDWARE_ENCODING_DATAPATH can be started and
|
||||||
* stopped with SBC hardware encoding config
|
* stopped with SBC hardware encoding config
|
||||||
*/
|
*/
|
||||||
TEST_F(BluetoothAudioProviderHearingAidSoftwareHidlTest,
|
TEST_P(BluetoothAudioProviderHearingAidSoftwareHidlTest,
|
||||||
OpenHearingAidSoftwareProvider) {}
|
OpenHearingAidSoftwareProvider) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -865,7 +845,7 @@ TEST_F(BluetoothAudioProviderHearingAidSoftwareHidlTest,
|
|||||||
* SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH can be started and
|
* SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH can be started and
|
||||||
* stopped with different PCM config
|
* stopped with different PCM config
|
||||||
*/
|
*/
|
||||||
TEST_F(BluetoothAudioProviderHearingAidSoftwareHidlTest,
|
TEST_P(BluetoothAudioProviderHearingAidSoftwareHidlTest,
|
||||||
StartAndEndHearingAidSessionWithPossiblePcmConfig) {
|
StartAndEndHearingAidSessionWithPossiblePcmConfig) {
|
||||||
bool is_codec_config_valid;
|
bool is_codec_config_valid;
|
||||||
std::unique_ptr<DataMQ> tempDataMQ;
|
std::unique_ptr<DataMQ> tempDataMQ;
|
||||||
@@ -904,12 +884,25 @@ TEST_F(BluetoothAudioProviderHearingAidSoftwareHidlTest,
|
|||||||
} // SampleRate
|
} // SampleRate
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
static const std::vector<std::string> kAudioInstances =
|
||||||
::testing::AddGlobalTestEnvironment(
|
android::hardware::getAllHalInstanceNames(
|
||||||
BluetoothAudioHidlEnvironment::Instance());
|
IBluetoothAudioProvidersFactory::descriptor);
|
||||||
::testing::InitGoogleTest(&argc, argv);
|
|
||||||
BluetoothAudioHidlEnvironment::Instance()->init(&argc, argv);
|
INSTANTIATE_TEST_SUITE_P(PerInstance, BluetoothAudioProvidersFactoryHidlTest,
|
||||||
int status = RUN_ALL_TESTS();
|
testing::ValuesIn(kAudioInstances),
|
||||||
LOG(INFO) << "Test result = " << status;
|
android::hardware::PrintInstanceNameToString);
|
||||||
return status;
|
|
||||||
}
|
INSTANTIATE_TEST_SUITE_P(PerInstance,
|
||||||
|
BluetoothAudioProviderA2dpSoftwareHidlTest,
|
||||||
|
testing::ValuesIn(kAudioInstances),
|
||||||
|
android::hardware::PrintInstanceNameToString);
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(PerInstance,
|
||||||
|
BluetoothAudioProviderA2dpHardwareHidlTest,
|
||||||
|
testing::ValuesIn(kAudioInstances),
|
||||||
|
android::hardware::PrintInstanceNameToString);
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_SUITE_P(PerInstance,
|
||||||
|
BluetoothAudioProviderHearingAidSoftwareHidlTest,
|
||||||
|
testing::ValuesIn(kAudioInstances),
|
||||||
|
android::hardware::PrintInstanceNameToString);
|
||||||
Reference in New Issue
Block a user