• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 "hiappevent_native_test.h"
17 
18 #include <string>
19 #include <vector>
20 
21 #include "hiappevent/hiappevent.h"
22 #include "hiappevent_base.h"
23 #include "hiappevent_config.h"
24 #include "time_util.h"
25 
26 using namespace testing::ext;
27 using namespace OHOS::HiviewDFX;
28 
29 namespace {
30 const std::string TEST_STORAGE_PATH = "/data/test/hiappevent/";
31 const char* TEST_DOMAIN_NAME = "test_domain";
32 const char* TEST_EVENT_NAME = "test_event";
33 
GetStorageFilePath()34 std::string GetStorageFilePath()
35 {
36     return "app_event_" + TimeUtil::GetDate() + ".log";
37 }
38 }
39 
SetUpTestCase()40 void HiAppEventNativeTest::SetUpTestCase()
41 {
42     HiAppEventConfig::GetInstance().SetStorageDir(TEST_STORAGE_PATH);
43 }
44 
45 /**
46  * @tc.name: HiAppEventNDKTest001
47  * @tc.desc: check the logging function
48  * @tc.type: FUNC
49  * @tc.require: AR000GIKMA
50  */
51 HWTEST_F(HiAppEventNativeTest, HiAppEventNDKTest001, TestSize.Level0)
52 {
53     /**
54      * @tc.steps: step1. create a ParamList pointer.
55      * @tc.steps: step2. add params to the ParamList.
56      * @tc.steps: step3. write event to the file.
57      * @tc.steps: step4. check the result of logging.
58      * @tc.steps: step5. destroy the ParamList pointer.
59      */
60     ParamList list = OH_HiAppEvent_CreateParamList();
61     bool boolean = true;
62     OH_HiAppEvent_AddBoolParam(list, "bool_key", boolean);
63     bool booleans[] = {true, false, true};
64     OH_HiAppEvent_AddBoolArrayParam(list, "bool_arr_key", booleans, sizeof(booleans) / sizeof(booleans[0]));
65     int8_t num1 = 1;
66     OH_HiAppEvent_AddInt8Param(list, "int8_key", num1);
67     int8_t nums1[] = {1, INT8_MIN, INT8_MAX};
68     OH_HiAppEvent_AddInt8ArrayParam(list, "int8_arr_key", nums1, sizeof(nums1) / sizeof(nums1[0]));
69     int16_t num2 = 1;
70     OH_HiAppEvent_AddInt16Param(list, "int16_key", num2);
71     int16_t nums2[] = {1, INT16_MAX, INT16_MIN};
72     OH_HiAppEvent_AddInt16ArrayParam(list, "int16_arr_key", nums2, sizeof(nums2) / sizeof(nums2[0]));
73     int32_t num3 = 1;
74     OH_HiAppEvent_AddInt32Param(list, "int32_key", num3);
75     int32_t nums3[] = {1, INT32_MAX, INT32_MIN};
76     OH_HiAppEvent_AddInt32ArrayParam(list, "int32_arr_key", nums3, sizeof(nums3) / sizeof(nums3[0]));
77     int64_t num4 = 1;
78     OH_HiAppEvent_AddInt64Param(list, "int64_key", num4);
79     int64_t nums4[] = {1ll, INT64_MAX, INT64_MIN};
80     OH_HiAppEvent_AddInt64ArrayParam(list, "int64_arr_key", nums4, sizeof(nums4) / sizeof(nums4[0]));
81     float num5 = 465.1234;
82     OH_HiAppEvent_AddFloatParam(list, "float_key", num5);
83     float nums5[] = {123.22f, num5, 131312.46464f};
84     OH_HiAppEvent_AddFloatArrayParam(list, "float_arr_key", nums5, sizeof(nums5) / sizeof(nums5[0]));
85     double num6 = 465.1234;
86     OH_HiAppEvent_AddDoubleParam(list, "double_key", num6);
87     double nums6[] = {123.22, num6, 131312.46464};
88     OH_HiAppEvent_AddDoubleArrayParam(list, "double_arr_key", nums6, sizeof(nums6) / sizeof(nums6[0]));
89     char str1[] = "hello";
90     OH_HiAppEvent_AddStringParam(list, "str_key", str1);
91     char str2[] = "world";
92     char* strs[] = {str1, str2};
93     OH_HiAppEvent_AddStringArrayParam(list, "str_arr_key", strs, sizeof(strs) / sizeof(strs[0]));
94 
95     int res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, TEST_EVENT_NAME, BEHAVIOR, list);
96     OH_HiAppEvent_DestroyParamList(list);
97     ASSERT_EQ(res, ErrorCode::HIAPPEVENT_VERIFY_SUCCESSFUL);
98 }
99 
100 /**
101  * @tc.name: HiAppEventNDKTest002
102  * @tc.desc: check the overwriting function of the same param name.
103  * @tc.type: FUNC
104  * @tc.require: AR000GIKMA
105  */
106 HWTEST_F(HiAppEventNativeTest, HiAppEventNDKTest002, TestSize.Level0)
107 {
108     /**
109      * @tc.steps: step1. create a ParamList pointer.
110      * @tc.steps: step2. add params with the same name to the ParamList.
111      * @tc.steps: step3. write event to the file.
112      * @tc.steps: step4. check the result of logging.
113      * @tc.steps: step5. destroy the ParamList pointer.
114      */
115     ParamList list = OH_HiAppEvent_CreateParamList();
116     int8_t num1 = 1;
117     OH_HiAppEvent_AddInt8Param(list, "int_key", num1);
118     int8_t nums1[] = {1, INT8_MIN, INT8_MAX};
119     OH_HiAppEvent_AddInt8ArrayParam(list, "int8_arr_key", nums1, sizeof(nums1) / sizeof(nums1[0]));
120     int16_t num2 = 1;
121     OH_HiAppEvent_AddInt16Param(list, "int16_key", num2);
122     int16_t nums2[] = {1, INT16_MAX, INT16_MIN};
123     OH_HiAppEvent_AddInt16ArrayParam(list, "int16_key", nums2, sizeof(nums2) / sizeof(nums2[0]));
124 
125     int res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, TEST_EVENT_NAME, BEHAVIOR, list);
126     OH_HiAppEvent_DestroyParamList(list);
127     ASSERT_EQ(res, ErrorCode::HIAPPEVENT_VERIFY_SUCCESSFUL);
128 }
129 
130 /**
131  * @tc.name: HiAppEventNDKTest003
132  * @tc.desc: check the logging function when the input value is nullptr.
133  * @tc.type: FUNC
134  * @tc.require: AR000GIKMA
135  */
136 HWTEST_F(HiAppEventNativeTest, HiAppEventNDKTest003, TestSize.Level0)
137 {
138     /**
139      * @tc.steps: step1. create a ParamList pointer.
140      * @tc.steps: step2. add params with the nullptr value to the ParamList.
141      * @tc.steps: step3. write event to the file.
142      * @tc.steps: step4. check the result of logging.
143      * @tc.steps: step5. destroy the ParamList pointer.
144      */
145     int res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, TEST_EVENT_NAME, FAULT, nullptr);
146     ASSERT_EQ(res, ErrorCode::HIAPPEVENT_VERIFY_SUCCESSFUL);
147 
148     ParamList list = OH_HiAppEvent_CreateParamList();
149     bool boolean = true;
150     OH_HiAppEvent_AddBoolParam(list, nullptr, boolean);
151     OH_HiAppEvent_AddBoolArrayParam(list, "bool_arr_key", nullptr, 0);
152     int8_t num1 = 1;
153     OH_HiAppEvent_AddInt8Param(list, nullptr, num1);
154     OH_HiAppEvent_AddInt8ArrayParam(list, "int8_arr_key", nullptr, 0);
155     int16_t num2 = 1;
156     OH_HiAppEvent_AddInt16Param(list, nullptr, num2);
157     OH_HiAppEvent_AddInt16ArrayParam(list, "int16_arr_key", nullptr, 1);
158     int32_t num3 = 1;
159     OH_HiAppEvent_AddInt32Param(list, nullptr, num3);
160     OH_HiAppEvent_AddInt32ArrayParam(list, "int32_arr_key", nullptr, 2);
161     int64_t num4 = 1;
162     OH_HiAppEvent_AddInt64Param(list, nullptr, num4);
163     OH_HiAppEvent_AddInt64ArrayParam(list, "int64_arr_key", nullptr, 3);
164     float num5 = 465.1234;
165     OH_HiAppEvent_AddFloatParam(list, nullptr, num5);
166     OH_HiAppEvent_AddFloatArrayParam(list, "float_arr_key", nullptr, -1);
167     double num6 = 465.1234;
168     OH_HiAppEvent_AddDoubleParam(list, nullptr, num6);
169     OH_HiAppEvent_AddDoubleArrayParam(list, "double_arr_key", nullptr, 0);
170     char str1[] = "hello";
171     OH_HiAppEvent_AddStringParam(list, nullptr, str1);
172     OH_HiAppEvent_AddStringParam(list, nullptr, nullptr);
173     OH_HiAppEvent_AddStringArrayParam(list, "str_arr_key", nullptr, 0);
174     char* strs[] = {str1, nullptr};
175     OH_HiAppEvent_AddStringArrayParam(list, "str_arr_null_key", strs, sizeof(strs) / sizeof(strs[0]));
176 
177     res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, TEST_EVENT_NAME, STATISTIC, list);
178     OH_HiAppEvent_DestroyParamList(list);
179     ASSERT_EQ(res, ErrorCode::HIAPPEVENT_VERIFY_SUCCESSFUL);
180 }
181 
182 /**
183  * @tc.name: HiAppEventNDKTest004
184  * @tc.desc: check the verification function of event logging.
185  * @tc.type: FUNC
186  * @tc.require: AR000GIKMA
187  */
188 HWTEST_F(HiAppEventNativeTest, HiAppEventNDKTest004, TestSize.Level0)
189 {
190     /**
191      * @tc.steps: step1. create a ParamList pointer.
192      * @tc.steps: step2. add params with the invalid name to the ParamList.
193      * @tc.steps: step3. write event to the file.
194      * @tc.steps: step4. check the result of logging.
195      * @tc.steps: step5. destroy the ParamList pointer.
196      */
197     ParamList list = OH_HiAppEvent_CreateParamList();
198     char key1[] = "**";
199     int8_t num1 = 1;
200     OH_HiAppEvent_AddInt8Param(list, key1, num1);
201     char key2[] = "HH22";
202     int16_t num2 = 1;
203     OH_HiAppEvent_AddInt16Param(list, key2, num2);
204     char key3[] = "aa_";
205     int32_t num3 = 1;
206     OH_HiAppEvent_AddInt32Param(list, key3, num3);
207     char key4[] = "";
208     int64_t num4 = 1;
209     OH_HiAppEvent_AddInt64Param(list, key4, num4);
210 
211     int res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, TEST_EVENT_NAME, SECURITY, list);
212     OH_HiAppEvent_DestroyParamList(list);
213     ASSERT_EQ(res,  ErrorCode::ERROR_INVALID_PARAM_NAME);
214 }
215 
216 /**
217  * @tc.name: HiAppEventNDKTest005
218  * @tc.desc: check the verification function of event logging.
219  * @tc.type: FUNC
220  * @tc.require: AR000GIKMA
221  */
222 HWTEST_F(HiAppEventNativeTest, HiAppEventNDKTest005, TestSize.Level0)
223 {
224     /**
225      * @tc.steps: step1. create a ParamList pointer.
226      * @tc.steps: step2. add params with too long string length to the ParamList.
227      * @tc.steps: step3. write event to the file.
228      * @tc.steps: step4. check the result of logging.
229      * @tc.steps: step5. destroy the ParamList pointer.
230      */
231     int maxStrLen = 8 * 1024;
232     std::string longStr(maxStrLen, 'a');
233     std::string longInvalidStr(maxStrLen + 1, 'a');
234     const char* strs[] = {"hello", longStr.c_str()};
235     const char* strIns[] = {"hello", longInvalidStr.c_str()};
236 
237     ParamList list = OH_HiAppEvent_CreateParamList();
238     OH_HiAppEvent_AddStringParam(list, "long_s_key", longStr.c_str());
239     OH_HiAppEvent_AddStringArrayParam(list, "long_s_a_key", strs, sizeof(strs) / sizeof(strs[0]));
240     OH_HiAppEvent_AddStringParam(list, "long_s_i_key", longInvalidStr.c_str());
241     OH_HiAppEvent_AddStringArrayParam(list, "long_s_a_i_key", strIns, sizeof(strIns) / sizeof(strIns[0]));
242 
243     int res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, TEST_EVENT_NAME, SECURITY, list);
244     OH_HiAppEvent_DestroyParamList(list);
245     ASSERT_EQ(res,  ErrorCode::ERROR_INVALID_PARAM_VALUE_LENGTH);
246 }
247 
248 /**
249  * @tc.name: HiAppEventNDKTest006
250  * @tc.desc: check the verification function of event logging.
251  * @tc.type: FUNC
252  * @tc.require: AR000GIKMA
253  */
254 HWTEST_F(HiAppEventNativeTest, HiAppEventNDKTest006, TestSize.Level0)
255 {
256     /**
257      * @tc.steps: step1. create a ParamList pointer.
258      * @tc.steps: step2. add too many params to the ParamList.
259      * @tc.steps: step3. write event to the file.
260      * @tc.steps: step4. check the result of logging.
261      * @tc.steps: step5. destroy the ParamList pointer.
262      */
263     // max len is 32
264     int len = 33;
265     std::vector<std::string> keys(len);
266     std::vector<std::string> values(len);
267     ParamList list = OH_HiAppEvent_CreateParamList();
268     for (int i = 0; i < len; i++) {
269         keys[i] = "key" + std::to_string(i);
270         values[i] = "value" + std::to_string(i);
271         OH_HiAppEvent_AddStringParam(list, keys[i].c_str(), values[i].c_str());
272     }
273 
274     int res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, TEST_EVENT_NAME, SECURITY, list);
275     OH_HiAppEvent_DestroyParamList(list);
276     ASSERT_EQ(res,  ErrorCode::ERROR_INVALID_PARAM_NUM);
277 }
278 
279 /**
280  * @tc.name: HiAppEventNDKTest007
281  * @tc.desc: check the verification function of event logging.
282  * @tc.type: FUNC
283  * @tc.require: AR000GIKMA
284  */
285 HWTEST_F(HiAppEventNativeTest, HiAppEventNDKTest007, TestSize.Level0)
286 {
287     /**
288      * @tc.steps: step1. create a ParamList pointer.
289      * @tc.steps: step2. add params to the ParamList.
290      * @tc.steps: step3. write event with invalid event name to the file.
291      * @tc.steps: step4. check the result of logging.
292      * @tc.steps: step5. destroy the ParamList pointer.
293      */
294     ParamList list = OH_HiAppEvent_CreateParamList();
295     OH_HiAppEvent_AddInt32Param(list, "int_key", 1);
296     int res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, "verify_**", SECURITY, list);
297     OH_HiAppEvent_DestroyParamList(list);
298     ASSERT_EQ(res,  ErrorCode::ERROR_INVALID_EVENT_NAME);
299 
300     list = OH_HiAppEvent_CreateParamList();
301     OH_HiAppEvent_AddInt32Param(list, "int_key", 2);
302     res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, "verify_TEST_", SECURITY, list);
303     OH_HiAppEvent_DestroyParamList(list);
304     ASSERT_EQ(res,  ErrorCode::ERROR_INVALID_EVENT_NAME);
305 
306     list = OH_HiAppEvent_CreateParamList();
307     OH_HiAppEvent_AddInt32Param(list, "int_key", 3);
308     res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, "", SECURITY, list);
309     OH_HiAppEvent_DestroyParamList(list);
310     ASSERT_EQ(res,  ErrorCode::ERROR_INVALID_EVENT_NAME);
311 }
312 
313 /**
314  * @tc.name: HiAppEventNDKTest008
315  * @tc.desc: check the verification function of event logging.
316  * @tc.type: FUNC
317  * @tc.require: AR000GIKMA
318  */
319 HWTEST_F(HiAppEventNativeTest, HiAppEventNDKTest008, TestSize.Level0)
320 {
321     /**
322      * @tc.steps: step1. create a ParamList pointer.
323      * @tc.steps: step2. add params to the ParamList.
324      * @tc.steps: step3. write event with nullptr event name to the file.
325      * @tc.steps: step4. check the result of logging.
326      * @tc.steps: step5. destroy the ParamList pointer.
327      */
328     ParamList list = OH_HiAppEvent_CreateParamList();
329     OH_HiAppEvent_AddInt32Param(list, "int_key", 1);
330 
331     int res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, nullptr, SECURITY, list);
332     OH_HiAppEvent_DestroyParamList(list);
333     ASSERT_EQ(res,  ErrorCode::ERROR_INVALID_EVENT_NAME);
334 }
335 
336 /**
337  * @tc.name: HiAppEventNDKTest009
338  * @tc.desc: check the verification function of event logging.
339  * @tc.type: FUNC
340  * @tc.require: AR000GIKMA
341  */
342 HWTEST_F(HiAppEventNativeTest, HiAppEventNDKTest009, TestSize.Level0)
343 {
344     /**
345      * @tc.steps: step1. disable the logging function.
346      * @tc.steps: step2. create a ParamList pointer.
347      * @tc.steps: step3. add params to the ParamList.
348      * @tc.steps: step4. write event to the file.
349      * @tc.steps: step5. check the result of logging.
350      * @tc.steps: step6. destroy the ParamList pointer.
351      */
352     OH_HiAppEvent_Configure(DISABLE, "true");
353     ParamList list = OH_HiAppEvent_CreateParamList();
354     OH_HiAppEvent_AddInt32Param(list, "int_key", 1);
355     int res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, TEST_EVENT_NAME, SECURITY, list);
356     OH_HiAppEvent_DestroyParamList(list);
357     ASSERT_EQ(res,  ErrorCode::ERROR_HIAPPEVENT_DISABLE);
358 
359     OH_HiAppEvent_Configure(DISABLE, "false");
360     list = OH_HiAppEvent_CreateParamList();
361     OH_HiAppEvent_AddStringParam(list, "str_key", "test");
362     res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, TEST_EVENT_NAME, SECURITY, list);
363     OH_HiAppEvent_DestroyParamList(list);
364     ASSERT_EQ(res,  ErrorCode::HIAPPEVENT_VERIFY_SUCCESSFUL);
365 }
366 
367 /**
368  * @tc.name: HiAppEventNDKTest010
369  * @tc.desc: check the configuration function of event logging.
370  * @tc.type: FUNC
371  * @tc.require: AR000GIKMA
372  */
373 HWTEST_F(HiAppEventNativeTest, HiAppEventNDKTest010, TestSize.Level0)
374 {
375     /**
376      * @tc.steps: step1. config with invalid params.
377      * @tc.steps: step2. check the result of config.
378      */
379     bool res = OH_HiAppEvent_Configure(nullptr, nullptr);
380     ASSERT_FALSE(res);
381 
382     res = OH_HiAppEvent_Configure("key", "true");
383     ASSERT_FALSE(res);
384 
385     res = OH_HiAppEvent_Configure(DISABLE, "xxx");
386     ASSERT_FALSE(res);
387 
388     res = OH_HiAppEvent_Configure(MAX_STORAGE, "xxx");
389     ASSERT_FALSE(res);
390 
391     res = OH_HiAppEvent_Configure("", "100M");
392     ASSERT_FALSE(res);
393 }
394 
395 /**
396  * @tc.name: HiAppEventNDKTest011
397  * @tc.desc: check the configuration function of event logging.
398  * @tc.type: FUNC
399  * @tc.require: AR000GIKMA
400  */
401 HWTEST_F(HiAppEventNativeTest, HiAppEventNDKTest011, TestSize.Level0)
402 {
403     /**
404      * @tc.steps: step1. config the storage directory quota of the logging function.
405      * @tc.steps: step2. check the result of config.
406      * @tc.steps: step3. write event to the file.
407      * @tc.steps: step4. check the result of logging.
408      */
409     bool res = OH_HiAppEvent_Configure(MAX_STORAGE, "1k");
410     ASSERT_TRUE(res);
411 
412     ParamList list = OH_HiAppEvent_CreateParamList();
413     OH_HiAppEvent_AddInt32Param(list, "int_key", 1);
414     int result = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, TEST_EVENT_NAME, SECURITY, list);
415     OH_HiAppEvent_DestroyParamList(list);
416     ASSERT_EQ(result,  ErrorCode::HIAPPEVENT_VERIFY_SUCCESSFUL);
417 
418     res = OH_HiAppEvent_Configure(MAX_STORAGE, "100M");
419     ASSERT_TRUE(res);
420 }
421 
422 /**
423  * @tc.name: HiAppEventNDKTest012
424  * @tc.desc: check the event logging function with predefined events.
425  * @tc.type: FUNC
426  * @tc.require: AR000GIKMA
427  */
428 HWTEST_F(HiAppEventNativeTest, HiAppEventNDKTest012, TestSize.Level0)
429 {
430     /**
431      * @tc.steps: step1. create a ParamList pointer.
432      * @tc.steps: step2. add params with predefined param name to the ParamList.
433      * @tc.steps: step3. write event with predefined event name to the file.
434      * @tc.steps: step4. check the result of logging.
435      * @tc.steps: step5. destroy the ParamList pointer.
436      */
437     ParamList list = OH_HiAppEvent_CreateParamList();
438     OH_HiAppEvent_AddInt32Param(list, PARAM_USER_ID, 123);
439     int res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, EVENT_USER_LOGIN, BEHAVIOR, list);
440     OH_HiAppEvent_DestroyParamList(list);
441     ASSERT_EQ(res,  ErrorCode::HIAPPEVENT_VERIFY_SUCCESSFUL);
442 
443     list = OH_HiAppEvent_CreateParamList();
444     OH_HiAppEvent_AddStringParam(list, PARAM_USER_ID, "123456");
445     res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, EVENT_USER_LOGOUT, SECURITY, list);
446     OH_HiAppEvent_DestroyParamList(list);
447     ASSERT_EQ(res,  ErrorCode::HIAPPEVENT_VERIFY_SUCCESSFUL);
448 
449     list = OH_HiAppEvent_CreateParamList();
450     OH_HiAppEvent_AddStringParam(list, PARAM_DISTRIBUTED_SERVICE_NAME, "hiview");
451     OH_HiAppEvent_AddStringParam(list, PARAM_DISTRIBUTED_SERVICE_INSTANCE_ID, "123");
452     res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, EVENT_DISTRIBUTED_SERVICE_START, SECURITY, list);
453     OH_HiAppEvent_DestroyParamList(list);
454     ASSERT_EQ(res,  ErrorCode::HIAPPEVENT_VERIFY_SUCCESSFUL);
455 }
456 
457 /**
458  * @tc.name: HiAppEventNDKTest013
459  * @tc.desc: check the local file.
460  * @tc.type: FUNC
461  * @tc.require: AR000GIKMA
462  */
463 HWTEST_F(HiAppEventNativeTest, HiAppEventNDKTest013, TestSize.Level0)
464 {
465     /**
466      * @tc.steps: step1. create a ParamList pointer.
467      * @tc.steps: step2. add params to the ParamList.
468      * @tc.steps: step3. write event to the file.
469      * @tc.steps: step4. check the result of logging.
470      * @tc.steps: step5. check the file.
471      */
472     ParamList list = OH_HiAppEvent_CreateParamList();
473     OH_HiAppEvent_AddInt32Param(list, "int_key", 123);
474     int res = OH_HiAppEvent_Write(TEST_DOMAIN_NAME, TEST_EVENT_NAME, BEHAVIOR, list);
475     OH_HiAppEvent_DestroyParamList(list);
476     ASSERT_EQ(res,  ErrorCode::HIAPPEVENT_VERIFY_SUCCESSFUL);
477 
478     std::string filePath = TEST_STORAGE_PATH + GetStorageFilePath();
479     ASSERT_EQ(access(filePath.c_str(), F_OK), 0);
480 }
481