Convert VtsHalBluetoothAudioV2_0TargetTest to be parameterized test
Bug: 142397658
Test: atest VtsHalBluetoothAudioV2_0TargetTest
Change-Id: I024abca2330ffb1fab709c97b01896ce9decba76
diff --git a/bluetooth/audio/2.0/vts/functional/Android.bp b/bluetooth/audio/2.0/vts/functional/Android.bp
index b672fe4..b778b97 100644
--- a/bluetooth/audio/2.0/vts/functional/Android.bp
+++ b/bluetooth/audio/2.0/vts/functional/Android.bp
@@ -9,4 +9,5 @@
shared_libs: [
"libfmq",
],
+ test_suites: ["general-tests", "vts-core"],
}
diff --git a/bluetooth/audio/2.0/vts/functional/VtsHalBluetoothAudioV2_0TargetTest.cpp b/bluetooth/audio/2.0/vts/functional/VtsHalBluetoothAudioV2_0TargetTest.cpp
index 9572d3f..b3cb6f7 100644
--- a/bluetooth/audio/2.0/vts/functional/VtsHalBluetoothAudioV2_0TargetTest.cpp
+++ b/bluetooth/audio/2.0/vts/functional/VtsHalBluetoothAudioV2_0TargetTest.cpp
@@ -21,12 +21,13 @@
#include <android/hardware/bluetooth/audio/2.0/IBluetoothAudioProvider.h>
#include <android/hardware/bluetooth/audio/2.0/IBluetoothAudioProvidersFactory.h>
#include <fmq/MessageQueue.h>
+#include <gtest/gtest.h>
+#include <hidl/GtestPrinter.h>
#include <hidl/MQDescriptor.h>
+#include <hidl/ServiceManagement.h>
#include <utils/Log.h>
#include <VtsHalHidlTargetCallbackBase.h>
-#include <VtsHalHidlTargetTestBase.h>
-#include <VtsHalHidlTargetTestEnvBase.h>
using ::android::sp;
using ::android::hardware::hidl_vec;
@@ -105,34 +106,13 @@
}
} // 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.
class BluetoothAudioProvidersFactoryHidlTest
- : public ::testing::VtsHalHidlTargetTestBase {
+ : public ::testing::TestWithParam<std::string> {
public:
virtual void SetUp() override {
- providers_factory_ = ::testing::VtsHalHidlTargetTestBase::getService<
- IBluetoothAudioProvidersFactory>(
- BluetoothAudioHidlEnvironment::Instance()
- ->getServiceName<IBluetoothAudioProvidersFactory>());
+ providers_factory_ =
+ IBluetoothAudioProvidersFactory::getService(GetParam());
ASSERT_NE(providers_factory_, nullptr);
}
@@ -300,13 +280,13 @@
/**
* 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
* getProviderCapabilities() with non-empty capabalities
*/
-TEST_F(BluetoothAudioProvidersFactoryHidlTest,
+TEST_P(BluetoothAudioProvidersFactoryHidlTest,
OpenProviderAndCheckCapabilitiesBySession) {
for (auto session_type : session_types_) {
GetProviderCapabilitiesHelper(session_type);
@@ -341,14 +321,14 @@
/**
* Test whether we can open a provider of type
*/
-TEST_F(BluetoothAudioProviderA2dpSoftwareHidlTest, OpenA2dpSoftwareProvider) {}
+TEST_P(BluetoothAudioProviderA2dpSoftwareHidlTest, OpenA2dpSoftwareProvider) {}
/**
* Test whether each provider of type
* SessionType::A2DP_SOFTWARE_ENCODING_DATAPATH can be started and stopped with
* different PCM config
*/
-TEST_F(BluetoothAudioProviderA2dpSoftwareHidlTest,
+TEST_P(BluetoothAudioProviderA2dpSoftwareHidlTest,
StartAndEndA2dpSoftwareSessionWithPossiblePcmConfig) {
bool is_codec_config_valid;
std::unique_ptr<DataMQ> tempDataMQ;
@@ -616,14 +596,14 @@
/**
* Test whether we can open a provider of type
*/
-TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest, OpenA2dpHardwareProvider) {}
+TEST_P(BluetoothAudioProviderA2dpHardwareHidlTest, OpenA2dpHardwareProvider) {}
/**
* Test whether each provider of type
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
* SBC hardware encoding config
*/
-TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest,
+TEST_P(BluetoothAudioProviderA2dpHardwareHidlTest,
StartAndEndA2dpSbcHardwareSession) {
if (!IsOffloadSupported()) {
return;
@@ -658,7 +638,7 @@
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
* AAC hardware encoding config
*/
-TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest,
+TEST_P(BluetoothAudioProviderA2dpHardwareHidlTest,
StartAndEndA2dpAacHardwareSession) {
if (!IsOffloadSupported()) {
return;
@@ -693,7 +673,7 @@
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
* LDAC hardware encoding config
*/
-TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest,
+TEST_P(BluetoothAudioProviderA2dpHardwareHidlTest,
StartAndEndA2dpLdacHardwareSession) {
if (!IsOffloadSupported()) {
return;
@@ -728,7 +708,7 @@
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
* AptX hardware encoding config
*/
-TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest,
+TEST_P(BluetoothAudioProviderA2dpHardwareHidlTest,
StartAndEndA2dpAptxHardwareSession) {
if (!IsOffloadSupported()) {
return;
@@ -767,7 +747,7 @@
* SessionType::A2DP_HARDWARE_ENCODING_DATAPATH can be started and stopped with
* an invalid codec config
*/
-TEST_F(BluetoothAudioProviderA2dpHardwareHidlTest,
+TEST_P(BluetoothAudioProviderA2dpHardwareHidlTest,
StartAndEndA2dpHardwareSessionInvalidCodecConfig) {
if (!IsOffloadSupported()) {
return;
@@ -857,7 +837,7 @@
* SessionType::HEARING_AID_HARDWARE_ENCODING_DATAPATH can be started and
* stopped with SBC hardware encoding config
*/
-TEST_F(BluetoothAudioProviderHearingAidSoftwareHidlTest,
+TEST_P(BluetoothAudioProviderHearingAidSoftwareHidlTest,
OpenHearingAidSoftwareProvider) {}
/**
@@ -865,7 +845,7 @@
* SessionType::HEARING_AID_SOFTWARE_ENCODING_DATAPATH can be started and
* stopped with different PCM config
*/
-TEST_F(BluetoothAudioProviderHearingAidSoftwareHidlTest,
+TEST_P(BluetoothAudioProviderHearingAidSoftwareHidlTest,
StartAndEndHearingAidSessionWithPossiblePcmConfig) {
bool is_codec_config_valid;
std::unique_ptr<DataMQ> tempDataMQ;
@@ -904,12 +884,25 @@
} // SampleRate
}
-int main(int argc, char** argv) {
- ::testing::AddGlobalTestEnvironment(
- BluetoothAudioHidlEnvironment::Instance());
- ::testing::InitGoogleTest(&argc, argv);
- BluetoothAudioHidlEnvironment::Instance()->init(&argc, argv);
- int status = RUN_ALL_TESTS();
- LOG(INFO) << "Test result = " << status;
- return status;
-}
+static const std::vector<std::string> kAudioInstances =
+ android::hardware::getAllHalInstanceNames(
+ IBluetoothAudioProvidersFactory::descriptor);
+
+INSTANTIATE_TEST_SUITE_P(PerInstance, BluetoothAudioProvidersFactoryHidlTest,
+ testing::ValuesIn(kAudioInstances),
+ android::hardware::PrintInstanceNameToString);
+
+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);
\ No newline at end of file