Skip to content

Commit

Permalink
Add arg tests for new methods in CommissioningWindowOpener
Browse files Browse the repository at this point in the history
  • Loading branch information
samadDotDev committed Jul 9, 2024
1 parent 923bd01 commit ef28d07
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
19 changes: 15 additions & 4 deletions src/controller/CHIPDeviceController.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,16 @@ struct CommissionerInitParams : public ControllerInitParams
Credentials::DeviceAttestationVerifier * deviceAttestationVerifier = nullptr;
};

// Interface class for DeviceController methods that need to be mocked
class IDeviceController
{
public:
virtual ~IDeviceController() = default;
virtual CHIP_ERROR GetConnectedDevice(NodeId peerNodeId, chip::Callback::Callback<OnDeviceConnected> * onConnection,
chip::Callback::Callback<OnDeviceConnectionFailure> * onFailure,
TransportPayloadCapability transportPayloadCapability) = 0;
};

/**
* @brief
* Controller applications can use this class to communicate with already paired CHIP devices. The
Expand All @@ -175,7 +185,7 @@ struct CommissionerInitParams : public ControllerInitParams
* and device pairing information for individual devices). Alternatively, this class can retrieve the
* relevant information when the application tries to communicate with the device
*/
class DLL_EXPORT DeviceController : public AbstractDnssdDiscoveryController
class DLL_EXPORT DeviceController : public AbstractDnssdDiscoveryController, IDeviceController
{
public:
DeviceController();
Expand Down Expand Up @@ -243,9 +253,10 @@ class DLL_EXPORT DeviceController : public AbstractDnssdDiscoveryController
* An error return from this function means that neither callback has been
* called yet, and neither callback will be called in the future.
*/
CHIP_ERROR GetConnectedDevice(NodeId peerNodeId, Callback::Callback<OnDeviceConnected> * onConnection,
chip::Callback::Callback<OnDeviceConnectionFailure> * onFailure,
TransportPayloadCapability transportPayloadCapability = TransportPayloadCapability::kMRPPayload)
CHIP_ERROR
GetConnectedDevice(NodeId peerNodeId, Callback::Callback<OnDeviceConnected> * onConnection,
chip::Callback::Callback<OnDeviceConnectionFailure> * onFailure,
TransportPayloadCapability transportPayloadCapability = TransportPayloadCapability::kMRPPayload) override
{
VerifyOrReturnError(mState == State::Initialized, CHIP_ERROR_INCORRECT_STATE);
mSystemState->CASESessionMgr()->FindOrEstablishSession(ScopedNodeId(peerNodeId, GetFabricIndex()), onConnection, onFailure,
Expand Down
2 changes: 1 addition & 1 deletion src/controller/tests/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import("${chip_root}/build/chip/chip_test_suite.gni")
chip_test_suite("tests") {
output_name = "libControllerTests"

test_sources = [ "TestCommissionableNodeController.cpp" ]
test_sources = [ "TestCommissionableNodeController.cpp", "TestCommissioningWindowOpener.cpp" ]

if (chip_device_platform != "mbed" && chip_device_platform != "efr32" &&
chip_device_platform != "esp32") {
Expand Down

0 comments on commit ef28d07

Please sign in to comment.