Skip to content

Commit

Permalink
Update wifi-apmanager-test-unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
abeltrano committed Jan 19, 2024
1 parent 2a54ac8 commit 6a01ff0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
14 changes: 8 additions & 6 deletions tests/unit/wifi/apmanager/TestAccessPointManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <catch2/catch_test_macros.hpp>
#include <microsoft/net/wifi/AccessPointDiscoveryAgent.hxx>
#include <microsoft/net/wifi/AccessPointManager.hxx>
#include <microsoft/net/wifi/test/AccessPointControllerTest.hxx>
#include <microsoft/net/wifi/test/AccessPointTest.hxx>

#include "AccessPointDiscoveryAgentOperationsTest.hxx"

Expand All @@ -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<Test::AccessPointFactoryTest>()));
}
}

Expand All @@ -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<Test::AccessPointFactoryTest>()) };
REQUIRE_NOTHROW(accessPointManager.reset());
}

Expand All @@ -34,7 +36,7 @@ TEST_CASE("Destroy an AccessPointManager instance", "[wifi][core][apmanager]")
auto accessPointDiscoveryAgent1{ AccessPointDiscoveryAgent::Create(std::make_unique<AccessPointDiscoveryAgentOperationsTest>()) };
auto accessPointDiscoveryAgent2{ AccessPointDiscoveryAgent::Create(std::make_unique<AccessPointDiscoveryAgentOperationsTest>()) };

auto accessPointManager{ AccessPointManager::Create() };
auto accessPointManager{ AccessPointManager::Create(std::make_unique<Test::AccessPointFactoryTest>()) };
accessPointManager->AddDiscoveryAgent(std::move(accessPointDiscoveryAgent1));
accessPointManager->AddDiscoveryAgent(std::move(accessPointDiscoveryAgent2));
REQUIRE_NOTHROW(accessPointManager.reset());
Expand All @@ -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<Test::AccessPointFactoryTest>()) };
REQUIRE(std::empty(accessPointManager->GetAllAccessPoints()));
}
}
Expand All @@ -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<Test::AccessPointFactoryTest>()) };
accessPointManager->AddDiscoveryAgent(std::move(accessPointDiscoveryAgentTest));

SECTION("Access points from arrival events are persisted via GetAccessPoint()")
Expand Down Expand Up @@ -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<Test::AccessPointFactoryTest>()) };
accessPointManager->AddDiscoveryAgent(std::move(accessPointDiscoveryAgentTest));

SECTION("Access points reported to have departed are not accessible via GetAccessPoint()")
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/wifi/helpers/AccessPointTest.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ AccessPointTest::CreateController()
std::shared_ptr<IAccessPoint>
AccessPointFactoryTest::Create(std::string_view interface)
{
return std::make_shared<AccessPointTest>(interface);
return Create(interface, nullptr);
}

std::shared_ptr<IAccessPoint>
AccessPointFactoryTest::Create(std::string_view interfaceName, [[maybe_unused]] std::unique_ptr<IAccessPointCreateArgs> createArgs)
{
return std::make_shared<AccessPointTest>(interfaceName);
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ struct AccessPointFactoryTest :
*/
std::shared_ptr<IAccessPoint>
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<IAccessPoint>
*/
std::shared_ptr<IAccessPoint>
Create(std::string_view interfaceName, std::unique_ptr<IAccessPointCreateArgs> createArgs) override;
};
} // namespace Microsoft::Net::Wifi::Test

Expand Down

0 comments on commit 6a01ff0

Please sign in to comment.