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 
16 #include "ans_log_wrapper.h"
17 #include "ans_convert_enum.h"
18 #include <gtest/gtest.h>
19 
20 using namespace testing::ext;
21 namespace OHOS {
22 namespace Notification {
23 
24 class AnsLogTest : public testing::Test {
25 public:
26     static void SetUpTestCase();
27     static void TearDownTestCase();
28     void SetUp();
29     void TearDown();
30 };
31 
SetUpTestCase()32 void AnsLogTest::SetUpTestCase()
33 {}
34 
TearDownTestCase()35 void AnsLogTest::TearDownTestCase()
36 {}
37 
SetUp()38 void AnsLogTest::SetUp()
39 {}
40 
TearDown()41 void AnsLogTest::TearDown()
42 {}
43 
44 /*
45  * @tc.name: AnsLogTest_001
46  * @tc.desc: test GetBriefFileName function
47  * @tc.type: FUNC
48  * @tc.require: issueI5UI8T
49  */
50 HWTEST_F(AnsLogTest, AnsLogTest_001, TestSize.Level1)
51 {
52     std::string fileName = "../function/EventFwk/test.cpp";
53     std::string exceptStr = "test.cpp";
54 
55     std::string result = AnsLogWrapper::GetBriefFileName(fileName.c_str());
56     EXPECT_EQ(exceptStr, result);
57 }
58 
59 /*
60  * @tc.name: AnsLogTest_002
61  * @tc.desc: test GetBriefFileName function
62  * @tc.type: FUNC
63  * @tc.require: issueI5UI8T
64  */
65 HWTEST_F(AnsLogTest, AnsLogTest_002, TestSize.Level1)
66 {
67     std::string fileName = "test.cpp";
68     std::string exceptStr = "";
69 
70     std::string result = AnsLogWrapper::GetBriefFileName(fileName.c_str());
71     EXPECT_EQ(exceptStr, result);
72 
73     fileName = "";
74     result = AnsLogWrapper::GetBriefFileName(fileName.c_str());
75     EXPECT_EQ(exceptStr, result);
76 
77     result = AnsLogWrapper::GetBriefFileName(nullptr);
78     EXPECT_EQ(exceptStr, result);
79 }
80 
81 /*
82  * @tc.name: AnsConvertTest_001
83  * @tc.desc: test ContentTypeJSToC function
84  * @tc.type: FUNC
85  * @tc.require: issueI5UI8T
86  */
87 HWTEST_F(AnsLogTest, AnsConvertTest_001, TestSize.Level1)
88 {
89     NotificationContent::Type outType;
90     NotificationNapi::ContentType inType = NotificationNapi::ContentType::NOTIFICATION_CONTENT_BASIC_TEXT;
91     NotificationNapi::AnsEnumUtil::ContentTypeJSToC(inType, outType);
92     EXPECT_EQ(outType, NotificationContent::Type::BASIC_TEXT);
93     inType = NotificationNapi::ContentType::NOTIFICATION_CONTENT_LONG_TEXT;
94     NotificationNapi::AnsEnumUtil::ContentTypeJSToC(inType, outType);
95     EXPECT_EQ(outType, NotificationContent::Type::LONG_TEXT);
96     inType = NotificationNapi::ContentType::NOTIFICATION_CONTENT_MULTILINE;
97     NotificationNapi::AnsEnumUtil::ContentTypeJSToC(inType, outType);
98     EXPECT_EQ(outType, NotificationContent::Type::MULTILINE);
99     inType = NotificationNapi::ContentType::NOTIFICATION_CONTENT_PICTURE;
100     NotificationNapi::AnsEnumUtil::ContentTypeJSToC(inType, outType);
101     EXPECT_EQ(outType, NotificationContent::Type::PICTURE);
102     inType = NotificationNapi::ContentType::NOTIFICATION_CONTENT_CONVERSATION;
103     NotificationNapi::AnsEnumUtil::ContentTypeJSToC(inType, outType);
104     EXPECT_EQ(outType, NotificationContent::Type::CONVERSATION);
105     inType = NotificationNapi::ContentType::NOTIFICATION_CONTENT_LOCAL_LIVE_VIEW;
106     NotificationNapi::AnsEnumUtil::ContentTypeJSToC(inType, outType);
107     EXPECT_EQ(outType, NotificationContent::Type::LOCAL_LIVE_VIEW);
108     inType = NotificationNapi::ContentType::NOTIFICATION_CONTENT_LIVE_VIEW;
109     NotificationNapi::AnsEnumUtil::ContentTypeJSToC(inType, outType);
110     EXPECT_EQ(outType, NotificationContent::Type::LIVE_VIEW);
111 }
112 
113 
114 /*
115  * @tc.name: AnsConvertTest_002
116  * @tc.desc: test ContentTypeCToJS function
117  * @tc.type: FUNC
118  * @tc.require: issueI5UI8T
119  */
120 HWTEST_F(AnsLogTest, AnsConvertTest_002, TestSize.Level1)
121 {
122     NotificationNapi::ContentType outType;
123     NotificationContent::Type inType = NotificationContent::Type::BASIC_TEXT;
124     NotificationNapi::AnsEnumUtil::ContentTypeCToJS(inType, outType);
125     EXPECT_EQ(outType, NotificationNapi::ContentType::NOTIFICATION_CONTENT_BASIC_TEXT);
126     inType = NotificationContent::Type::LONG_TEXT;
127     NotificationNapi::AnsEnumUtil::ContentTypeCToJS(inType, outType);
128     EXPECT_EQ(outType, NotificationNapi::ContentType::NOTIFICATION_CONTENT_LONG_TEXT);
129     inType = NotificationContent::Type::MULTILINE;
130     NotificationNapi::AnsEnumUtil::ContentTypeCToJS(inType, outType);
131     EXPECT_EQ(outType, NotificationNapi::ContentType::NOTIFICATION_CONTENT_MULTILINE);
132     inType = NotificationContent::Type::PICTURE;
133     NotificationNapi::AnsEnumUtil::ContentTypeCToJS(inType, outType);
134     EXPECT_EQ(outType, NotificationNapi::ContentType::NOTIFICATION_CONTENT_PICTURE);
135     inType = NotificationContent::Type::CONVERSATION;
136     NotificationNapi::AnsEnumUtil::ContentTypeCToJS(inType, outType);
137     EXPECT_EQ(outType, NotificationNapi::ContentType::NOTIFICATION_CONTENT_CONVERSATION);
138     inType = NotificationContent::Type::LOCAL_LIVE_VIEW;
139     NotificationNapi::AnsEnumUtil::ContentTypeCToJS(inType, outType);
140     EXPECT_EQ(outType, NotificationNapi::ContentType::NOTIFICATION_CONTENT_LOCAL_LIVE_VIEW);
141     inType = NotificationContent::Type::LIVE_VIEW;
142     NotificationNapi::AnsEnumUtil::ContentTypeCToJS(inType, outType);
143     EXPECT_EQ(outType, NotificationNapi::ContentType::NOTIFICATION_CONTENT_LIVE_VIEW);
144 }
145 
146 /*
147  * @tc.name: AnsConvertTest_003
148  * @tc.desc: test SlotTypeJSToC function
149  * @tc.type: FUNC
150  * @tc.require: issueI5UI8T
151  */
152 HWTEST_F(AnsLogTest, AnsConvertTest_003, TestSize.Level1)
153 {
154     NotificationConstant::SlotType outType;
155     NotificationNapi::SlotType inType = NotificationNapi::SlotType::SOCIAL_COMMUNICATION;
156     NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
157     EXPECT_EQ(outType, NotificationConstant::SlotType::SOCIAL_COMMUNICATION);
158     inType = NotificationNapi::SlotType::SERVICE_INFORMATION;
159     NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
160     EXPECT_EQ(outType, NotificationConstant::SlotType::SERVICE_REMINDER);
161     inType = NotificationNapi::SlotType::CONTENT_INFORMATION;
162     NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
163     EXPECT_EQ(outType, NotificationConstant::SlotType::CONTENT_INFORMATION);
164     inType = NotificationNapi::SlotType::LIVE_VIEW;
165     NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
166     EXPECT_EQ(outType, NotificationConstant::SlotType::LIVE_VIEW);
167     inType = NotificationNapi::SlotType::CUSTOMER_SERVICE;
168     NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
169     EXPECT_EQ(outType, NotificationConstant::SlotType::CUSTOMER_SERVICE);
170     inType = NotificationNapi::SlotType::EMERGENCY_INFORMATION;
171     NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
172     EXPECT_EQ(outType, NotificationConstant::SlotType::EMERGENCY_INFORMATION);
173     inType = NotificationNapi::SlotType::UNKNOWN_TYPE;
174     NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
175     EXPECT_EQ(outType, NotificationConstant::SlotType::OTHER);
176     inType = NotificationNapi::SlotType::OTHER_TYPES;
177     NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
178     EXPECT_EQ(outType, NotificationConstant::SlotType::OTHER);
179 }
180 
181 /*
182  * @tc.name: AnsConvertTest_004
183  * @tc.desc: test SlotTypeCToJS function
184  * @tc.type: FUNC
185  * @tc.require: issueI5UI8T
186  */
187 HWTEST_F(AnsLogTest, AnsConvertTest_004, TestSize.Level1)
188 {
189     NotificationNapi::SlotType outType;
190     NotificationConstant::SlotType inType = NotificationConstant::SlotType::CUSTOM;
191     NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
192     EXPECT_EQ(outType, NotificationNapi::SlotType::UNKNOWN_TYPE);
193     inType = NotificationConstant::SlotType::SOCIAL_COMMUNICATION;
194     NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
195     EXPECT_EQ(outType, NotificationNapi::SlotType::SOCIAL_COMMUNICATION);
196     inType = NotificationConstant::SlotType::SERVICE_REMINDER;
197     NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
198     EXPECT_EQ(outType, NotificationNapi::SlotType::SERVICE_INFORMATION);
199     inType = NotificationConstant::SlotType::CONTENT_INFORMATION;
200     NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
201     EXPECT_EQ(outType, NotificationNapi::SlotType::CONTENT_INFORMATION);
202     inType = NotificationConstant::SlotType::LIVE_VIEW;
203     NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
204     EXPECT_EQ(outType, NotificationNapi::SlotType::LIVE_VIEW);
205     inType = NotificationConstant::SlotType::CUSTOMER_SERVICE;
206     NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
207     EXPECT_EQ(outType, NotificationNapi::SlotType::CUSTOMER_SERVICE);
208     inType = NotificationConstant::SlotType::EMERGENCY_INFORMATION;
209     NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
210     EXPECT_EQ(outType, NotificationNapi::SlotType::EMERGENCY_INFORMATION);
211     inType = NotificationConstant::SlotType::OTHER;
212     NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
213     EXPECT_EQ(outType, NotificationNapi::SlotType::OTHER_TYPES);
214 }
215 
216 /*
217  * @tc.name: AnsConvertTest_005
218  * @tc.desc: test SlotLevelJSToC function
219  * @tc.type: FUNC
220  * @tc.require: issueI5UI8T
221  */
222 HWTEST_F(AnsLogTest, AnsConvertTest_005, TestSize.Level1)
223 {
224     NotificationSlot::NotificationLevel outType;
225     NotificationNapi::SlotLevel inType = NotificationNapi::SlotLevel::LEVEL_NONE;
226     NotificationNapi::AnsEnumUtil::SlotLevelJSToC(inType, outType);
227     EXPECT_EQ(outType, NotificationSlot::NotificationLevel::LEVEL_NONE);
228     inType = NotificationNapi::SlotLevel::LEVEL_MIN;
229     NotificationNapi::AnsEnumUtil::SlotLevelJSToC(inType, outType);
230     EXPECT_EQ(outType, NotificationSlot::NotificationLevel::LEVEL_MIN);
231     inType = NotificationNapi::SlotLevel::LEVEL_LOW;
232     NotificationNapi::AnsEnumUtil::SlotLevelJSToC(inType, outType);
233     EXPECT_EQ(outType, NotificationSlot::NotificationLevel::LEVEL_LOW);
234     inType = NotificationNapi::SlotLevel::LEVEL_DEFAULT;
235     NotificationNapi::AnsEnumUtil::SlotLevelJSToC(inType, outType);
236     EXPECT_EQ(outType, NotificationSlot::NotificationLevel::LEVEL_DEFAULT);
237     inType = NotificationNapi::SlotLevel::LEVEL_HIGH;
238     NotificationNapi::AnsEnumUtil::SlotLevelJSToC(inType, outType);
239     EXPECT_EQ(outType, NotificationSlot::NotificationLevel::LEVEL_HIGH);
240 }
241 
242 /*
243  * @tc.name: AnsConvertTest_006
244  * @tc.desc: test LiveViewStatusJSToC function
245  * @tc.type: FUNC
246  * @tc.require: issueI5UI8T
247  */
248 HWTEST_F(AnsLogTest, AnsConvertTest_006, TestSize.Level1)
249 {
250     NotificationLiveViewContent::LiveViewStatus outType;
251     NotificationNapi::LiveViewStatus inType = NotificationNapi::LiveViewStatus::LIVE_VIEW_CREATE;
252     NotificationNapi::AnsEnumUtil::LiveViewStatusJSToC(inType, outType);
253     EXPECT_EQ(outType, NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_CREATE);
254     inType = NotificationNapi::LiveViewStatus::LIVE_VIEW_INCREMENTAL_UPDATE;
255     NotificationNapi::AnsEnumUtil::LiveViewStatusJSToC(inType, outType);
256     EXPECT_EQ(outType, NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_INCREMENTAL_UPDATE);
257     inType = NotificationNapi::LiveViewStatus::LIVE_VIEW_END;
258     NotificationNapi::AnsEnumUtil::LiveViewStatusJSToC(inType, outType);
259     EXPECT_EQ(outType, NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_END);
260     inType = NotificationNapi::LiveViewStatus::LIVE_VIEW_FULL_UPDATE;
261     NotificationNapi::AnsEnumUtil::LiveViewStatusJSToC(inType, outType);
262     EXPECT_EQ(outType, NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_FULL_UPDATE);
263 }
264 
265 /*
266  * @tc.name: AnsConvertTest_007
267  * @tc.desc: test SlotLevelCToJS function
268  * @tc.type: FUNC
269  * @tc.require: issueI5UI8T
270  */
271 HWTEST_F(AnsLogTest, AnsConvertTest_007, TestSize.Level1)
272 {
273     NotificationNapi::SlotLevel outType;
274     NotificationSlot::NotificationLevel inType = NotificationSlot::NotificationLevel::LEVEL_NONE;
275     NotificationNapi::AnsEnumUtil::SlotLevelCToJS(inType, outType);
276     EXPECT_EQ(outType, NotificationNapi::SlotLevel::LEVEL_NONE);
277     inType = NotificationSlot::NotificationLevel::LEVEL_UNDEFINED;
278     NotificationNapi::AnsEnumUtil::SlotLevelCToJS(inType, outType);
279     EXPECT_EQ(outType, NotificationNapi::SlotLevel::LEVEL_NONE);
280     inType = NotificationSlot::NotificationLevel::LEVEL_MIN;
281     NotificationNapi::AnsEnumUtil::SlotLevelCToJS(inType, outType);
282     EXPECT_EQ(outType, NotificationNapi::SlotLevel::LEVEL_MIN);
283     inType = NotificationSlot::NotificationLevel::LEVEL_LOW;
284     NotificationNapi::AnsEnumUtil::SlotLevelCToJS(inType, outType);
285     EXPECT_EQ(outType, NotificationNapi::SlotLevel::LEVEL_LOW);
286     inType = NotificationSlot::NotificationLevel::LEVEL_DEFAULT;
287     NotificationNapi::AnsEnumUtil::SlotLevelCToJS(inType, outType);
288     EXPECT_EQ(outType, NotificationNapi::SlotLevel::LEVEL_DEFAULT);
289     inType = NotificationSlot::NotificationLevel::LEVEL_HIGH;
290     NotificationNapi::AnsEnumUtil::SlotLevelCToJS(inType, outType);
291     EXPECT_EQ(outType, NotificationNapi::SlotLevel::LEVEL_HIGH);
292 }
293 
294 /*
295  * @tc.name: AnsConvertTest_008
296  * @tc.desc: test ReasonCToJS function
297  * @tc.type: FUNC
298  * @tc.require: issueI5UI8T
299  */
300 HWTEST_F(AnsLogTest, AnsConvertTest_008, TestSize.Level1)
301 {
302     int outType;
303     int inType = NotificationConstant::CLICK_REASON_DELETE;
304     NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
305     EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::CLICK_REASON_REMOVE));
306     inType = NotificationConstant::CANCEL_REASON_DELETE;
307     NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
308     EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::CANCEL_REASON_REMOVE));
309     inType = NotificationConstant::CANCEL_ALL_REASON_DELETE;
310     NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
311     EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::CANCEL_ALL_REASON_REMOVE));
312     inType = NotificationConstant::ERROR_REASON_DELETE;
313     NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
314     EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::ERROR_REASON_REMOVE));
315     inType = NotificationConstant::PACKAGE_CHANGED_REASON_DELETE;
316     NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
317     EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::PACKAGE_CHANGED_REASON_REMOVE));
318     inType = NotificationConstant::USER_STOPPED_REASON_DELETE;
319     NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
320     EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::USER_STOPPED_REASON_REMOVE));
321     inType = NotificationConstant::APP_CANCEL_REASON_DELETE;
322     NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
323     EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::APP_CANCEL_REASON_REMOVE));
324     inType = NotificationConstant::APP_CANCEL_ALL_REASON_DELETE;
325     NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
326     EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::APP_CANCEL_ALL_REASON_REMOVE));
327     inType = NotificationConstant::USER_REMOVED_REASON_DELETE;
328     NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
329     EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::USER_REMOVED_REASON_DELETE));
330     inType = NotificationConstant::FLOW_CONTROL_REASON_DELETE;
331     NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
332     EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::FLOW_CONTROL_REASON_DELETE));
333     inType = NotificationConstant::DISABLE_SLOT_REASON_DELETE;
334     NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
335     EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::DISABLE_SLOT_REASON_DELETE));
336     inType = NotificationConstant::DISABLE_NOTIFICATION_REASON_DELETE;
337     NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
338     EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::DISABLE_NOTIFICATION_REASON_DELETE));
339     inType = NotificationConstant::APP_CANCEL_REASON_OTHER;
340     NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
341     EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::APP_CANCEL_REASON_OTHER));
342 }
343 
344 /*
345  * @tc.name: AnsConvertTest_009
346  * @tc.desc: test DoNotDisturbTypeJSToC function
347  * @tc.type: FUNC
348  * @tc.require: issueI5UI8T
349  */
350 HWTEST_F(AnsLogTest, AnsConvertTest_009, TestSize.Level1)
351 {
352     NotificationConstant::DoNotDisturbType outType;
353     NotificationNapi::DoNotDisturbType inType = NotificationNapi::DoNotDisturbType::TYPE_NONE;
354     NotificationNapi::AnsEnumUtil::DoNotDisturbTypeJSToC(inType, outType);
355     EXPECT_EQ(outType, NotificationConstant::DoNotDisturbType::NONE);
356     inType = NotificationNapi::DoNotDisturbType::TYPE_ONCE;
357     NotificationNapi::AnsEnumUtil::DoNotDisturbTypeJSToC(inType, outType);
358     EXPECT_EQ(outType, NotificationConstant::DoNotDisturbType::ONCE);
359     inType = NotificationNapi::DoNotDisturbType::TYPE_DAILY;
360     NotificationNapi::AnsEnumUtil::DoNotDisturbTypeJSToC(inType, outType);
361     EXPECT_EQ(outType, NotificationConstant::DoNotDisturbType::DAILY);
362     inType = NotificationNapi::DoNotDisturbType::TYPE_CLEARLY;
363     NotificationNapi::AnsEnumUtil::DoNotDisturbTypeJSToC(inType, outType);
364     EXPECT_EQ(outType, NotificationConstant::DoNotDisturbType::CLEARLY);
365 }
366 
367 /*
368  * @tc.name: AnsConvertTest_010
369  * @tc.desc: test DoNotDisturbTypeCToJS function
370  * @tc.type: FUNC
371  * @tc.require: issueI5UI8T
372  */
373 HWTEST_F(AnsLogTest, AnsConvertTest_010, TestSize.Level1)
374 {
375     NotificationNapi::DoNotDisturbType outType;
376     NotificationConstant::DoNotDisturbType inType = NotificationConstant::DoNotDisturbType::NONE;
377     NotificationNapi::AnsEnumUtil::DoNotDisturbTypeCToJS(inType, outType);
378     EXPECT_EQ(outType, NotificationNapi::DoNotDisturbType::TYPE_NONE);
379     inType = NotificationConstant::DoNotDisturbType::ONCE;
380     NotificationNapi::AnsEnumUtil::DoNotDisturbTypeCToJS(inType, outType);
381     EXPECT_EQ(outType, NotificationNapi::DoNotDisturbType::TYPE_ONCE);
382     inType = NotificationConstant::DoNotDisturbType::DAILY;
383     NotificationNapi::AnsEnumUtil::DoNotDisturbTypeCToJS(inType, outType);
384     EXPECT_EQ(outType, NotificationNapi::DoNotDisturbType::TYPE_DAILY);
385     inType = NotificationConstant::DoNotDisturbType::CLEARLY;
386     NotificationNapi::AnsEnumUtil::DoNotDisturbTypeCToJS(inType, outType);
387     EXPECT_EQ(outType, NotificationNapi::DoNotDisturbType::TYPE_CLEARLY);
388 }
389 
390 /*
391  * @tc.name: AnsConvertTest_011
392  * @tc.desc: test DeviceRemindTypeCToJS function
393  * @tc.type: FUNC
394  * @tc.require: issueI5UI8T
395  */
396 HWTEST_F(AnsLogTest, AnsConvertTest_011, TestSize.Level1)
397 {
398     NotificationNapi::DeviceRemindType outType;
399     NotificationConstant::RemindType inType = NotificationConstant::RemindType::DEVICE_IDLE_DONOT_REMIND;
400     NotificationNapi::AnsEnumUtil::DeviceRemindTypeCToJS(inType, outType);
401     EXPECT_EQ(outType, NotificationNapi::DeviceRemindType::IDLE_DONOT_REMIND);
402     inType = NotificationConstant::RemindType::DEVICE_IDLE_REMIND;
403     NotificationNapi::AnsEnumUtil::DeviceRemindTypeCToJS(inType, outType);
404     EXPECT_EQ(outType, NotificationNapi::DeviceRemindType::IDLE_REMIND);
405     inType = NotificationConstant::RemindType::DEVICE_ACTIVE_DONOT_REMIND;
406     NotificationNapi::AnsEnumUtil::DeviceRemindTypeCToJS(inType, outType);
407     EXPECT_EQ(outType, NotificationNapi::DeviceRemindType::ACTIVE_DONOT_REMIND);
408     inType = NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND;
409     NotificationNapi::AnsEnumUtil::DeviceRemindTypeCToJS(inType, outType);
410     EXPECT_EQ(outType, NotificationNapi::DeviceRemindType::ACTIVE_REMIND);
411 }
412 
413 /*
414  * @tc.name: AnsConvertTest_012
415  * @tc.desc: test SourceTypeCToJS function
416  * @tc.type: FUNC
417  * @tc.require: issueI5UI8T
418  */
419 HWTEST_F(AnsLogTest, AnsConvertTest_012, TestSize.Level1)
420 {
421     NotificationNapi::SourceType outType;
422     NotificationConstant::SourceType inType = NotificationConstant::SourceType::TYPE_NORMAL;
423     NotificationNapi::AnsEnumUtil::SourceTypeCToJS(inType, outType);
424     EXPECT_EQ(outType, NotificationNapi::SourceType::TYPE_NORMAL);
425     inType = NotificationConstant::SourceType::TYPE_CONTINUOUS;
426     NotificationNapi::AnsEnumUtil::SourceTypeCToJS(inType, outType);
427     EXPECT_EQ(outType, NotificationNapi::SourceType::TYPE_CONTINUOUS);
428     inType = NotificationConstant::SourceType::TYPE_TIMER;
429     NotificationNapi::AnsEnumUtil::SourceTypeCToJS(inType, outType);
430     EXPECT_EQ(outType, NotificationNapi::SourceType::TYPE_TIMER);
431 }
432 
433 /*
434  * @tc.name: AnsConvertTest_013
435  * @tc.desc: test LiveViewStatusCToJS function
436  * @tc.type: FUNC
437  * @tc.require: issueI5UI8T
438  */
439 HWTEST_F(AnsLogTest, AnsConvertTest_013, TestSize.Level1)
440 {
441     NotificationNapi::LiveViewStatus outType;
442     NotificationLiveViewContent::LiveViewStatus inType = NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_CREATE;
443     NotificationNapi::AnsEnumUtil::LiveViewStatusCToJS(inType, outType);
444     EXPECT_EQ(outType, NotificationNapi::LiveViewStatus::LIVE_VIEW_CREATE);
445     inType = NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_INCREMENTAL_UPDATE;
446     NotificationNapi::AnsEnumUtil::LiveViewStatusCToJS(inType, outType);
447     EXPECT_EQ(outType, NotificationNapi::LiveViewStatus::LIVE_VIEW_INCREMENTAL_UPDATE);
448     inType = NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_END;
449     NotificationNapi::AnsEnumUtil::LiveViewStatusCToJS(inType, outType);
450     EXPECT_EQ(outType, NotificationNapi::LiveViewStatus::LIVE_VIEW_END);
451     inType = NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_FULL_UPDATE;
452     NotificationNapi::AnsEnumUtil::LiveViewStatusCToJS(inType, outType);
453     EXPECT_EQ(outType, NotificationNapi::LiveViewStatus::LIVE_VIEW_FULL_UPDATE);
454 }
455 }
456 }