-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #136 from microsoft/apmanagertest
Add helpers for managing access points for unit tests
- Loading branch information
Showing
16 changed files
with
204 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,56 @@ | ||
|
||
#include <stdexcept> | ||
|
||
#include <microsoft/net/wifi/test/AccessPointControllerTest.hxx> | ||
#include <microsoft/net/wifi/test/AccessPointTest.hxx> | ||
|
||
using namespace Microsoft::Net::Wifi; | ||
using namespace Microsoft::Net::Wifi::Test; | ||
|
||
AccessPointControllerTest::AccessPointControllerTest(std::string_view interfaceName) : | ||
InterfaceName(interfaceName) | ||
AccessPointControllerTest::AccessPointControllerTest(AccessPointTest *accessPoint) : | ||
AccessPoint(accessPoint) | ||
{} | ||
|
||
std::string_view | ||
AccessPointControllerTest::GetInterfaceName() const noexcept | ||
AccessPointControllerTest::GetInterfaceName() const | ||
{ | ||
return InterfaceName; | ||
if (AccessPoint == nullptr) { | ||
throw std::runtime_error("AccessPointControllerTest::GetInterfaceName called with null AccessPoint"); | ||
} | ||
|
||
return AccessPoint->InterfaceName; | ||
} | ||
|
||
bool | ||
AccessPointControllerTest::GetIsEnabled() | ||
{ | ||
return IsEnabled; | ||
if (AccessPoint == nullptr) { | ||
throw std::runtime_error("AccessPointControllerTest::GetIsEnabled called with null AccessPoint"); | ||
} | ||
|
||
return AccessPoint->IsEnabled; | ||
} | ||
|
||
Ieee80211AccessPointCapabilities | ||
AccessPointControllerTest::GetCapabilities() | ||
{ | ||
return {}; // TODO: return something | ||
if (AccessPoint == nullptr) { | ||
throw std::runtime_error("AccessPointControllerTest::GetCapabilities called with null AccessPoint"); | ||
} | ||
|
||
return AccessPoint->Capabilities; | ||
} | ||
|
||
AccessPointControllerFactoryTest::AccessPointControllerFactoryTest(AccessPointTest *accessPoint) : | ||
AccessPoint(accessPoint) | ||
{} | ||
|
||
std::unique_ptr<IAccessPointController> | ||
AccessPointControllerFactoryTest::Create(std::string_view interfaceName) | ||
{ | ||
return std::make_unique<AccessPointControllerTest>(interfaceName); | ||
if (AccessPoint != nullptr && interfaceName != AccessPoint->InterfaceName) { | ||
throw std::runtime_error("AccessPointControllerFactoryTest::Create called with unexpected interface name"); | ||
} | ||
|
||
return std::make_unique<AccessPointControllerTest>(AccessPoint); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
#include <microsoft/net/wifi/test/AccessPointManagerTest.hxx> | ||
|
||
using namespace Microsoft::Net::Wifi::Test; | ||
|
||
void | ||
AccessPointManagerTest::AddAccessPoint(std::shared_ptr<IAccessPoint> accessPoint) | ||
{ | ||
return AccessPointManager::AddAccessPoint(std::move(accessPoint)); | ||
} | ||
|
||
void | ||
AccessPointManagerTest::RemoveAccessPoint(std::shared_ptr<IAccessPoint> accessPoint) | ||
{ | ||
return AccessPointManager::RemoveAccessPoint(std::move(accessPoint)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
tests/unit/wifi/helpers/include/microsoft/net/wifi/test/AccessPointManagerTest.hxx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
|
||
#ifndef ACCESS_POINT_MANAGER_TEST | ||
#define ACCESS_POINT_MANAGER_TEST | ||
|
||
#include <memory> | ||
|
||
#include <microsoft/net/wifi/AccessPointManager.hxx> | ||
#include <microsoft/net/wifi/IAccessPoint.hxx> | ||
|
||
namespace Microsoft::Net::Wifi::Test | ||
{ | ||
/** | ||
* @brief AccessPointManager to be used in tests, allowing access to protected methods to add/remove known access | ||
* points. | ||
*/ | ||
struct AccessPointManagerTest : | ||
public Microsoft::Net::Wifi::AccessPointManager | ||
{ | ||
/** | ||
* @brief Construct a new AccessPointManagerTest object. | ||
*/ | ||
AccessPointManagerTest() = default; | ||
|
||
/** | ||
* @brief Adds a new access point. | ||
* | ||
* @param accessPoint The access point to add. | ||
*/ | ||
void | ||
AddAccessPoint(std::shared_ptr<IAccessPoint> accessPoint) override; | ||
|
||
/** | ||
* @brief Removes an existing access point from use. | ||
* | ||
* @param accessPoint The access point to remove. | ||
*/ | ||
void | ||
RemoveAccessPoint(std::shared_ptr<IAccessPoint> accessPoint) override; | ||
}; | ||
} // namespace Microsoft::Net::Wifi::Test | ||
|
||
#endif // ACCESS_POINT_MANAGER_TEST |
Oops, something went wrong.