From 6a01ff05ce3b0048c2c76ac8e09e7eec7be25701 Mon Sep 17 00:00:00 2001 From: Andrew Beltrano Date: Fri, 19 Jan 2024 17:29:15 +0000 Subject: [PATCH] Update wifi-apmanager-test-unit tests. --- .../unit/wifi/apmanager/TestAccessPointManager.cxx | 14 ++++++++------ tests/unit/wifi/helpers/AccessPointTest.cxx | 7 ++++++- .../microsoft/net/wifi/test/AccessPointTest.hxx | 12 ++++++++++++ 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/tests/unit/wifi/apmanager/TestAccessPointManager.cxx b/tests/unit/wifi/apmanager/TestAccessPointManager.cxx index af822b1b..c2462922 100644 --- a/tests/unit/wifi/apmanager/TestAccessPointManager.cxx +++ b/tests/unit/wifi/apmanager/TestAccessPointManager.cxx @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include "AccessPointDiscoveryAgentOperationsTest.hxx" @@ -13,7 +15,7 @@ TEST_CASE("Create an AccessPointManager instance", "[wifi][core][apmanager]") SECTION("Create doesn't cause a crash") { - REQUIRE_NOTHROW(AccessPointManager::Create()); + REQUIRE_NOTHROW(AccessPointManager::Create(std::make_unique())); } } @@ -25,7 +27,7 @@ TEST_CASE("Destroy an AccessPointManager instance", "[wifi][core][apmanager]") SECTION("Destroy doesn't cause a crash") { - auto accessPointManager{ AccessPointManager::Create() }; + auto accessPointManager{ AccessPointManager::Create(std::make_unique()) }; REQUIRE_NOTHROW(accessPointManager.reset()); } @@ -34,7 +36,7 @@ TEST_CASE("Destroy an AccessPointManager instance", "[wifi][core][apmanager]") auto accessPointDiscoveryAgent1{ AccessPointDiscoveryAgent::Create(std::make_unique()) }; auto accessPointDiscoveryAgent2{ AccessPointDiscoveryAgent::Create(std::make_unique()) }; - auto accessPointManager{ AccessPointManager::Create() }; + auto accessPointManager{ AccessPointManager::Create(std::make_unique()) }; accessPointManager->AddDiscoveryAgent(std::move(accessPointDiscoveryAgent1)); accessPointManager->AddDiscoveryAgent(std::move(accessPointDiscoveryAgent2)); REQUIRE_NOTHROW(accessPointManager.reset()); @@ -47,7 +49,7 @@ TEST_CASE("AccessPointManager instance reflects basic properties", "[wifi][core] SECTION("GetAllAccessPoints() returns an empty list") { - auto accessPointManager{ AccessPointManager::Create() }; + auto accessPointManager{ AccessPointManager::Create(std::make_unique()) }; REQUIRE(std::empty(accessPointManager->GetAllAccessPoints())); } } @@ -64,7 +66,7 @@ TEST_CASE("AccessPointManager persists access points reported by discovery agent auto* accessPointDiscoveryAgentOperationsTestPtr{ accessPointDiscoveryAgentOperationsTest.get() }; auto accessPointDiscoveryAgentTest{ AccessPointDiscoveryAgent::Create(std::move(accessPointDiscoveryAgentOperationsTest)) }; - auto accessPointManager{ AccessPointManager::Create() }; + auto accessPointManager{ AccessPointManager::Create(std::make_unique()) }; accessPointManager->AddDiscoveryAgent(std::move(accessPointDiscoveryAgentTest)); SECTION("Access points from arrival events are persisted via GetAccessPoint()") @@ -129,7 +131,7 @@ TEST_CASE("AccessPointManager discards access points reported to have departed b auto* accessPointDiscoveryAgentOperationsTestPtr{ accessPointDiscoveryAgentOperationsTest.get() }; auto accessPointDiscoveryAgentTest{ AccessPointDiscoveryAgent::Create(std::move(accessPointDiscoveryAgentOperationsTest)) }; - auto accessPointManager{ AccessPointManager::Create() }; + auto accessPointManager{ AccessPointManager::Create(std::make_unique()) }; accessPointManager->AddDiscoveryAgent(std::move(accessPointDiscoveryAgentTest)); SECTION("Access points reported to have departed are not accessible via GetAccessPoint()") diff --git a/tests/unit/wifi/helpers/AccessPointTest.cxx b/tests/unit/wifi/helpers/AccessPointTest.cxx index b9f83578..1e880fb8 100644 --- a/tests/unit/wifi/helpers/AccessPointTest.cxx +++ b/tests/unit/wifi/helpers/AccessPointTest.cxx @@ -24,6 +24,11 @@ AccessPointTest::CreateController() std::shared_ptr AccessPointFactoryTest::Create(std::string_view interface) { - return std::make_shared(interface); + return Create(interface, nullptr); } +std::shared_ptr +AccessPointFactoryTest::Create(std::string_view interfaceName, [[maybe_unused]] std::unique_ptr createArgs) +{ + return std::make_shared(interfaceName); +} diff --git a/tests/unit/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx b/tests/unit/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx index 15a3c52b..57997cc2 100644 --- a/tests/unit/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx +++ b/tests/unit/wifi/helpers/include/microsoft/net/wifi/test/AccessPointTest.hxx @@ -48,6 +48,18 @@ struct AccessPointFactoryTest : */ std::shared_ptr Create(std::string_view interface) override; + + /** + * @brief Create an AccessPoint for testing purposes. + * + * @param interface The interface to create the AccessPoint for. This can be + * any string and does not have to correspond to a real device interface. + * @param createArgs + * + * @return std::shared_ptr + */ + std::shared_ptr + Create(std::string_view interfaceName, std::unique_ptr createArgs) override; }; } // namespace Microsoft::Net::Wifi::Test