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