1 /*
2 * Copyright (c) 2024 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 "animate_impl.h"
17 #include "core/interfaces/arkoala/arkoala_api.h"
18 #include "dialog_model.h"
19 #include "error_code.h"
20 #include "event_converter.h"
21 #include "gtest/gtest.h"
22 #include "native_animate.h"
23 #include "native_interface.h"
24 #include "native_node.h"
25 #include "node_extened.h"
26 #include "node_model.h"
27 #include "native_dialog.h"
28
29 using namespace testing;
30 using namespace testing::ext;
31 using namespace OHOS::Ace::DialogModel;
32
33 class DialogModelTest : public testing::Test {
34 public:
SetUpTestCase()35 static void SetUpTestCase() {};
TearDownTestCase()36 static void TearDownTestCase() {};
37 };
38
OnWillDismissEvent(int32_t reason)39 bool OnWillDismissEvent(int32_t reason)
40 {
41 return true;
42 }
43
44 /**
45 * @tc.name: DialogModelTest001
46 * @tc.desc: Test Create function.
47 * @tc.type: FUNC
48 */
49 HWTEST_F(DialogModelTest, DialogModelTest001, TestSize.Level1)
50 {
51 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
52 ASSERT_EQ(nativeDialogHandle, nullptr);
53
54 Dispose(nativeDialogHandle);
55 }
56
57 /**
58 * @tc.name: DialogModelTest002
59 * @tc.desc: Test Create function.
60 * @tc.type: FUNC
61 */
62 HWTEST_F(DialogModelTest, DialogModelTest002, TestSize.Level1)
63 {
64 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
65 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
66 ASSERT_NE(nativeDialogHandle, nullptr);
67
68 Dispose(nativeDialogHandle);
69 nativeDialogHandle = nullptr;
70 }
71
72 /**
73 * @tc.name: DialogModelTest003
74 * @tc.desc: Test SetContent function.
75 * @tc.type: FUNC
76 */
77 HWTEST_F(DialogModelTest, DialogModelTest003, TestSize.Level1)
78 {
79 int32_t ret = SetContent(nullptr, nullptr);
80 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
81 }
82
83 /**
84 * @tc.name: DialogModelTest004
85 * @tc.desc: Test SetContent function.
86 * @tc.type: FUNC
87 */
88 HWTEST_F(DialogModelTest, DialogModelTest004, TestSize.Level1)
89 {
90 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
91 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
92 ASSERT_NE(nativeDialogHandle, nullptr);
93 ArkUI_NodeHandle nodeHandle = new ArkUI_Node();
94 int32_t ret = SetContent(nativeDialogHandle, nodeHandle);
95 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
96 Dispose(nativeDialogHandle);
97 nativeDialogHandle = nullptr;
98 delete nodeHandle;
99 }
100
101 /**
102 * @tc.name: DialogModelTest005
103 * @tc.desc: Test RemoveContent function.
104 * @tc.type: FUNC
105 */
106 HWTEST_F(DialogModelTest, DialogModelTest005, TestSize.Level1)
107 {
108 int32_t ret = RemoveContent(nullptr);
109 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
110 }
111
112 /**
113 * @tc.name: DialogModelTest006
114 * @tc.desc: Test RemoveContent function.
115 * @tc.type: FUNC
116 */
117 HWTEST_F(DialogModelTest, DialogModelTest006, TestSize.Level1)
118 {
119 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
120 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
121 ASSERT_NE(nativeDialogHandle, nullptr);
122 int32_t ret = RemoveContent(nativeDialogHandle);
123 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
124 Dispose(nativeDialogHandle);
125 nativeDialogHandle = nullptr;
126 }
127
128 /**
129 * @tc.name: DialogModelTest007
130 * @tc.desc: Test SetContentAlignment function.
131 * @tc.type: FUNC
132 */
133 HWTEST_F(DialogModelTest, DialogModelTest007, TestSize.Level1)
134 {
135 int32_t ret = SetContentAlignment(nullptr, 0, 0.0f, 0.0f);
136 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
137 }
138
139 /**
140 * @tc.name: DialogModelTest008
141 * @tc.desc: Test SetContentAlignment function.
142 * @tc.type: FUNC
143 */
144 HWTEST_F(DialogModelTest, DialogModelTest008, TestSize.Level1)
145 {
146 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
147 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
148 ASSERT_NE(nativeDialogHandle, nullptr);
149 int32_t ret = SetContentAlignment(nativeDialogHandle, 0, 0.0f, 0.0f);
150 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
151 Dispose(nativeDialogHandle);
152 nativeDialogHandle = nullptr;
153 }
154
155 /**
156 * @tc.name: DialogModelTest009
157 * @tc.desc: Test ResetContentAlignment function.
158 * @tc.type: FUNC
159 */
160 HWTEST_F(DialogModelTest, DialogModelTest009, TestSize.Level1)
161 {
162 int32_t ret = ResetContentAlignment(nullptr);
163 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
164 }
165
166 /**
167 * @tc.name: DialogModelTest010
168 * @tc.desc: Test SetContentAlignment function.
169 * @tc.type: FUNC
170 */
171 HWTEST_F(DialogModelTest, DialogModelTest010, TestSize.Level1)
172 {
173 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
174 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
175 ASSERT_NE(nativeDialogHandle, nullptr);
176 int32_t ret = ResetContentAlignment(nativeDialogHandle);
177 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
178 Dispose(nativeDialogHandle);
179 nativeDialogHandle = nullptr;
180 }
181
182 /**
183 * @tc.name: DialogModelTest011
184 * @tc.desc: Test SetModalMode function.
185 * @tc.type: FUNC
186 */
187 HWTEST_F(DialogModelTest, DialogModelTest011, TestSize.Level1)
188 {
189 int32_t ret = SetModalMode(nullptr, true);
190 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
191 }
192
193 /**
194 * @tc.name: DialogModelTest012
195 * @tc.desc: Test SetModalMode function.
196 * @tc.type: FUNC
197 */
198 HWTEST_F(DialogModelTest, DialogModelTest012, TestSize.Level1)
199 {
200 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
201 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
202 ASSERT_NE(nativeDialogHandle, nullptr);
203 int32_t ret = SetModalMode(nativeDialogHandle, true);
204 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
205 Dispose(nativeDialogHandle);
206 nativeDialogHandle = nullptr;
207 }
208
209 /**
210 * @tc.name: DialogModelTest013
211 * @tc.desc: Test SetAutoCancel function.
212 * @tc.type: FUNC
213 */
214 HWTEST_F(DialogModelTest, DialogModelTest013, TestSize.Level1)
215 {
216 int32_t ret = SetAutoCancel(nullptr, true);
217 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
218 }
219
220 /**
221 * @tc.name: DialogModelTest014
222 * @tc.desc: Test SetAutoCancel function.
223 * @tc.type: FUNC
224 */
225 HWTEST_F(DialogModelTest, DialogModelTest014, TestSize.Level1)
226 {
227 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
228 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
229 ASSERT_NE(nativeDialogHandle, nullptr);
230 int32_t ret = SetAutoCancel(nativeDialogHandle, true);
231 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
232 Dispose(nativeDialogHandle);
233 nativeDialogHandle = nullptr;
234 }
235
236 /**
237 * @tc.name: DialogModelTest015
238 * @tc.desc: Test SetMask function.
239 * @tc.type: FUNC
240 */
241 HWTEST_F(DialogModelTest, DialogModelTest015, TestSize.Level1)
242 {
243 int32_t ret = SetMask(nullptr, 0, nullptr);
244 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
245 }
246
247 /**
248 * @tc.name: DialogModelTest016
249 * @tc.desc: Test SetMask function.
250 * @tc.type: FUNC
251 */
252 HWTEST_F(DialogModelTest, DialogModelTest016, TestSize.Level1)
253 {
254 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
255 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
256 ASSERT_NE(nativeDialogHandle, nullptr);
257 ArkUI_Rect rect = {0.0f, 0.0f, 0.0f, 0.0f};
258 int32_t ret = SetMask(nativeDialogHandle, 0, &rect);
259 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
260 Dispose(nativeDialogHandle);
261 nativeDialogHandle = nullptr;
262 }
263
264 /**
265 * @tc.name: DialogModelTest017
266 * @tc.desc: Test SetMask function.
267 * @tc.type: FUNC
268 */
269 HWTEST_F(DialogModelTest, DialogModelTest017, TestSize.Level1)
270 {
271 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
272 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
273 ASSERT_NE(nativeDialogHandle, nullptr);
274 int32_t ret = SetMask(nativeDialogHandle, 0, nullptr);
275 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
276 Dispose(nativeDialogHandle);
277 nativeDialogHandle = nullptr;
278 }
279
280 /**
281 * @tc.name: DialogModelTest018
282 * @tc.desc: Test SetBackgroundColor function.
283 * @tc.type: FUNC
284 */
285 HWTEST_F(DialogModelTest, DialogModelTest018, TestSize.Level1)
286 {
287 int32_t ret = SetBackgroundColor(nullptr, 0);
288 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
289 }
290
291 /**
292 * @tc.name: DialogModelTest019
293 * @tc.desc: Test SetBackgroundColor function.
294 * @tc.type: FUNC
295 */
296 HWTEST_F(DialogModelTest, DialogModelTest019, TestSize.Level1)
297 {
298 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
299 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
300 ASSERT_NE(nativeDialogHandle, nullptr);
301 int32_t ret = SetBackgroundColor(nativeDialogHandle, 0);
302 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
303 Dispose(nativeDialogHandle);
304 nativeDialogHandle = nullptr;
305 }
306
307 /**
308 * @tc.name: DialogModelTest020
309 * @tc.desc: Test SetCornerRadius function.
310 * @tc.type: FUNC
311 */
312 HWTEST_F(DialogModelTest, DialogModelTest020, TestSize.Level1)
313 {
314 int32_t ret = SetCornerRadius(nullptr, 0.0f, 0.0f, 0.0f, 0.0f);
315 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
316 }
317
318 /**
319 * @tc.name: DialogModelTest021
320 * @tc.desc: Test SetCornerRadius function.
321 * @tc.type: FUNC
322 */
323 HWTEST_F(DialogModelTest, DialogModelTest021, TestSize.Level1)
324 {
325 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
326 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
327 ASSERT_NE(nativeDialogHandle, nullptr);
328 int32_t ret = SetCornerRadius(nativeDialogHandle, 0.0f, 0.0f, 0.0f, 0.0f);
329 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
330 Dispose(nativeDialogHandle);
331 nativeDialogHandle = nullptr;
332 }
333
334 /**
335 * @tc.name: DialogModelTest022
336 * @tc.desc: Test SetGridColumnCount function.
337 * @tc.type: FUNC
338 */
339 HWTEST_F(DialogModelTest, DialogModelTest022, TestSize.Level1)
340 {
341 int32_t ret = SetGridColumnCount(nullptr, 0);
342 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
343 }
344
345 /**
346 * @tc.name: DialogModelTest023
347 * @tc.desc: Test SetGridColumnCount function.
348 * @tc.type: FUNC
349 */
350 HWTEST_F(DialogModelTest, DialogModelTest023, TestSize.Level1)
351 {
352 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
353 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
354 ASSERT_NE(nativeDialogHandle, nullptr);
355 int32_t ret = SetGridColumnCount(nativeDialogHandle, 0);
356 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
357 Dispose(nativeDialogHandle);
358 nativeDialogHandle = nullptr;
359 }
360
361 /**
362 * @tc.name: DialogModelTest024
363 * @tc.desc: Test EnableCustomStyle function.
364 * @tc.type: FUNC
365 */
366 HWTEST_F(DialogModelTest, DialogModelTest024, TestSize.Level1)
367 {
368 int32_t ret = EnableCustomStyle(nullptr, true);
369 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
370 }
371
372 /**
373 * @tc.name: DialogModelTest025
374 * @tc.desc: Test EnableCustomStyle function.
375 * @tc.type: FUNC
376 */
377 HWTEST_F(DialogModelTest, DialogModelTest025, TestSize.Level1)
378 {
379 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
380 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
381 ASSERT_NE(nativeDialogHandle, nullptr);
382 int32_t ret = EnableCustomStyle(nativeDialogHandle, true);
383 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
384 Dispose(nativeDialogHandle);
385 nativeDialogHandle = nullptr;
386 }
387
388 /**
389 * @tc.name: DialogModelTest026
390 * @tc.desc: Test EnableCustomAnimation function.
391 * @tc.type: FUNC
392 */
393 HWTEST_F(DialogModelTest, DialogModelTest026, TestSize.Level1)
394 {
395 int32_t ret = EnableCustomAnimation(nullptr, true);
396 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
397 }
398
399 /**
400 * @tc.name: DialogModelTest027
401 * @tc.desc: Test EnableCustomAnimation function.
402 * @tc.type: FUNC
403 */
404 HWTEST_F(DialogModelTest, DialogModelTest027, TestSize.Level1)
405 {
406 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
407 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
408 ASSERT_NE(nativeDialogHandle, nullptr);
409 int32_t ret = EnableCustomAnimation(nativeDialogHandle, true);
410 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
411 Dispose(nativeDialogHandle);
412 nativeDialogHandle = nullptr;
413 }
414
415 /**
416 * @tc.name: DialogModelTest028
417 * @tc.desc: Test Show function.
418 * @tc.type: FUNC
419 */
420 HWTEST_F(DialogModelTest, DialogModelTest028, TestSize.Level1)
421 {
422 int32_t ret = Show(nullptr, true);
423 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
424 }
425
426 /**
427 * @tc.name: DialogModelTest029
428 * @tc.desc: Test Show function.
429 * @tc.type: FUNC
430 */
431 HWTEST_F(DialogModelTest, DialogModelTest029, TestSize.Level1)
432 {
433 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
434 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
435 ASSERT_NE(nativeDialogHandle, nullptr);
436 int32_t ret = Show(nativeDialogHandle, false);
437 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
438 Dispose(nativeDialogHandle);
439 nativeDialogHandle = nullptr;
440 }
441
442 /**
443 * @tc.name: DialogModelTest030
444 * @tc.desc: Test Close function.
445 * @tc.type: FUNC
446 */
447 HWTEST_F(DialogModelTest, DialogModelTest030, TestSize.Level1)
448 {
449 int32_t ret = Close(nullptr);
450 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
451 }
452
453 /**
454 * @tc.name: DialogModelTest031
455 * @tc.desc: Test Close function.
456 * @tc.type: FUNC
457 */
458 HWTEST_F(DialogModelTest, DialogModelTest031, TestSize.Level1)
459 {
460 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
461 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
462 ASSERT_NE(nativeDialogHandle, nullptr);
463 int32_t ret = Close(nativeDialogHandle);
464 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
465 Dispose(nativeDialogHandle);
466 nativeDialogHandle = nullptr;
467 }
468
469 /**
470 * @tc.name: DialogModelTest032
471 * @tc.desc: Test RegisterOnWillDismiss function.
472 * @tc.type: FUNC
473 */
474 HWTEST_F(DialogModelTest, DialogModelTest032, TestSize.Level1)
475 {
476 int32_t ret = RegisterOnWillDismiss(nullptr, nullptr);
477 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
478 }
479
480 /**
481 * @tc.name: DialogModelTest033
482 * @tc.desc: Test RegisterOnWillDismiss function.
483 * @tc.type: FUNC
484 */
485 HWTEST_F(DialogModelTest, DialogModelTest033, TestSize.Level1)
486 {
487 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
488 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
489 ASSERT_NE(nativeDialogHandle, nullptr);
490 ArkUI_OnWillDismissEvent eventHandler = OnWillDismissEvent;
491 int32_t ret = RegisterOnWillDismiss(nativeDialogHandle, eventHandler);
492 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
493 Dispose(nativeDialogHandle);
494 nativeDialogHandle = nullptr;
495 }
496
497 /**
498 * @tc.name: DialogModelTest034
499 * @tc.desc: Test RegisterOnWillDismissWithUserData function.
500 * @tc.type: FUNC
501 */
502 HWTEST_F(DialogModelTest, DialogModelTest034, TestSize.Level1)
503 {
504 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
505 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
506 ASSERT_NE(nativeDialogHandle, nullptr);
507 ArkUI_DialogDismissEvent nEvent;
508 int32_t ret =
__anon76185ca80102(ArkUI_DialogDismissEvent* event) 509 RegisterOnWillDismissWithUserData(nativeDialogHandle, nEvent.userData, [](ArkUI_DialogDismissEvent* event) {});
510 ASSERT_EQ(ret, 0);
511 ret = RegisterOnWillDismissWithUserData(nullptr, nullptr, nullptr);
512 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
513 Dispose(nativeDialogHandle);
514 nativeDialogHandle = nullptr;
515 }
516
517 /**
518 * @tc.name: DialogModelTest035
519 * @tc.desc: Test ArkUI_DialogDismissEvent_SetShouldBlockDismiss function.
520 * @tc.type: FUNC
521 */
522 HWTEST_F(DialogModelTest, DialogModelTest035, TestSize.Level1)
523 {
524 ArkUI_DialogDismissEvent* nEvent = new ArkUI_DialogDismissEvent({ nullptr, 0, false });
525 OH_ArkUI_DialogDismissEvent_SetShouldBlockDismiss(nEvent, true);
526 ASSERT_TRUE(nEvent->BlockDismiss);
527 nEvent = nullptr;
528 OH_ArkUI_DialogDismissEvent_SetShouldBlockDismiss(nEvent, true);
529 ASSERT_TRUE(nEvent == nullptr);
530 }
531
532 /**
533 * @tc.name: DialogModelTest036
534 * @tc.desc: Test ArkUI_DialogDismissEvent_GetUserData function.
535 * @tc.type: FUNC
536 */
537 HWTEST_F(DialogModelTest, DialogModelTest036, TestSize.Level1)
538 {
539 struct ArkUICustomData {
540 float id;
541 int index;
542 };
543 auto customData = new ArkUICustomData { 12, 1 };
544 ArkUI_DialogDismissEvent* nEvent = new ArkUI_DialogDismissEvent({ nullptr, 0, false });
545 nEvent->userData = customData;
546 void* ret = OH_ArkUI_DialogDismissEvent_GetUserData(nEvent);
547 ASSERT_EQ(ret, nEvent->userData);
548 nEvent = nullptr;
549 ret = OH_ArkUI_DialogDismissEvent_GetUserData(nEvent);
550 ASSERT_TRUE(ret == nullptr);
551 }
552
553 /**
554 * @tc.name: DialogModelTest037
555 * @tc.desc: Test ArkUI_DialogDismissEvent_GetUserData function.
556 * @tc.type: FUNC
557 */
558 HWTEST_F(DialogModelTest, DialogModelTest037, TestSize.Level1)
559 {
560 ArkUI_DialogDismissEvent* nEvent = new ArkUI_DialogDismissEvent({ nullptr, 0, false });
561 int32_t ret = OH_ArkUI_DialogDismissEvent_GetDismissReason(nEvent);
562 ASSERT_EQ(ret, nEvent->reason);
563 nEvent = nullptr;
564 ret = OH_ArkUI_DialogDismissEvent_GetDismissReason(nEvent);
565 ASSERT_EQ(ret, -1);
566 }
567
568 /**
569 * @tc.name: DialogModelTest038
570 * @tc.desc: Test SetLevelMode function.
571 * @tc.type: FUNC
572 */
573 HWTEST_F(DialogModelTest, DialogModelTest038, TestSize.Level1)
574 {
575 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
576 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
577 ASSERT_NE(nativeDialogHandle, nullptr);
578 int32_t ret = SetLevelMode(nativeDialogHandle, ARKUI_LEVEL_MODE_OVERLAY);
579 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
580 ret = SetLevelMode(nativeDialogHandle, static_cast<ArkUI_LevelMode>(-1));
581 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
582 Dispose(nativeDialogHandle);
583 nativeDialogHandle = nullptr;
584 }
585
586 /**
587 * @tc.name: DialogModelTest039
588 * @tc.desc: Test SetLevelUniqueId function.
589 * @tc.type: FUNC
590 */
591 HWTEST_F(DialogModelTest, DialogModelTest039, TestSize.Level1)
592 {
593 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
594 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
595 ASSERT_NE(nativeDialogHandle, nullptr);
596 int32_t ret = SetLevelUniqueId(nativeDialogHandle, 0);
597 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
598 ret = SetLevelUniqueId(nativeDialogHandle, -1);
599 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
600 Dispose(nativeDialogHandle);
601 nativeDialogHandle = nullptr;
602 }
603
604 /**
605 * @tc.name: DialogModelTest040
606 * @tc.desc: Test SetImmersiveMode function.
607 * @tc.type: FUNC
608 */
609 HWTEST_F(DialogModelTest, DialogModelTest040, TestSize.Level1)
610 {
611 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
612 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
613 ASSERT_NE(nativeDialogHandle, nullptr);
614 int32_t ret = SetImmersiveMode(nativeDialogHandle, ARKUI_IMMERSIVE_MODE_DEFAULT);
615 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
616 ret = SetImmersiveMode(nativeDialogHandle, static_cast<ArkUI_ImmersiveMode>(-1));
617 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
618 Dispose(nativeDialogHandle);
619 nativeDialogHandle = nullptr;
620 }
621
622 /**
623 * @tc.name: DialogModelTest041
624 * @tc.desc: Test SetLevelOrder function.
625 * @tc.type: FUNC
626 */
627 HWTEST_F(DialogModelTest, DialogModelTest041, TestSize.Level1)
628 {
629 int32_t ret = SetLevelOrder(nullptr, 0.0f);
630 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
631 }
632
633 /**
634 * @tc.name: DialogModelTest042
635 * @tc.desc: Test SetLevelOrder function.
636 * @tc.type: FUNC
637 */
638 HWTEST_F(DialogModelTest, DialogModelTest042, TestSize.Level1)
639 {
640 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
641 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
642 ASSERT_NE(nativeDialogHandle, nullptr);
643 int32_t ret = SetLevelOrder(nativeDialogHandle, 0.0f);
644 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
645 Dispose(nativeDialogHandle);
646 nativeDialogHandle = nullptr;
647 }
648
649 /**
650 * @tc.name: DialogModelTest043
651 * @tc.desc: Test SetFocusable function.
652 * @tc.type: FUNC
653 */
654 HWTEST_F(DialogModelTest, DialogModelTest043, TestSize.Level1)
655 {
656 int32_t ret = SetFocusable(nullptr, false);
657 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID);
658 }
659
660 /**
661 * @tc.name: DialogModelTest044
662 * @tc.desc: Test SetFocusable function.
663 * @tc.type: FUNC
664 */
665 HWTEST_F(DialogModelTest, DialogModelTest044, TestSize.Level1)
666 {
667 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
668 ArkUI_NativeDialogHandle nativeDialogHandle = Create();
669 ASSERT_NE(nativeDialogHandle, nullptr);
670 int32_t ret = SetFocusable(nativeDialogHandle, false);
671 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR);
672 Dispose(nativeDialogHandle);
673 nativeDialogHandle = nullptr;
674 }
675