1 /*
2  * Copyright (c) 2021 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 #include "gtest/gtest.h"
17 #include "utils/DMSTestBase.h"
18 #include "utils/dms_packet.h"
19 #include "distributed_service_interface.h"
20 
21 using namespace testing::ext;
22 
23 static const int MAX_LENGTH = 1024;
24 static BOOL handleFlag = FALSE;
25 
RunTest(const uint8_t *buffer, uint16_t bufferLen, const TlvParseCallback onTlvParseDone, const StartAbilityCallback onStartAbilityDone)26 static int8_t RunTest(const uint8_t *buffer, uint16_t bufferLen, const TlvParseCallback onTlvParseDone,
27                       const StartAbilityCallback onStartAbilityDone)
28 {
29     IDmsFeatureCallback dmsFeatureCallback = {
30         .onTlvParseDone = onTlvParseDone,
31         .onStartAbilityDone = onStartAbilityDone
32     };
33 
34     CommuInterInfo interInfo;
35     interInfo.payloadLength = bufferLen;
36     interInfo.payload = buffer;
37 
38     return DmsLiteProcessCommuMsg(&interInfo, &dmsFeatureCallback);
39 }
40 
41 class MsgParserFuncTest : public testing::Test {
42 protected:
43     // SetUpTestCase: Testsuit setup, run before 1st testcase
SetUpTestCase(void)44     static void SetUpTestCase(void)
45     {
46         SystemInitProxy();
47         InstallHap();
48     }
49     // TearDownTestCase: Testsuit teardown, run after last testcase
TearDownTestCase(void)50     static void TearDownTestCase(void)
51     {
52     }
53     // Testcase setup
SetUp()54     virtual void SetUp()
55     {
56     }
57     // Testcase teardown
TearDown()58     virtual void TearDown()
59     {
60     }
61 };
62 
63 /**
64  * @tc.number    : DMSLite_DMS_MsgParserFunc_0010
65  * @tc.name      : Normal package with bundle name and ability name can be parsed correctly
66  * @tc.desc      : [C- SOFTWARE -0200]
67 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0010, Function | MediumTest | Level1)68 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0010, Function | MediumTest | Level1) {
69     uint8_t buffer[] = {
70         0x01, 0x01, 0x01, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x6f,
71         0x68, 0x6f, 0x73, 0x2e, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68,
72         0x65, 0x72, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69, 0x6e, 0x41,
73         0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00, 0x04, 0x0a,
74         0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65, 0x79, 0x00
75     };
76 
77     handleFlag = FALSE;
78     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
79         handleFlag = TRUE;
80         const TlvDmsMsgInfo *msg = reinterpret_cast<const TlvDmsMsgInfo *>(dmsMsg);
81         EXPECT_EQ(errCode, DMS_TLV_SUCCESS);
82         EXPECT_EQ(msg->commandId, 1);
83         EXPECT_EQ(string(msg->calleeBundleName), "com.ohos.launcher");
84         EXPECT_EQ(string(msg->calleeAbilityName), "MainActivity");
85         EXPECT_EQ(string(msg->callerSignature), "publickey");
86     };
87 
88     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
89     ASSERT_EQ(TRUE, handleFlag);
90 }
91 
92 /**
93  * @tc.number    : DMSLite_DMS_MsgParserFunc_0020
94  * @tc.name      : When parse abnormal package with null payload user get error code
95  * @tc.desc      : [C- SOFTWARE -0200]
96 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0020, Function | MediumTest | Level2)97 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0020, Function | MediumTest | Level2) {
98     uint8_t buffer[] = {
99         0x01, 0x01, 0x01, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
100         0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
101         0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
102         0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00,
103         0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65,
104         0x79, 0x00
105     };
106 
107     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
108         printf("[hcpptest]result code : %d \n", errCode);
109     };
110 
111     int8_t resultCode = RunTest(nullptr, sizeof(buffer), onTlvParseDone, nullptr);
112     ASSERT_EQ(resultCode, DMS_EC_FAILURE);
113 }
114 
115 /**
116  * @tc.number    : DMSLite_DMS_MsgParserFunc_0030
117  * @tc.name      : When parse abnormal package that size less than min user get error code
118  * @tc.desc      : [C- SOFTWARE -0200]
119 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0030, Function | MediumTest | Level2)120 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0030, Function | MediumTest | Level2) {
121     uint8_t buffer[] = {
122         0x01
123     };
124     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
125         printf("[hcpptest]result code:%d \n", errCode);
126     };
127 
128     // the length range: [2,1024]
129     int8_t resultCode = RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
130     ASSERT_EQ(resultCode, DMS_EC_PARSE_TLV_FAILURE);
131 }
132 
133 /**
134  * @tc.number    : DMSLite_DMS_MsgParserFunc_0040
135  * @tc.name      : When parse abnormal package longer than max length user get error code
136  * @tc.desc      : [C- SOFTWARE -0200]
137 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0040, Function | MediumTest | Level2)138 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0040, Function | MediumTest | Level2) {
139     uint8_t buffer[] = {
140         0x01, 0x01, 0x01, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
141         0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
142         0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
143         0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00,
144         0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65,
145         0x79, 0x00
146     };
147     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
148         printf("[hcpptest]result code:%d \n", errCode);
149     };
150 
151     // the length range: [2,1024]
152     int8_t resultCode = RunTest(buffer, MAX_LENGTH + 1, onTlvParseDone, nullptr);
153     ASSERT_EQ(resultCode, DMS_EC_PARSE_TLV_FAILURE);
154 }
155 
156 /**
157  * @tc.number    : DMSLite_DMS_MsgParserFunc_0050
158  * @tc.name      : When parse abnormal package lack of COMMAND_ID node user get error code
159  * @tc.desc      : [C- SOFTWARE -0200]
160 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0050, Function | MediumTest | Level2)161 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0050, Function | MediumTest | Level2) {
162     uint8_t buffer[] = { };
163 
164     handleFlag = FALSE;
165     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
166         handleFlag = TRUE;
167         EXPECT_EQ(errCode, DMS_TLV_ERR_LEN);
168     };
169     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
170     ASSERT_EQ(TRUE, handleFlag);
171 }
172 
173 /**
174  * @tc.number    : DMSLite_DMS_MsgParserFunc_0060
175  * @tc.name      : When parse abnormal package lack of BUNDLE_NAME node user get error code
176  * @tc.desc      : [C- SOFTWARE -0200]
177 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0060, Function | MediumTest | Level2)178 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0060, Function | MediumTest | Level2) {
179     uint8_t buffer[] = {
180         0x01, 0x01, 0x01,
181     };
182     handleFlag = FALSE;
183     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
184         handleFlag = TRUE;
185         EXPECT_EQ(errCode, DMS_TLV_ERR_BAD_NODE_NUM);
186     };
187     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
188     ASSERT_EQ(TRUE, handleFlag);
189 }
190 
191 /**
192  * @tc.number    : DMSLite_DMS_MsgParserFunc_0070
193  * @tc.name      : When parse abnormal package lack of ABILITY_NAME node user get error code
194  * @tc.desc      : [C- SOFTWARE -0200]
195 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0070, Function | MediumTest | Level2)196 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0070, Function | MediumTest | Level2) {
197     uint8_t buffer[] = {
198         0x01, 0x01, 0x01, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
199         0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
200         0x63, 0x68, 0x65, 0x72, 0x00
201     };
202     handleFlag = FALSE;
203     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
204         handleFlag = TRUE;
205         EXPECT_EQ(errCode, DMS_TLV_ERR_BAD_NODE_NUM);
206     };
207     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
208     ASSERT_EQ(TRUE, handleFlag);
209 }
210 
211 /**
212  * @tc.number    : DMSLite_DMS_MsgParserFunc_0080
213  * @tc.name      : When parse abnormal package lack of SIGNATURE node user get error code
214  * @tc.desc      : [C- SOFTWARE -0200]
215 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0080, Function | MediumTest | Level2)216 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0080, Function | MediumTest | Level2) {
217     uint8_t buffer[] = {
218         0x01, 0x01, 0x01, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
219         0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
220         0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
221         0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00
222     };
223     handleFlag = FALSE;
224     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
225         handleFlag = TRUE;
226         EXPECT_EQ(errCode, DMS_TLV_ERR_BAD_NODE_NUM);
227     };
228     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
229     ASSERT_EQ(TRUE, handleFlag);
230 }
231 
232 /**
233  * @tc.number    : DMSLite_DMS_MsgParserFunc_0090
234  * @tc.name      : When parse abnormal package with an additional node user get error code
235  * @tc.desc      : [C- SOFTWARE -0200]
236 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0090, Function | MediumTest | Level2)237 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0090, Function | MediumTest | Level2) {
238     uint8_t buffer[] = {
239         0x01, 0x01, 0x01, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
240         0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
241         0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
242         0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00,
243         0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65,
244         0x79, 0x00, 0x05, 0x01, 0x00
245     };
246     handleFlag = FALSE;
247     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
248         handleFlag = TRUE;
249         EXPECT_EQ(errCode, DMS_TLV_ERR_BAD_NODE_NUM);
250     };
251     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
252     ASSERT_EQ(TRUE, handleFlag);
253 }
254 
255 /**
256  * @tc.number    : DMSLite_DMS_MsgParserFunc_0100
257  * @tc.name      : When parse abnormal package with node type sequence in non-continuous order user get error code
258  * @tc.desc      : [C- SOFTWARE -0200]
259 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0100, Function | MediumTest | Level2)260 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0100, Function | MediumTest | Level2) {
261     // this sequence is: node1 node2 node4
262     uint8_t buffer[] = {
263         0x01, 0x01, 0x01, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
264         0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
265         0x63, 0x68, 0x65, 0x72, 0x04, 0x00, 0x04, 0x6d, 0x80, 0xff,
266         0x00
267     };
268     handleFlag = FALSE;
269     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
270         handleFlag = TRUE;
271         EXPECT_EQ(errCode, DMS_TLV_ERR_OUT_OF_ORDER);
272     };
273     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
274     ASSERT_EQ(TRUE, handleFlag);
275 }
276 
277 /**
278  * @tc.number    : DMSLite_DMS_MsgParserFunc_0110
279  * @tc.name      : When parse abnormal package with node type sequence in disorder user get error code
280  * @tc.desc      : [C- SOFTWARE -0200]
281 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0110, Function | MediumTest | Level2)282 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0110, Function | MediumTest | Level2) {
283     uint8_t buffer[] = {
284         0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68, 0x75, 0x61, 0x77,
285         0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65,
286         0x72, 0x01, 0x01, 0x00, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
287         0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00
288     };
289     handleFlag = FALSE;
290     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
291         handleFlag = TRUE;
292         EXPECT_EQ(errCode, DMS_TLV_ERR_OUT_OF_ORDER);
293     };
294     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
295     ASSERT_EQ(TRUE, handleFlag);
296 }
297 
298 /**
299  * @tc.number    : DMSLite_DMS_MsgParserFunc_0120
300  * @tc.name      : When parse abnormal package with duplicated COMMAND_ID node user get error code
301  * @tc.desc      : [C- SOFTWARE -0200]
302 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0120, Function | MediumTest | Level2)303 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0120, Function | MediumTest | Level2) {
304     uint8_t buffer[] = {
305         0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x14, 0x63, 0x6f,
306         0x6d, 0x2e, 0x68, 0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c,
307         0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d,
308         0x4d, 0x61, 0x69, 0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69,
309         0x74, 0x79, 0x00, 0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69,
310         0x63, 0x6B, 0x65, 0x79, 0x00
311     };
312     handleFlag = FALSE;
313     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
314         handleFlag = TRUE;
315         EXPECT_EQ(errCode, DMS_TLV_ERR_OUT_OF_ORDER);
316     };
317     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
318     ASSERT_EQ(TRUE, handleFlag);
319 }
320 
321 /**
322  * @tc.number    : DMSLite_DMS_MsgParserFunc_0130
323  * @tc.name      : When parse abnormal package with duplicated BUNDLE_NAME node user get error code
324  * @tc.desc      : [C- SOFTWARE -0200]
325 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0130, Function | MediumTest | Level2)326 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0130, Function | MediumTest | Level2) {
327     uint8_t buffer[] = {
328         0x01, 0x01, 0x01,
329         0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68, 0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c,
330               0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x00,
331         0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68, 0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c,
332               0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x00,
333         0x03, 0x0d, 0x4d, 0x61, 0x69, 0x6e, 0x41, 0x63, 0x74, 0x69,
334               0x76, 0x69, 0x74, 0x79, 0x00,
335         0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65, 0x79, 0x00
336     };
337     handleFlag = FALSE;
338     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
339         handleFlag = TRUE;
340         EXPECT_EQ(errCode, DMS_TLV_ERR_OUT_OF_ORDER);
341     };
342     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
343     ASSERT_EQ(TRUE, handleFlag);
344 }
345 
346 /**
347  * @tc.number    : DMSLite_DMS_MsgParserFunc_0140
348  * @tc.name      : When parse abnormal package with duplicated ABILITY_NAME node user get error code
349  * @tc.desc      : [C- SOFTWARE -0200]
350 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0140, Function | MediumTest | Level2)351 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0140, Function | MediumTest | Level2) {
352     uint8_t buffer[] = {
353         0x01, 0x01, 0x01,
354         0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68, 0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c,
355               0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x00,
356         0x03, 0x0d, 0x4d, 0x61, 0x69, 0x6e, 0x41, 0x63, 0x74, 0x69,
357               0x76, 0x69, 0x74, 0x79, 0x00,
358         0x03, 0x0d, 0x4d, 0x61, 0x69, 0x6e, 0x41, 0x63, 0x74, 0x69,
359               0x76, 0x69, 0x74, 0x79, 0x00,
360         0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65, 0x79, 0x00
361     };
362     handleFlag = FALSE;
363     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
364         handleFlag = TRUE;
365         EXPECT_EQ(errCode, DMS_TLV_ERR_OUT_OF_ORDER);
366     };
367     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
368     ASSERT_EQ(TRUE, handleFlag);
369 }
370 
371 /**
372  * @tc.number    : DMSLite_DMS_MsgParserFunc_0150
373  * @tc.name      : When parse abnormal package with duplicated SIGNATURE node user get error code
374  * @tc.desc      : [C- SOFTWARE -0200]
375 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0150, Function | MediumTest | Level2)376 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0150, Function | MediumTest | Level2) {
377     uint8_t buffer[] = {
378         0x01, 0x01, 0x01,
379         0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68, 0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c,
380               0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x00,
381         0x03, 0x0d, 0x4d, 0x61, 0x69, 0x6e, 0x41, 0x63, 0x74, 0x69,
382               0x76, 0x69, 0x74, 0x79, 0x00,
383         0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65, 0x79, 0x00,
384         0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65, 0x79, 0x00
385     };
386     handleFlag = FALSE;
387     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
388         handleFlag = TRUE;
389         EXPECT_EQ(errCode, DMS_TLV_ERR_BAD_NODE_NUM);    // catched by node number validation
390     };
391     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
392     ASSERT_EQ(TRUE, handleFlag);
393 }
394 
395 /**
396  * @tc.number    : DMSLite_DMS_MsgParserFunc_0160
397  * @tc.name      : When parse abnormal package which BUNDLE_NAME lack of length attribute user get error code
398  * @tc.desc      : [C- SOFTWARE -0200]
399 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0160, Function | MediumTest | Level2)400 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0160, Function | MediumTest | Level2) {
401     uint8_t buffer[] = {
402         0x01, 0x01, 0x01, 0x02
403     };
404     handleFlag = FALSE;
405     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
406         handleFlag = TRUE;
407         EXPECT_EQ(errCode, DMS_TLV_ERR_LEN);
408     };
409     int8_t resultCode = RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
410     ASSERT_EQ(resultCode, DMS_EC_PARSE_TLV_FAILURE);
411     ASSERT_EQ(TRUE, handleFlag);
412 }
413 
414 /**
415  * @tc.number    : DMSLite_DMS_MsgParserFunc_0170
416  * @tc.name      : When parse abnormal package which ABILITY_NAME lack of length attribute user get error code
417  * @tc.desc      : [C- SOFTWARE -0200]
418 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0170, Function | MediumTest | Level2)419 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0170, Function | MediumTest | Level2) {
420     uint8_t buffer[] = {
421         0x01, 0x01, 0x01, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
422         0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
423         0x63, 0x68, 0x65, 0x72, 0x00, 0x03
424     };
425     handleFlag = FALSE;
426     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
427         handleFlag = TRUE;
428         EXPECT_EQ(errCode, DMS_TLV_ERR_LEN);
429     };
430     int8_t resultCode = RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
431     ASSERT_EQ(resultCode, DMS_EC_PARSE_TLV_FAILURE);
432     ASSERT_EQ(TRUE, handleFlag);
433 }
434 
435 /**
436  * @tc.number    : DMSLite_DMS_MsgParserFunc_0180
437  * @tc.name      : When parse abnormal package which CALLER_SIGNATURE lack of length attribute user get error code
438  * @tc.desc      : [C- SOFTWARE -0200]
439 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0180, Function | MediumTest | Level2)440 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0180, Function | MediumTest | Level2) {
441     uint8_t buffer[] = {
442         0x01, 0x01, 0x01, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
443         0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
444         0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
445         0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00,
446         0x04
447     };
448     handleFlag = FALSE;
449     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
450         handleFlag = TRUE;
451         EXPECT_EQ(errCode, DMS_TLV_ERR_LEN);
452     };
453     int8_t resultCode = RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
454     ASSERT_EQ(resultCode, DMS_EC_PARSE_TLV_FAILURE);
455     ASSERT_EQ(TRUE, handleFlag);
456 }
457 
458 /**
459  * @tc.number    : DMSLite_DMS_MsgParserFunc_0190
460  * @tc.name      : When parse abnormal package with COMMAND_ID length 0 user get error code
461  * @tc.desc      : [C- SOFTWARE -0200]
462 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0190, Function | MediumTest | Level2)463 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0190, Function | MediumTest | Level2) {
464     uint8_t buffer[] = {
465         0x01, 0x00, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
466         0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
467         0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
468         0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00,
469         0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65,
470         0x79, 0x00
471     };
472     handleFlag = FALSE;
473     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
474         handleFlag = TRUE;
475         printf("[hcpptest]testMsgParserFunc0190:%d \n", errCode);
476         EXPECT_EQ(TRUE, errCode != DMS_TLV_SUCCESS);
477     };
478     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
479     ASSERT_EQ(TRUE, handleFlag);
480 }
481 
482 /**
483  * @tc.number    : DMSLite_DMS_MsgParserFunc_0200
484  * @tc.name      : When parse abnormal package with BUNDLE_NAME length 0 user get error code
485  * @tc.desc      : [C- SOFTWARE -0200]
486 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0200, Function | MediumTest | Level2)487 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0200, Function | MediumTest | Level2) {
488     uint8_t buffer[] = {
489         0x01, 0x01, 0x01,
490         0x02, 0x00,
491         0x03, 0x0d, 0x4d, 0x61, 0x69, 0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00,
492         0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65, 0x79, 0x00
493     };
494     handleFlag = FALSE;
495     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
496         handleFlag = TRUE;
497         printf("[hcpptest]testMsgParserFunc0200:%d \n", errCode);
498         EXPECT_EQ(TRUE, errCode != DMS_TLV_SUCCESS);
499     };
500     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
501     ASSERT_EQ(TRUE, handleFlag);
502 }
503 
504 /**
505  * @tc.number    : DMSLite_DMS_MsgParserFunc_0210
506  * @tc.name      : When parse abnormal package with ABILITY_NAME length 0 user get error code
507  * @tc.desc      : [C- SOFTWARE -0200]
508 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0210, Function | MediumTest | Level2)509 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0210, Function | MediumTest | Level2) {
510     uint8_t buffer[] = {
511         0x01, 0x01, 0x01,
512         0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68, 0x75, 0x61, 0x77, 0x65,
513               0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x00,
514         0x03, 0x00,
515         0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65, 0x79, 0x00
516     };
517     handleFlag = FALSE;
518     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
519         handleFlag = TRUE;
520         printf("[hcpptest]testMsgParserFunc0210:%d \n", errCode);
521         EXPECT_EQ(TRUE, errCode != DMS_TLV_SUCCESS);
522     };
523     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
524     ASSERT_EQ(TRUE, handleFlag);
525 }
526 
527 /**
528  * @tc.number    : DMSLite_DMS_MsgParserFunc_0220
529  * @tc.name      : When parse abnormal package with SIGNATURE length 0 user get error code
530  * @tc.desc      : [C- SOFTWARE -0200]
531 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0220, Function | MediumTest | Level2)532 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0220, Function | MediumTest | Level2) {
533     uint8_t buffer[] = {
534         0x01, 0x01, 0x01, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
535         0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
536         0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
537         0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00,
538         0x04, 0x00
539     };
540     handleFlag = FALSE;
541     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
542         handleFlag = TRUE;
543         printf("[hcpptest]testMsgParserFunc0220:%d \n", errCode);
544         EXPECT_EQ(TRUE, errCode != DMS_TLV_SUCCESS);
545     };
546     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
547     ASSERT_EQ(TRUE, handleFlag);
548 }
549 
550 /**
551  * @tc.number    : DMSLite_DMS_MsgParserFunc_0230
552  * @tc.name      : When parse abnormal package that COMMAND_ID lake of value user get error code
553  * @tc.desc      : [C- SOFTWARE -0200]
554 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0230, Function | MediumTest | Level2)555 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0230, Function | MediumTest | Level2) {
556     uint8_t buffer[] = {
557         0x01, 0x01
558     };
559     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
560         printf("[hcpptest]testMsgParserFunc0230:%d \n", errCode);
561         EXPECT_EQ(TRUE, errCode != DMS_TLV_SUCCESS);
562     };
563     int8_t resultCode = RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
564     ASSERT_EQ(resultCode, DMS_EC_PARSE_TLV_FAILURE);
565 }
566 
567 /**
568  * @tc.number    : DMSLite_DMS_MsgParserFunc_0240
569  * @tc.name      : When parse abnormal package that BUNDLE_NAME lake of value user get error code
570  * @tc.desc      : [C- SOFTWARE -0200]
571 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0240, Function | MediumTest | Level2)572 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0240, Function | MediumTest | Level2) {
573     uint8_t buffer[] = {
574         0x01, 0x01, 0x01, 0x02, 0x14
575     };
576     handleFlag = FALSE;
577     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
578         handleFlag = TRUE;
579         printf("[hcpptest]errCode:%d \n", errCode);
580         EXPECT_EQ(TRUE, errCode != DMS_TLV_SUCCESS);
581     };
582     int8_t resultCode = RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
583     ASSERT_EQ(resultCode, DMS_EC_PARSE_TLV_FAILURE);
584     ASSERT_EQ(TRUE, handleFlag);
585 }
586 
587 /**
588  * @tc.number    : DMSLite_DMS_MsgParserFunc_0250
589  * @tc.name      : When parse abnormal package that ABILITY_NAME lake of value user get error code
590  * @tc.desc      : [C- SOFTWARE -0200]
591 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0250, Function | MediumTest | Level2)592 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0250, Function | MediumTest | Level2) {
593     uint8_t buffer[] = {
594         0x01, 0x01, 0x01, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
595         0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
596         0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d
597     };
598     handleFlag = FALSE;
599     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
600         handleFlag = TRUE;
601         printf("[hcpptest]errCode:%d \n", errCode);
602         EXPECT_EQ(TRUE, errCode != DMS_TLV_SUCCESS);
603     };
604     int8_t resultCode = RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
605     ASSERT_EQ(resultCode, DMS_EC_PARSE_TLV_FAILURE);
606     ASSERT_EQ(TRUE, handleFlag);
607 }
608 
609 /**
610  * @tc.number    : DMSLite_DMS_MsgParserFunc_0260
611  * @tc.name      : When parse abnormal package that CALLER_SIGNATURE lake of value user get error code
612  * @tc.desc      : [C- SOFTWARE -0200]
613 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0260, Function | MediumTest | Level2)614 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0260, Function | MediumTest | Level2) {
615     uint8_t buffer[] = {
616         0x01, 0x01, 0x01, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
617         0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
618         0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
619         0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00,
620         0x04, 0x0a
621     };
622     handleFlag = FALSE;
623     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
624         handleFlag = TRUE;
625         printf("[hcpptest]errCode:%d \n", errCode);
626         EXPECT_EQ(TRUE, errCode != DMS_TLV_SUCCESS);
627     };
628     int8_t resultCode = RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
629     ASSERT_EQ(resultCode, DMS_EC_PARSE_TLV_FAILURE);
630     ASSERT_EQ(TRUE, handleFlag);
631 }
632 
633 /**
634  * @tc.number    : DMSLite_DMS_MsgParserFunc_0270
635  * @tc.name      : When parse abnormal package which BUNDLE_NAME value is not string user get error code
636  * @tc.desc      : [C- SOFTWARE -0200]
637 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0270, Function | MediumTest | Level2)638 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0270, Function | MediumTest | Level2) {
639     uint8_t buffer[] = {
640         0x01, 0x01, 0x01,
641         0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68, 0x75, 0x61, 0x77, 0x65, 0x69,
642               0x2e, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x01,
643         0x03, 0x0d, 0x4d, 0x61, 0x69, 0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69,
644               0x74, 0x79, 0x00,
645         0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65, 0x79, 0x00
646     };
647     handleFlag = FALSE;
648     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
649         handleFlag = TRUE;
650         EXPECT_EQ(TRUE, errCode != DMS_TLV_SUCCESS);
651     };
652     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
653     ASSERT_EQ(TRUE, handleFlag);
654 }
655 
656 /**
657  * @tc.number    : DMSLite_DMS_MsgParserFunc_0280
658  * @tc.name      : When parse abnormal package which ABILITY_NAME value is not string user get error code
659  * @tc.desc      : [C- SOFTWARE -0200]
660 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0280, Function | MediumTest | Level2)661 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0280, Function | MediumTest | Level2) {
662     uint8_t buffer[] = {
663         0x01, 0x01, 0x01,
664         0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68, 0x75, 0x61, 0x77, 0x65, 0x69,
665               0x2e, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x00,
666         0x03, 0x0d, 0x4d, 0x61, 0x69, 0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69,
667               0x74, 0x79, 0x01,
668         0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65, 0x79, 0x00
669     };
670     handleFlag = FALSE;
671     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
672         handleFlag = TRUE;
673         EXPECT_EQ(TRUE, errCode != DMS_TLV_SUCCESS);
674     };
675     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
676     ASSERT_EQ(TRUE, handleFlag);
677 }
678 
679 /**
680  * @tc.number    : DMSLite_DMS_MsgParserFunc_0290
681  * @tc.name      : When parse abnormal package which SIGNATURE value is not string user get error code
682  * @tc.desc      : [C- SOFTWARE -0200]
683 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0290, Function | MediumTest | Level2)684 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0290, Function | MediumTest | Level2) {
685     uint8_t buffer[] = {
686         0x01, 0x01, 0x01,
687         0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68, 0x75, 0x61, 0x77, 0x65, 0x69,
688               0x2e, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65, 0x72, 0x00,
689         0x03, 0x0d, 0x4d, 0x61, 0x69, 0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69,
690               0x74, 0x79, 0x00,
691         0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65, 0x79, 0x01
692     };
693     handleFlag = FALSE;
694     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
695         handleFlag = TRUE;
696         EXPECT_EQ(TRUE, errCode != DMS_TLV_SUCCESS);
697     };
698     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
699     ASSERT_EQ(TRUE, handleFlag);
700 }
701 
702 /**
703  * @tc.number    : DMSLite_DMS_MsgParserFunc_0300
704  * @tc.name      : Normal package with 255 bytes long bundle name can be parsed
705  * @tc.desc      : [C- SOFTWARE -0200]
706 */
HWTEST_F(MsgParserFuncTest, testMsgParserFunc0300, Function | MediumTest | Level2)707 HWTEST_F(MsgParserFuncTest, testMsgParserFunc0300, Function | MediumTest | Level2) {
708     uint8_t buffer[] = {
709         0x01, 0x01, 0x01, 0x02, 0x82, 0x00, 0x63, 0x6f, 0x6d, 0x2e, 0x61,
710         0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
711         0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
712         0x78, 0x79, 0x7a, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
713         0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53,
714         0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64,
715         0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
716         0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
717         0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b,
718         0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
719         0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
720         0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72,
721         0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x41, 0x42, 0x43,
722         0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
723         0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
724         0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
725         0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75,
726         0x76, 0x77, 0x78, 0x79, 0x7a, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
727         0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
728         0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62,
729         0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
730         0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
731         0x79, 0x7a, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
732         0x4a, 0x2e, 0x6f, 0x68, 0x6f, 0x73, 0x00, 0x03, 0x0d, 0x4d, 0x61,
733         0x69, 0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00,
734         0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65, 0x79,
735         0x00
736     };
737 
738     handleFlag = FALSE;
739     auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
740         handleFlag = TRUE;
741         const TlvDmsMsgInfo *msg = reinterpret_cast<const TlvDmsMsgInfo *>(dmsMsg);
742         EXPECT_EQ(errCode, DMS_TLV_SUCCESS);
743         std::stringstream ss;
744         ss << "com.";
745         for (int8_t i = 0; i < 4; i++) {
746             ss << "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
747         }
748         ss << "abcdefghijklmnopqrstuvwxyzABCDEFGHIJ";
749         ss << ".ohos";
750         EXPECT_EQ(msg->commandId, 1);
751         EXPECT_EQ(string(msg->calleeBundleName), ss.str());
752         EXPECT_EQ(string(msg->calleeAbilityName), "MainActivity");
753         EXPECT_EQ(string(msg->callerSignature), "publickey");
754     };
755 
756     RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
757     ASSERT_EQ(TRUE, handleFlag);
758 }
759