Skip to content

Commit b6ecce0

Browse files
author
Kimmo Vaisanen
committed
Add UT for AT_CellularNetwork::is_active_context
1 parent 02de20a commit b6ecce0

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

UNITTESTS/features/cellular/framework/AT/at_cellularnetwork/at_cellularnetworktest.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -767,3 +767,43 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_packet_domain_event_r
767767
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_packet_domain_event_reporting(true));
768768
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_packet_domain_event_reporting(false));
769769
}
770+
771+
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_is_active_context)
772+
{
773+
EventQueue que;
774+
FileHandle_stub fh1;
775+
ATHandler at(&fh1, que, 0, ",");
776+
777+
AT_CellularNetwork cn(at);
778+
779+
// No contexts
780+
int active_contexts = -1;
781+
EXPECT_FALSE(cn.is_active_context(&active_contexts));
782+
EXPECT_EQ(0, active_contexts);
783+
784+
// Active contexts
785+
ATHandler_stub::resp_info_true_counter = 2;
786+
ATHandler_stub::int_count = 4;
787+
ATHandler_stub::int_valid_count_table[3] = 0; // ctx 0
788+
ATHandler_stub::int_valid_count_table[2] = 0; // ctx 0 inactive
789+
ATHandler_stub::int_valid_count_table[1] = 1; // ctx 1
790+
ATHandler_stub::int_valid_count_table[0] = 1; // ctx 1 active
791+
792+
EXPECT_TRUE(cn.is_active_context(&active_contexts));
793+
EXPECT_EQ(1, active_contexts);
794+
795+
ATHandler_stub::resp_info_true_counter = 2;
796+
ATHandler_stub::int_count = 4;
797+
EXPECT_FALSE(cn.is_active_context(&active_contexts, 0));
798+
EXPECT_EQ(1, active_contexts);
799+
800+
ATHandler_stub::resp_info_true_counter = 2;
801+
ATHandler_stub::int_count = 4;
802+
EXPECT_TRUE(cn.is_active_context(&active_contexts, 1));
803+
EXPECT_EQ(1, active_contexts);
804+
805+
ATHandler_stub::resp_info_true_counter = 2;
806+
ATHandler_stub::int_count = 4;
807+
EXPECT_TRUE(cn.is_active_context(NULL, 1));
808+
EXPECT_EQ(1, active_contexts);
809+
}

features/cellular/framework/API/CellularNetwork.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ class CellularNetwork {
338338

339339
/** Check if there is any PDP context active. If cid is given, then check is done only for that cid.
340340
*
341-
* @param number_of_active_contexts If given then in return contains the number of active contexts
342-
* @param cid If given then active contexts are checked only against this cid
341+
* @param number_of_active_contexts If given then in return contains the number of all active contexts
342+
* @param cid If given then check if the context with this cid is active
343343
*
344344
* @return true if any (or the given cid) context is active, false otherwise or in case of error
345345
*/

0 commit comments

Comments
 (0)