• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #define private public
17 #define protected public
18 
19 #include "cdma_sms_transport_message.h"
20 #include "core_manager_inner.h"
21 #include "core_service_client.h"
22 #include "gtest/gtest.h"
23 #include "i_sms_service_interface.h"
24 #include "if_system_ability_manager.h"
25 #include "iservice_registry.h"
26 #include "mms_address.h"
27 #include "mms_apn_info.h"
28 #include "mms_attachment.h"
29 #include "mms_base64.h"
30 #include "mms_body.h"
31 #include "mms_body_part.h"
32 #include "mms_body_part_header.h"
33 #include "mms_charset.h"
34 #include "mms_codec_type.h"
35 #include "mms_decode_buffer.h"
36 #include "mms_header.h"
37 #include "mms_msg.h"
38 #include "mms_persist_helper.h"
39 #include "mms_quoted_printable.h"
40 #include "pdp_profile_data.h"
41 #include "radio_event.h"
42 #include "sms_broadcast_subscriber_gtest.h"
43 #include "sms_mms_gtest.h"
44 #include "sms_mms_test_helper.h"
45 #include "sms_service.h"
46 #include "sms_service_manager_client.h"
47 #include "string_utils.h"
48 #include "telephony_log_wrapper.h"
49 #include "telephony_types.h"
50 #include "uri.h"
51 
52 namespace OHOS {
53 namespace Telephony {
54 namespace {
55 sptr<ISmsServiceInterface> g_telephonyService = nullptr;
56 } // namespace
57 using namespace testing::ext;
58 
59 class MmsGtest : public testing::Test {
60 public:
61     static void SetUpTestCase();
62     static void TearDownTestCase();
63     void SetUp();
64     void TearDown();
65     static sptr<ISmsServiceInterface> GetProxy();
HasSimCard(int32_t slotId)66     static bool HasSimCard(int32_t slotId)
67     {
68         bool hasSimCard = false;
69         if (CoreServiceClient::GetInstance().GetProxy() == nullptr) {
70             return hasSimCard;
71         }
72         CoreServiceClient::GetInstance().HasSimCard(slotId, hasSimCard);
73         return hasSimCard;
74     }
75 };
76 
77 constexpr uint32_t EVENT_RELEASE_DATA_SHARE_HELPER = 10000;
TearDownTestCase()78 void MmsGtest::TearDownTestCase()
79 {
80     DelayedSingleton<SmsPersistHelper>::GetInstance()->RemoveEvent(EVENT_RELEASE_DATA_SHARE_HELPER);
81 }
82 
SetUp()83 void MmsGtest::SetUp() {}
84 
TearDown()85 void MmsGtest::TearDown() {}
86 
87 const int32_t DEFAULT_SIM_SLOT_ID_1 = 1;
88 const uint16_t MESSAGE_TYPE = 4;
89 const uint16_t WAPPUSH_PDU_LEN = 164;
90 const uint32_t MAX_MMS_ATTACHMENT_LEN = 10 * 1024 * 1024;
91 const char PDU_TEST_DATA = 35;
92 const char MIN_SHORT_OCTET = 30;
93 const char QUOTE_CHAR_LEN = 0X7F - 1;
94 const char VALUE_CHAR = 8;
95 const char PDU_COUNT = 10;
96 const char PDU_CUSITION = 5;
97 const char PDU_LENGTH = 4;
98 const char *ENCODE_CHARSET = "01010101";
99 const uint32_t ENCODE_CHARSET1 = 0x0100;
100 const uint32_t ENCODE_CHARSET2 = 0x0001;
101 const uint32_t MMS_PDU_MAX_SIZE = 300 * 1024;
102 static constexpr const char *PDU = "pdu";
103 static constexpr uint32_t MAX_PDU_PAGES = 4;
104 static constexpr uint8_t HEX_VALUE_0F = 0x0F;
105 static constexpr uint8_t HEX_VALUE_F0 = 0xF0;
106 static constexpr uint32_t SPLIT_PDU_LENGTH = 195 * 1024;
107 static constexpr const char *PDU_CONTENT = "pdu_content";
108 const std::string PDP_PROFILE_NET_URI = "datashare:///com.ohos.pdpprofileability/net/pdp_profile?simId=";
109 const std::string MMS_APN_TYPE = "mms";
110 const std::string ALL_APN_TYPE = "*";
111 const std::string MMS_FILE_ADDRESS = "/data/app/test.mms";
112 const std::string SMS_PROFILE_MMS_PDU_URI = "datashare:///com.ohos.smsmmsability/sms_mms/mms_pdu";
113 
SetUpTestCase()114 void MmsGtest::SetUpTestCase()
115 {
116     TELEPHONY_LOGI("SetUpTestCase slotId%{public}d", DEFAULT_SIM_SLOT_ID_1);
117     g_telephonyService = GetProxy();
118     if (g_telephonyService == nullptr) {
119         return;
120     }
121     Singleton<SmsServiceManagerClient>::GetInstance().ResetSmsServiceProxy();
122     Singleton<SmsServiceManagerClient>::GetInstance().InitSmsServiceProxy();
123 }
124 
GetProxy()125 sptr<ISmsServiceInterface> MmsGtest::GetProxy()
126 {
127     auto systemAbilityMgr = SystemAbilityManagerClient::GetInstance().GetSystemAbilityManager();
128     if (systemAbilityMgr == nullptr) {
129         return nullptr;
130     }
131     sptr<IRemoteObject> remote = systemAbilityMgr->CheckSystemAbility(TELEPHONY_SMS_MMS_SYS_ABILITY_ID);
132     if (remote) {
133         sptr<ISmsServiceInterface> smsService = iface_cast<ISmsServiceInterface>(remote);
134         return smsService;
135     }
136     return nullptr;
137 }
138 
139 #ifndef TEL_TEST_UNSUPPORT
ReceiveWapPushTestFunc(SmsMmsTestHelper & helper)140 void ReceiveWapPushTestFunc(SmsMmsTestHelper &helper)
141 {
142     AccessMmsToken token;
143     auto smsReceiveHandler = std::make_shared<GsmSmsReceiveHandler>(helper.slotId);
144     auto message = std::make_shared<SmsMessageInfo>();
145     message->indicationType = MESSAGE_TYPE;
146     message->size = WAPPUSH_PDU_LEN;
147     message->pdu = StringUtils::HexToByteVector(
148         "0891683110205005F0640BA10156455102F1000432109261715023880605040B8423F04C06246170706C69636174696F6E2F766E642E77"
149         "61702E6D6D732D6D65737361676500B487AF848C829850765030303031365A645430008D9089178031363630373532313930382F545950"
150         "453D504C4D4E008A808E040001298D"
151         "8805810303F47B83687474703A2F2F31302E3132332E31382E38303A3138302F76564F455F3000");
152 
153     AppExecFwk::InnerEvent::Pointer event = AppExecFwk::InnerEvent::Get(RadioEvent::RADIO_GSM_SMS, message);
154     smsReceiveHandler->ProcessEvent(event);
155 }
156 
GetSendReqDataTest(MmsMsg & encodeMsg,std::string number)157 void GetSendReqDataTest(MmsMsg &encodeMsg, std::string number)
158 {
159     if (!encodeMsg.SetMmsMessageType(MMS_MSGTYPE_SEND_REQ)) {
160         TELEPHONY_LOGE("SetMmsMessageType fail");
161     }
162     if (!encodeMsg.SetMmsTransactionId("2077.1427358451410")) {
163         TELEPHONY_LOGE("SetMmsTransactionId fail");
164     }
165     if (!encodeMsg.SetMmsVersion(static_cast<uint16_t>(MmsVersionType::MMS_VERSION_1_2))) {
166         TELEPHONY_LOGE("SetMmsVersion fail");
167     }
168     MmsAddress address;
169     address.SetMmsAddressString(number);
170     if (!encodeMsg.SetMmsFrom(address)) {
171         TELEPHONY_LOGE("SetMmsFrom fail");
172     }
173     if (!encodeMsg.SetHeaderContentType("application/vnd.wap.multipart.related")) {
174         TELEPHONY_LOGE("SetHeaderContentType fail");
175     }
176     if (!encodeMsg.SetMmsSubject("mms")) {
177         TELEPHONY_LOGE("SetMmsSubject fail");
178     }
179     if (!encodeMsg.SetHeaderOctetValue(MMS_CONTENT_CLASS, static_cast<uint8_t>(MmsContentClass::MMS_TEXT))) {
180         TELEPHONY_LOGE("SetHeaderOctetValue MMS_CONTENT_CLASS fail");
181     }
182 }
183 
MmsAddAttachment(MmsMsg & msg,std::string pathName,std::string contentId,std::string contenType,bool isSmil)184 bool MmsAddAttachment(MmsMsg &msg, std::string pathName, std::string contentId, std::string contenType, bool isSmil)
185 {
186     MmsAttachment imageAttachment;
187     std::size_t pos = pathName.find_last_of('/');
188     std::string fileName(pathName.substr(pos + 1));
189     if (!imageAttachment.SetAttachmentFilePath(pathName, isSmil)) {
190         TELEPHONY_LOGE("MmsAddAttachment SetAttachmentFilePath fail");
191         return false;
192     }
193     if (!imageAttachment.SetFileName(fileName)) {
194         TELEPHONY_LOGE("MmsAddAttachment SetFileName fail");
195         return false;
196     }
197     if (!imageAttachment.SetContentId(contentId)) {
198         TELEPHONY_LOGE("MmsAddAttachment SetContentId fail");
199         return false;
200     }
201     if (!imageAttachment.SetContentLocation(fileName)) {
202         TELEPHONY_LOGE("MmsAddAttachment SetContentLocation fail");
203         return false;
204     }
205     if (!imageAttachment.SetContentType(contenType)) {
206         TELEPHONY_LOGE("MmsAddAttachment SetContentType fail");
207         return false;
208     }
209     imageAttachment.SetContentDisposition("attachment");
210     if (!msg.AddAttachment(imageAttachment)) {
211         TELEPHONY_LOGE("MmsAddAttachment AddAttachment fail");
212         return false;
213     }
214     return true;
215 }
216 
WriteBufferToFile(const std::unique_ptr<char[]> & buff,uint32_t len,const std::string & strPathName)217 bool WriteBufferToFile(const std::unique_ptr<char[]> &buff, uint32_t len, const std::string &strPathName)
218 {
219     FILE *pFile = nullptr;
220     pFile = fopen(strPathName.c_str(), "wb");
221     if (!pFile || buff == nullptr) {
222         return false;
223     }
224     uint32_t fileLen = fwrite(buff.get(), len, 1, pFile);
225     if (fileLen > 0) {
226         TELEPHONY_LOGD("write mms buffer to file success");
227     } else {
228         TELEPHONY_LOGE("write mms buffer to file error");
229     }
230     (void)fclose(pFile);
231     return true;
232 }
233 
GetMmsPduFromFile(const std::string & fileName,std::string & mmsPdu)234 bool GetMmsPduFromFile(const std::string &fileName, std::string &mmsPdu)
235 {
236     char realPath[PATH_MAX] = { 0 };
237     if (fileName.empty() || realpath(fileName.c_str(), realPath) == nullptr) {
238         TELEPHONY_LOGE("path or realPath is nullptr");
239         return false;
240     }
241     FILE *pFile = fopen(realPath, "rb");
242     if (pFile == nullptr) {
243         TELEPHONY_LOGE("openFile Error");
244         return false;
245     }
246     (void)fseek(pFile, 0, SEEK_END);
247     long fileLen = ftell(pFile);
248     if (fileLen <= 0 || fileLen > static_cast<long>(MMS_PDU_MAX_SIZE)) {
249         (void)fclose(pFile);
250         TELEPHONY_LOGE("fileLen Over Max Error");
251         return false;
252     }
253     std::unique_ptr<char[]> pduBuffer = std::make_unique<char[]>(fileLen);
254     if (!pduBuffer) {
255         (void)fclose(pFile);
256         TELEPHONY_LOGE("make unique pduBuffer nullptr Error");
257         return false;
258     }
259     (void)fseek(pFile, 0, SEEK_SET);
260     int32_t totolLength = static_cast<int32_t>(fread(pduBuffer.get(), 1, MMS_PDU_MAX_SIZE, pFile));
261     TELEPHONY_LOGI("fread totolLength%{public}d", totolLength);
262     long i = 0;
263     while (i < fileLen) {
264         mmsPdu += pduBuffer[i];
265         i++;
266     }
267     (void)fclose(pFile);
268     return true;
269 }
270 
SplitPdu(const std::string & mmsPdu)271 std::vector<std::string> SplitPdu(const std::string &mmsPdu)
272 {
273     std::vector<std::string> mmsPdus;
274     if (mmsPdu.compare(PDU) == 0) {
275         for (uint32_t locate = 0; locate < MAX_PDU_PAGES; locate++) {
276             mmsPdus.push_back(PDU);
277         }
278         return mmsPdus;
279     }
280     std::string targetMmsPdu;
281     for (size_t i = 0; i < mmsPdu.size(); i++) {
282         targetMmsPdu += static_cast<char>((mmsPdu[i] & HEX_VALUE_0F) | HEX_VALUE_F0);
283         targetMmsPdu += static_cast<char>((mmsPdu[i] & HEX_VALUE_F0) | HEX_VALUE_0F);
284     }
285     std::string mmsPduData;
286     for (uint32_t locate = 0; locate * SPLIT_PDU_LENGTH < targetMmsPdu.size(); locate++) {
287         if ((locate + 1) * SPLIT_PDU_LENGTH < targetMmsPdu.size()) {
288             mmsPduData = targetMmsPdu.substr(locate * SPLIT_PDU_LENGTH, SPLIT_PDU_LENGTH);
289             mmsPdus.push_back(mmsPduData);
290         } else {
291             mmsPduData = targetMmsPdu.substr(locate * SPLIT_PDU_LENGTH);
292             mmsPdus.push_back(mmsPduData);
293             break;
294         }
295     }
296     TELEPHONY_LOGI("pduLen:%{public}zu,targetPduLen:%{public}zu", mmsPdu.size(), targetMmsPdu.size());
297     return mmsPdus;
298 }
299 
GetPduToFile(int32_t slotId)300 void GetPduToFile(int32_t slotId)
301 {
302     SmsMmsTestHelper smsMmsTestHelper;
303     smsMmsTestHelper.slotId = slotId;
304     std::string dest = "10086";
305     std::u16string simcardNumber;
306     if (!CoreServiceClient::GetInstance().GetSimTelephoneNumber(smsMmsTestHelper.slotId, simcardNumber) &&
307         !simcardNumber.empty()) {
308         dest = StringUtils::ToUtf8(simcardNumber);
309     }
310     MmsMsg encodeMsg;
311     std::vector<MmsAddress> vecAddrs;
312     std::string toAddr = dest + "/TYPE=PLMN";
313     MmsAddress toAddrs(toAddr);
314     GetSendReqDataTest(encodeMsg, toAddr);
315     vecAddrs.push_back(toAddrs);
316     if (!encodeMsg.SetMmsTo(vecAddrs)) {
317         TELEPHONY_LOGE("SetMmsTo fail");
318     }
319     const std::string filePathNameText = "/data/app/mms.text";
320     const char *source = "mms";
321     size_t sourceLen = std::strlen(source);
322     std::unique_ptr<char[]> text = std::make_unique<char[]>(sourceLen + 1);
323     if (snprintf_s(text.get(), sourceLen + 1, sourceLen + 1, "%s", source) < 0) {
324         TELEPHONY_LOGE("snprintf_s failed");
325         return;
326     }
327     if (!WriteBufferToFile(std::move(text), std::strlen(source) + 1, filePathNameText)) {
328         TELEPHONY_LOGE("file error.");
329     }
330     if (!MmsAddAttachment(encodeMsg, filePathNameText, "<content.text>", "text/plain", false)) {
331         TELEPHONY_LOGE("MmsAddAttachment text fail");
332     }
333     uint32_t len = 0;
334     std::unique_ptr<char[]> results = encodeMsg.EncodeMsg(len);
335     if (results == nullptr) {
336         TELEPHONY_LOGE("encode fail result nullptr !!!!");
337     }
338     if (!WriteBufferToFile(std::move(results), len, MMS_FILE_ADDRESS)) {
339         TELEPHONY_LOGE("Encode write to file error.");
340     }
341 }
342 
GetFileToDb()343 std::string GetFileToDb()
344 {
345     std::string mmsPdu;
346     GetMmsPduFromFile(MMS_FILE_ADDRESS, mmsPdu);
347     Uri uri(SMS_PROFILE_MMS_PDU_URI);
348     std::shared_ptr<MmsPersistHelper> mmsPersistHelper = std::make_shared<MmsPersistHelper>();
349     if (mmsPersistHelper == nullptr) {
350         return "";
351     }
352     std::shared_ptr<DataShare::DataShareHelper> helper = mmsPersistHelper->CreateSmsHelper();
353     if (helper == nullptr) {
354         return "";
355     }
356     std::vector<std::string> mmsPdus = SplitPdu(mmsPdu);
357     std::string dbUrl;
358     for (std::string mmsPdu : mmsPdus) {
359         DataShare::DataShareValuesBucket bucket;
360         bucket.Put(PDU_CONTENT, mmsPdu);
361         int32_t result = helper->Insert(uri, bucket);
362         if (result < 0) {
363             TELEPHONY_LOGE("mms pdu insert fail");
364         }
365         dbUrl += std::to_string(result) + ',';
366     }
367     helper->Release();
368     return dbUrl;
369 }
370 
GetMmsc(int32_t slotId)371 std::string GetMmsc(int32_t slotId)
372 {
373     int32_t simId = CoreManagerInner::GetInstance().GetSimId(slotId);
374     Uri pdpUri(PDP_PROFILE_NET_URI + std::to_string(simId));
375     std::vector<std::string> colume;
376     DataShare::DataSharePredicates predicates;
377     std::u16string operatorNumeric;
378     CoreServiceClient::GetInstance().GetSimOperatorNumeric(slotId, operatorNumeric);
379     std::string mccmnc = StringUtils::ToUtf8(operatorNumeric);
380     predicates.EqualTo(PdpProfileData::MCCMNC, mccmnc);
381     std::shared_ptr<MmsApnInfo> mmsApnInfo = std::make_shared<MmsApnInfo>(slotId);
382     auto pdpHelper = mmsApnInfo->CreatePdpProfileHelper();
383     if (pdpHelper == nullptr) {
384         return "";
385     }
386     auto resultSet = pdpHelper->Query(pdpUri, predicates, colume);
387     if (resultSet == nullptr) {
388         pdpHelper->Release();
389         return "";
390     }
391     int count;
392     resultSet->GetRowCount(count);
393     if (count <= 0) {
394         resultSet->Close();
395         pdpHelper->Release();
396         return "";
397     }
398     std::string homeUrlVal;
399     std::string mmsIPAddressVal;
400     if (!mmsApnInfo->GetMmsApnValue(resultSet, count, homeUrlVal, mmsIPAddressVal)) {
401         TELEPHONY_LOGI("homeUrlVal and mmsIPAddressVal not matched");
402         resultSet->Close();
403         pdpHelper->Release();
404         return "";
405     }
406     resultSet->Close();
407     pdpHelper->Release();
408     return homeUrlVal;
409 }
410 
411 /**
412  * @tc.number   Telephony_SmsMmsGtest_Receive_Wap_Push_0001
413  * @tc.name     Receive a Wap Push
414  * @tc.desc     Function test
415  */
416 HWTEST_F(MmsGtest, Receive_Wap_Push_0001, Function | MediumTest | Level2)
417 {
418     TELEPHONY_LOGI("TelSMSMMSTest::Receive_Wap_Push_0001 -->");
419     int32_t slotId = DEFAULT_SIM_SLOT_ID;
420     ASSERT_TRUE(MmsGtest::HasSimCard(slotId));
421     SmsMmsTestHelper helper;
422     helper.slotId = slotId;
423 
424     EventFwk::MatchingSkills matchingSkills;
425     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SMS_WAPPUSH_RECEIVE_COMPLETED);
426     EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
427     std::shared_ptr<SmsBroadcastSubscriberGtest> subscriberTest =
428         std::make_shared<SmsBroadcastSubscriberGtest>(subscriberInfo, helper);
429     ASSERT_NE(subscriberTest, nullptr);
430     bool subscribeResult = EventFwk::CommonEventManager::SubscribeCommonEvent(subscriberTest);
431     TELEPHONY_LOGI("subscribeResult is : %{public}d", subscribeResult);
432 
433     EXPECT_TRUE(!helper.Run(ReceiveWapPushTestFunc, helper) || helper.GetBoolResult());
434     TELEPHONY_LOGI("TelSMSMMSTest::Receive_Wap_Push_0001 -->finished");
435 }
436 
437 /**
438  * @tc.number   Telephony_SmsMmsGtest_Receive_Wap_Push_0002
439  * @tc.name     Receive a Wap Push
440  * @tc.desc     Function test
441  */
442 HWTEST_F(MmsGtest, Receive_Wap_Push_0002, Function | MediumTest | Level2)
443 {
444     TELEPHONY_LOGI("TelSMSMMSTest::Receive_Wap_Push_0002 -->");
445     int32_t slotId = DEFAULT_SIM_SLOT_ID_1;
446     if (!(MmsGtest::HasSimCard(slotId))) {
447         return;
448     }
449     SmsMmsTestHelper helper;
450     helper.slotId = slotId;
451 
452     EventFwk::MatchingSkills matchingSkills;
453     matchingSkills.AddEvent(EventFwk::CommonEventSupport::COMMON_EVENT_SMS_WAPPUSH_RECEIVE_COMPLETED);
454     EventFwk::CommonEventSubscribeInfo subscriberInfo(matchingSkills);
455     std::shared_ptr<SmsBroadcastSubscriberGtest> subscriberTest =
456         std::make_shared<SmsBroadcastSubscriberGtest>(subscriberInfo, helper);
457     ASSERT_NE(subscriberTest, nullptr);
458     bool subscribeResult = EventFwk::CommonEventManager::SubscribeCommonEvent(subscriberTest);
459     TELEPHONY_LOGI("subscribeResult is : %{public}d", subscribeResult);
460 
461     EXPECT_TRUE(!helper.Run(ReceiveWapPushTestFunc, helper) || helper.GetBoolResult());
462     TELEPHONY_LOGI("TelSMSMMSTest::Receive_Wap_Push_0002 -->finished");
463 }
464 
465 /**
466  * @tc.number   Telephony_SmsMmsGtest_MmsAddress_0001
467  * @tc.name     Test MmsAddress
468  * @tc.desc     Function test
469  */
470 HWTEST_F(MmsGtest, MmsAddress_0001, Function | MediumTest | Level1)
471 {
472     TELEPHONY_LOGI("TelSMSMMSTest::MmsAddress_0001 -->");
473     MmsAddress address;
474     address.SetMmsAddressString("12345678/TYPE=PLMN");
475     address.SetMmsAddressString("12345678/TYPE=IPv4");
476     address.SetMmsAddressString("12345678/TYPE=IPv6");
477     address.SetMmsAddressString("12345678/TYPE=UNKNOWN");
478     address.SetMmsAddressString("12345678/TYPE=EMAIL");
479     std::string ret = address.GetAddressString();
480     EXPECT_STREQ(ret.c_str(), "12345678/TYPE=EMAIL");
481     MmsAddress::MmsAddressType type = address.GetAddressType();
482     EXPECT_EQ(type, MmsAddress::MmsAddressType::ADDRESS_TYPE_PLMN);
483     MmsCharSets charset = address.GetAddressCharset();
484     EXPECT_EQ(charset, MmsCharSets::UTF_8);
485 }
486 
487 /**
488  * @tc.number   Telephony_SmsMmsGtest_MmsAttachment_0001
489  * @tc.name     Test MmsAttachment
490  * @tc.desc     Function test
491  */
492 HWTEST_F(MmsGtest, MmsAttachment_0001, Function | MediumTest | Level1)
493 {
494     TELEPHONY_LOGI("TelSMSMMSTest::MmsAttachment_0001 -->");
495     const std::string pathName = "/data/app/enSrc/618C0A89.smil";
496     std::size_t pos = pathName.find_last_of('/');
497     std::string fileName(pathName.substr(pos + 1));
498     MmsAttachment attachment;
499     bool retBool;
500     std::string retStr;
501     retBool = attachment.SetAttachmentFilePath("", false);
502     EXPECT_EQ(false, retBool);
503     retBool = attachment.SetAttachmentFilePath(pathName, true);
504     EXPECT_EQ(true, retBool);
505     retStr = attachment.GetAttachmentFilePath();
506     EXPECT_STREQ(retStr.c_str(), pathName.c_str());
507     retBool = attachment.SetContentId("");
508     EXPECT_EQ(false, retBool);
509     retBool = attachment.SetContentId("0000");
510     EXPECT_EQ(true, retBool);
511     retBool = attachment.SetContentId("<0000>");
512     EXPECT_EQ(true, retBool);
513     retStr = attachment.GetContentId();
514     EXPECT_STREQ(retStr.c_str(), "<0000>");
515     retBool = attachment.SetContentLocation("");
516     EXPECT_EQ(false, retBool);
517     retBool = attachment.SetContentLocation("SetContentLocation");
518     EXPECT_EQ(true, retBool);
519     retStr = attachment.GetContentLocation();
520     EXPECT_STREQ(retStr.c_str(), "SetContentLocation");
521     retBool = attachment.SetContentDisposition("");
522     EXPECT_EQ(false, retBool);
523     retBool = attachment.SetContentDisposition("attachment");
524     EXPECT_EQ(true, retBool);
525     retStr = attachment.GetContentDisposition();
526     EXPECT_STREQ(retStr.c_str(), "attachment");
527     retBool = attachment.SetContentTransferEncoding("");
528     EXPECT_EQ(false, retBool);
529     retBool = attachment.SetFileName(fileName);
530     EXPECT_EQ(true, retBool);
531     retStr = attachment.GetFileName();
532     EXPECT_STREQ(retStr.c_str(), fileName.c_str());
533     attachment.strFileName_ = "";
534     retStr = attachment.GetFileName();
535     EXPECT_STRNE(retStr.c_str(), fileName.c_str());
536 }
537 
538 /**
539  * @tc.number   Telephony_SmsMmsGtest_MmsAttachment_0002
540  * @tc.name     Test MmsAttachment
541  * @tc.desc     Function test
542  */
543 HWTEST_F(MmsGtest, MmsAttachment_0002, Function | MediumTest | Level1)
544 {
545     TELEPHONY_LOGI("TelSMSMMSTest::MmsAttachment_0002 -->");
546     MmsAttachment attachment;
547     bool retBool;
548     std::string retStr;
549     uint32_t retU32t;
550     uint32_t len = 10 * 1024 * 1024;
551     uint32_t charset = 0;
552     retBool = attachment.SetContentTransferEncoding("SetContentTransferEncoding");
553     EXPECT_EQ(true, retBool);
554     retStr = attachment.GetContentTransferEncoding();
555     EXPECT_STREQ(retStr.c_str(), "SetContentTransferEncoding");
556     retBool = attachment.SetContentType("");
557     EXPECT_EQ(false, retBool);
558     attachment.SetIsSmilFile(true);
559     retBool = attachment.IsSmilFile();
560     EXPECT_EQ(true, retBool);
561     attachment.SetCharSet(charset);
562     retU32t = attachment.GetCharSet();
563     EXPECT_EQ(charset, retU32t);
564     retBool = attachment.SetDataBuffer(nullptr, 0);
565     retBool = attachment.SetDataBuffer(nullptr, MAX_MMS_ATTACHMENT_LEN + 1);
566     EXPECT_EQ(false, retBool);
567     retBool = attachment.SetDataBuffer(std::make_unique<char[]>(len + 1), len + 1);
568     EXPECT_EQ(false, retBool);
569     retBool = attachment.SetDataBuffer(std::make_unique<char[]>(len - 1), len - 1);
570     EXPECT_EQ(true, retBool);
571     retBool = attachment.SetDataBuffer(std::make_unique<char[]>(len - 1), len + 1);
572     EXPECT_EQ(false, retBool);
573     EXPECT_FALSE(attachment.GetDataBuffer(len) == nullptr);
574     attachment.dataLength_ = MAX_MMS_ATTACHMENT_LEN + 1;
575     EXPECT_TRUE(attachment.GetDataBuffer(len) == nullptr);
576     MmsAttachment attachment1(attachment);
577     attachment1.SetContentType("application/smil");
578     retStr = attachment1.GetContentType();
579     EXPECT_STREQ(retStr.c_str(), "application/smil");
580 }
581 
582 /**
583  * @tc.number   Telephony_SmsMmsGtest_MmsBodyPartHeader_0001
584  * @tc.name     Test MmsBodyPartHeader
585  * @tc.desc     Function test
586  */
587 HWTEST_F(MmsGtest, MmsBodyPartHeader_0001, Function | MediumTest | Level1)
588 {
589     TELEPHONY_LOGI("TelSMSMMSTest::MmsBodyPartHeader_0001 -->");
590     MmsBodyPartHeader mmsBodyPartHeader;
591     MmsDecodeBuffer decodeBuffer;
592     std::string testStr;
593     uint32_t len = 0;
594     uint32_t lenErr = -1;
595     uint32_t lenMax = 300 * 1024;
596     mmsBodyPartHeader.DumpBodyPartHeader();
597     mmsBodyPartHeader.DecodeContentLocation(decodeBuffer, len);
598     mmsBodyPartHeader.DecodeContentId(decodeBuffer, len);
599     mmsBodyPartHeader.DecodeContentDisposition(decodeBuffer, len);
600     mmsBodyPartHeader.DecodeDispositionParameter(decodeBuffer, lenMax, len);
601     mmsBodyPartHeader.DecodeDispositionParameter(decodeBuffer, lenErr, len);
602     mmsBodyPartHeader.DecodeWellKnownHeader(decodeBuffer, len);
603     mmsBodyPartHeader.DecodeApplicationHeader(decodeBuffer, len);
604     mmsBodyPartHeader.SetContentId("contentId");
605     mmsBodyPartHeader.GetContentId(testStr);
606     EXPECT_STREQ(testStr.c_str(), "contentId");
607     mmsBodyPartHeader.SetContentTransferEncoding("contentTransferEncoding");
608     mmsBodyPartHeader.GetContentTransferEncoding(testStr);
609     EXPECT_STREQ(testStr.c_str(), "contentTransferEncoding");
610     mmsBodyPartHeader.SetContentLocation("contentLocation");
611     mmsBodyPartHeader.GetContentLocation(testStr);
612     EXPECT_STREQ(testStr.c_str(), "contentLocation");
613     MmsEncodeBuffer encodeBuffer;
614     mmsBodyPartHeader.EncodeContentLocation(encodeBuffer);
615     mmsBodyPartHeader.EncodeContentId(encodeBuffer);
616     mmsBodyPartHeader.EncodeContentDisposition(encodeBuffer);
617     mmsBodyPartHeader.EncodeContentTransferEncoding(encodeBuffer);
618     mmsBodyPartHeader.EncodeMmsBodyPartHeader(encodeBuffer);
619     MmsBodyPartHeader mmsBodyPartHeader2;
620     MmsBodyPartHeader mmsBodyPartHeader3 = MmsBodyPartHeader(mmsBodyPartHeader);
621     mmsBodyPartHeader2 = mmsBodyPartHeader;
622     mmsBodyPartHeader2.SetContentDisposition("contentDisposition");
623     mmsBodyPartHeader2.GetContentDisposition(testStr);
624     EXPECT_STREQ(testStr.c_str(), "contentDisposition");
625 }
626 
627 /**
628  * @tc.number   Telephony_SmsMmsGtest_MmsBuffer_0001
629  * @tc.name     Test MmsBuffer
630  * @tc.desc     Function test
631  */
632 HWTEST_F(MmsGtest, MmsBuffer_0001, Function | MediumTest | Level1)
633 {
634     TELEPHONY_LOGI("TelSMSMMSTest::MmsBuffer_0001 -->");
635     MmsBuffer mmsBuffer;
636     uint32_t len = 10;
637     bool retBool;
638     std::string strPathName = "/data/app/enSrc/618C0A89.smil";
639     mmsBuffer.ReadDataBuffer(len);
640     mmsBuffer.ReadDataBuffer(len, len);
641     retBool = mmsBuffer.WriteDataBuffer(std::make_unique<char[]>(len), 0);
642     EXPECT_EQ(false, retBool);
643     retBool = mmsBuffer.WriteDataBuffer(std::make_unique<char[]>(len), len);
644     EXPECT_EQ(true, retBool);
645     mmsBuffer.WriteBufferFromFile(strPathName);
646     mmsBuffer.GetCurPosition();
647     uint32_t ret = mmsBuffer.GetSize();
648     EXPECT_GE(ret, 0);
649 }
650 
651 /**
652  * @tc.number   Telephony_SmsMmsGtest_MmsContentParam_0001
653  * @tc.name     Test MmsContentParam
654  * @tc.desc     Function test
655  */
656 HWTEST_F(MmsGtest, MmsContentParam_0001, Function | MediumTest | Level1)
657 {
658     TELEPHONY_LOGI("TelSMSMMSTest::MmsContentParam_0001 -->");
659     MmsContentParam mmsContentParam;
660     MmsContentParam mmsContentParam2;
661     uint8_t field = 1;
662     uint32_t charset = 10;
663     std::string testStr;
664     uint32_t retU32t;
665     mmsContentParam.DumpContentParam();
666     mmsContentParam.SetCharSet(charset);
667     retU32t = mmsContentParam.GetCharSet();
668     EXPECT_EQ(charset, retU32t);
669     mmsContentParam.SetType("type");
670     testStr = mmsContentParam.GetType();
671     EXPECT_STREQ(testStr.c_str(), "type");
672     mmsContentParam.SetFileName("");
673     mmsContentParam.SetStart("");
674     mmsContentParam.SetStart("start");
675     mmsContentParam.GetStart(testStr);
676     EXPECT_STREQ(testStr.c_str(), "start");
677     mmsContentParam.AddNormalField(field, "value");
678     mmsContentParam.GetNormalField(field, testStr);
679     EXPECT_STREQ(testStr.c_str(), "value");
680     mmsContentParam.GetParamMap();
681     mmsContentParam2 = mmsContentParam;
682     mmsContentParam2.SetFileName("fileName");
683     mmsContentParam2.GetFileName(testStr);
684     EXPECT_STREQ(testStr.c_str(), "fileName");
685 
686     mmsContentParam.textMap_.clear();
687     mmsContentParam.AddNormalField(field, "value");
688     mmsContentParam.textMap_.clear();
689     mmsContentParam.GetNormalField(field, testStr);
690     mmsContentParam.GetStart(testStr);
691     mmsContentParam2.GetFileName(testStr);
692     mmsContentParam.DumpContentParam();
693     EXPECT_STREQ(testStr.c_str(), "fileName");
694 }
695 
696 /**
697  * @tc.number   Telephony_SmsMmsGtest_MmsContentType_0001
698  * @tc.name     Test MmsContentType
699  * @tc.desc     Function test
700  */
701 HWTEST_F(MmsGtest, MmsContentType_0001, Function | MediumTest | Level1)
702 {
703     TELEPHONY_LOGI("TelSMSMMSTest::MmsContentType_0001 -->");
704     MmsContentType mmsContentType;
705     MmsDecodeBuffer decodeBuffer;
706     MmsContentParam contentParam;
707     int32_t len = 10;
708     uint8_t type = 10;
709     std::string testStr;
710     uint8_t count = 10;
711     uint8_t index = 0;
712     while (index < count) {
713         decodeBuffer.pduBuffer_[index] = '1';
714         index++;
715     }
716     mmsContentType.DumpMmsContentType();
717 
718     decodeBuffer.curPosition_ = 0;
719     decodeBuffer.pduBuffer_[decodeBuffer.curPosition_++] = PDU_TEST_DATA;
720     decodeBuffer.pduBuffer_[decodeBuffer.curPosition_++] = PDU_TEST_DATA;
721     decodeBuffer.pduBuffer_[decodeBuffer.curPosition_] = PDU_TEST_DATA;
722     mmsContentType.DecodeMmsContentType(decodeBuffer, len);
723 
724     decodeBuffer.curPosition_ = 0;
725     mmsContentType.DecodeMmsCTGeneralForm(decodeBuffer, len);
726     mmsContentType.GetContentTypeFromInt(type);
727     mmsContentType.GetContentTypeFromString("");
728 
729     decodeBuffer.curPosition_ = 0;
730     mmsContentType.DecodeParameter(decodeBuffer, len);
731     mmsContentType.SetContentParam(contentParam);
732     mmsContentType.DecodeTextField(decodeBuffer, type, len);
733 
734     decodeBuffer.curPosition_ = 0;
735     mmsContentType.DecodeCharsetField(decodeBuffer, len);
736     mmsContentType.DecodeTypeField(decodeBuffer, len);
737 
738     MmsEncodeBuffer encodeBuffer;
739     mmsContentType.EncodeTextField(encodeBuffer);
740     mmsContentType.EncodeCharsetField(encodeBuffer);
741     mmsContentType.EncodeTypeField(encodeBuffer);
742     mmsContentType.EncodeMmsBodyPartContentParam(encodeBuffer);
743     mmsContentType.EncodeMmsBodyPartContentType(encodeBuffer);
744     mmsContentType.GetContentParam();
745     MmsContentType mmsContentType2(mmsContentType);
746     mmsContentType2 = mmsContentType;
747     mmsContentType2.SetContentType("contentType");
748     mmsContentType2.GetContentType(testStr);
749     EXPECT_STREQ(testStr.c_str(), "contentType");
750 }
751 
752 /**
753  * @tc.number   Telephony_SmsMmsGtest_MmsDecodeBuffer_0001
754  * @tc.name     Test MmsDecodeBuffer
755  * @tc.desc     Function test
756  */
757 HWTEST_F(MmsGtest, MmsDecodeBuffer_0001, Function | MediumTest | Level1)
758 {
759     TELEPHONY_LOGI("TelSMSMMSTest::MmsDecodeBuffer_0001 -->");
760     uint8_t byteVar = 1;
761     uint32_t intVar = PDU_COUNT;
762     std::string testStr;
763     MmsDecodeBuffer mmsDecodeBuffer;
764     uint8_t count = PDU_COUNT;
765     uint8_t index = 0;
766     while (index < count) {
767         mmsDecodeBuffer.pduBuffer_[index] = '1';
768         index++;
769     }
770 
771     mmsDecodeBuffer.PeekOneByte(byteVar);
772     mmsDecodeBuffer.GetOneByte(byteVar);
773     mmsDecodeBuffer.IncreasePointer(intVar);
774     mmsDecodeBuffer.DecreasePointer(intVar);
775     mmsDecodeBuffer.curPosition_ = PDU_CUSITION;
776     mmsDecodeBuffer.totolLength_ = PDU_LENGTH;
777     mmsDecodeBuffer.PeekOneByte(byteVar);
778     mmsDecodeBuffer.GetOneByte(byteVar);
779     mmsDecodeBuffer.IncreasePointer(intVar);
780     mmsDecodeBuffer.DecreasePointer(intVar);
781 
782     mmsDecodeBuffer.curPosition_ = 0;
783     mmsDecodeBuffer.DecodeUintvar(intVar, intVar);
784     mmsDecodeBuffer.DecodeShortLength(byteVar);
785 
786     char testChar = MIN_SHORT_OCTET + 1;
787     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = testChar;
788     mmsDecodeBuffer.DecodeShortLength(byteVar);
789     mmsDecodeBuffer.curPosition_ = 0;
790     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = MIN_SHORT_OCTET;
791     mmsDecodeBuffer.DecodeValueLengthReturnLen(intVar, intVar);
792     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = testChar;
793     mmsDecodeBuffer.DecodeValueLengthReturnLen(intVar, intVar);
794     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = testChar + 1;
795     mmsDecodeBuffer.DecodeValueLengthReturnLen(intVar, intVar);
796 
797     uint8_t errVar = -1;
798     bool ret = mmsDecodeBuffer.CharIsToken(errVar);
799     EXPECT_EQ(false, ret);
800 }
801 
802 /**
803  * @tc.number   Telephony_SmsMmsGtest_MmsDecodeBuffer_0002
804  * @tc.name     Test MmsDecodeBuffer
805  * @tc.desc     Function test
806  */
807 HWTEST_F(MmsGtest, MmsDecodeBuffer_0002, Function | MediumTest | Level1)
808 {
809     TELEPHONY_LOGI("TelSMSMMSTest::MmsDecodeBuffer_0002 -->");
810     uint32_t intVar = 10;
811     std::string testStr;
812     MmsDecodeBuffer mmsDecodeBuffer;
813     uint8_t count = 10;
814     uint8_t index = 0;
815     while (index < count) {
816         mmsDecodeBuffer.pduBuffer_[index] = '1';
817         index++;
818     }
819     mmsDecodeBuffer.curPosition_ = 0;
820     char testChar = MIN_SHORT_OCTET + 1;
821     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = MIN_SHORT_OCTET;
822     mmsDecodeBuffer.DecodeValueLength(intVar);
823     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = testChar;
824     mmsDecodeBuffer.DecodeValueLength(intVar);
825     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = testChar + 1;
826     mmsDecodeBuffer.DecodeValueLength(intVar);
827 
828     mmsDecodeBuffer.curPosition_ = 0;
829     testChar += 1;
830     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = testChar;
831     mmsDecodeBuffer.DecodeTokenText(testStr, intVar);
832     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = testChar + 1;
833     mmsDecodeBuffer.DecodeTokenText(testStr, intVar);
834     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = QUOTE_CHAR_LEN;
835     mmsDecodeBuffer.DecodeTokenText(testStr, intVar);
836 
837     mmsDecodeBuffer.curPosition_ = 0;
838     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = QUOTE_CHAR_LEN - 1;
839     mmsDecodeBuffer.DecodeText(testStr, intVar);
840     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = QUOTE_CHAR_LEN;
841     mmsDecodeBuffer.DecodeText(testStr, intVar);
842 
843     mmsDecodeBuffer.curPosition_ = 0;
844     testChar += 1;
845     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = testChar;
846     mmsDecodeBuffer.DecodeQuotedText(testStr, intVar);
847     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = testChar + 1;
848     mmsDecodeBuffer.DecodeQuotedText(testStr, intVar);
849 
850     uint8_t errVar = -1;
851     bool ret = mmsDecodeBuffer.CharIsToken(errVar);
852     EXPECT_EQ(false, ret);
853 }
854 
855 /**
856  * @tc.number   Telephony_SmsMmsGtest_MmsDecodeBuffer_0003
857  * @tc.name     Test MmsDecodeBuffer
858  * @tc.desc     Function test
859  */
860 HWTEST_F(MmsGtest, MmsDecodeBuffer_0003, Function | MediumTest | Level1)
861 {
862     TELEPHONY_LOGI("TelSMSMMSTest::MmsDecodeBuffer_0003 -->");
863     uint8_t byteVar = 1;
864     uint64_t longVar = 10;
865     std::string testStr;
866     MmsDecodeBuffer mmsDecodeBuffer;
867     uint8_t count = 10;
868     uint8_t index = 0;
869     while (index < count) {
870         mmsDecodeBuffer.pduBuffer_[index] = '1';
871         index++;
872     }
873 
874     mmsDecodeBuffer.curPosition_ = 0;
875     char testChar = QUOTE_CHAR_LEN + 1;
876     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = testChar;
877     mmsDecodeBuffer.DecodeShortInteger(byteVar);
878     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = testChar + 1;
879     mmsDecodeBuffer.DecodeShortInteger(byteVar);
880 
881     mmsDecodeBuffer.curPosition_ = 0;
882     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = VALUE_CHAR;
883     mmsDecodeBuffer.DecodeLongInteger(longVar);
884     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = VALUE_CHAR + 1;
885     mmsDecodeBuffer.DecodeLongInteger(longVar);
886 
887     mmsDecodeBuffer.curPosition_ = 0;
888     mmsDecodeBuffer.DecodeInteger(longVar);
889     mmsDecodeBuffer.curPosition_ = 0;
890     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = testChar;
891     mmsDecodeBuffer.DecodeIsShortInt();
892     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = testChar + 1;
893     mmsDecodeBuffer.DecodeIsShortInt();
894 
895     mmsDecodeBuffer.curPosition_ = 0;
896     char srcChar = MIN_SHORT_OCTET + 1;
897     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = srcChar;
898     mmsDecodeBuffer.DecodeIsString();
899     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = srcChar + 1;
900     mmsDecodeBuffer.DecodeIsString();
901     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = testChar + 1;
902     mmsDecodeBuffer.DecodeIsString();
903 
904     mmsDecodeBuffer.curPosition_ = 0;
905     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = srcChar;
906     mmsDecodeBuffer.DecodeIsValueLength();
907     mmsDecodeBuffer.pduBuffer_[mmsDecodeBuffer.curPosition_] = srcChar + 1;
908     mmsDecodeBuffer.DecodeIsValueLength();
909 
910     mmsDecodeBuffer.MarkPosition();
911     mmsDecodeBuffer.UnMarkPosition();
912     uint8_t errVar = -1;
913     bool ret = mmsDecodeBuffer.CharIsToken(errVar);
914     EXPECT_EQ(false, ret);
915 }
916 
917 /**
918  * @tc.number   Telephony_SmsMmsGtest_MmsEncodeString_0001
919  * @tc.name     Test MmsEncodeString
920  * @tc.desc     Function test
921  */
922 HWTEST_F(MmsGtest, MmsEncodeString_0001, Function | MediumTest | Level1)
923 {
924     TELEPHONY_LOGI("TelSMSMMSTest::MmsEncodeString_0001 -->");
925     MmsEncodeString mmsEncodeString;
926     MmsDecodeBuffer decodeBuffer;
927     MmsEncodeBuffer encodeBuffer;
928     std::string testStr;
929     uint32_t charset = PDU_COUNT;
930     MmsAddress addrsss;
931     uint32_t len = PDU_COUNT;
932     std::unique_ptr<char[]> inBuff = std::make_unique<char[]>(len);
933     for (uint32_t i = 0; i < len; i++) {
934         inBuff[i] = 1;
935     }
936     decodeBuffer.WriteDataBuffer(std::move(inBuff), len);
937     mmsEncodeString.DecodeEncodeString(decodeBuffer);
938     decodeBuffer.curPosition_ = MAX_MMS_ATTACHMENT_LEN + 1;
939     mmsEncodeString.DecodeEncodeString(decodeBuffer);
940     mmsEncodeString.charset_ = ENCODE_CHARSET1;
941     mmsEncodeString.EncodeEncodeString(encodeBuffer);
942     mmsEncodeString.charset_ = ENCODE_CHARSET2;
943     mmsEncodeString.EncodeEncodeString(encodeBuffer);
944     mmsEncodeString.GetEncodeString(testStr);
945     EXPECT_GE(testStr.size(), 0);
946     mmsEncodeString.SetAddressString(addrsss);
947     mmsEncodeString.GetStrEncodeString();
948     MmsEncodeString mmsEncodeString1(mmsEncodeString);
949     charset = 0;
950     bool ret = mmsEncodeString1.SetEncodeString(charset, testStr);
951     EXPECT_EQ(true, ret);
952     ret = mmsEncodeString1.SetEncodeString(charset, testStr);
953     EXPECT_EQ(true, ret);
954 }
955 
956 /**
957  * @tc.number   Telephony_SmsMmsGtest_MmsHeaderCateg_0001
958  * @tc.name     Test MmsHeaderCateg
959  * @tc.desc     Function test
960  */
961 HWTEST_F(MmsGtest, MmsHeaderCateg_0001, Function | MediumTest | Level1)
962 {
963     TELEPHONY_LOGI("TelSMSMMSTest::MmsHeaderCateg_0001 -->");
964     MmsHeaderCateg mmsHeaderCateg;
965     uint8_t fieldId = 0;
966     mmsHeaderCateg.FindSendReqOptType(fieldId);
967     mmsHeaderCateg.FindSendConfOptType(fieldId);
968     mmsHeaderCateg.FindFieldDes(fieldId);
969     mmsHeaderCateg.CheckIsValueLen(fieldId);
970     bool ret = mmsHeaderCateg.CheckIsValueLen(fieldId);
971     EXPECT_EQ(false, ret);
972 }
973 
974 /**
975  * @tc.number   Telephony_SmsMmsGtest_MmsBase64_0001
976  * @tc.name     Test MmsBase64
977  * @tc.desc     Function test
978  */
979 HWTEST_F(MmsGtest, MmsBase64_0001, Function | MediumTest | Level1)
980 {
981     TELEPHONY_LOGI("TelSMSMMSTest::MmsBase64_0001 -->");
982     MmsBase64 mmsBase64;
983     std::string valueStr = "valueStr";
984     mmsBase64.Encode(valueStr);
985     std::string ret = mmsBase64.Decode(valueStr);
986     EXPECT_STRNE(ret.c_str(), "test");
987 }
988 
989 /**
990  * @tc.number   Telephony_SmsMmsGtest_MmsCharSet_0001
991  * @tc.name     Test MmsCharSet
992  * @tc.desc     Function test
993  */
994 HWTEST_F(MmsGtest, MmsCharSet_0001, Function | MediumTest | Level1)
995 {
996     TELEPHONY_LOGI("TelSMSMMSTest::MmsCharSet_0001 -->");
997     MmsCharSet mmsCharSet;
998     uint32_t charSet = 10;
999     std::string strCharSet = "US-ASCII";
1000     mmsCharSet.GetCharSetStrFromInt(strCharSet, charSet);
1001     bool ret = mmsCharSet.GetCharSetIntFromString(charSet, strCharSet);
1002     EXPECT_EQ(true, ret);
1003 }
1004 
1005 /**
1006  * @tc.number   Telephony_SmsMmsGtest_MmsQuotedPrintable_0001
1007  * @tc.name     Test MmsQuotedPrintable
1008  * @tc.desc     Function test
1009  */
1010 HWTEST_F(MmsGtest, MmsQuotedPrintable_0001, Function | MediumTest | Level1)
1011 {
1012     TELEPHONY_LOGI("TelSMSMMSTest::MmsQuotedPrintable_0001 -->");
1013     MmsQuotedPrintable mmsQuotedPrintable;
1014     std::string valueStr = "123";
1015     mmsQuotedPrintable.Encode(valueStr);
1016     std::string destStr = "";
1017     mmsQuotedPrintable.Decode(valueStr, destStr);
1018     bool ret = mmsQuotedPrintable.Decode("", valueStr);
1019     EXPECT_EQ(false, ret);
1020 }
1021 
1022 /**
1023  * @tc.number   Telephony_SmsServiceTest_0001
1024  * @tc.name     Test MmsQuotedPrintable
1025  * @tc.desc     Function test
1026  */
1027 HWTEST_F(MmsGtest, SmsServiceTest_0001, Function | MediumTest | Level1)
1028 {
1029     AccessMmsToken token;
1030     int32_t slotId = 0;
1031     int64_t timeStamp = 0;
1032     std::string homeUrlVal;
1033     std::string dbUrl;
1034     GetPduToFile(slotId);
1035     dbUrl = GetFileToDb();
1036     homeUrlVal = GetMmsc(slotId);
1037     std::u16string mmsc = StringUtils::ToUtf16(homeUrlVal);
1038     std::u16string data = StringUtils::ToUtf16(dbUrl);
1039     std::u16string ua = u"";
1040     std::u16string uaprof = u"";
1041     Singleton<SmsServiceManagerClient>::GetInstance().SendMms(slotId, mmsc, data, ua, uaprof, timeStamp);
1042     Singleton<SmsServiceManagerClient>::GetInstance().DownloadMms(slotId, mmsc, data, ua, uaprof);
1043     EXPECT_GE(dbUrl.length(), 0);
1044     EXPECT_GE(homeUrlVal.length(), 0);
1045 }
1046 #endif // TEL_TEST_UNSUPPORT
1047 } // namespace Telephony
1048 } // namespace OHOS