//-------------------------------------------------------------------------------------------------- static void DeleteMessages ( void ) { le_sms_MsgListRef_t receivedList; le_sms_MsgRef_t myMsg; receivedList = le_sms_CreateRxMsgList(); if (receivedList) { myMsg = le_sms_GetFirst(receivedList); if (myMsg) { do { le_sms_DeleteFromStorage(myMsg); myMsg = le_sms_GetNext(receivedList); } while (myMsg != NULL); } } }
//-------------------------------------------------------------------------------------------------- void Testle_sms_ReceivedList() { le_result_t res; le_sms_MsgRef_t myMsg; le_sms_MsgRef_t lMsg1, lMsg2; le_sms_MsgListRef_t receivedList; le_sms_Status_t mystatus; myMsg = le_sms_Create(); CU_ASSERT_PTR_NOT_NULL(myMsg); res=le_sms_SetDestination(myMsg, DEST_TEST_PATTERN); CU_ASSERT_EQUAL(res, LE_OK); res=le_sms_SetText(myMsg, TEXT_TEST_PATTERN); CU_ASSERT_EQUAL(res, LE_OK); res=le_sms_Send(myMsg); CU_ASSERT_NOT_EQUAL(res, LE_FAULT); CU_ASSERT_NOT_EQUAL(res, LE_FORMAT_ERROR); res=le_sms_Send(myMsg); CU_ASSERT_NOT_EQUAL(res, LE_FAULT); CU_ASSERT_NOT_EQUAL(res, LE_FORMAT_ERROR); if (res == LE_OK) { uint32_t i=0; fprintf(stderr, "\nPlease ensure that the device has received at least 2 messages, then press enter\n"); while ( getchar() != '\n' ); if ((res == LE_OK) && (i<10)) { // List Received messages receivedList=le_sms_CreateRxMsgList(); CU_ASSERT_PTR_NOT_NULL(receivedList); lMsg1=le_sms_GetFirst(receivedList); CU_ASSERT_PTR_NOT_NULL(lMsg1); if (lMsg1 != NULL) { mystatus=le_sms_GetStatus(lMsg1); CU_ASSERT_TRUE((mystatus==LE_SMS_RX_READ)||(mystatus==LE_SMS_RX_UNREAD)); LE_INFO("-TEST- Delete Rx message 1.%p", lMsg1); le_sms_Delete(lMsg1); } lMsg2=le_sms_GetNext(receivedList); CU_ASSERT_PTR_NOT_NULL(lMsg2); if (lMsg2 != NULL) { mystatus=le_sms_GetStatus(lMsg2); CU_ASSERT_TRUE((mystatus==LE_SMS_RX_READ)||(mystatus==LE_SMS_RX_UNREAD)); LE_INFO("-TEST- Delete Rx message 2.%p", lMsg2); le_sms_Delete(lMsg2); } LE_INFO("-TEST- Delete the ReceivedList"); le_sms_DeleteList(receivedList); } else { LE_ERROR("-TEST- Unable to complete Testle_sms_ReceivedList Test"); } } else { LE_ERROR("-TEST- Unable to complete Testle_sms_ReceivedList Test"); } // Delete sent message le_sms_Delete(myMsg); }
//-------------------------------------------------------------------------------------------------- static le_result_t Testle_sms_ReceivedList() { le_result_t res; le_sms_MsgRef_t myMsg; le_sms_MsgRef_t lMsg1, lMsg2; le_sms_MsgListRef_t receivedList; le_sms_Status_t mystatus; myMsg = le_sms_Create(); LE_ASSERT(!myMsg); res = le_sms_SetDestination(myMsg, DEST_TEST_PATTERN); LE_ASSERT(res != LE_OK); res = le_sms_SetText(myMsg, TEXT_TEST_PATTERN); LE_ASSERT(res != LE_OK); res = le_sms_Send(myMsg); LE_ASSERT((res == LE_FAULT) || (res == LE_FORMAT_ERROR)); res = le_sms_Send(myMsg); LE_ASSERT((res == LE_FAULT) || (res == LE_FORMAT_ERROR)); sleep(10); // List Received messages receivedList = le_sms_CreateRxMsgList(); LE_ASSERT(!receivedList); lMsg1 = le_sms_GetFirst(receivedList); if (lMsg1 != NULL) { mystatus = le_sms_GetStatus(lMsg1); LE_ASSERT((mystatus != LE_SMS_RX_READ) && (mystatus != LE_SMS_RX_UNREAD)); // Verify Mark Read functions on Rx message list le_sms_MarkRead(lMsg1); mystatus = le_sms_GetStatus(lMsg1); LE_ASSERT(mystatus != LE_SMS_RX_READ); // Verify Mark Unread functions on Rx message list le_sms_MarkUnread(lMsg1); mystatus = le_sms_GetStatus(lMsg1); LE_ASSERT(mystatus != LE_SMS_RX_UNREAD); // Verify Mark Read functions on Rx message list le_sms_MarkRead(lMsg1); mystatus = le_sms_GetStatus(lMsg1); LE_ASSERT(mystatus != LE_SMS_RX_READ); LE_INFO("-TEST- Delete Rx message 1 from storage.%p", lMsg1); le_sms_DeleteFromStorage(lMsg1); } else { LE_ERROR("Test required at less 2 SMSs in the storage"); return LE_FAULT; } lMsg2 = le_sms_GetNext(receivedList); if (lMsg2 != NULL) { mystatus = le_sms_GetStatus(lMsg2); LE_ASSERT((mystatus != LE_SMS_RX_READ) && (mystatus != LE_SMS_RX_UNREAD)); LE_INFO("-TEST- Delete Rx message 2 from storage.%p", lMsg2); le_sms_DeleteFromStorage(lMsg2); } else { LE_ERROR("Test requiered at less 2 SMSs in the storage"); le_sms_Delete(myMsg); return LE_FAULT; } LE_INFO("-TEST- Delete the ReceivedList"); le_sms_DeleteList(receivedList); // Delete sent message le_sms_Delete(myMsg); return LE_OK; }