• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 #define private public
16 #define protected public
17 #include "gtest/gtest.h"
18 #include "mms_header.h"
19 #include "msg_text_convert.h"
20 #include "sms_wap_push_buffer.h"
21 #include "telephony_errors.h"
22 #include "telephony_hisysevent.h"
23 #include "telephony_log_wrapper.h"
24 
25 namespace OHOS {
26 namespace Telephony {
27 using namespace testing::ext;
28 
29 namespace {
30 const std::string TEXT_SMS_CONTENT = "hello world";
31 const uint32_t TRANSACTION_ID_LENGTH = 3;
32 const uint8_t MIN_TOKEN = 30;
33 const uint8_t MAX_TOKEN = 127;
34 const int BUF_SIZE = 2401;
35 const int TEXT_LENGTH = 2;
36 const unsigned char SRC_TEXT = 2;
37 const uint8_t FIELD_ID = 2;
38 } // namespace
39 
40 class BranchTest : public testing::Test {
41 public:
42     static void SetUpTestCase();
43     static void TearDownTestCase();
44     void SetUp();
45     void TearDown();
46 };
SetUpTestCase()47 void BranchTest::SetUpTestCase() {}
48 
TearDownTestCase()49 void BranchTest::TearDownTestCase() {}
50 
SetUp()51 void BranchTest::SetUp() {}
52 
TearDown()53 void BranchTest::TearDown() {}
54 
55 /**
56  * @tc.number   Telephony_SmsMmsGtest_MsgTextConvert_0001
57  * @tc.name     Test CdmaSmsReceiveHandler
58  * @tc.desc     Function test
59  */
60 HWTEST_F(BranchTest, MsgTextConvert_0001, Function | MediumTest | Level1)
61 {
62     MsgTextConvert *textCvt = MsgTextConvert::Instance();
63     SmsCodingScheme smsCodingScheme;
64     MsgLangInfo msgLangInfo;
65     unsigned char encodeData[BUF_SIZE];
66     MSG_LANGUAGE_ID_T langId = 0;
67     bool bAbnormal = false;
68     unsigned short inText = 1;
69     const unsigned char *pMsgText = (const unsigned char *)TEXT_SMS_CONTENT.c_str();
70     unsigned char *pDestText = encodeData;
71     MSG_LANGUAGE_ID_T *pLangId = &langId;
72     bool *pIncludeAbnormalChar = &bAbnormal;
73     std::tuple<unsigned char *, int, unsigned char *, int, MSG_LANGUAGE_ID_T *, bool *> paras(
74         pDestText, BUF_SIZE, const_cast<unsigned char *>(pMsgText), 0, pLangId, pIncludeAbnormalChar);
75     EXPECT_GE(textCvt->ConvertUTF8ToGSM7bit(paras), 0);
76     EXPECT_GE(textCvt->ConvertCdmaUTF8ToAuto(pDestText, 1, pMsgText, 1, &smsCodingScheme), -1);
77     EXPECT_GE(textCvt->ConvertGsmUTF8ToAuto(pDestText, 1, pMsgText, 1, &smsCodingScheme), -1);
78     EXPECT_EQ(textCvt->ConvertUTF8ToUCS2(pDestText, 1, pMsgText, -1), -1);
79     EXPECT_EQ(textCvt->ConvertUTF8ToUCS2(pDestText, 0, pMsgText, -1), -1);
80     EXPECT_EQ(textCvt->ConvertCdmaUTF8ToAuto(pDestText, 1, pMsgText, 0, &smsCodingScheme), 0);
81     EXPECT_EQ(textCvt->ConvertGsmUTF8ToAuto(pDestText, 1, pMsgText, 0, &smsCodingScheme), 0);
82     EXPECT_EQ(textCvt->ConvertGSM7bitToUTF8(pDestText, 0, pMsgText, 0, &msgLangInfo), 0);
83     EXPECT_GE(textCvt->ConvertSHIFTJISToUTF8(pDestText, 1, pMsgText, -1), 0);
84     EXPECT_GE(textCvt->ConvertUCS2ToUTF8(pDestText, 1, pMsgText, -1), 0);
85     EXPECT_GE(textCvt->ConvertEUCKRToUTF8(pDestText, 1, pMsgText, -1), 0);
86     EXPECT_FALSE(textCvt->ConvertUCS2ToUTF8(pDestText, 0, pMsgText, 0));
87     EXPECT_FALSE(textCvt->ConvertEUCKRToUTF8(pDestText, 0, pMsgText, 1));
88     EXPECT_FALSE(textCvt->ConvertSHIFTJISToUTF8(pDestText, 0, pMsgText, 1));
89     EXPECT_EQ(textCvt->ConvertUCS2ToGSM7bit(pDestText, 0, pMsgText, 0, pLangId, pIncludeAbnormalChar), -1);
90     EXPECT_GT(textCvt->ConvertUCS2ToGSM7bit(pDestText, 1, pMsgText, TEXT_LENGTH, pLangId, pIncludeAbnormalChar), 0);
91     EXPECT_EQ(textCvt->ConvertUCS2ToGSM7bitAuto(pDestText, 0, pMsgText, 0, pIncludeAbnormalChar), -1);
92     EXPECT_GE(textCvt->ConvertUCS2ToGSM7bitAuto(pDestText, 1, pMsgText, 1, pIncludeAbnormalChar), 0);
93     EXPECT_EQ(textCvt->ConvertUCS2ToASCII(pDestText, 0, pMsgText, 0, pIncludeAbnormalChar), -1);
94     EXPECT_GE(textCvt->ConvertUCS2ToASCII(pDestText, 1, pMsgText, 1, pIncludeAbnormalChar), 0);
95     EXPECT_EQ(textCvt->GetLangType(pMsgText, 0), MSG_DEFAULT_CHAR);
96     EXPECT_GE(textCvt->GetLangType(pMsgText, 0), MSG_DEFAULT_CHAR);
97     EXPECT_EQ(textCvt->FindUCS2toGSM7Ext(pDestText, 0, inText, bAbnormal), 0);
98     EXPECT_GE(textCvt->FindUCS2toGSM7Ext(pDestText, 1, inText, bAbnormal), 0);
99     EXPECT_EQ(textCvt->FindUCS2toTurkish(pDestText, 0, inText, bAbnormal), 0);
100     EXPECT_GE(textCvt->FindUCS2toTurkish(pDestText, 1, inText, bAbnormal), 0);
101     EXPECT_EQ(textCvt->FindUCS2toSpanish(pDestText, 0, inText, bAbnormal), 0);
102     EXPECT_GE(textCvt->FindUCS2toSpanish(pDestText, 1, inText, bAbnormal), 0);
103     EXPECT_EQ(textCvt->FindUCS2toPortu(pDestText, 0, inText, bAbnormal), 0);
104     EXPECT_GE(textCvt->FindUCS2toPortu(pDestText, 1, inText, bAbnormal), 0);
105     EXPECT_GE(textCvt->FindUCS2ReplaceChar(inText), MSG_DEFAULT_CHAR);
106 }
107 
108 /**
109  * @tc.number   Telephony_SmsMmsGtest_MsgTextConvert_0002
110  * @tc.name     Test CdmaSmsReceiveHandler
111  * @tc.desc     Function test
112  */
113 HWTEST_F(BranchTest, MsgTextConvert_0002, Function | MediumTest | Level1)
114 {
115     MsgTextConvert *textCvt = MsgTextConvert::Instance();
116     MsgLangInfo pLangInfo;
117     pLangInfo.bLockingShift = true;
118     pLangInfo.bSingleShift = true;
119     unsigned char encodeData[BUF_SIZE];
120     unsigned short result = 1;
121     const unsigned char *pText = nullptr;
122     const unsigned char *pMsgText = (const unsigned char *)TEXT_SMS_CONTENT.c_str();
123     unsigned char *pDestText = encodeData;
124     textCvt->ConvertDumpTextToHex(pText, 1);
125     textCvt->ConvertDumpTextToHex(pMsgText, 1);
126     EXPECT_EQ(textCvt->ConvertGSM7bitToUCS2(pDestText, 0, pMsgText, 0, &pLangInfo), -1);
127     pLangInfo.lockingLang = MSG_ID_TURKISH_LANG;
128     EXPECT_GT(textCvt->ConvertGSM7bitToUCS2(pDestText, 1, pMsgText, 1, &pLangInfo), 0);
129     EXPECT_GT(textCvt->EscapeToUCS2(SRC_TEXT, pLangInfo), 0);
130     pLangInfo.lockingLang = MSG_ID_PORTUGUESE_LANG;
131     EXPECT_GT(textCvt->ConvertGSM7bitToUCS2(pDestText, 1, pMsgText, 1, &pLangInfo), 0);
132     EXPECT_GT(textCvt->EscapeToUCS2(SRC_TEXT, pLangInfo), 0);
133     pLangInfo.bLockingShift = false;
134     EXPECT_GT(textCvt->ConvertGSM7bitToUCS2(pDestText, 1, pMsgText, 1, &pLangInfo), 0);
135     EXPECT_EQ(textCvt->EscapeTurkishLockingToUCS2(pMsgText, 0, pLangInfo, result), 0);
136     EXPECT_EQ(textCvt->EscapeTurkishLockingToUCS2(pMsgText, 1, pLangInfo, result), 0);
137     EXPECT_EQ(textCvt->EscapePortuLockingToUCS2(pMsgText, 0, pLangInfo, result), 0);
138     EXPECT_EQ(textCvt->EscapePortuLockingToUCS2(pMsgText, 1, pLangInfo, result), 0);
139     EXPECT_EQ(textCvt->EscapeGSM7BitToUCS2(pMsgText, 0, pLangInfo, result), 0);
140     EXPECT_EQ(textCvt->EscapeGSM7BitToUCS2(pMsgText, 1, pLangInfo, result), 0);
141     pLangInfo.singleLang = MSG_ID_SPANISH_LANG;
142     EXPECT_GT(textCvt->EscapeToUCS2(SRC_TEXT, pLangInfo), 0);
143     pLangInfo.singleLang = MSG_ID_RESERVED_LANG;
144     EXPECT_GT(textCvt->EscapeToUCS2(SRC_TEXT, pLangInfo), 0);
145     pLangInfo.bSingleShift = false;
146     EXPECT_GT(textCvt->EscapeToUCS2(SRC_TEXT, pLangInfo), 0);
147 }
148 
149 /**
150  * @tc.number   Telephony_SmsMmsGtest_MmsHeader_0001
151  * @tc.name     Test CdmaSmsReceiveHandler
152  * @tc.desc     Function test
153  */
154 HWTEST_F(BranchTest, MmsHeader_0001, Function | MediumTest | Level1)
155 {
156     auto mmsHeader = std::make_shared<MmsHeader>();
157     MmsEncodeString encodeString;
158     MmsDecodeBuffer decodeBuffer;
159     MmsEncodeBuffer encodeBuffer;
160     std::string encodeAddress = "123";
161     uint8_t value = 0;
162     MmsAddress address(encodeAddress);
163     std::vector<MmsAddress> addressValue;
164     addressValue.push_back(address);
165     mmsHeader->octetValueMap_.insert(pair<uint8_t, uint8_t>(1, 1));
166     mmsHeader->longValueMap_.insert(pair<uint8_t, int64_t>(1, 1));
167     mmsHeader->textValueMap_.insert(pair<uint8_t, std::string>(1, "1"));
168     mmsHeader->encodeStringsMap_.insert(pair<uint8_t, MmsEncodeString>(1, encodeString));
169     mmsHeader->addressMap_.insert(pair<uint8_t, std::vector<MmsAddress>>(1, addressValue));
170     mmsHeader->DumpMmsHeader();
171     EXPECT_TRUE(mmsHeader->DecodeMmsHeader(decodeBuffer));
172     EXPECT_FALSE(mmsHeader->EncodeMmsHeader(encodeBuffer));
173     EXPECT_TRUE(mmsHeader->GetOctetValue(1, value));
174     EXPECT_FALSE(mmsHeader->SetOctetValue(1, 0));
175     mmsHeader->mmsHaderCateg_.mmsFieldDesMap_.insert(
176         pair<uint8_t, MmsFieldValueType>(MMS_MESSAGE_TYPE, MmsFieldValueType::MMS_FIELD_OCTET_TYPE));
177     mmsHeader->mmsHaderCateg_.mmsFieldDesMap_.insert(
178         pair<uint8_t, MmsFieldValueType>(MMS_PRIORITY, MmsFieldValueType::MMS_FIELD_OCTET_TYPE));
179     mmsHeader->mmsHaderCateg_.mmsFieldDesMap_.insert(
180         pair<uint8_t, MmsFieldValueType>(MMS_RESPONSE_STATUS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE));
181     mmsHeader->mmsHaderCateg_.mmsFieldDesMap_.insert(
182         pair<uint8_t, MmsFieldValueType>(MMS_SENDER_VISIBILITY, MmsFieldValueType::MMS_FIELD_OCTET_TYPE));
183     mmsHeader->mmsHaderCateg_.mmsFieldDesMap_.insert(
184         pair<uint8_t, MmsFieldValueType>(MMS_STATUS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE));
185     mmsHeader->mmsHaderCateg_.mmsFieldDesMap_.insert(
186         pair<uint8_t, MmsFieldValueType>(MMS_RETRIEVE_STATUS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE));
187     mmsHeader->mmsHaderCateg_.mmsFieldDesMap_.insert(
188         pair<uint8_t, MmsFieldValueType>(MMS_READ_STATUS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE));
189     mmsHeader->mmsHaderCateg_.mmsFieldDesMap_.insert(
190         pair<uint8_t, MmsFieldValueType>(MMS_REPLY_CHARGING, MmsFieldValueType::MMS_FIELD_OCTET_TYPE));
191     EXPECT_FALSE(mmsHeader->SetOctetValue(MMS_MESSAGE_TYPE, MMS_MESSAGE_TYPE));
192     EXPECT_FALSE(mmsHeader->SetOctetValue(MMS_PRIORITY, MMS_PRIORITY));
193     EXPECT_FALSE(mmsHeader->SetOctetValue(MMS_RESPONSE_STATUS, MMS_RESPONSE_STATUS));
194     EXPECT_FALSE(mmsHeader->SetOctetValue(MMS_SENDER_VISIBILITY, MMS_SENDER_VISIBILITY));
195     EXPECT_FALSE(mmsHeader->SetOctetValue(MMS_STATUS, MMS_STATUS));
196     EXPECT_FALSE(mmsHeader->SetOctetValue(MMS_RETRIEVE_STATUS, MMS_RETRIEVE_STATUS));
197     EXPECT_FALSE(mmsHeader->SetOctetValue(MMS_READ_STATUS, MMS_READ_STATUS));
198     EXPECT_FALSE(mmsHeader->SetOctetValue(MMS_REPLY_CHARGING, MMS_REPLY_CHARGING));
199     EXPECT_FALSE(mmsHeader->SetOctetValue(MMS_MM_STATE, MMS_MM_STATE));
200     EXPECT_TRUE(mmsHeader->GetHeaderAllAddressValue(1, addressValue));
201 }
202 
203 /**
204  * @tc.number   Telephony_SmsMmsGtest_MmsHeader_0002
205  * @tc.name     Test CdmaSmsReceiveHandler
206  * @tc.desc     Function test
207  */
208 HWTEST_F(BranchTest, MmsHeader_0002, Function | MediumTest | Level1)
209 {
210     auto mmsHeader = std::make_shared<MmsHeader>();
211     int64_t value = 0;
212     std::string valueStr = "";
213     std::string encodeAddress = "123";
214     MmsAddress address(encodeAddress);
215     std::vector<MmsAddress> addressValue;
216     addressValue.push_back(address);
217     MmsEncodeString encodeString;
218     mmsHeader->longValueMap_.insert(pair<uint8_t, int64_t>(1, 1));
219     mmsHeader->textValueMap_.insert(pair<uint8_t, std::string>(1, "1"));
220     mmsHeader->encodeStringsMap_.insert(pair<uint8_t, MmsEncodeString>(1, encodeString));
221     mmsHeader->mmsHaderCateg_.mmsFieldDesMap_.insert(
222         pair<uint8_t, MmsFieldValueType>(MMS_STORE_STATUS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE));
223     mmsHeader->mmsHaderCateg_.mmsFieldDesMap_.insert(
224         pair<uint8_t, MmsFieldValueType>(MMS_CONTENT_CLASS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE));
225     mmsHeader->mmsHaderCateg_.mmsFieldDesMap_.insert(
226         pair<uint8_t, MmsFieldValueType>(MMS_MESSAGE_CLASS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE));
227     mmsHeader->mmsHaderCateg_.mmsFieldDesMap_.insert(
228         pair<uint8_t, MmsFieldValueType>(MMS_CANCEL_STATUS, MmsFieldValueType::MMS_FIELD_OCTET_TYPE));
229     mmsHeader->mmsHaderCateg_.mmsFieldDesMap_.insert(
230         pair<uint8_t, MmsFieldValueType>(MMS_ADAPTATION_ALLOWED, MmsFieldValueType::MMS_FIELD_OCTET_TYPE));
231     EXPECT_TRUE(mmsHeader->SetOctetValue(MMS_ADAPTATION_ALLOWED, MMS_BCC));
232     EXPECT_TRUE(mmsHeader->GetLongValue(1, value));
233     EXPECT_TRUE(mmsHeader->GetTextValue(1, valueStr));
234     EXPECT_TRUE(mmsHeader->GetEncodeStringValue(1, encodeString));
235     EXPECT_FALSE(mmsHeader->SetTextValue(MMS_CANCEL_STATUS, ""));
236     EXPECT_FALSE(mmsHeader->SetTextValue(MMS_CANCEL_STATUS, "123"));
237     EXPECT_FALSE(mmsHeader->SetOctetValue(MMS_MM_FLAGS, MMS_MM_FLAGS));
238     EXPECT_FALSE(mmsHeader->SetOctetValue(MMS_CONTENT_CLASS, MMS_CONTENT_CLASS));
239     EXPECT_FALSE(mmsHeader->SetOctetValue(MMS_MESSAGE_CLASS, MMS_MESSAGE_CLASS));
240     EXPECT_FALSE(mmsHeader->SetOctetValue(MMS_CANCEL_STATUS, MMS_CANCEL_STATUS));
241     EXPECT_FALSE(mmsHeader->SetLongValue(MMS_MESSAGE_CLASS, 0));
242     EXPECT_FALSE(mmsHeader->SetEncodeStringValue(1, 1, valueStr));
243     EXPECT_FALSE(mmsHeader->SetEncodeStringValue(MMS_STORE_STATUS, 1, encodeAddress));
244     EXPECT_FALSE(mmsHeader->AddHeaderAddressValue(1, address));
245     EXPECT_TRUE(mmsHeader->GetStringValue(1, encodeAddress));
246     EXPECT_FALSE(mmsHeader->GetStringValue(FIELD_ID, encodeAddress));
247     EXPECT_TRUE(mmsHeader->GetSmilFileName(valueStr));
248     EXPECT_FALSE(mmsHeader->IsHaveBody());
249 }
250 
251 /**
252  * @tc.number   Telephony_SmsMmsGtest_MmsHeader_0003
253  * @tc.name     Test CdmaSmsReceiveHandler
254  * @tc.desc     Function test
255  */
256 HWTEST_F(BranchTest, MmsHeader_0003, Function | MediumTest | Level1)
257 {
258     auto mmsHeader = std::make_shared<MmsHeader>();
259     MmsDecodeBuffer decodeBuffer;
260     MmsEncodeBuffer buff;
261     std::string encodeAddress = "123";
262     MmsAddress address(encodeAddress);
263     std::vector<MmsAddress> addressValue;
264     addressValue.push_back(address);
265     int32_t data = 0;
266     mmsHeader->addressMap_.insert(pair<uint8_t, std::vector<MmsAddress>>(MMS_BCC, addressValue));
267     mmsHeader->addressMap_.insert(pair<uint8_t, std::vector<MmsAddress>>(MMS_FROM, addressValue));
268     EXPECT_NE(mmsHeader->MakeTransactionId(TRANSACTION_ID_LENGTH), "");
269     EXPECT_FALSE(mmsHeader->DecodeMmsMsgType(1, decodeBuffer, data));
270     EXPECT_FALSE(mmsHeader->DecodeMmsMsgType(MMS_BCC, decodeBuffer, data));
271     EXPECT_FALSE(mmsHeader->DecodeFieldAddressModelValue(1, decodeBuffer, data));
272     EXPECT_TRUE(mmsHeader->DecodeFieldAddressModelValue(MMS_BCC, decodeBuffer, data));
273     EXPECT_FALSE(mmsHeader->DecodeFieldOctetValue(1, decodeBuffer, data));
274     EXPECT_FALSE(mmsHeader->DecodeFieldLongValue(1, decodeBuffer, data));
275     EXPECT_FALSE(mmsHeader->DecodeFieldIntegerValue(1, decodeBuffer, data));
276     EXPECT_FALSE(mmsHeader->DecodeFieldTextStringValue(1, decodeBuffer, data));
277     EXPECT_FALSE(mmsHeader->DecodeFieldTextStringValue(MMS_BCC, decodeBuffer, data));
278     EXPECT_FALSE(mmsHeader->DecodeFieldEncodedStringValue(1, decodeBuffer, data));
279     EXPECT_FALSE(mmsHeader->DecodeFieldEncodedStringValue(MMS_BCC, decodeBuffer, data));
280     EXPECT_FALSE(mmsHeader->DecodeFromValue(1, decodeBuffer, data));
281     EXPECT_FALSE(mmsHeader->DecodeMmsMsgUnKnownField(decodeBuffer));
282     EXPECT_FALSE(mmsHeader->DecodeMmsContentType(1, decodeBuffer, data));
283     EXPECT_FALSE(mmsHeader->DecodeFieldDate(1, decodeBuffer, data));
284     EXPECT_FALSE(mmsHeader->DecodeFieldDate(MMS_BCC, decodeBuffer, data));
285     EXPECT_FALSE(mmsHeader->DecodeFieldPreviouslySentDate(1, decodeBuffer, data));
286     EXPECT_FALSE(mmsHeader->DecodeFieldPreviouslySentDate(MMS_BCC, decodeBuffer, data));
287     EXPECT_FALSE(mmsHeader->DecodeFieldMBox(1, decodeBuffer, data));
288     EXPECT_FALSE(mmsHeader->DecodeFieldMBox(MMS_BCC, decodeBuffer, data));
289     EXPECT_FALSE(mmsHeader->DecodeFieldMMFlag(1, decodeBuffer, data));
290     EXPECT_FALSE(mmsHeader->DecodeFieldMMFlag(MMS_BCC, decodeBuffer, data));
291     EXPECT_TRUE(mmsHeader->EncodeFieldFromValue(buff, addressValue));
292     mmsHeader->textValueMap_.insert(pair<uint8_t, std::string>(MMS_MESSAGE_CLASS, "personal"));
293     EXPECT_TRUE(mmsHeader->EcondeFieldMessageClassValue(buff));
294     mmsHeader->textValueMap_.insert(pair<uint8_t, std::string>(MMS_MESSAGE_CLASS, "advertisement"));
295     EXPECT_TRUE(mmsHeader->EcondeFieldMessageClassValue(buff));
296     mmsHeader->textValueMap_.insert(pair<uint8_t, std::string>(MMS_MESSAGE_CLASS, "informational"));
297     EXPECT_TRUE(mmsHeader->EcondeFieldMessageClassValue(buff));
298     mmsHeader->textValueMap_.insert(pair<uint8_t, std::string>(MMS_MESSAGE_CLASS, "auto"));
299     EXPECT_TRUE(mmsHeader->EcondeFieldMessageClassValue(buff));
300     mmsHeader->octetValueMap_.insert(pair<uint8_t, uint8_t>(MMS_MESSAGE_CLASS, 1));
301     EXPECT_TRUE(mmsHeader->EcondeFieldMessageClassValue(buff));
302 }
303 
304 /**
305  * @tc.number   Telephony_SmsMmsGtest_MmsHeader_0004
306  * @tc.name     Test CdmaSmsReceiveHandler
307  * @tc.desc     Function test
308  */
309 HWTEST_F(BranchTest, MmsHeader_0004, Function | MediumTest | Level1)
310 {
311     auto mmsHeader = std::make_shared<MmsHeader>();
312     MmsEncodeBuffer buff;
313     std::string encodeAddress = "123";
314     MmsAddress address(encodeAddress);
315     std::vector<MmsAddress> addrs;
316     mmsHeader->longValueMap_.insert(pair<uint8_t, int64_t>(MMS_EXPIRY, 1));
317     mmsHeader->textValueMap_.insert(pair<uint8_t, std::string>(MMS_TRANSACTION_ID, "auto"));
318     EXPECT_TRUE(mmsHeader->EncodeCommontFieldValue(buff));
319     EXPECT_FALSE(mmsHeader->EncodeMultipleAddressValue(buff, 1, addrs));
320     addrs.push_back(address);
321     EXPECT_TRUE(mmsHeader->EncodeMultipleAddressValue(buff, 1, addrs));
322     EXPECT_TRUE(mmsHeader->EncodeMmsSendReq(buff));
323     EXPECT_FALSE(mmsHeader->EncodeMmsSendConf(buff));
324     EXPECT_FALSE(mmsHeader->EncodeMmsNotificationInd(buff));
325     mmsHeader->textValueMap_.insert(pair<uint8_t, std::string>(MMS_CONTENT_LOCATION, "auto"));
326     EXPECT_FALSE(mmsHeader->EncodeMmsNotificationInd(buff));
327     EXPECT_FALSE(mmsHeader->EnocdeMmsNotifyRespInd(buff));
328     EXPECT_FALSE(mmsHeader->EnocdeMmsRetrieveConf(buff));
329     mmsHeader->longValueMap_.insert(pair<uint8_t, int64_t>(MMS_DATE, 1));
330     mmsHeader->addressMap_.insert(pair<uint8_t, std::vector<MmsAddress>>(MMS_CC, addrs));
331     EXPECT_TRUE(mmsHeader->EnocdeMmsRetrieveConf(buff));
332     EXPECT_FALSE(mmsHeader->EnocdeMmsDeliveryInd(buff));
333     mmsHeader->addressMap_.insert(pair<uint8_t, std::vector<MmsAddress>>(MMS_TO, addrs));
334     EXPECT_TRUE(mmsHeader->EnocdeMmsRetrieveConf(buff));
335     mmsHeader->addressMap_.insert(pair<uint8_t, std::vector<MmsAddress>>(MMS_FROM, addrs));
336     EXPECT_TRUE(mmsHeader->EnocdeMmsRetrieveConf(buff));
337     EXPECT_FALSE(mmsHeader->EnocdeMmsDeliveryInd(buff));
338     EXPECT_FALSE(mmsHeader->EncodeMmsReadRecInd(buff));
339     mmsHeader->textValueMap_.insert(pair<uint8_t, std::string>(MMS_MESSAGE_ID, "auto"));
340     EXPECT_FALSE(mmsHeader->EnocdeMmsDeliveryInd(buff));
341     mmsHeader->longValueMap_.clear();
342     EXPECT_FALSE(mmsHeader->EnocdeMmsDeliveryInd(buff));
343     mmsHeader->addressMap_.clear();
344     mmsHeader->textValueMap_.clear();
345     EXPECT_FALSE(mmsHeader->EncodeMmsReadRecInd(buff));
346     EXPECT_FALSE(mmsHeader->EncodeMmsReadOrigInd(buff));
347     mmsHeader->textValueMap_.insert(pair<uint8_t, std::string>(MMS_MESSAGE_ID, "auto"));
348     EXPECT_FALSE(mmsHeader->EncodeMmsReadOrigInd(buff));
349     mmsHeader->addressMap_.insert(pair<uint8_t, std::vector<MmsAddress>>(MMS_TO, addrs));
350     EXPECT_FALSE(mmsHeader->EncodeMmsReadOrigInd(buff));
351     mmsHeader->octetValueMap_.insert(pair<uint8_t, uint8_t>(MMS_READ_STATUS, 1));
352     EXPECT_FALSE(mmsHeader->EncodeMmsReadOrigInd(buff));
353     EXPECT_FALSE(mmsHeader->CheckBooleanValue(MMS_DRM_CONTENT, 0));
354     EXPECT_FALSE(mmsHeader->CheckBooleanValue(MMS_BCC, 1));
355 }
356 
357 /**
358  * @tc.number   Telephony_SmsMmsGtest_MmsHeader_0005
359  * @tc.name     Test CdmaSmsReceiveHandler
360  * @tc.desc     Function test
361  */
362 HWTEST_F(BranchTest, MmsHeader_0005, Function | MediumTest | Level1)
363 {
364     auto mmsHeader = std::make_shared<MmsHeader>();
365     MmsEncodeBuffer buff;
366     MmsEncodeString value;
367     std::string str = "q";
368     mmsHeader->TrimString(str);
369     str = "qwer";
370     mmsHeader->TrimString(str);
371     str = "<wer";
372     mmsHeader->TrimString(str);
373     EXPECT_FALSE(mmsHeader->EncodeTextStringValue(buff, 1, ""));
374     EXPECT_FALSE(mmsHeader->EncodeEncodeStringValue(buff, 1, value));
375     EXPECT_TRUE(mmsHeader->IsHaveTransactionId(MMS_MSGTYPE_SEND_REQ));
376     EXPECT_TRUE(mmsHeader->IsHaveTransactionId(MMS_MSGTYPE_SEND_CONF));
377     EXPECT_TRUE(mmsHeader->IsHaveTransactionId(MMS_MSGTYPE_NOTIFICATION_IND));
378     EXPECT_TRUE(mmsHeader->IsHaveTransactionId(MMS_MSGTYPE_NOTIFYRESP_IND));
379     EXPECT_TRUE(mmsHeader->IsHaveTransactionId(MMS_MSGTYPE_RETRIEVE_CONF));
380     EXPECT_TRUE(mmsHeader->IsHaveTransactionId(MMS_MSGTYPE_ACKNOWLEDGE_IND));
381     EXPECT_TRUE(mmsHeader->CheckResponseStatus(static_cast<uint8_t>(MmsResponseStatus::MMS_OK)));
382     EXPECT_TRUE(mmsHeader->CheckResponseStatus(static_cast<uint8_t>(MmsResponseStatus::MMS_ERROR_UNSUPPORTED_MESSAGE)));
383     EXPECT_TRUE(mmsHeader->CheckResponseStatus(static_cast<uint8_t>(MmsResponseStatus::MMS_ERROR_PERMANENT_FAILURE)));
384     EXPECT_TRUE(
385         mmsHeader->CheckResponseStatus(static_cast<uint8_t>(MmsResponseStatus::MMS_ERROR_PERMANENT_LACK_OF_PREPAID)));
386     EXPECT_TRUE(mmsHeader->CheckRetrieveStatus(static_cast<uint8_t>(MmsRetrieveStatus::MMS_RETRIEVE_STATUS_OK)));
387     EXPECT_TRUE(mmsHeader->CheckRetrieveStatus(
388         static_cast<uint8_t>(MmsRetrieveStatus::MMS_RETRIEVE_STATUS_ERROR_PERMANENT_FAILURE)));
389     EXPECT_TRUE(mmsHeader->CheckRetrieveStatus(
390         static_cast<uint8_t>(MmsRetrieveStatus::MMS_RETRIEVE_STATUS_ERROR_PERMANENT_CONTENT_UNSUPPORTED)));
391     EXPECT_TRUE(mmsHeader->CheckRetrieveStatus(
392         static_cast<uint8_t>(MmsRetrieveStatus::MMS_RETRIEVE_STATUS_ERROR_TRANSIENT_FAILURE)));
393     EXPECT_TRUE(mmsHeader->CheckRetrieveStatus(
394         static_cast<uint8_t>(MmsRetrieveStatus::MMS_RETRIEVE_STATUS_ERROR_TRANSIENT_NETWORK_PROBLEM)));
395     EXPECT_TRUE(mmsHeader->CheckStoreStatus(static_cast<uint8_t>(MmsStoreStatus::MMS_STORE_STATUS_SUCCESS)));
396     EXPECT_TRUE(
397         mmsHeader->CheckStoreStatus(static_cast<uint8_t>(MmsStoreStatus::MMS_STORE_STATUS_ERROR_TRANSIENT_FAILURE)));
398     EXPECT_TRUE(mmsHeader->CheckStoreStatus(
399         static_cast<uint8_t>(MmsStoreStatus::MMS_STORE_STATUS_ERROR_TRANSIENT_NETWORK_PROBLEM)));
400     EXPECT_TRUE(
401         mmsHeader->CheckStoreStatus(static_cast<uint8_t>(MmsStoreStatus::MMS_STORE_STATUS_ERROR_PERMANENT_FAILURE)));
402     EXPECT_TRUE(
403         mmsHeader->CheckStoreStatus(static_cast<uint8_t>(MmsStoreStatus::MMS_STORE_STATUS_ERROR_PERMANENT_MMBOX_FULL)));
404     EXPECT_TRUE(mmsHeader->CheckBooleanValue(MMS_DELIVERY_REPORT, static_cast<uint8_t>(MmsBoolType::MMS_YES)));
405     EXPECT_FALSE(mmsHeader->CheckBooleanValue(MMS_READ_REPORT, 0));
406     EXPECT_FALSE(mmsHeader->CheckBooleanValue(MMS_REPORT_ALLOWED, 0));
407     EXPECT_FALSE(mmsHeader->CheckBooleanValue(MMS_STORE, 0));
408     EXPECT_FALSE(mmsHeader->CheckBooleanValue(MMS_STORED, 0));
409     EXPECT_FALSE(mmsHeader->CheckBooleanValue(MMS_TOTALS, 0));
410     EXPECT_FALSE(mmsHeader->CheckBooleanValue(MMS_QUOTAS, 0));
411     EXPECT_FALSE(mmsHeader->CheckBooleanValue(MMS_DISTRIBUTION_INDICATOR, 0));
412 }
413 
414 /**
415  * @tc.number   Telephony_SmsMmsGtest_SmsWapPushBuffer_0001
416  * @tc.name     Test CdmaSmsReceiveHandler
417  * @tc.desc     Function test
418  */
419 HWTEST_F(BranchTest, SmsWapPushBuffer_0001, Function | MediumTest | Level1)
420 {
421     auto smsWapPushBuffer = std::make_shared<SmsWapPushBuffer>();
422     uint8_t oneByte = 0;
423     uint8_t sValueLength = 0;
424     uint32_t valueLength = 0;
425     uint64_t iInteger = 0;
426     uint32_t length = 1;
427     std::string str = "qwe";
428     bool isNoValue = true;
429     EXPECT_FALSE(smsWapPushBuffer->GetOneByte(oneByte));
430     EXPECT_FALSE(smsWapPushBuffer->IncreasePointer(1));
431     EXPECT_FALSE(smsWapPushBuffer->DecreasePointer(1));
432     smsWapPushBuffer->MarkPosition();
433     smsWapPushBuffer->UnMarkPosition();
434     EXPECT_FALSE(smsWapPushBuffer->DecodeShortLength(sValueLength));
435     EXPECT_FALSE(smsWapPushBuffer->DecodeValueLengthReturnLen(valueLength, length));
436     EXPECT_FALSE(smsWapPushBuffer->DecodeValueLength(valueLength));
437     EXPECT_FALSE(smsWapPushBuffer->DecodeUintvar(valueLength, length));
438     EXPECT_FALSE(smsWapPushBuffer->DecodeText(str, length));
439     EXPECT_FALSE(smsWapPushBuffer->CharIsToken(MIN_TOKEN));
440     EXPECT_FALSE(smsWapPushBuffer->CharIsToken(MAX_TOKEN));
441     EXPECT_FALSE(smsWapPushBuffer->DecodeTokenText(str, length));
442     EXPECT_FALSE(smsWapPushBuffer->DecodeShortInteger(oneByte));
443     EXPECT_FALSE(smsWapPushBuffer->DecodeLongInteger(iInteger));
444     EXPECT_FALSE(smsWapPushBuffer->DecodeExtensionMedia());
445     EXPECT_FALSE(smsWapPushBuffer->DecodeConstrainedEncoding());
446     EXPECT_FALSE(smsWapPushBuffer->DecodeTextValue(str, isNoValue));
447     EXPECT_FALSE(smsWapPushBuffer->DecodeNoValue(isNoValue));
448     EXPECT_TRUE(smsWapPushBuffer->ReadDataBuffer(1) == nullptr);
449     EXPECT_TRUE(smsWapPushBuffer->ReadDataBuffer(1, 0) == nullptr);
450     EXPECT_TRUE(smsWapPushBuffer->ReadDataBuffer(0, 0) == nullptr);
451     EXPECT_FALSE(smsWapPushBuffer->WriteRawStringBuffer(str));
452     EXPECT_FALSE(smsWapPushBuffer->WriteDataBuffer(nullptr, 1));
453     smsWapPushBuffer->GetCurPosition();
454     smsWapPushBuffer->GetSize();
455 }
456 } // namespace Telephony
457 } // namespace OHOS
458