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: AnsConvertTest_001
46 * @tc.desc: test ContentTypeJSToC function
47 * @tc.type: FUNC
48 * @tc.require: issueI5UI8T
49 */
50 HWTEST_F(AnsLogTest, AnsConvertTest_001, TestSize.Level1)
51 {
52 NotificationContent::Type outType;
53 NotificationNapi::ContentType inType = NotificationNapi::ContentType::NOTIFICATION_CONTENT_BASIC_TEXT;
54 NotificationNapi::AnsEnumUtil::ContentTypeJSToC(inType, outType);
55 EXPECT_EQ(outType, NotificationContent::Type::BASIC_TEXT);
56 inType = NotificationNapi::ContentType::NOTIFICATION_CONTENT_LONG_TEXT;
57 NotificationNapi::AnsEnumUtil::ContentTypeJSToC(inType, outType);
58 EXPECT_EQ(outType, NotificationContent::Type::LONG_TEXT);
59 inType = NotificationNapi::ContentType::NOTIFICATION_CONTENT_MULTILINE;
60 NotificationNapi::AnsEnumUtil::ContentTypeJSToC(inType, outType);
61 EXPECT_EQ(outType, NotificationContent::Type::MULTILINE);
62 inType = NotificationNapi::ContentType::NOTIFICATION_CONTENT_PICTURE;
63 NotificationNapi::AnsEnumUtil::ContentTypeJSToC(inType, outType);
64 EXPECT_EQ(outType, NotificationContent::Type::PICTURE);
65 inType = NotificationNapi::ContentType::NOTIFICATION_CONTENT_CONVERSATION;
66 NotificationNapi::AnsEnumUtil::ContentTypeJSToC(inType, outType);
67 EXPECT_EQ(outType, NotificationContent::Type::CONVERSATION);
68 inType = NotificationNapi::ContentType::NOTIFICATION_CONTENT_LOCAL_LIVE_VIEW;
69 NotificationNapi::AnsEnumUtil::ContentTypeJSToC(inType, outType);
70 EXPECT_EQ(outType, NotificationContent::Type::LOCAL_LIVE_VIEW);
71 inType = NotificationNapi::ContentType::NOTIFICATION_CONTENT_LIVE_VIEW;
72 NotificationNapi::AnsEnumUtil::ContentTypeJSToC(inType, outType);
73 EXPECT_EQ(outType, NotificationContent::Type::LIVE_VIEW);
74 }
75
76
77 /*
78 * @tc.name: AnsConvertTest_002
79 * @tc.desc: test ContentTypeCToJS function
80 * @tc.type: FUNC
81 * @tc.require: issueI5UI8T
82 */
83 HWTEST_F(AnsLogTest, AnsConvertTest_002, TestSize.Level1)
84 {
85 NotificationNapi::ContentType outType;
86 NotificationContent::Type inType = NotificationContent::Type::BASIC_TEXT;
87 NotificationNapi::AnsEnumUtil::ContentTypeCToJS(inType, outType);
88 EXPECT_EQ(outType, NotificationNapi::ContentType::NOTIFICATION_CONTENT_BASIC_TEXT);
89 inType = NotificationContent::Type::LONG_TEXT;
90 NotificationNapi::AnsEnumUtil::ContentTypeCToJS(inType, outType);
91 EXPECT_EQ(outType, NotificationNapi::ContentType::NOTIFICATION_CONTENT_LONG_TEXT);
92 inType = NotificationContent::Type::MULTILINE;
93 NotificationNapi::AnsEnumUtil::ContentTypeCToJS(inType, outType);
94 EXPECT_EQ(outType, NotificationNapi::ContentType::NOTIFICATION_CONTENT_MULTILINE);
95 inType = NotificationContent::Type::PICTURE;
96 NotificationNapi::AnsEnumUtil::ContentTypeCToJS(inType, outType);
97 EXPECT_EQ(outType, NotificationNapi::ContentType::NOTIFICATION_CONTENT_PICTURE);
98 inType = NotificationContent::Type::CONVERSATION;
99 NotificationNapi::AnsEnumUtil::ContentTypeCToJS(inType, outType);
100 EXPECT_EQ(outType, NotificationNapi::ContentType::NOTIFICATION_CONTENT_CONVERSATION);
101 inType = NotificationContent::Type::LOCAL_LIVE_VIEW;
102 NotificationNapi::AnsEnumUtil::ContentTypeCToJS(inType, outType);
103 EXPECT_EQ(outType, NotificationNapi::ContentType::NOTIFICATION_CONTENT_LOCAL_LIVE_VIEW);
104 inType = NotificationContent::Type::LIVE_VIEW;
105 NotificationNapi::AnsEnumUtil::ContentTypeCToJS(inType, outType);
106 EXPECT_EQ(outType, NotificationNapi::ContentType::NOTIFICATION_CONTENT_LIVE_VIEW);
107 }
108
109 /*
110 * @tc.name: AnsConvertTest_003
111 * @tc.desc: test SlotTypeJSToC function
112 * @tc.type: FUNC
113 * @tc.require: issueI5UI8T
114 */
115 HWTEST_F(AnsLogTest, AnsConvertTest_003, TestSize.Level1)
116 {
117 NotificationConstant::SlotType outType;
118 NotificationNapi::SlotType inType = NotificationNapi::SlotType::SOCIAL_COMMUNICATION;
119 NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
120 EXPECT_EQ(outType, NotificationConstant::SlotType::SOCIAL_COMMUNICATION);
121 inType = NotificationNapi::SlotType::SERVICE_INFORMATION;
122 NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
123 EXPECT_EQ(outType, NotificationConstant::SlotType::SERVICE_REMINDER);
124 inType = NotificationNapi::SlotType::CONTENT_INFORMATION;
125 NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
126 EXPECT_EQ(outType, NotificationConstant::SlotType::CONTENT_INFORMATION);
127 inType = NotificationNapi::SlotType::LIVE_VIEW;
128 NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
129 EXPECT_EQ(outType, NotificationConstant::SlotType::LIVE_VIEW);
130 inType = NotificationNapi::SlotType::CUSTOMER_SERVICE;
131 NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
132 EXPECT_EQ(outType, NotificationConstant::SlotType::CUSTOMER_SERVICE);
133 inType = NotificationNapi::SlotType::EMERGENCY_INFORMATION;
134 NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
135 EXPECT_EQ(outType, NotificationConstant::SlotType::EMERGENCY_INFORMATION);
136 inType = NotificationNapi::SlotType::UNKNOWN_TYPE;
137 NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
138 EXPECT_EQ(outType, NotificationConstant::SlotType::OTHER);
139 inType = NotificationNapi::SlotType::OTHER_TYPES;
140 NotificationNapi::AnsEnumUtil::SlotTypeJSToC(inType, outType);
141 EXPECT_EQ(outType, NotificationConstant::SlotType::OTHER);
142 }
143
144 /*
145 * @tc.name: AnsConvertTest_004
146 * @tc.desc: test SlotTypeCToJS function
147 * @tc.type: FUNC
148 * @tc.require: issueI5UI8T
149 */
150 HWTEST_F(AnsLogTest, AnsConvertTest_004, TestSize.Level1)
151 {
152 NotificationNapi::SlotType outType;
153 NotificationConstant::SlotType inType = NotificationConstant::SlotType::CUSTOM;
154 NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
155 EXPECT_EQ(outType, NotificationNapi::SlotType::UNKNOWN_TYPE);
156 inType = NotificationConstant::SlotType::SOCIAL_COMMUNICATION;
157 NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
158 EXPECT_EQ(outType, NotificationNapi::SlotType::SOCIAL_COMMUNICATION);
159 inType = NotificationConstant::SlotType::SERVICE_REMINDER;
160 NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
161 EXPECT_EQ(outType, NotificationNapi::SlotType::SERVICE_INFORMATION);
162 inType = NotificationConstant::SlotType::CONTENT_INFORMATION;
163 NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
164 EXPECT_EQ(outType, NotificationNapi::SlotType::CONTENT_INFORMATION);
165 inType = NotificationConstant::SlotType::LIVE_VIEW;
166 NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
167 EXPECT_EQ(outType, NotificationNapi::SlotType::LIVE_VIEW);
168 inType = NotificationConstant::SlotType::CUSTOMER_SERVICE;
169 NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
170 EXPECT_EQ(outType, NotificationNapi::SlotType::CUSTOMER_SERVICE);
171 inType = NotificationConstant::SlotType::EMERGENCY_INFORMATION;
172 NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
173 EXPECT_EQ(outType, NotificationNapi::SlotType::EMERGENCY_INFORMATION);
174 inType = NotificationConstant::SlotType::OTHER;
175 NotificationNapi::AnsEnumUtil::SlotTypeCToJS(inType, outType);
176 EXPECT_EQ(outType, NotificationNapi::SlotType::OTHER_TYPES);
177 }
178
179 /*
180 * @tc.name: AnsConvertTest_005
181 * @tc.desc: test SlotLevelJSToC function
182 * @tc.type: FUNC
183 * @tc.require: issueI5UI8T
184 */
185 HWTEST_F(AnsLogTest, AnsConvertTest_005, TestSize.Level1)
186 {
187 NotificationSlot::NotificationLevel outType;
188 NotificationNapi::SlotLevel inType = NotificationNapi::SlotLevel::LEVEL_NONE;
189 NotificationNapi::AnsEnumUtil::SlotLevelJSToC(inType, outType);
190 EXPECT_EQ(outType, NotificationSlot::NotificationLevel::LEVEL_NONE);
191 inType = NotificationNapi::SlotLevel::LEVEL_MIN;
192 NotificationNapi::AnsEnumUtil::SlotLevelJSToC(inType, outType);
193 EXPECT_EQ(outType, NotificationSlot::NotificationLevel::LEVEL_MIN);
194 inType = NotificationNapi::SlotLevel::LEVEL_LOW;
195 NotificationNapi::AnsEnumUtil::SlotLevelJSToC(inType, outType);
196 EXPECT_EQ(outType, NotificationSlot::NotificationLevel::LEVEL_LOW);
197 inType = NotificationNapi::SlotLevel::LEVEL_DEFAULT;
198 NotificationNapi::AnsEnumUtil::SlotLevelJSToC(inType, outType);
199 EXPECT_EQ(outType, NotificationSlot::NotificationLevel::LEVEL_DEFAULT);
200 inType = NotificationNapi::SlotLevel::LEVEL_HIGH;
201 NotificationNapi::AnsEnumUtil::SlotLevelJSToC(inType, outType);
202 EXPECT_EQ(outType, NotificationSlot::NotificationLevel::LEVEL_HIGH);
203 }
204
205 /*
206 * @tc.name: AnsConvertTest_006
207 * @tc.desc: test LiveViewStatusJSToC function
208 * @tc.type: FUNC
209 * @tc.require: issueI5UI8T
210 */
211 HWTEST_F(AnsLogTest, AnsConvertTest_006, TestSize.Level1)
212 {
213 NotificationLiveViewContent::LiveViewStatus outType;
214 NotificationNapi::LiveViewStatus inType = NotificationNapi::LiveViewStatus::LIVE_VIEW_CREATE;
215 NotificationNapi::AnsEnumUtil::LiveViewStatusJSToC(inType, outType);
216 EXPECT_EQ(outType, NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_CREATE);
217 inType = NotificationNapi::LiveViewStatus::LIVE_VIEW_INCREMENTAL_UPDATE;
218 NotificationNapi::AnsEnumUtil::LiveViewStatusJSToC(inType, outType);
219 EXPECT_EQ(outType, NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_INCREMENTAL_UPDATE);
220 inType = NotificationNapi::LiveViewStatus::LIVE_VIEW_END;
221 NotificationNapi::AnsEnumUtil::LiveViewStatusJSToC(inType, outType);
222 EXPECT_EQ(outType, NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_END);
223 inType = NotificationNapi::LiveViewStatus::LIVE_VIEW_FULL_UPDATE;
224 NotificationNapi::AnsEnumUtil::LiveViewStatusJSToC(inType, outType);
225 EXPECT_EQ(outType, NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_FULL_UPDATE);
226 }
227
228 /*
229 * @tc.name: AnsConvertTest_007
230 * @tc.desc: test SlotLevelCToJS function
231 * @tc.type: FUNC
232 * @tc.require: issueI5UI8T
233 */
234 HWTEST_F(AnsLogTest, AnsConvertTest_007, TestSize.Level1)
235 {
236 NotificationNapi::SlotLevel outType;
237 NotificationSlot::NotificationLevel inType = NotificationSlot::NotificationLevel::LEVEL_NONE;
238 NotificationNapi::AnsEnumUtil::SlotLevelCToJS(inType, outType);
239 EXPECT_EQ(outType, NotificationNapi::SlotLevel::LEVEL_NONE);
240 inType = NotificationSlot::NotificationLevel::LEVEL_UNDEFINED;
241 NotificationNapi::AnsEnumUtil::SlotLevelCToJS(inType, outType);
242 EXPECT_EQ(outType, NotificationNapi::SlotLevel::LEVEL_NONE);
243 inType = NotificationSlot::NotificationLevel::LEVEL_MIN;
244 NotificationNapi::AnsEnumUtil::SlotLevelCToJS(inType, outType);
245 EXPECT_EQ(outType, NotificationNapi::SlotLevel::LEVEL_MIN);
246 inType = NotificationSlot::NotificationLevel::LEVEL_LOW;
247 NotificationNapi::AnsEnumUtil::SlotLevelCToJS(inType, outType);
248 EXPECT_EQ(outType, NotificationNapi::SlotLevel::LEVEL_LOW);
249 inType = NotificationSlot::NotificationLevel::LEVEL_DEFAULT;
250 NotificationNapi::AnsEnumUtil::SlotLevelCToJS(inType, outType);
251 EXPECT_EQ(outType, NotificationNapi::SlotLevel::LEVEL_DEFAULT);
252 inType = NotificationSlot::NotificationLevel::LEVEL_HIGH;
253 NotificationNapi::AnsEnumUtil::SlotLevelCToJS(inType, outType);
254 EXPECT_EQ(outType, NotificationNapi::SlotLevel::LEVEL_HIGH);
255 }
256
257 /*
258 * @tc.name: AnsConvertTest_008
259 * @tc.desc: test ReasonCToJS function
260 * @tc.type: FUNC
261 * @tc.require: issueI5UI8T
262 */
263 HWTEST_F(AnsLogTest, AnsConvertTest_008, TestSize.Level1)
264 {
265 int outType;
266 int inType = NotificationConstant::DEFAULT_REASON_DELETE;
267 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
268 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::DEFAULT_REASON_DELETE));
269 inType = NotificationConstant::CLICK_REASON_DELETE;
270 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
271 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::CLICK_REASON_REMOVE));
272 inType = NotificationConstant::CANCEL_REASON_DELETE;
273 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
274 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::CANCEL_REASON_REMOVE));
275 inType = NotificationConstant::CANCEL_ALL_REASON_DELETE;
276 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
277 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::CANCEL_ALL_REASON_REMOVE));
278 inType = NotificationConstant::ERROR_REASON_DELETE;
279 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
280 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::ERROR_REASON_REMOVE));
281 inType = NotificationConstant::PACKAGE_CHANGED_REASON_DELETE;
282 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
283 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::PACKAGE_CHANGED_REASON_REMOVE));
284 inType = NotificationConstant::USER_STOPPED_REASON_DELETE;
285 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
286 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::USER_STOPPED_REASON_REMOVE));
287 inType = NotificationConstant::APP_CANCEL_REASON_DELETE;
288 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
289 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::APP_CANCEL_REASON_REMOVE));
290 inType = NotificationConstant::APP_CANCEL_ALL_REASON_DELETE;
291 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
292 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::APP_CANCEL_ALL_REASON_REMOVE));
293 inType = NotificationConstant::USER_REMOVED_REASON_DELETE;
294 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
295 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::USER_REMOVED_REASON_DELETE));
296 inType = NotificationConstant::FLOW_CONTROL_REASON_DELETE;
297 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
298 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::FLOW_CONTROL_REASON_DELETE));
299 inType = NotificationConstant::DISABLE_SLOT_REASON_DELETE;
300 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
301 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::DISABLE_SLOT_REASON_DELETE));
302 inType = NotificationConstant::DISABLE_NOTIFICATION_REASON_DELETE;
303 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
304 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::DISABLE_NOTIFICATION_REASON_DELETE));
305 inType = NotificationConstant::APP_CANCEL_AS_BUNELE_REASON_DELETE;
306 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
307 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::APP_CANCEL_AS_BUNELE_REASON_DELETE));
308 inType = NotificationConstant::APP_CANCEL_AS_BUNELE_WITH_AGENT_REASON_DELETE;
309 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
310 EXPECT_EQ(outType,
311 static_cast<int32_t>(NotificationNapi::RemoveReason::APP_CANCEL_AS_BUNELE_WITH_AGENT_REASON_DELETE));
312 inType = NotificationConstant::APP_CANCEL_REMINDER_REASON_DELETE;
313 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
314 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::APP_CANCEL_REMINDER_REASON_DELETE));
315 inType = NotificationConstant::APP_CANCEL_GROPU_REASON_DELETE;
316 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
317 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::APP_CANCEL_GROPU_REASON_DELETE));
318 inType = NotificationConstant::APP_REMOVE_GROUP_REASON_DELETE;
319 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
320 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::APP_REMOVE_GROUP_REASON_DELETE));
321 inType = NotificationConstant::APP_REMOVE_ALL_REASON_DELETE;
322 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
323 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::APP_REMOVE_ALL_REASON_DELETE));
324 inType = NotificationConstant::APP_REMOVE_ALL_USER_REASON_DELETE;
325 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
326 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::APP_REMOVE_ALL_USER_REASON_DELETE));
327 inType = NotificationConstant::TRIGGER_EIGHT_HOUR_REASON_DELETE;
328 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
329 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::TRIGGER_EIGHT_HOUR_REASON_DELETE));
330 inType = NotificationConstant::TRIGGER_FOUR_HOUR_REASON_DELETE;
331 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
332 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::TRIGGER_FOUR_HOUR_REASON_DELETE));
333 inType = NotificationConstant::TRIGGER_TEN_MINUTES_REASON_DELETE;
334 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
335 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::TRIGGER_TEN_MINUTES_REASON_DELETE));
336 inType = NotificationConstant::TRIGGER_FIFTEEN_MINUTES_REASON_DELETE;
337 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
338 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::TRIGGER_FIFTEEN_MINUTES_REASON_DELETE));
339 inType = NotificationConstant::TRIGGER_THIRTY_MINUTES_REASON_DELETE;
340 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
341 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::TRIGGER_THIRTY_MINUTES_REASON_DELETE));
342 inType = NotificationConstant::TRIGGER_START_ARCHIVE_REASON_DELETE;
343 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
344 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::TRIGGER_START_ARCHIVE_REASON_DELETE));
345 inType = NotificationConstant::TRIGGER_AUTO_DELETE_REASON_DELETE;
346 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
347 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::TRIGGER_AUTO_DELETE_REASON_DELETE));
348 inType = NotificationConstant::PACKAGE_REMOVE_REASON_DELETE;
349 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
350 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::PACKAGE_REMOVE_REASON_DELETE));
351 inType = NotificationConstant::SLOT_ENABLED_REASON_DELETE;
352 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
353 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::SLOT_ENABLED_REASON_DELETE));
354 inType = NotificationConstant::APP_CANCEL_REASON_OTHER;
355 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
356 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::APP_CANCEL_REASON_OTHER));
357 inType = NotificationConstant::RECOVER_LIVE_VIEW_DELETE;
358 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
359 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::RECOVER_LIVE_VIEW_DELETE));
360 inType = NotificationConstant::DISABLE_NOTIFICATION_FEATURE_REASON_DELETE;
361 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
362 EXPECT_EQ(outType,
363 static_cast<int32_t>(NotificationNapi::RemoveReason::DISABLE_NOTIFICATION_FEATURE_REASON_DELETE));
364 inType = NotificationConstant::DISTRIBUTED_COLLABORATIVE_DELETE;
365 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
366 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::DISTRIBUTED_COLLABORATIVE_DELETE));
367 inType = NotificationConstant::DISTRIBUTED_COLLABORATIVE_CLICK_DELETE;
368 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
369 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::DISTRIBUTED_COLLABORATIVE_CLICK_DELETE));
370 inType = NotificationConstant::APP_CANCEL_REASON_OTHER;
371 NotificationNapi::AnsEnumUtil::ReasonCToJS(inType, outType);
372 EXPECT_EQ(outType, static_cast<int32_t>(NotificationNapi::RemoveReason::APP_CANCEL_REASON_OTHER));
373 }
374
375 /*
376 * @tc.name: AnsConvertTest_009
377 * @tc.desc: test DoNotDisturbTypeJSToC function
378 * @tc.type: FUNC
379 * @tc.require: issueI5UI8T
380 */
381 HWTEST_F(AnsLogTest, AnsConvertTest_009, TestSize.Level1)
382 {
383 NotificationConstant::DoNotDisturbType outType;
384 NotificationNapi::DoNotDisturbType inType = NotificationNapi::DoNotDisturbType::TYPE_NONE;
385 NotificationNapi::AnsEnumUtil::DoNotDisturbTypeJSToC(inType, outType);
386 EXPECT_EQ(outType, NotificationConstant::DoNotDisturbType::NONE);
387 inType = NotificationNapi::DoNotDisturbType::TYPE_ONCE;
388 NotificationNapi::AnsEnumUtil::DoNotDisturbTypeJSToC(inType, outType);
389 EXPECT_EQ(outType, NotificationConstant::DoNotDisturbType::ONCE);
390 inType = NotificationNapi::DoNotDisturbType::TYPE_DAILY;
391 NotificationNapi::AnsEnumUtil::DoNotDisturbTypeJSToC(inType, outType);
392 EXPECT_EQ(outType, NotificationConstant::DoNotDisturbType::DAILY);
393 inType = NotificationNapi::DoNotDisturbType::TYPE_CLEARLY;
394 NotificationNapi::AnsEnumUtil::DoNotDisturbTypeJSToC(inType, outType);
395 EXPECT_EQ(outType, NotificationConstant::DoNotDisturbType::CLEARLY);
396 }
397
398 /*
399 * @tc.name: AnsConvertTest_010
400 * @tc.desc: test DoNotDisturbTypeCToJS function
401 * @tc.type: FUNC
402 * @tc.require: issueI5UI8T
403 */
404 HWTEST_F(AnsLogTest, AnsConvertTest_010, TestSize.Level1)
405 {
406 NotificationNapi::DoNotDisturbType outType;
407 NotificationConstant::DoNotDisturbType inType = NotificationConstant::DoNotDisturbType::NONE;
408 NotificationNapi::AnsEnumUtil::DoNotDisturbTypeCToJS(inType, outType);
409 EXPECT_EQ(outType, NotificationNapi::DoNotDisturbType::TYPE_NONE);
410 inType = NotificationConstant::DoNotDisturbType::ONCE;
411 NotificationNapi::AnsEnumUtil::DoNotDisturbTypeCToJS(inType, outType);
412 EXPECT_EQ(outType, NotificationNapi::DoNotDisturbType::TYPE_ONCE);
413 inType = NotificationConstant::DoNotDisturbType::DAILY;
414 NotificationNapi::AnsEnumUtil::DoNotDisturbTypeCToJS(inType, outType);
415 EXPECT_EQ(outType, NotificationNapi::DoNotDisturbType::TYPE_DAILY);
416 inType = NotificationConstant::DoNotDisturbType::CLEARLY;
417 NotificationNapi::AnsEnumUtil::DoNotDisturbTypeCToJS(inType, outType);
418 EXPECT_EQ(outType, NotificationNapi::DoNotDisturbType::TYPE_CLEARLY);
419 }
420
421 /*
422 * @tc.name: AnsConvertTest_011
423 * @tc.desc: test DeviceRemindTypeCToJS function
424 * @tc.type: FUNC
425 * @tc.require: issueI5UI8T
426 */
427 HWTEST_F(AnsLogTest, AnsConvertTest_011, TestSize.Level1)
428 {
429 NotificationNapi::DeviceRemindType outType;
430 NotificationConstant::RemindType inType = NotificationConstant::RemindType::DEVICE_IDLE_DONOT_REMIND;
431 NotificationNapi::AnsEnumUtil::DeviceRemindTypeCToJS(inType, outType);
432 EXPECT_EQ(outType, NotificationNapi::DeviceRemindType::IDLE_DONOT_REMIND);
433 inType = NotificationConstant::RemindType::DEVICE_IDLE_REMIND;
434 NotificationNapi::AnsEnumUtil::DeviceRemindTypeCToJS(inType, outType);
435 EXPECT_EQ(outType, NotificationNapi::DeviceRemindType::IDLE_REMIND);
436 inType = NotificationConstant::RemindType::DEVICE_ACTIVE_DONOT_REMIND;
437 NotificationNapi::AnsEnumUtil::DeviceRemindTypeCToJS(inType, outType);
438 EXPECT_EQ(outType, NotificationNapi::DeviceRemindType::ACTIVE_DONOT_REMIND);
439 inType = NotificationConstant::RemindType::DEVICE_ACTIVE_REMIND;
440 NotificationNapi::AnsEnumUtil::DeviceRemindTypeCToJS(inType, outType);
441 EXPECT_EQ(outType, NotificationNapi::DeviceRemindType::ACTIVE_REMIND);
442 }
443
444 /*
445 * @tc.name: AnsConvertTest_012
446 * @tc.desc: test SourceTypeCToJS function
447 * @tc.type: FUNC
448 * @tc.require: issueI5UI8T
449 */
450 HWTEST_F(AnsLogTest, AnsConvertTest_012, TestSize.Level1)
451 {
452 NotificationNapi::SourceType outType;
453 NotificationConstant::SourceType inType = NotificationConstant::SourceType::TYPE_NORMAL;
454 NotificationNapi::AnsEnumUtil::SourceTypeCToJS(inType, outType);
455 EXPECT_EQ(outType, NotificationNapi::SourceType::TYPE_NORMAL);
456 inType = NotificationConstant::SourceType::TYPE_CONTINUOUS;
457 NotificationNapi::AnsEnumUtil::SourceTypeCToJS(inType, outType);
458 EXPECT_EQ(outType, NotificationNapi::SourceType::TYPE_CONTINUOUS);
459 inType = NotificationConstant::SourceType::TYPE_TIMER;
460 NotificationNapi::AnsEnumUtil::SourceTypeCToJS(inType, outType);
461 EXPECT_EQ(outType, NotificationNapi::SourceType::TYPE_TIMER);
462 }
463
464 /*
465 * @tc.name: AnsConvertTest_013
466 * @tc.desc: test LiveViewStatusCToJS function
467 * @tc.type: FUNC
468 * @tc.require: issueI5UI8T
469 */
470 HWTEST_F(AnsLogTest, AnsConvertTest_013, TestSize.Level1)
471 {
472 NotificationNapi::LiveViewStatus outType;
473 NotificationLiveViewContent::LiveViewStatus inType = NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_CREATE;
474 NotificationNapi::AnsEnumUtil::LiveViewStatusCToJS(inType, outType);
475 EXPECT_EQ(outType, NotificationNapi::LiveViewStatus::LIVE_VIEW_CREATE);
476 inType = NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_INCREMENTAL_UPDATE;
477 NotificationNapi::AnsEnumUtil::LiveViewStatusCToJS(inType, outType);
478 EXPECT_EQ(outType, NotificationNapi::LiveViewStatus::LIVE_VIEW_INCREMENTAL_UPDATE);
479 inType = NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_END;
480 NotificationNapi::AnsEnumUtil::LiveViewStatusCToJS(inType, outType);
481 EXPECT_EQ(outType, NotificationNapi::LiveViewStatus::LIVE_VIEW_END);
482 inType = NotificationLiveViewContent::LiveViewStatus::LIVE_VIEW_FULL_UPDATE;
483 NotificationNapi::AnsEnumUtil::LiveViewStatusCToJS(inType, outType);
484 EXPECT_EQ(outType, NotificationNapi::LiveViewStatus::LIVE_VIEW_FULL_UPDATE);
485 }
486
487 /*
488 * @tc.name: AnsConvertTest_014
489 * @tc.desc: test LiveViewTypesJSToC function
490 * @tc.type: FUNC
491 * @tc.require: issueI5UI8T
492 */
493 HWTEST_F(AnsLogTest, AnsConvertTest_014, TestSize.Level1)
494 {
495 NotificationLocalLiveViewContent::LiveViewTypes outType;
496 NotificationNapi::LiveViewTypes inType = NotificationNapi::LiveViewTypes::LIVE_VIEW_ACTIVITY;
497 NotificationNapi::AnsEnumUtil::LiveViewTypesJSToC(inType, outType);
498 EXPECT_EQ(outType, NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_ACTIVITY);
499 inType = NotificationNapi::LiveViewTypes::LIVE_VIEW_INSTANT;
500 NotificationNapi::AnsEnumUtil::LiveViewTypesJSToC(inType, outType);
501 EXPECT_EQ(outType, NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_INSTANT);
502 inType = NotificationNapi::LiveViewTypes::LIVE_VIEW_LONG_TERM;
503 NotificationNapi::AnsEnumUtil::LiveViewTypesJSToC(inType, outType);
504 EXPECT_EQ(outType, NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_LONG_TERM);
505 inType = NotificationNapi::LiveViewTypes::LIVE_VIEW_INSTANT_BANNER;
506 NotificationNapi::AnsEnumUtil::LiveViewTypesJSToC(inType, outType);
507 EXPECT_EQ(outType, NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_INSTANT_BANNER);
508 }
509
510 /*
511 * @tc.name: AnsConvertTest_015
512 * @tc.desc: test LiveViewTypesCToJS function
513 * @tc.type: FUNC
514 * @tc.require: issueI5UI8T
515 */
516 HWTEST_F(AnsLogTest, AnsConvertTest_015, TestSize.Level1)
517 {
518 NotificationNapi::LiveViewTypes outType;
519 NotificationLocalLiveViewContent::LiveViewTypes inType =
520 NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_ACTIVITY;
521 NotificationNapi::AnsEnumUtil::LiveViewTypesCToJS(inType, outType);
522 EXPECT_EQ(outType, NotificationNapi::LiveViewTypes::LIVE_VIEW_ACTIVITY);
523 inType = NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_INSTANT;
524 NotificationNapi::AnsEnumUtil::LiveViewTypesCToJS(inType, outType);
525 EXPECT_EQ(outType, NotificationNapi::LiveViewTypes::LIVE_VIEW_INSTANT);
526 inType = NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_LONG_TERM;
527 NotificationNapi::AnsEnumUtil::LiveViewTypesCToJS(inType, outType);
528 EXPECT_EQ(outType, NotificationNapi::LiveViewTypes::LIVE_VIEW_LONG_TERM);
529 inType = NotificationLocalLiveViewContent::LiveViewTypes::LIVE_VIEW_INSTANT_BANNER;
530 NotificationNapi::AnsEnumUtil::LiveViewTypesCToJS(inType, outType);
531 EXPECT_EQ(outType, NotificationNapi::LiveViewTypes::LIVE_VIEW_INSTANT_BANNER);
532 }
533 }
534 }
535