diff options
author | Dan Shi <dshi@google.com> | 2019-10-29 14:30:18 -0700 |
---|---|---|
committer | Dan Shi <dshi@google.com> | 2019-11-13 14:33:25 -0800 |
commit | 59c749595f56d5d0339fe8fabdaae28208f26eef (patch) | |
tree | b9d81583a8a623e19c9991088e941fe2c3ffcc48 /wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp | |
parent | bbdd5e32fd5a5d6e8b13c8f2a0c12e02ea037953 (diff) |
Convert VtsHalWifiSupplicantV1_0TargetTest to be parameterized test
Bug: 142397658
Test: atest VtsHalWifiSupplicantV1_0TargetTest \
VtsHalWifiSupplicantP2pV1_0TargetTest
Change-Id: I0cba2c29d90018d8248c583dec2354f9d3feba47
Diffstat (limited to 'wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp')
-rw-r--r-- | wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp | 68 |
1 files changed, 46 insertions, 22 deletions
diff --git a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp index 436b88b816..4f25465d79 100644 --- a/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp +++ b/wifi/supplicant/1.0/vts/functional/supplicant_hidl_test.cpp @@ -16,35 +16,47 @@ #include <android-base/logging.h> -#include <VtsHalHidlTargetTestBase.h> - +#include <VtsCoreUtil.h> +#include <android/hardware/wifi/1.0/IWifi.h> #include <android/hardware/wifi/supplicant/1.0/ISupplicant.h> +#include <gtest/gtest.h> +#include <hidl/GtestPrinter.h> +#include <hidl/ServiceManagement.h> #include "supplicant_hidl_test_utils.h" using ::android::sp; using ::android::hardware::hidl_vec; +using ::android::hardware::wifi::supplicant::V1_0::IfaceType; using ::android::hardware::wifi::supplicant::V1_0::ISupplicant; using ::android::hardware::wifi::supplicant::V1_0::ISupplicantIface; using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatus; using ::android::hardware::wifi::supplicant::V1_0::SupplicantStatusCode; -using ::android::hardware::wifi::supplicant::V1_0::IfaceType; +using ::android::hardware::wifi::V1_0::IWifi; -extern WifiSupplicantHidlEnvironment* gEnv; - -class SupplicantHidlTest : public ::testing::VtsHalHidlTargetTestBase { +class SupplicantHidlTest + : public ::testing::TestWithParam<std::tuple<std::string, std::string>> { public: virtual void SetUp() override { - startSupplicantAndWaitForHidlService(); - supplicant_ = getSupplicant(); + wifi_instance_name_ = std::get<0>(GetParam()); + supplicant_instance_name_ = std::get<1>(GetParam()); + stopSupplicant(wifi_instance_name_); + startSupplicantAndWaitForHidlService(wifi_instance_name_, + supplicant_instance_name_); + isP2pOn_ = + testing::deviceSupportsFeature("android.hardware.wifi.direct"); + supplicant_ = getSupplicant(supplicant_instance_name_, isP2pOn_); ASSERT_NE(supplicant_.get(), nullptr); } - virtual void TearDown() override { stopSupplicant(); } + virtual void TearDown() override { stopSupplicant(wifi_instance_name_); } protected: // ISupplicant object used for all tests in this fixture. sp<ISupplicant> supplicant_; + bool isP2pOn_ = false; + std::string wifi_instance_name_; + std::string supplicant_instance_name_; }; /* @@ -52,16 +64,19 @@ class SupplicantHidlTest : public ::testing::VtsHalHidlTargetTestBase { * Ensures that an instance of the ISupplicant proxy object is * successfully created. */ -TEST(SupplicantHidlTestNoFixture, Create) { - startSupplicantAndWaitForHidlService(); - EXPECT_NE(nullptr, getSupplicant().get()); - stopSupplicant(); +TEST_P(SupplicantHidlTest, Create) { + // Stop the proxy object created in setup. + stopSupplicant(wifi_instance_name_); + startSupplicantAndWaitForHidlService(wifi_instance_name_, + supplicant_instance_name_); + EXPECT_NE(nullptr, + getSupplicant(supplicant_instance_name_, isP2pOn_).get()); } /* * ListInterfaces */ -TEST_F(SupplicantHidlTest, ListInterfaces) { +TEST_P(SupplicantHidlTest, ListInterfaces) { std::vector<ISupplicant::IfaceInfo> ifaces; supplicant_->listInterfaces( [&](const SupplicantStatus& status, @@ -74,7 +89,7 @@ TEST_F(SupplicantHidlTest, ListInterfaces) { std::find_if(ifaces.begin(), ifaces.end(), [](const auto& iface) { return iface.type == IfaceType::STA; })); - if (gEnv->isP2pOn) { + if (isP2pOn_) { EXPECT_NE( ifaces.end(), std::find_if(ifaces.begin(), ifaces.end(), [](const auto& iface) { @@ -86,7 +101,7 @@ TEST_F(SupplicantHidlTest, ListInterfaces) { /* * GetInterface */ -TEST_F(SupplicantHidlTest, GetInterface) { +TEST_P(SupplicantHidlTest, GetInterface) { std::vector<ISupplicant::IfaceInfo> ifaces; supplicant_->listInterfaces( [&](const SupplicantStatus& status, @@ -107,7 +122,7 @@ TEST_F(SupplicantHidlTest, GetInterface) { /* * SetDebugParams */ -TEST_F(SupplicantHidlTest, SetDebugParams) { +TEST_P(SupplicantHidlTest, SetDebugParams) { bool show_timestamp = true; bool show_keys = true; ISupplicant::DebugLevel level = ISupplicant::DebugLevel::EXCESSIVE; @@ -124,7 +139,7 @@ TEST_F(SupplicantHidlTest, SetDebugParams) { /* * GetDebugLevel */ -TEST_F(SupplicantHidlTest, GetDebugLevel) { +TEST_P(SupplicantHidlTest, GetDebugLevel) { bool show_timestamp = true; bool show_keys = true; ISupplicant::DebugLevel level = ISupplicant::DebugLevel::EXCESSIVE; @@ -142,7 +157,7 @@ TEST_F(SupplicantHidlTest, GetDebugLevel) { /* * IsDebugShowTimestampEnabled */ -TEST_F(SupplicantHidlTest, IsDebugShowTimestampEnabled) { +TEST_P(SupplicantHidlTest, IsDebugShowTimestampEnabled) { bool show_timestamp = true; bool show_keys = true; ISupplicant::DebugLevel level = ISupplicant::DebugLevel::EXCESSIVE; @@ -160,7 +175,7 @@ TEST_F(SupplicantHidlTest, IsDebugShowTimestampEnabled) { /* * IsDebugShowKeysEnabled */ -TEST_F(SupplicantHidlTest, IsDebugShowKeysEnabled) { +TEST_P(SupplicantHidlTest, IsDebugShowKeysEnabled) { bool show_timestamp = true; bool show_keys = true; ISupplicant::DebugLevel level = ISupplicant::DebugLevel::EXCESSIVE; @@ -178,15 +193,24 @@ TEST_F(SupplicantHidlTest, IsDebugShowKeysEnabled) { /* * SetConcurrenyPriority */ -TEST_F(SupplicantHidlTest, SetConcurrencyPriority) { +TEST_P(SupplicantHidlTest, SetConcurrencyPriority) { supplicant_->setConcurrencyPriority( IfaceType::STA, [](const SupplicantStatus& status) { EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code); }); - if (gEnv->isP2pOn) { + if (isP2pOn_) { supplicant_->setConcurrencyPriority( IfaceType::P2P, [](const SupplicantStatus& status) { EXPECT_EQ(SupplicantStatusCode::SUCCESS, status.code); }); } } + +INSTANTIATE_TEST_CASE_P( + PerInstance, SupplicantHidlTest, + testing::Combine( + testing::ValuesIn( + android::hardware::getAllHalInstanceNames(IWifi::descriptor)), + testing::ValuesIn(android::hardware::getAllHalInstanceNames( + ISupplicant::descriptor))), + android::hardware::PrintInstanceTupleNameToString<>);
\ No newline at end of file |