Skip to content

Commit ef28d07

Browse files
committed
Add arg tests for new methods in CommissioningWindowOpener
1 parent 923bd01 commit ef28d07

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/controller/CHIPDeviceController.h

+15-4
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,16 @@ struct CommissionerInitParams : public ControllerInitParams
167167
Credentials::DeviceAttestationVerifier * deviceAttestationVerifier = nullptr;
168168
};
169169

170+
// Interface class for DeviceController methods that need to be mocked
171+
class IDeviceController
172+
{
173+
public:
174+
virtual ~IDeviceController() = default;
175+
virtual CHIP_ERROR GetConnectedDevice(NodeId peerNodeId, chip::Callback::Callback<OnDeviceConnected> * onConnection,
176+
chip::Callback::Callback<OnDeviceConnectionFailure> * onFailure,
177+
TransportPayloadCapability transportPayloadCapability) = 0;
178+
};
179+
170180
/**
171181
* @brief
172182
* Controller applications can use this class to communicate with already paired CHIP devices. The
@@ -175,7 +185,7 @@ struct CommissionerInitParams : public ControllerInitParams
175185
* and device pairing information for individual devices). Alternatively, this class can retrieve the
176186
* relevant information when the application tries to communicate with the device
177187
*/
178-
class DLL_EXPORT DeviceController : public AbstractDnssdDiscoveryController
188+
class DLL_EXPORT DeviceController : public AbstractDnssdDiscoveryController, IDeviceController
179189
{
180190
public:
181191
DeviceController();
@@ -243,9 +253,10 @@ class DLL_EXPORT DeviceController : public AbstractDnssdDiscoveryController
243253
* An error return from this function means that neither callback has been
244254
* called yet, and neither callback will be called in the future.
245255
*/
246-
CHIP_ERROR GetConnectedDevice(NodeId peerNodeId, Callback::Callback<OnDeviceConnected> * onConnection,
247-
chip::Callback::Callback<OnDeviceConnectionFailure> * onFailure,
248-
TransportPayloadCapability transportPayloadCapability = TransportPayloadCapability::kMRPPayload)
256+
CHIP_ERROR
257+
GetConnectedDevice(NodeId peerNodeId, Callback::Callback<OnDeviceConnected> * onConnection,
258+
chip::Callback::Callback<OnDeviceConnectionFailure> * onFailure,
259+
TransportPayloadCapability transportPayloadCapability = TransportPayloadCapability::kMRPPayload) override
249260
{
250261
VerifyOrReturnError(mState == State::Initialized, CHIP_ERROR_INCORRECT_STATE);
251262
mSystemState->CASESessionMgr()->FindOrEstablishSession(ScopedNodeId(peerNodeId, GetFabricIndex()), onConnection, onFailure,

src/controller/tests/BUILD.gn

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import("${chip_root}/build/chip/chip_test_suite.gni")
2121
chip_test_suite("tests") {
2222
output_name = "libControllerTests"
2323

24-
test_sources = [ "TestCommissionableNodeController.cpp" ]
24+
test_sources = [ "TestCommissionableNodeController.cpp", "TestCommissioningWindowOpener.cpp" ]
2525

2626
if (chip_device_platform != "mbed" && chip_device_platform != "efr32" &&
2727
chip_device_platform != "esp32") {

0 commit comments

Comments
 (0)