mirror of https://github.com/ARMmbed/mbed-os.git
Add UT for AT_CellularNetwork::is_active_context
parent
02de20acb6
commit
b6ecce0bfb
|
@ -767,3 +767,43 @@ TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_set_packet_domain_event_r
|
||||||
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_packet_domain_event_reporting(true));
|
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_packet_domain_event_reporting(true));
|
||||||
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_packet_domain_event_reporting(false));
|
EXPECT_TRUE(NSAPI_ERROR_DEVICE_ERROR == cn.set_packet_domain_event_reporting(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(TestAT_CellularNetwork, test_AT_CellularNetwork_is_active_context)
|
||||||
|
{
|
||||||
|
EventQueue que;
|
||||||
|
FileHandle_stub fh1;
|
||||||
|
ATHandler at(&fh1, que, 0, ",");
|
||||||
|
|
||||||
|
AT_CellularNetwork cn(at);
|
||||||
|
|
||||||
|
// No contexts
|
||||||
|
int active_contexts = -1;
|
||||||
|
EXPECT_FALSE(cn.is_active_context(&active_contexts));
|
||||||
|
EXPECT_EQ(0, active_contexts);
|
||||||
|
|
||||||
|
// Active contexts
|
||||||
|
ATHandler_stub::resp_info_true_counter = 2;
|
||||||
|
ATHandler_stub::int_count = 4;
|
||||||
|
ATHandler_stub::int_valid_count_table[3] = 0; // ctx 0
|
||||||
|
ATHandler_stub::int_valid_count_table[2] = 0; // ctx 0 inactive
|
||||||
|
ATHandler_stub::int_valid_count_table[1] = 1; // ctx 1
|
||||||
|
ATHandler_stub::int_valid_count_table[0] = 1; // ctx 1 active
|
||||||
|
|
||||||
|
EXPECT_TRUE(cn.is_active_context(&active_contexts));
|
||||||
|
EXPECT_EQ(1, active_contexts);
|
||||||
|
|
||||||
|
ATHandler_stub::resp_info_true_counter = 2;
|
||||||
|
ATHandler_stub::int_count = 4;
|
||||||
|
EXPECT_FALSE(cn.is_active_context(&active_contexts, 0));
|
||||||
|
EXPECT_EQ(1, active_contexts);
|
||||||
|
|
||||||
|
ATHandler_stub::resp_info_true_counter = 2;
|
||||||
|
ATHandler_stub::int_count = 4;
|
||||||
|
EXPECT_TRUE(cn.is_active_context(&active_contexts, 1));
|
||||||
|
EXPECT_EQ(1, active_contexts);
|
||||||
|
|
||||||
|
ATHandler_stub::resp_info_true_counter = 2;
|
||||||
|
ATHandler_stub::int_count = 4;
|
||||||
|
EXPECT_TRUE(cn.is_active_context(NULL, 1));
|
||||||
|
EXPECT_EQ(1, active_contexts);
|
||||||
|
}
|
||||||
|
|
|
@ -338,8 +338,8 @@ public:
|
||||||
|
|
||||||
/** Check if there is any PDP context active. If cid is given, then check is done only for that cid.
|
/** Check if there is any PDP context active. If cid is given, then check is done only for that cid.
|
||||||
*
|
*
|
||||||
* @param number_of_active_contexts If given then in return contains the number of active contexts
|
* @param number_of_active_contexts If given then in return contains the number of all active contexts
|
||||||
* @param cid If given then active contexts are checked only against this cid
|
* @param cid If given then check if the context with this cid is active
|
||||||
*
|
*
|
||||||
* @return true if any (or the given cid) context is active, false otherwise or in case of error
|
* @return true if any (or the given cid) context is active, false otherwise or in case of error
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue