Skip to content

Commit d859905

Browse files
silabs-aydoganerzr
authored andcommitted
uic: zpc: UIC-3616: Add unit test for ucl_mqtt module
(cherry picked from commit ac0651934a24efe72d542c86e1b5b752ae266951) Forwarded: #11 Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
1 parent 30bf152 commit d859905

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

applications/zpc/components/ucl_mqtt/test/zpc_node_state_test.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,72 @@ void test_discover_security_command()
233233
UIC_MQTT_DOTDOT_CALLBACK_TYPE_NORMAL));
234234
TEST_ASSERT_TRUE(attribute_store_is_reported_defined(granted_keys_node));
235235
}
236+
237+
void test_enable_nls_support_check()
238+
{
239+
// Set our node to online functional
240+
NodeStateNetworkStatus network_status
241+
= ZCL_NODE_STATE_NETWORK_STATUS_ONLINE_FUNCTIONAL;
242+
attribute_store_set_child_reported(node_id_node,
243+
DOTDOT_ATTRIBUTE_ID_STATE_NETWORK_STATUS,
244+
&network_status,
245+
sizeof(network_status));
246+
247+
// Enable NLS should be supported:
248+
TEST_ASSERT_EQUAL(
249+
SL_STATUS_OK,
250+
enable_nls_command(supporting_node_unid,
251+
endpoint_id,
252+
UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK));
253+
254+
// Offline should not show this state command
255+
network_status = ZCL_NODE_STATE_NETWORK_STATUS_OFFLINE;
256+
attribute_store_set_child_reported(node_id_node,
257+
DOTDOT_ATTRIBUTE_ID_STATE_NETWORK_STATUS,
258+
&network_status,
259+
sizeof(network_status));
260+
TEST_ASSERT_EQUAL(
261+
SL_STATUS_FAIL,
262+
enable_nls_command(supporting_node_unid,
263+
endpoint_id,
264+
UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK));
265+
266+
// Unavailable should not show this state command
267+
network_status = ZCL_NODE_STATE_NETWORK_STATUS_UNAVAILABLE;
268+
attribute_store_set_child_reported(node_id_node,
269+
DOTDOT_ATTRIBUTE_ID_STATE_NETWORK_STATUS,
270+
&network_status,
271+
sizeof(network_status));
272+
TEST_ASSERT_EQUAL(
273+
SL_STATUS_FAIL,
274+
enable_nls_command(supporting_node_unid,
275+
endpoint_id,
276+
UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK));
277+
278+
// ZPC SHOULD not support this state command either
279+
network_status = ZCL_NODE_STATE_NETWORK_STATUS_ONLINE_FUNCTIONAL;
280+
attribute_store_set_child_reported(zpc_node_id_node,
281+
DOTDOT_ATTRIBUTE_ID_STATE_NETWORK_STATUS,
282+
&network_status,
283+
sizeof(network_status));
284+
TEST_ASSERT_EQUAL(
285+
SL_STATUS_NOT_SUPPORTED,
286+
enable_nls_command(zpc_unid,
287+
zpc_endpoint_id,
288+
UIC_MQTT_DOTDOT_CALLBACK_TYPE_SUPPORT_CHECK));
289+
}
290+
291+
void test_enable_nls_command()
292+
{
293+
attribute_store_node_t target_node
294+
= attribute_store_add_node(ATTRIBUTE_ZWAVE_NLS_STATE, node_id_node);
295+
attribute_store_set_reported_number(target_node, 0);
296+
attribute_store_set_desired_number(target_node, 0);
297+
298+
TEST_ASSERT_EQUAL(SL_STATUS_OK,
299+
enable_nls_command(supporting_node_unid,
300+
endpoint_id,
301+
UIC_MQTT_DOTDOT_CALLBACK_TYPE_NORMAL));
302+
TEST_ASSERT_EQUAL(0, attribute_store_get_reported_number(target_node));
303+
TEST_ASSERT_EQUAL(1, attribute_store_get_desired_number(target_node));
304+
}

0 commit comments

Comments
 (0)