1 /*
2  * Copyright (c) 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 <gtest/gtest.h>
17 #include "window_session_property.h"
18 
19 using namespace testing;
20 using namespace testing::ext;
21 
22 namespace OHOS {
23 namespace Rosen {
24 
25 class WindowSessionPropertyTest : public testing::Test {
26 public:
27     static void SetUpTestCase();
28     static void TearDownTestCase();
29 };
30 
SetUpTestCase()31 void WindowSessionPropertyTest::SetUpTestCase()
32 {
33 }
34 
TearDownTestCase()35 void WindowSessionPropertyTest::TearDownTestCase()
36 {
37 }
38 
39 namespace {
40 /**
41  * @tc.name: SetDragEnabled001
42  * @tc.desc: SetDragEnabled and GetDragEnabled to check the value
43  * @tc.type: FUNC
44  */
45 HWTEST_F(WindowSessionPropertyTest, SetDragEnabled001, Function | SmallTest | Level2)
46 {
47     WindowSessionProperty *property = new WindowSessionProperty();
48     ASSERT_EQ(property->GetDragEnabled(), true);
49     property->SetDragEnabled(false);
50     ASSERT_EQ(property->GetDragEnabled(), false);
51 }
52 
53 /**
54  * @tc.name: SetRaiseEnabled001
55  * @tc.desc: SetRaiseEnabled and GetRaiseEnabled to check the value
56  * @tc.type: FUNC
57  */
58 HWTEST_F(WindowSessionPropertyTest, SetRaiseEnabled001, Function | SmallTest | Level2)
59 {
60     WindowSessionProperty *property = new WindowSessionProperty();
61     ASSERT_EQ(property->GetRaiseEnabled(), true);
62     property->SetRaiseEnabled(false);
63     ASSERT_EQ(property->GetRaiseEnabled(), false);
64 }
65 
66 /**
67  * @tc.name: WindowSessionProperty
68  * @tc.desc: WindowSessionProperty
69  * @tc.type: FUNC
70  */
71 HWTEST_F(WindowSessionPropertyTest, WindowSessionProperty, Function | SmallTest | Level2)
72 {
73     const sptr<WindowSessionProperty> property = new WindowSessionProperty();
74     ASSERT_EQ(property->GetDragEnabled(), true);
75 }
76 
77 /**
78  * @tc.name: SetSessionInfo
79  * @tc.desc: SetSessionInfo
80  * @tc.type: FUNC
81  */
82 HWTEST_F(WindowSessionPropertyTest, SetSessionInfo, Function | SmallTest | Level2)
83 {
84     SessionInfo *info = new SessionInfo();
85     WindowSessionProperty *property = new WindowSessionProperty();
86     property->SetSessionInfo(*info);
87     ASSERT_EQ(property->GetRaiseEnabled(), true);
88 }
89 /**
90  * @tc.name: SetRequestedOrientation
91  * @tc.desc: SetRequestedOrientation test
92  * @tc.type: FUNC
93 */
94 HWTEST_F(WindowSessionPropertyTest, SetRequestedOrientation, Function | SmallTest | Level2)
95 {
96     Orientation orientation = Orientation::REVERSE_HORIZONTAL;
97     WindowSessionProperty *property = new WindowSessionProperty();
98     property->SetRequestedOrientation(orientation);
99     Orientation ret = property->GetRequestedOrientation();
100     ASSERT_EQ(ret, orientation);
101 
102     property->SetRequestedOrientation(Orientation::AUTO_ROTATION_UNSPECIFIED);
103     Orientation ret1 = property->GetRequestedOrientation();
104     ASSERT_EQ(ret1, Orientation::AUTO_ROTATION_UNSPECIFIED);
105 
106     property->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT);
107     Orientation ret2 = property->GetRequestedOrientation();
108     ASSERT_EQ(ret2, Orientation::USER_ROTATION_PORTRAIT);
109 
110     property->SetRequestedOrientation(Orientation::USER_ROTATION_LANDSCAPE);
111     Orientation ret3 = property->GetRequestedOrientation();
112     ASSERT_EQ(ret3, Orientation::USER_ROTATION_LANDSCAPE);
113 
114     property->SetRequestedOrientation(Orientation::USER_ROTATION_PORTRAIT_INVERTED);
115     Orientation ret4 = property->GetRequestedOrientation();
116     ASSERT_EQ(ret4, Orientation::USER_ROTATION_PORTRAIT_INVERTED);
117 
118     property->SetRequestedOrientation(Orientation::USER_ROTATION_LANDSCAPE_INVERTED);
119     Orientation ret5 = property->GetRequestedOrientation();
120     ASSERT_EQ(ret5, Orientation::USER_ROTATION_LANDSCAPE_INVERTED);
121 
122     property->SetRequestedOrientation(Orientation::FOLLOW_DESKTOP);
123     Orientation ret6 = property->GetRequestedOrientation();
124     ASSERT_EQ(ret6, Orientation::FOLLOW_DESKTOP);
125 }
126 
127 /**
128  * @tc.name: SetDefaultRequestedOrientation
129  * @tc.desc: SetDefaultRequestedOrientation test
130  * @tc.type: FUNC
131  */
132 HWTEST_F(WindowSessionPropertyTest, SetDefaultRequestedOrientation, Function | SmallTest | Level2)
133 {
134     Orientation orientation = Orientation::REVERSE_HORIZONTAL;
135     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
136     property->SetDefaultRequestedOrientation(orientation);
137     Orientation ret = property->GetDefaultRequestedOrientation();
138     ASSERT_EQ(ret, orientation);
139 }
140 
141 /**
142  * @tc.name: SetPrivacyMode
143  * @tc.desc: SetPrivacyMode test
144  * @tc.type: FUNC
145  */
146 HWTEST_F(WindowSessionPropertyTest, SetPrivacyMode, Function | SmallTest | Level2)
147 {
148     WindowSessionProperty *property = new WindowSessionProperty();
149     ASSERT_EQ(property->GetPrivacyMode(), false);
150     property->SetPrivacyMode(false);
151     ASSERT_EQ(property->GetPrivacyMode(), false);
152 }
153 
154 /**
155  * @tc.name: SetSystemPrivacyMode
156  * @tc.desc: SetSystemPrivacyMode test
157  * @tc.type: FUNC
158  */
159 HWTEST_F(WindowSessionPropertyTest, SetSystemPrivacyMode, Function | SmallTest | Level2)
160 {
161     WindowSessionProperty *property = new WindowSessionProperty();
162     ASSERT_EQ(property->GetSystemPrivacyMode(), false);
163 }
164 
165 /**
166  * @tc.name: SetBrightness
167  * @tc.desc: SetBrightness test
168  * @tc.type: FUNC
169  */
170 HWTEST_F(WindowSessionPropertyTest, SetBrightness, Function | SmallTest | Level2)
171 {
172     float brightness = 0.02;
173     WindowSessionProperty windowSessionProperty;
174     windowSessionProperty.SetBrightness(brightness);
175     WindowSessionProperty *property = new WindowSessionProperty();
176     ASSERT_NE(property->GetBrightness(), 0);
177 }
178 
179 /**
180  * @tc.name: SetTopmost
181  * @tc.desc: SetTopmost test
182  * @tc.type: FUNC
183  */
184 HWTEST_F(WindowSessionPropertyTest, SetTopmost, Function | SmallTest | Level2)
185 {
186     bool topmost = true;
187     WindowSessionProperty windowSessionProperty;
188     windowSessionProperty.SetTopmost(topmost);
189     ASSERT_TRUE(windowSessionProperty.IsTopmost());
190 }
191 
192 /**
193  * @tc.name: SetMainWindowTopmost
194  * @tc.desc: SetMainWindowTopmost test
195  * @tc.type: FUNC
196  */
197 HWTEST_F(WindowSessionPropertyTest, SetMainWindowTopmost, Function | SmallTest | Level2)
198 {
199     bool isTopmost = true;
200     WindowSessionProperty windowSessionProperty;
201     windowSessionProperty.SetMainWindowTopmost(isTopmost);
202     ASSERT_TRUE(windowSessionProperty.IsMainWindowTopmost());
203 }
204 
205 /**
206  * @tc.name: GetParentId
207  * @tc.desc: GetParentId test
208  * @tc.type: FUNC
209  */
210 HWTEST_F(WindowSessionPropertyTest, GetParentId, Function | SmallTest | Level2)
211 {
212     WindowSessionProperty windowSessionProperty;
213     int32_t result = windowSessionProperty.GetParentId();
214     ASSERT_EQ(0, result);
215 }
216 
217 /**
218  * @tc.name: SetWindowFlags
219  * @tc.desc: SetWindowFlags test
220  * @tc.type: FUNC
221  */
222 HWTEST_F(WindowSessionPropertyTest, SetWindowFlags, Function | SmallTest | Level2)
223 {
224     WindowSessionProperty *property = new WindowSessionProperty();
225     ASSERT_EQ(property->GetWindowFlags(), 0);
226 }
227 
228 /**
229  * @tc.name: SetAndGetPipTemplateInfo
230  * @tc.desc: SetAndGetPipTemplateInfo test
231  * @tc.type: FUNC
232  */
233 HWTEST_F(WindowSessionPropertyTest, SetAndGetPipTemplateInfo, Function | SmallTest | Level2)
234 {
235     WindowSessionProperty *property = new WindowSessionProperty();
236     PiPTemplateInfo pipTemplateInfo;
237     pipTemplateInfo.pipTemplateType = static_cast<uint32_t>(PiPTemplateType::VIDEO_CALL);
238     property->SetPiPTemplateInfo(pipTemplateInfo);
239     ASSERT_EQ(property->GetPiPTemplateInfo().pipTemplateType,
240         static_cast<uint32_t>(PiPTemplateType::VIDEO_CALL));
241 }
242 
243 /**
244  * @tc.name: SetAndGetRealParentId
245  * @tc.desc: SetRealParentId and GetRealParentId test
246  * @tc.type: FUNC
247  */
248 HWTEST_F(WindowSessionPropertyTest, SetAndGetRealParentId, Function | SmallTest | Level2)
249 {
250     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
251     ASSERT_NE(property, nullptr);
252     property->SetRealParentId(1919);
253     EXPECT_EQ(1919, property->GetRealParentId());
254     property->SetRealParentId(810);
255     EXPECT_EQ(810, property->GetRealParentId());
256 }
257 
258 /**
259  * @tc.name: SetAndGetUIExtensionUsage
260  * @tc.desc: SetUIExtensionUsage and GetUIExtensionUsage test
261  * @tc.type: FUNC
262  */
263 HWTEST_F(WindowSessionPropertyTest, SetAndGetUIExtensionUsage, Function | SmallTest | Level2)
264 {
265     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
266     ASSERT_NE(property, nullptr);
267     property->SetUIExtensionUsage(UIExtensionUsage::MODAL);
268     EXPECT_EQ(UIExtensionUsage::MODAL, property->GetUIExtensionUsage());
269     property->SetUIExtensionUsage(UIExtensionUsage::EMBEDDED);
270     EXPECT_EQ(UIExtensionUsage::EMBEDDED, property->GetUIExtensionUsage());
271 }
272 
273 /**
274  * @tc.name: SetParentWindowType
275  * @tc.desc: SetParentWindowType and GetParentWindowType test
276  * @tc.type: FUNC
277  */
278 HWTEST_F(WindowSessionPropertyTest, SetParentWindowType, Function | SmallTest | Level2)
279 {
280     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
281     ASSERT_NE(property, nullptr);
282     property->SetParentWindowType(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW);
283     EXPECT_EQ(WindowType::WINDOW_TYPE_APP_MAIN_WINDOW, property->GetParentWindowType());
284     property->SetParentWindowType(WindowType::WINDOW_TYPE_TOAST);
285     EXPECT_EQ(WindowType::WINDOW_TYPE_TOAST, property->GetParentWindowType());
286 }
287 
288 /**
289  * @tc.name: SetAndGetIsUIExtensionAbilityProcess
290  * @tc.desc: SetIsUIExtensionAbilityProcess and GetIsUIExtensionAbilityProcess test
291  * @tc.type: FUNC
292  */
293 HWTEST_F(WindowSessionPropertyTest, SetAndGetIsUIExtensionAbilityProcess, Function | SmallTest | Level2)
294 {
295     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
296     ASSERT_NE(property, nullptr);
297     property->SetIsUIExtensionAbilityProcess(true);
298     EXPECT_EQ(true, property->GetIsUIExtensionAbilityProcess());
299     property->SetIsUIExtensionAbilityProcess(false);
300     EXPECT_EQ(false, property->GetIsUIExtensionAbilityProcess());
301 }
302 
303 /**
304  * @tc.name: AddWindowFlag
305  * @tc.desc: AddWindowFlag test
306  * @tc.type: FUNC
307  */
308 HWTEST_F(WindowSessionPropertyTest, AddWindowFlag, Function | SmallTest | Level2)
309 {
310     WindowFlag flags=WindowFlag();
311     WindowSessionProperty windowSessionProperty;
312     windowSessionProperty.AddWindowFlag(flags);
313     WindowSessionProperty *property = new WindowSessionProperty();
314     ASSERT_EQ(property->GetWindowFlags(), false);
315 }
316 
317 /**
318  * @tc.name: IsTurnScreenOn
319  * @tc.desc: IsTurnScreenOn test
320  * @tc.type: FUNC
321  */
322 HWTEST_F(WindowSessionPropertyTest, IsTurnScreenOn, Function | SmallTest | Level2)
323 {
324     WindowSessionProperty windowSessionProperty;
325     bool result = windowSessionProperty.IsTurnScreenOn();
326     ASSERT_EQ(false, result);
327 }
328 
329 /**
330  * @tc.name: IsKeepScreenOn
331  * @tc.desc: IsKeepScreenOn test
332  * @tc.type: FUNC
333  */
334 HWTEST_F(WindowSessionPropertyTest, IsKeepScreenOn, Function | SmallTest | Level2)
335 {
336     WindowSessionProperty windowSessionProperty;
337     bool result = windowSessionProperty.IsKeepScreenOn();
338     ASSERT_EQ(false, result);
339 }
340 
341 /**
342  * @tc.name: GetAccessTokenId
343  * @tc.desc: GetAccessTokenId test
344  * @tc.type: FUNC
345  */
346 HWTEST_F(WindowSessionPropertyTest, GetAccessTokenId, Function | SmallTest | Level2)
347 {
348     WindowSessionProperty windowSessionProperty;
349     auto result = windowSessionProperty.GetAccessTokenId();
350     ASSERT_EQ(false, result);
351 }
352 
353 /**
354  * @tc.name: SetTokenState
355  * @tc.desc: SetTokenState test
356  * @tc.type: FUNC
357  */
358 HWTEST_F(WindowSessionPropertyTest, SetTokenState, Function | SmallTest | Level2)
359 {
360     WindowSessionProperty *property = new WindowSessionProperty();
361     ASSERT_EQ(property->GetTokenState(), false);
362 }
363 
364 /**
365  * @tc.name: SetMaximizeMode
366  * @tc.desc: SetMaximizeMode test
367  * @tc.type: FUNC
368 */
369 HWTEST_F(WindowSessionPropertyTest, SetMaximizeMode, Function | SmallTest | Level2)
370 {
371     WindowSessionProperty windowSessionProperty;
372     MaximizeMode mode = MaximizeMode::MODE_RECOVER;
373     windowSessionProperty.SetMaximizeMode(mode);
374     WindowSessionProperty *property = new WindowSessionProperty();
375     ASSERT_EQ(property->GetMaximizeMode(), mode);
376 }
377 
378 /**
379  * @tc.name: SetSystemBarProperty
380  * @tc.desc: SetSystemBarProperty test
381  * @tc.type: FUNC
382 */
383 HWTEST_F(WindowSessionPropertyTest, SetSystemBarProperty, Function | SmallTest | Level2)
384 {
385     SystemBarProperty *systemBarProperty = new SystemBarProperty();
386     WindowType windowtype = WindowType::APP_WINDOW_BASE;
387     WindowSessionProperty windowSessionProperty;
388     windowSessionProperty.SetSystemBarProperty(windowtype, *systemBarProperty);
389     WindowSessionProperty *property = new WindowSessionProperty();
390     ASSERT_EQ(property->GetTokenState(), false);
391 }
392 
393 /**
394  * @tc.name: IsDecorEnable
395  * @tc.desc: IsDecorEnable test
396  * @tc.type: FUNC
397 */
398 HWTEST_F(WindowSessionPropertyTest, IsDecorEnable, Function | SmallTest | Level2)
399 {
400     WindowSessionProperty windowSessionProperty;
401     auto result = windowSessionProperty.IsDecorEnable();
402     ASSERT_EQ(false, result);
403 }
404 
405 /**
406  * @tc.name: SetWindowModeSupportType
407  * @tc.desc: SetWindowModeSupportType test
408  * @tc.type: FUNC
409 */
410 HWTEST_F(WindowSessionPropertyTest, SetWindowModeSupportType, Function | SmallTest | Level2)
411 {
412     uint32_t windowModeSupportType = 1234567890;
413     WindowSessionProperty windowSessionProperty;
414     windowSessionProperty.SetWindowModeSupportType(windowModeSupportType);
415     WindowSessionProperty *property = new WindowSessionProperty();
416     ASSERT_NE(property->GetWindowModeSupportType(), 0);
417 }
418 /**
419  * @tc.name: IsFloatingWindowAppType
420  * @tc.desc: IsFloatingWindowAppType test
421  * @tc.type: FUNC
422 */
423 HWTEST_F(WindowSessionPropertyTest, IsFloatingWindowAppType, Function | SmallTest | Level2)
424 {
425     WindowSessionProperty windowSessionProperty;
426     auto result = windowSessionProperty.IsFloatingWindowAppType();
427     ASSERT_EQ(false, result);
428 }
429 
430 /**
431  * @tc.name: SetTouchHotAreas
432  * @tc.desc: SetTouchHotAreas test
433  * @tc.type: FUNC
434 */
435 HWTEST_F(WindowSessionPropertyTest, SetTouchHotAreas, Function | SmallTest | Level2)
436 {
437     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
438     EXPECT_NE(nullptr, property);
439     Rect rect { 4, 4, 4, 4 };
440     std::vector<Rect> vRect { rect };
441     property->SetPersistentId(0);
442     property->SetSessionPropertyChangeCallback(nullptr);
443     EXPECT_EQ(nullptr, property->touchHotAreasChangeCallback_);
444     property->SetTouchHotAreas(vRect);
445 
__anon30316e700202()446     auto func = [](){};
447     property->SetPersistentId(1);
448     property->SetSessionPropertyChangeCallback(func);
449     property->SetTouchHotAreas(vRect);
450     EXPECT_NE(nullptr, property->touchHotAreasChangeCallback_);
451 
452     Rect rect1 { 5, 5, 5, 5 };
453     vRect.emplace_back(rect1);
454     property->SetTouchHotAreas(vRect);
455 }
456 
457 /**
458  * @tc.name: UnmarshallingWindowLimits
459  * @tc.desc: UnmarshallingWindowLimits test
460  * @tc.type: FUNC
461 */
462 HWTEST_F(WindowSessionPropertyTest, UnmarshallingWindowLimits, Function | SmallTest | Level2)
463 {
464     Parcel parcel = Parcel();
465     WindowSessionProperty *property = new WindowSessionProperty();
466     WindowSessionProperty windowSessionProperty;
467     windowSessionProperty.UnmarshallingWindowLimits(parcel, property);
468     ASSERT_EQ(property->GetTokenState(), false);
469 }
470 
471 /**
472  * @tc.name: UnMarshallingSystemBarMap
473  * @tc.desc: UnMarshallingSystemBarMap test
474  * @tc.type: FUNC
475 */
476 HWTEST_F(WindowSessionPropertyTest, UnMarshallingSystemBarMap, Function | SmallTest | Level2)
477 {
478     Parcel parcel = Parcel();
479     WindowSessionProperty *property = new WindowSessionProperty();
480     WindowSessionProperty windowSessionProperty;
481     windowSessionProperty.UnMarshallingSystemBarMap(parcel, property);
482     ASSERT_EQ(property->GetTokenState(), false);
483 }
484 
485 /**
486  * @tc.name: UnmarshallingTouchHotAreas
487  * @tc.desc: UnmarshallingTouchHotAreas test
488  * @tc.type: FUNC
489 */
490 HWTEST_F(WindowSessionPropertyTest, UnmarshallingTouchHotAreas, Function | SmallTest | Level2)
491 {
492     Parcel parcel = Parcel();
493     WindowSessionProperty *property = new WindowSessionProperty();
494     WindowSessionProperty windowSessionProperty;
495     windowSessionProperty.UnmarshallingTouchHotAreas(parcel, property);
496     ASSERT_EQ(property->GetTokenState(), false);
497 }
498 
499 /**
500  * @tc.name: UnmarshallingPiPTemplateInfo
501  * @tc.desc: UnmarshallingPiPTemplateInfo test
502  * @tc.type: FUNC
503 */
504 HWTEST_F(WindowSessionPropertyTest, UnmarshallingPiPTemplateInfo, Function | SmallTest | Level2)
505 {
506     Parcel parcel = Parcel();
507     WindowSessionProperty *property = new WindowSessionProperty();
508     EXPECT_NE(nullptr, property);
509     property->SetWindowType(WindowType::WINDOW_TYPE_PIP);
510     EXPECT_EQ(WindowType::WINDOW_TYPE_PIP, property->GetWindowType());
511     property->UnmarshallingPiPTemplateInfo(parcel, property);
512     delete property;
513 }
514 
515 /**
516  * @tc.name: CopyFrom
517  * @tc.desc: CopyFrom test
518  * @tc.type: FUNC
519 */
520 HWTEST_F(WindowSessionPropertyTest, CopyFrom, Function | SmallTest | Level2)
521 {
522     sptr<WindowSessionProperty> property = new WindowSessionProperty();
523     WindowSessionProperty windowSessionProperty;
524     windowSessionProperty.CopyFrom(property);
525     WindowSessionProperty *wproperty = new WindowSessionProperty();
526     ASSERT_EQ(wproperty->GetTokenState(), false);
527 }
528 
529 /**
530  * @tc.name: SetFocusable
531  * @tc.desc: SetFocusable and GetFocusable to check the value
532  * @tc.type: FUNC
533  */
534 HWTEST_F(WindowSessionPropertyTest, SetFocusable, Function | SmallTest | Level2)
535 {
536     sptr<WindowSessionProperty> property = new WindowSessionProperty();
537     ASSERT_NE(nullptr, property);
538     ASSERT_EQ(property->GetFocusable(), true);
539     property->SetFocusable(false);
540     ASSERT_EQ(property->GetFocusable(), false);
541 }
542 
543 /**
544  * @tc.name: SetTouchable
545  * @tc.desc: SetTouchable and GetTouchable to check the value
546  * @tc.type: FUNC
547  */
548 HWTEST_F(WindowSessionPropertyTest, SetTouchable, Function | SmallTest | Level2)
549 {
550     sptr<WindowSessionProperty> property = new WindowSessionProperty();
551     ASSERT_NE(nullptr, property);
552     ASSERT_EQ(property->GetTouchable(), true);
553     property->SetTouchable(false);
554     ASSERT_EQ(property->GetTouchable(), false);
555 }
556 
557 /**
558  * @tc.name: SetForceHide
559  * @tc.desc: SetForceHide and GetForceHide to check the value
560  * @tc.type: FUNC
561  */
562 HWTEST_F(WindowSessionPropertyTest, SetForceHide, Function | SmallTest | Level2)
563 {
564     sptr<WindowSessionProperty> property = new WindowSessionProperty();
565     ASSERT_NE(nullptr, property);
566     ASSERT_EQ(property->GetForceHide(), false);
567     property->SetForceHide(true);
568     ASSERT_EQ(property->GetForceHide(), true);
569 }
570 
571 /**
572  * @tc.name: SetSystemCalling
573  * @tc.desc: SetSystemCalling and GetSystemCalling to check the value
574  * @tc.type: FUNC
575  */
576 HWTEST_F(WindowSessionPropertyTest, SetSystemCalling, Function | SmallTest | Level2)
577 {
578     sptr<WindowSessionProperty> property = new WindowSessionProperty();
579     ASSERT_NE(nullptr, property);
580     ASSERT_EQ(property->GetSystemCalling(), false);
581     property->SetSystemCalling(true);
582     ASSERT_EQ(property->GetSystemCalling(), true);
583 }
584 
585 /**
586  * @tc.name: SetIsNeedUpdateWindowMode
587  * @tc.desc: SetIsNeedUpdateWindowMode and GetIsNeedUpdateWindowMode to check the value
588  * @tc.type: FUNC
589  */
590 HWTEST_F(WindowSessionPropertyTest, SetIsNeedUpdateWindowMode, Function | SmallTest | Level2)
591 {
592     sptr<WindowSessionProperty> property = new WindowSessionProperty();
593     ASSERT_NE(nullptr, property);
594     ASSERT_EQ(property->GetIsNeedUpdateWindowMode(), false);
595     property->SetIsNeedUpdateWindowMode(true);
596     ASSERT_EQ(property->GetIsNeedUpdateWindowMode(), true);
597 }
598 
599 /**
600  * @tc.name: SetIsShaped
601  * @tc.desc: SetIsShaped and GetIsShaped to check the value
602  * @tc.type: FUNC
603  */
604 HWTEST_F(WindowSessionPropertyTest, SetIsShaped, Function | SmallTest | Level2)
605 {
606     sptr<WindowSessionProperty> property = new WindowSessionProperty();
607     ASSERT_NE(nullptr, property);
608     ASSERT_EQ(property->GetIsShaped(), false);
609     property->SetIsShaped(true);
610     ASSERT_EQ(property->GetIsShaped(), true);
611 }
612 
613 /**
614  * @tc.name: SetHideNonSystemFloatingWindows
615  * @tc.desc: SetHideNonSystemFloatingWindows and GetHideNonSystemFloatingWindows to check the value
616  * @tc.type: FUNC
617  */
618 HWTEST_F(WindowSessionPropertyTest, SetHideNonSystemFloatingWindows, Function | SmallTest | Level2)
619 {
620     sptr<WindowSessionProperty> property = new WindowSessionProperty();
621     ASSERT_NE(nullptr, property);
622     ASSERT_EQ(property->GetHideNonSystemFloatingWindows(), false);
623     property->SetHideNonSystemFloatingWindows(true);
624     ASSERT_EQ(property->GetHideNonSystemFloatingWindows(), true);
625 }
626 
627 /**
628  * @tc.name: KeepKeyboardOnFocus
629  * @tc.desc: KeepKeyboardOnFocus and GetKeepKeyboardFlag to check the value
630  * @tc.type: FUNC
631  */
632 HWTEST_F(WindowSessionPropertyTest, KeepKeyboardOnFocus, Function | SmallTest | Level2)
633 {
634     sptr<WindowSessionProperty> property = new WindowSessionProperty();
635     ASSERT_NE(nullptr, property);
636     ASSERT_EQ(property->GetKeepKeyboardFlag(), false);
637     property->KeepKeyboardOnFocus(true);
638     ASSERT_EQ(property->GetKeepKeyboardFlag(), true);
639 }
640 
641 /**
642  * @tc.name: SetTextFieldPositionY
643  * @tc.desc: SetTextFieldPositionY and GetTextFieldPositionY to check the value
644  * @tc.type: FUNC
645  */
646 HWTEST_F(WindowSessionPropertyTest, SetTextFieldPositionY, Function | SmallTest | Level2)
647 {
648     sptr<WindowSessionProperty> property = new WindowSessionProperty();
649     ASSERT_NE(nullptr, property);
650     property->SetTextFieldPositionY(5.5);
651     ASSERT_EQ(property->GetTextFieldPositionY(), 5.5);
652 }
653 
654 /**
655  * @tc.name: SetTextFieldHeight
656  * @tc.desc: SetTextFieldHeight and GetTextFieldHeight to check the value
657  * @tc.type: FUNC
658  */
659 HWTEST_F(WindowSessionPropertyTest, SetTextFieldHeight, Function | SmallTest | Level2)
660 {
661     sptr<WindowSessionProperty> property = new WindowSessionProperty();
662     ASSERT_NE(nullptr, property);
663     property->SetTextFieldHeight(5.5);
664     ASSERT_EQ(property->GetTextFieldHeight(), 5.5);
665 }
666 
667 /**
668  * @tc.name: SetIsLayoutFullScreen
669  * @tc.desc: SetIsLayoutFullScreen and IsLayoutFullScreen to check the value
670  * @tc.type: FUNC
671  */
672 HWTEST_F(WindowSessionPropertyTest, SetIsLayoutFullScreen, Function | SmallTest | Level2)
673 {
674     sptr<WindowSessionProperty> property = new WindowSessionProperty();
675     ASSERT_NE(nullptr, property);
676     ASSERT_EQ(property->IsLayoutFullScreen(), false);
677     property->SetIsLayoutFullScreen(true);
678     ASSERT_EQ(property->IsLayoutFullScreen(), true);
679 }
680 
681 /**
682  * @tc.name: Read
683  * @tc.desc: Read test
684  * @tc.type: FUNC
685  */
686 HWTEST_F(WindowSessionPropertyTest, Read, Function | SmallTest | Level2)
687 {
688     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
689     if (property != nullptr) {
690         Parcel parcel = Parcel();
691         property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_MODE);
692         property->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST);
693         ASSERT_EQ(property->GetPersistentId(), INVALID_SESSION_ID);
694         delete property;
695     }
696 }
697 
698 /**
699  * @tc.name: Write
700  * @tc.desc: Write and Read to check the value
701  * @tc.type: FUNC
702  */
703 HWTEST_F(WindowSessionPropertyTest, Write, Function | SmallTest | Level2)
704 {
705     WindowSessionProperty *oldProperty = new (std::nothrow) WindowSessionProperty();
706     WindowSessionProperty *newProperty = new (std::nothrow) WindowSessionProperty();
707     if ((oldProperty != nullptr) && (newProperty != nullptr)) {
708         int32_t persistentId = 2;
709         oldProperty->SetPersistentId(persistentId);
710         oldProperty->SetFocusable(true);
711         oldProperty->SetMainWindowTopmost(true);
712         Parcel parcel = Parcel();
713         oldProperty->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE);
714         oldProperty->Write(parcel, WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST);
715 
716         newProperty->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_FOCUSABLE);
717         newProperty->Read(parcel, WSPropertyChangeAction::ACTION_UPDATE_MAIN_WINDOW_TOPMOST);
718         ASSERT_EQ(newProperty->GetPersistentId(), persistentId);
719         ASSERT_EQ(newProperty->GetFocusable(), true);
720         ASSERT_EQ(newProperty->IsMainWindowTopmost(), true);
721         delete oldProperty;
722         delete newProperty;
723     }
724 }
725 
726 /**
727  * @tc.name: GetWindowName
728  * @tc.desc: GetWindowName
729  * @tc.type: FUNC
730  */
731 HWTEST_F(WindowSessionPropertyTest, GetWindowName, Function | SmallTest | Level2)
732 {
733     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
734     if (property == nullptr) {
735         return;
736     }
737     std::string name = "test";
738     property->SetWindowName(name);
739     auto result = property->GetWindowName();
740     ASSERT_EQ(result, name);
741     delete property;
742 }
743 
744 /**
745  * @tc.name: GetSessionInfo
746  * @tc.desc: GetSessionInfo
747  * @tc.type: FUNC
748  */
749 HWTEST_F(WindowSessionPropertyTest, GetSessionInfo, Function | SmallTest | Level2)
750 {
751     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
752     if (property == nullptr) {
753         return;
754     }
755     SessionInfo *info = new SessionInfo();
756     if (info == nullptr) {
757         return;
758     }
759     property->SetSessionInfo(*info);
760     auto result = property->GetSessionInfo();
761     ASSERT_EQ(property->GetRaiseEnabled(), true);
762     delete property;
763 }
764 
765 /**
766  * @tc.name: EditSessionInfo
767  * @tc.desc: EditSessionInfo
768  * @tc.type: FUNC
769  */
770 HWTEST_F(WindowSessionPropertyTest, EditSessionInfo, Function | SmallTest | Level2)
771 {
772     std::string abilityName = "1234";
773     std::string abilityNameNew = "12345";
774     SessionInfo info;
775     info.abilityName_ = abilityName;
776     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
777     property->SetSessionInfo(info);
778     property->EditSessionInfo().abilityName_ = abilityNameNew;
779     ASSERT_EQ(property->EditSessionInfo().abilityName_, abilityNameNew);
780 }
781 
782 /**
783  * @tc.name: GetWindowRect
784  * @tc.desc: GetWindowRect
785  * @tc.type: FUNC
786  */
787 HWTEST_F(WindowSessionPropertyTest, GetWindowRect, Function | SmallTest | Level2)
788 {
789     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
790     if (property == nullptr) {
791         return;
792     }
793     Rect rect = {0, 0, 0, 0};
794     property->SetWindowRect(rect);
795     auto result = property->GetWindowRect();
796     ASSERT_EQ(result, rect);
797     delete property;
798 }
799 
800 /**
801  * @tc.name: GetRequestRect
802  * @tc.desc: GetRequestRect
803  * @tc.type: FUNC
804  */
805 HWTEST_F(WindowSessionPropertyTest, GetRequestRect, Function | SmallTest | Level2)
806 {
807     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
808     if (property == nullptr) {
809         return;
810     }
811     Rect requestRect = {0, 0, 0, 0};
812     property->SetWindowRect(requestRect);
813     auto result = property->GetWindowRect();
814     ASSERT_EQ(result, requestRect);
815     delete property;
816 }
817 
818 /**
819  * @tc.name: GetWindowType
820  * @tc.desc: GetWindowType
821  * @tc.type: FUNC
822  */
823 HWTEST_F(WindowSessionPropertyTest, GetWindowType, Function | SmallTest | Level2)
824 {
825     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
826     if (property == nullptr) {
827         return;
828     }
829     WindowType type = WindowType::APP_WINDOW_BASE;
830     property->SetWindowType(type);
831     auto result = property->GetWindowType();
832     ASSERT_EQ(result, type);
833     delete property;
834 }
835 
836 /**
837  * @tc.name: GetDisplayId
838  * @tc.desc: GetDisplayId
839  * @tc.type: FUNC
840  */
841 HWTEST_F(WindowSessionPropertyTest, GetDisplayId, Function | SmallTest | Level2)
842 {
843     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
844     if (property == nullptr) {
845         return;
846     }
847     DisplayId displayId = 1;
848     property->SetDisplayId(displayId);
849     auto result = property->GetDisplayId();
850     ASSERT_EQ(result, displayId);
851     delete property;
852 }
853 
854 /**
855  * @tc.name: GetPersistentId
856  * @tc.desc: GetPersistentId
857  * @tc.type: FUNC
858  */
859 HWTEST_F(WindowSessionPropertyTest, GetPersistentId, Function | SmallTest | Level2)
860 {
861     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
862     if (property == nullptr) {
863         return;
864     }
865     int32_t persistentId = 1;
866     property->SetPersistentId(persistentId);
867     auto result = property->GetPersistentId();
868     ASSERT_EQ(result, persistentId);
869     delete property;
870 }
871 
872 /**
873  * @tc.name: GetParentPersistentId
874  * @tc.desc: GetParentPersistentId
875  * @tc.type: FUNC
876  */
877 HWTEST_F(WindowSessionPropertyTest, GetParentPersistentId, Function | SmallTest | Level2)
878 {
879     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
880     if (property == nullptr) {
881         return;
882     }
883     int32_t persistentId = 1;
884     property->SetParentPersistentId(persistentId);
885     auto result = property->GetParentPersistentId();
886     ASSERT_EQ(result, persistentId);
887     delete property;
888 }
889 
890 /**
891  * @tc.name: SetTurnScreenOn
892  * @tc.desc: SetTurnScreenOn
893  * @tc.type: FUNC
894  */
895 HWTEST_F(WindowSessionPropertyTest, SetTurnScreenOn, Function | SmallTest | Level2)
896 {
897     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
898     if (property == nullptr) {
899         return;
900     }
901     bool turnScreenOn = false;
902     property->SetTurnScreenOn(turnScreenOn);
903     ASSERT_EQ(property->turnScreenOn_, turnScreenOn);
904     delete property;
905 }
906 
907 /**
908  * @tc.name: SetKeepScreenOn
909  * @tc.desc: SetKeepScreenOn
910  * @tc.type: FUNC
911  */
912 HWTEST_F(WindowSessionPropertyTest, SetKeepScreenOn, Function | SmallTest | Level2)
913 {
914     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
915     if (property == nullptr) {
916         return;
917     }
918     bool keepScreenOn = false;
919     property->SetKeepScreenOn(keepScreenOn);
920     ASSERT_EQ(property->keepScreenOn_, keepScreenOn);
921     delete property;
922 }
923 
924 /**
925  * @tc.name: MarshallingSessionInfo
926  * @tc.desc: MarshallingSessionInfo test
927  * @tc.type: FUNC
928  */
929 HWTEST_F(WindowSessionPropertyTest, MarshallingSessionInfo, Function | SmallTest | Level2)
930 {
931     Parcel parcel;
932     SessionInfo info = { "testBundleName", "testModuleName", "testAbilityName" };
933     info.want = std::make_shared<AAFwk::Want>();
934     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
935     bool result = property->MarshallingSessionInfo(parcel);
936     ASSERT_EQ(result, true);
937 }
938 
939 /**
940  * @tc.name: UnMarshallingSessionInfo
941  * @tc.desc: UnMarshallingSessionInfo test
942  * @tc.type: FUNC
943  */
944 HWTEST_F(WindowSessionPropertyTest, UnMarshallingSessionInfo, Function | SmallTest | Level2)
945 {
946     Parcel parcel;
947     WindowSessionProperty windowSessionProperty;
948     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
949     windowSessionProperty.UnmarshallingWindowLimits(parcel, property);
950     ASSERT_EQ(property->GetTokenState(), false);
951 }
952 
953 /**
954  * @tc.name: SetAccessTokenId
955  * @tc.desc: SetAccessTokenId
956  * @tc.type: FUNC
957  */
958 HWTEST_F(WindowSessionPropertyTest, SetAccessTokenId, Function | SmallTest | Level2)
959 {
960     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
961     if (property == nullptr) {
962         return;
963     }
964     uint32_t accessTokenId = 1;
965     property->SetAccessTokenId(accessTokenId);
966     ASSERT_EQ(property->accessTokenId_, accessTokenId);
967     delete property;
968 }
969 
970 /**
971  * @tc.name: GetWindowState
972  * @tc.desc: GetWindowState
973  * @tc.type: FUNC
974  */
975 HWTEST_F(WindowSessionPropertyTest, GetWindowState, Function | SmallTest | Level2)
976 {
977     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
978     if (property == nullptr) {
979         return;
980     }
981     WindowState state = WindowState::STATE_INITIAL;
982     property->SetWindowState(state);
983     auto result = property->GetWindowState();
984     ASSERT_EQ(result, state);
985     delete property;
986 }
987 
988 /**
989  * @tc.name: SetSystemPrivacyMode02
990  * @tc.desc: SetSystemPrivacyMode
991  * @tc.type: FUNC
992  */
993 HWTEST_F(WindowSessionPropertyTest, SetSystemPrivacyMode02, Function | SmallTest | Level2)
994 {
995     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
996     if (property == nullptr) {
997         return;
998     }
999     bool isSystemPrivate = false;
1000     property->SetSystemPrivacyMode(isSystemPrivate);
1001     ASSERT_EQ(property->isSystemPrivacyMode_, isSystemPrivate);
1002     delete property;
1003 }
1004 
1005 /**
1006  * @tc.name: SetTokenState02
1007  * @tc.desc: SetTokenState
1008  * @tc.type: FUNC
1009  */
1010 HWTEST_F(WindowSessionPropertyTest, SetTokenState02, Function | SmallTest | Level2)
1011 {
1012     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
1013     if (property == nullptr) {
1014         return;
1015     }
1016     bool hasToken = false;
1017     property->SetTokenState(hasToken);
1018     ASSERT_EQ(property->tokenState_, hasToken);
1019     delete property;
1020 }
1021 
1022 /**
1023  * @tc.name: MarshallingTouchHotAreas
1024  * @tc.desc: MarshallingTouchHotAreas test
1025  * @tc.type: FUNC
1026 */
1027 HWTEST_F(WindowSessionPropertyTest, MarshallingTouchHotAreas, Function | SmallTest | Level2)
1028 {
1029     Parcel parcel = Parcel();
1030     WindowSessionProperty *property = new WindowSessionProperty();
1031     if (property == nullptr) {
1032         return;
1033     }
1034     for (int i = 0; i < 55; i++) {
1035         struct Rect rect[i];
1036         property->touchHotAreas_.push_back(rect[i]);
1037     }
1038     bool result = property->MarshallingTouchHotAreas(parcel);
1039     ASSERT_EQ(result, false);
1040     delete property;
1041 }
1042 
1043 /**
1044  * @tc.name: UnmarshallingPiPTemplateInfo02
1045  * @tc.desc: UnmarshallingPiPTemplateInfo test
1046  * @tc.type: FUNC
1047 */
1048 HWTEST_F(WindowSessionPropertyTest, UnmarshallingPiPTemplateInfo02, Function | SmallTest | Level2)
1049 {
1050     Parcel parcel = Parcel();
1051     WindowSessionProperty *property = new WindowSessionProperty();
1052     if (property == nullptr) {
1053         return;
1054     }
1055     property->type_ = WindowType::WINDOW_TYPE_APP_MAIN_WINDOW;
1056     WindowSessionProperty windowSessionProperty;
1057     windowSessionProperty.UnmarshallingPiPTemplateInfo(parcel, property);
1058     ASSERT_EQ(property->GetTokenState(), false);
1059     delete property;
1060 }
1061 
1062 /**
1063  * @tc.name: MarshallingPiPTemplateInfo
1064  * @tc.desc: MarshallingPiPTemplateInfo test
1065  * @tc.type: FUNC
1066 */
1067 HWTEST_F(WindowSessionPropertyTest, MarshallingPiPTemplateInfo, Function | SmallTest | Level2)
1068 {
1069     Parcel parcel = Parcel();
1070     WindowSessionProperty *property = new WindowSessionProperty();
1071     if (property == nullptr) {
1072         return;
1073     }
1074     property->type_ = WindowType::WINDOW_TYPE_PIP;
1075     for (int i = 0; i < 10; i++) {
1076         property->pipTemplateInfo_.controlGroup.push_back(i);
1077     }
1078     bool result = property->MarshallingPiPTemplateInfo(parcel);
1079     ASSERT_EQ(result, false);
1080     delete property;
1081 }
1082 
1083 /**
1084  * @tc.name: SetIsPcAppInPad/GetIsPcAppInPad
1085  * @tc.desc: SetIsPcAppInPad/GetIsPcAppInPad
1086  * @tc.type: FUNC
1087  */
1088 HWTEST_F(WindowSessionPropertyTest, SetIsPcAppInPad, Function | SmallTest | Level2)
1089 {
1090     WindowSessionProperty *property = new (std::nothrow) WindowSessionProperty();
1091     if (property == nullptr) {
1092         return;
1093     }
1094     bool isPcAppInPad = true;
1095     property->SetIsPcAppInPad(isPcAppInPad);
1096     auto result = property->GetIsPcAppInPad();
1097     ASSERT_EQ(result, isPcAppInPad);
1098     delete property;
1099 }
1100 
1101 /**
1102  * @tc.name: SetSubWindowLevel
1103  * @tc.desc: SetSubWindowLevel Test
1104  * @tc.type: FUNC
1105  */
1106 HWTEST_F(WindowSessionPropertyTest, SetSubWindowLevel, Function | SmallTest | Level2)
1107 {
1108     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1109     EXPECT_NE(property, nullptr);
1110     uint32_t level = 4;
1111     property->SetSubWindowLevel(level);
1112     ASSERT_EQ(level, property->GetSubWindowLevel());
1113 }
1114 
1115 /**
1116  * @tc.name: GetSubWindowLevel
1117  * @tc.desc: GetSubWindowLevel Test
1118  * @tc.type: FUNC
1119  */
1120 HWTEST_F(WindowSessionPropertyTest, GetSubWindowLevel, Function | SmallTest | Level2)
1121 {
1122     sptr<WindowSessionProperty> property = sptr<WindowSessionProperty>::MakeSptr();
1123     EXPECT_NE(property, nullptr);;
1124     ASSERT_EQ(1, property->GetSubWindowLevel());
1125 }
1126 } // namespace
1127 } // namespace Rosen
1128 } // namespace OHOS
1129