1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <gtest/gtest.h>
17
18 #include "window_property.h"
19 #include "wm_common_inner.h"
20
21 using namespace testing;
22 using namespace testing::ext;
23
24 namespace OHOS {
25 namespace Rosen {
26 class WindowPropertyTest : public testing::Test {
27 public:
28 static void SetUpTestCase();
29 static void TearDownTestCase();
30 virtual void SetUp() override;
31 virtual void TearDown() override;
32 };
33
SetUpTestCase()34 void WindowPropertyTest::SetUpTestCase() {}
35
TearDownTestCase()36 void WindowPropertyTest::TearDownTestCase() {}
37
SetUp()38 void WindowPropertyTest::SetUp() {}
39
TearDown()40 void WindowPropertyTest::TearDown() {}
41
42 namespace {
43 /**
44 * @tc.name: MarshallingUnmarshalling
45 * @tc.desc: Marshalling Unmarshalling test
46 * @tc.type: FUNC
47 */
48 HWTEST_F(WindowPropertyTest, MarshallingUnmarshalling, TestSize.Level1)
49 {
50 WindowProperty winPropSrc;
51 winPropSrc.SetPrivacyMode(true);
52 winPropSrc.SetTransparent(true);
53 winPropSrc.SetTransform(Transform::Identity());
54 winPropSrc.SetFollowScreenChange(true);
55
56 Parcel parcel;
57 winPropSrc.Marshalling(parcel);
58 sptr<WindowProperty> winPropDst = sptr<WindowProperty>::MakeSptr(winPropSrc.Unmarshalling(parcel));
59
60 EXPECT_EQ(winPropDst->GetPrivacyMode(), true);
61 EXPECT_EQ(winPropDst->GetTransparent(), true);
62 EXPECT_EQ(winPropDst->GetTransform(), Transform::Identity());
63 EXPECT_EQ(winPropDst->GetFollowScreenChange(), true);
64 }
65
66 /**
67 * @tc.name: CopyFrom
68 * @tc.desc: CopyFrom test
69 * @tc.type: FUNC
70 */
71 HWTEST_F(WindowPropertyTest, CopyFrom, TestSize.Level1)
72 {
73 const sptr<WindowProperty> winPropSrc = new (std::nothrow) WindowProperty();
74 winPropSrc->SetPrivacyMode(true);
75 winPropSrc->SetTransparent(true);
76 winPropSrc->SetTransform(Transform::Identity());
77
78 WindowProperty winPropDst(winPropSrc); // winPropDst.CopyFrom(winPropSrc);
79
80 ASSERT_EQ(winPropSrc->GetPrivacyMode(), winPropDst.GetPrivacyMode());
81 ASSERT_EQ(winPropSrc->GetTransparent(), winPropDst.GetTransparent());
82 ASSERT_EQ(winPropSrc->GetTransform(), winPropDst.GetTransform());
83 }
84
85 /**
86 * @tc.name: Read
87 * @tc.desc: Read test
88 * @tc.type: FUNC
89 */
90 HWTEST_F(WindowPropertyTest, Read, TestSize.Level1)
91 {
92 WindowProperty winPropSrc;
93 winPropSrc.SetPrivacyMode(true);
94 winPropSrc.SetTransparent(true);
95
96 Parcel parcel;
97 winPropSrc.Marshalling(parcel);
98
99 WindowProperty winPropDst;
100 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_RECT);
101 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_MODE);
102 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_FLAGS);
103 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_OTHER_PROPS);
104 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_FOCUSABLE);
105 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_TOUCHABLE);
106 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_CALLING_WINDOW);
107 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_ORIENTATION);
108 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON);
109 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON);
110 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS);
111 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO);
112 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA);
113 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY);
114 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG);
115 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE);
116 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE);
117 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_FOLLOW_SCREEN_CHANGE);
118
119 ASSERT_EQ(false, winPropDst.GetPrivacyMode());
120 ASSERT_EQ(false, winPropDst.GetTransparent());
121 }
122
123 /**
124 * @tc.name: Write
125 * @tc.desc: Write test
126 * @tc.type: FUNC
127 */
128 HWTEST_F(WindowPropertyTest, Write, TestSize.Level1)
129 {
130 Parcel parcel;
131 WindowProperty winPropDst;
132 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_RECT));
133 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_MODE));
134 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_FLAGS));
135 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_OTHER_PROPS));
136 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_FOCUSABLE));
137 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_TOUCHABLE));
138 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_CALLING_WINDOW));
139 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_ORIENTATION));
140 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_TURN_SCREEN_ON));
141 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_KEEP_SCREEN_ON));
142 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_SET_BRIGHTNESS));
143 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_MODE_SUPPORT_INFO));
144 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_TOUCH_HOT_AREA));
145 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_TRANSFORM_PROPERTY));
146 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_ANIMATION_FLAG));
147 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_FOLLOW_SCREEN_CHANGE));
148 }
149
150 /**
151 * @tc.name: SetAbilityInfo
152 * @tc.desc: Test SetAbilityInfo and GetAbilityInfo
153 * @tc.type: FUNC
154 */
155 HWTEST_F(WindowPropertyTest, SetAbilityInfo, TestSize.Level1)
156 {
157 WindowProperty winPropDst;
158 AbilityInfo info;
159 info.bundleName_ = "testBundleName";
160 info.abilityName_ = "testAbilityName";
161 winPropDst.SetAbilityInfo(info);
162 ASSERT_EQ("testBundleName", winPropDst.GetAbilityInfo().bundleName_);
163 ASSERT_EQ("testAbilityName", winPropDst.GetAbilityInfo().abilityName_);
164 }
165
166 /**
167 * @tc.name: ResumeLastWindowMode
168 * @tc.desc: Test ResumeLastWindowMode
169 * @tc.type: FUNC
170 */
171 HWTEST_F(WindowPropertyTest, ResumeLastWindowMode, TestSize.Level1)
172 {
173 WindowProperty winPropDst;
174 winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_PIP;
175 winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP;
176 winPropDst.mode_ = WindowMode::WINDOW_MODE_UNDEFINED;
177 winPropDst.ResumeLastWindowMode();
178 ASSERT_EQ(WindowMode::WINDOW_MODE_PIP, winPropDst.mode_);
179
180 winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_SPLIT_SECONDARY;
181 winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP;
182 winPropDst.mode_ = WindowMode::WINDOW_MODE_UNDEFINED;
183 winPropDst.ResumeLastWindowMode();
184 ASSERT_EQ(WindowMode::WINDOW_MODE_UNDEFINED, winPropDst.mode_);
185
186 winPropDst.windowModeSupportType_ = WindowModeSupport::WINDOW_MODE_SUPPORT_FLOATING;
187 winPropDst.lastMode_ = WindowMode::WINDOW_MODE_PIP;
188 winPropDst.mode_ = WindowMode::WINDOW_MODE_UNDEFINED;
189 winPropDst.ResumeLastWindowMode();
190 ASSERT_EQ(WindowMode::WINDOW_MODE_FLOATING, winPropDst.mode_);
191 }
192
193 /**
194 * @tc.name: AddWindowFlag001
195 * @tc.desc: AddWindowFlag test
196 * @tc.type: FUNC
197 */
198 HWTEST_F(WindowPropertyTest, AddWindowFlag001, TestSize.Level1)
199 {
200 WindowProperty winPropSrc;
201 int resultValue = 0;
202 WindowFlag flag = WindowFlag::WINDOW_FLAG_NEED_AVOID;
__anon5ddef9830202() 203 std::function<void()> func = [&]() {
204 winPropSrc.AddWindowFlag(flag);
205 resultValue = 1;
206 };
207 func();
208 ASSERT_EQ(resultValue, 1);
209 }
210
211 /**
212 * @tc.name: GetRequestRect002
213 * @tc.desc: GetRequestRect test
214 * @tc.type: FUNC
215 */
216 HWTEST_F(WindowPropertyTest, GetRequestRect001, TestSize.Level1)
217 {
218 WindowProperty winPropSrc;
219 Rect requestRect{ 0, 0, 0, 0 };
220 winPropSrc.SetRequestRect(requestRect);
221 Rect res = winPropSrc.GetRequestRect();
222 ASSERT_EQ(res, requestRect);
223 }
224
225 /**
226 * @tc.name: GetWindowSizeChangeReason003
227 * @tc.desc: GetWindowSizeChangeReason test
228 * @tc.type: FUNC
229 */
230 HWTEST_F(WindowPropertyTest, GetWindowSizeChangeReason003, TestSize.Level1)
231 {
232 WindowProperty winPropSrc;
233 WindowSizeChangeReason reason = WindowSizeChangeReason::UNDEFINED;
234 winPropSrc.SetWindowSizeChangeReason(reason);
235 WindowSizeChangeReason res = winPropSrc.GetWindowSizeChangeReason();
236 ASSERT_EQ(res, reason);
237 }
238
239 /**
240 * @tc.name: GetFullScreen004
241 * @tc.desc: GetFullScreen test
242 * @tc.type: FUNC
243 */
244 HWTEST_F(WindowPropertyTest, GetFullScreen004, TestSize.Level1)
245 {
246 WindowProperty winPropSrc;
247 bool isFullScreen = true;
248 winPropSrc.SetFullScreen(isFullScreen);
249 bool res = winPropSrc.GetFullScreen();
250 ASSERT_EQ(res, isFullScreen);
251 }
252
253 /**
254 * @tc.name: GetFocusable005
255 * @tc.desc: GetFocusable test
256 * @tc.type: FUNC
257 */
258 HWTEST_F(WindowPropertyTest, GetFocusable005, TestSize.Level1)
259 {
260 WindowProperty winPropSrc;
261 bool isFocusable = true;
262 winPropSrc.SetFocusable(isFocusable);
263 bool res = winPropSrc.GetFocusable();
264 ASSERT_EQ(res, isFocusable);
265 }
266
267 /**
268 * @tc.name: GetTouchable006
269 * @tc.desc: GetTouchable test
270 * @tc.type: FUNC
271 */
272 HWTEST_F(WindowPropertyTest, GetTouchable006, TestSize.Level1)
273 {
274 WindowProperty winPropSrc;
275 bool isTouchable = true;
276 winPropSrc.SetTouchable(isTouchable);
277 bool res = winPropSrc.GetFocusable();
278 ASSERT_EQ(res, isTouchable);
279 }
280
281 /**
282 * @tc.name: GetCallingWindow007
283 * @tc.desc: GetCallingWindow test
284 * @tc.type: FUNC
285 */
286 HWTEST_F(WindowPropertyTest, GetCallingWindow007, TestSize.Level1)
287 {
288 WindowProperty winPropSrc;
289 uint32_t windowId = 1;
290 winPropSrc.SetCallingWindow(windowId);
291 uint32_t res = winPropSrc.GetCallingWindow();
292 ASSERT_EQ(res, windowId);
293 }
294
295 /**
296 * @tc.name: GetPrivacyMode008
297 * @tc.desc: GetPrivacyMode test
298 * @tc.type: FUNC
299 */
300 HWTEST_F(WindowPropertyTest, GetPrivacyMode008, TestSize.Level1)
301 {
302 WindowProperty winPropSrc;
303 bool isPrivate = true;
304 winPropSrc.SetPrivacyMode(isPrivate);
305 bool res = winPropSrc.GetPrivacyMode();
306 ASSERT_EQ(res, isPrivate);
307 }
308
309 /**
310 * @tc.name: GetSystemPrivacyMode009
311 * @tc.desc: GetSystemPrivacyMode test
312 * @tc.type: FUNC
313 */
314 HWTEST_F(WindowPropertyTest, GetSystemPrivacyMode009, TestSize.Level1)
315 {
316 WindowProperty winPropSrc;
317 bool isSystemPrivate = true;
318 winPropSrc.SetSystemPrivacyMode(isSystemPrivate);
319 bool res = winPropSrc.GetSystemPrivacyMode();
320 ASSERT_EQ(res, isSystemPrivate);
321 }
322
323 /**
324 * @tc.name: GetSnapshotSkip010
325 * @tc.desc: GetSnapshotSkip test
326 * @tc.type: FUNC
327 */
328 HWTEST_F(WindowPropertyTest, GetSnapshotSkip010, TestSize.Level1)
329 {
330 WindowProperty winPropSrc;
331 bool isSkip = true;
332 winPropSrc.SetSnapshotSkip(isSkip);
333 bool res = winPropSrc.GetSnapshotSkip();
334 ASSERT_EQ(res, isSkip);
335 }
336
337 /**
338 * @tc.name: GetAlpha011
339 * @tc.desc: GetAlpha test
340 * @tc.type: FUNC
341 */
342 HWTEST_F(WindowPropertyTest, GetAlpha011, TestSize.Level1)
343 {
344 WindowProperty winPropSrc;
345 float alpha = 1;
346 winPropSrc.SetAlpha(alpha);
347 float res = winPropSrc.GetAlpha();
348 ASSERT_EQ(res, alpha);
349 }
350
351 /**
352 * @tc.name: GetBrightness012
353 * @tc.desc: GetBrightness test
354 * @tc.type: FUNC
355 */
356 HWTEST_F(WindowPropertyTest, GetBrightness012, TestSize.Level1)
357 {
358 WindowProperty winPropSrc;
359 float brightness = 1;
360 winPropSrc.SetBrightness(brightness);
361 float res = winPropSrc.GetBrightness();
362 ASSERT_EQ(res, brightness);
363 }
364
365 /**
366 * @tc.name: IsTurnScreenOn013
367 * @tc.desc: IsTurnScreenOn test
368 * @tc.type: FUNC
369 */
370 HWTEST_F(WindowPropertyTest, IsTurnScreenOn013, TestSize.Level1)
371 {
372 WindowProperty winPropSrc;
373 bool turnScreenOn = true;
374 winPropSrc.SetTurnScreenOn(turnScreenOn);
375 bool res = winPropSrc.IsTurnScreenOn();
376 ASSERT_EQ(res, turnScreenOn);
377 }
378
379 /**
380 * @tc.name: IsKeepScreenOn014
381 * @tc.desc: IsKeepScreenOn test
382 * @tc.type: FUNC
383 */
384 HWTEST_F(WindowPropertyTest, IsKeepScreenOn014, TestSize.Level1)
385 {
386 WindowProperty winPropSrc;
387 bool keepScreenOn = true;
388 winPropSrc.SetKeepScreenOn(keepScreenOn);
389 bool res = winPropSrc.IsKeepScreenOn();
390 ASSERT_EQ(res, keepScreenOn);
391 }
392
393 /**
394 * @tc.name: GetWindowFlags015
395 * @tc.desc: GetWindowFlags test
396 * @tc.type: FUNC
397 */
398 HWTEST_F(WindowPropertyTest, GetWindowFlags015, TestSize.Level1)
399 {
400 WindowProperty winPropSrc;
401 uint32_t flags = 1;
402 winPropSrc.SetWindowFlags(flags);
403 uint32_t res = winPropSrc.GetWindowFlags();
404 ASSERT_EQ(res, flags);
405 }
406
407 /**
408 * @tc.name: GetSystemBarProperty016
409 * @tc.desc: GetSystemBarProperty test
410 * @tc.type: FUNC
411 */
412 HWTEST_F(WindowPropertyTest, GetSystemBarProperty016, TestSize.Level1)
413 {
414 WindowProperty winPropSrc;
415 SystemBarProperty property;
416 WindowType type = WindowType::WINDOW_TYPE_STATUS_BAR;
417 winPropSrc.SetSystemBarProperty(type, property);
418 std::unordered_map<WindowType, SystemBarProperty> res = winPropSrc.GetSystemBarProperty();
419 ASSERT_EQ(res[type], property);
420 }
421
422 /**
423 * @tc.name: GetStretchable017
424 * @tc.desc: GetHitOffset test
425 * @tc.type: FUNC
426 */
427 HWTEST_F(WindowPropertyTest, GetStretchable017, TestSize.Level1)
428 {
429 WindowProperty winPropSrc;
430 bool stretchable = true;
431 winPropSrc.SetStretchable(stretchable);
432 bool res = winPropSrc.GetStretchable();
433 ASSERT_EQ(res, stretchable);
434 }
435
436 /**
437 * @tc.name: GetAnimationFlag018
438 * @tc.desc: GetAnimationFlag test
439 * @tc.type: FUNC
440 */
441 HWTEST_F(WindowPropertyTest, GetAnimationFlag018, TestSize.Level1)
442 {
443 WindowProperty winPropSrc;
444 uint32_t animationFlag = 1;
445 winPropSrc.SetAnimationFlag(animationFlag);
446 uint32_t res = winPropSrc.GetAnimationFlag();
447 ASSERT_EQ(res, animationFlag);
448 }
449
450 /**
451 * @tc.name: GetWindowModeSupportType019
452 * @tc.desc: GetWindowModeSupportType test
453 * @tc.type: FUNC
454 */
455 HWTEST_F(WindowPropertyTest, GetWindowModeSupportType019, TestSize.Level1)
456 {
457 WindowProperty winPropSrc;
458 uint32_t windowModeSupportType = 1;
459 winPropSrc.SetWindowModeSupportType(windowModeSupportType);
460 uint32_t res = winPropSrc.GetWindowModeSupportType();
461 ASSERT_EQ(res, windowModeSupportType);
462 }
463
464 /**
465 * @tc.name: GetRequestWindowModeSupportType020
466 * @tc.desc: GetRequestWindowModeSupportType test
467 * @tc.type: FUNC
468 */
469 HWTEST_F(WindowPropertyTest, GetRequestWindowModeSupportType020, TestSize.Level1)
470 {
471 WindowProperty winPropSrc;
472 uint32_t requestWindowModeSupportType = 1;
473 winPropSrc.SetRequestWindowModeSupportType(requestWindowModeSupportType);
474 uint32_t res = winPropSrc.GetRequestWindowModeSupportType();
475 ASSERT_EQ(res, requestWindowModeSupportType);
476 }
477
478 /**
479 * @tc.name: GetTokenState021
480 * @tc.desc: GetTokenState test
481 * @tc.type: FUNC
482 */
483 HWTEST_F(WindowPropertyTest, GetTokenState021, TestSize.Level1)
484 {
485 WindowProperty winPropSrc;
486 bool hasToken = true;
487 winPropSrc.SetTokenState(hasToken);
488 bool res = winPropSrc.GetTokenState();
489 ASSERT_EQ(res, hasToken);
490 }
491
492 /**
493 * @tc.name: GetDragType022
494 * @tc.desc: GetDragType test
495 * @tc.type: FUNC
496 */
497 HWTEST_F(WindowPropertyTest, GetDragType022, TestSize.Level1)
498 {
499 WindowProperty winPropSrc;
500 DragType dragType = DragType::DRAG_UNDEFINED;
501 winPropSrc.SetDragType(dragType);
502 DragType res = winPropSrc.GetDragType();
503 ASSERT_EQ(res, dragType);
504 }
505
506 /**
507 * @tc.name: GetOriginRect023
508 * @tc.desc: GetOriginRect test
509 * @tc.type: FUNC
510 */
511 HWTEST_F(WindowPropertyTest, GetOriginRect023, TestSize.Level1)
512 {
513 WindowProperty winPropSrc;
514 Rect rect = { 0, 0, 0, 0 };
515 winPropSrc.SetOriginRect(rect);
516 Rect res = winPropSrc.GetOriginRect();
517 ASSERT_EQ(res, rect);
518 }
519
520 /**
521 * @tc.name: SetTouchHotAreas028
522 * @tc.desc: SetTouchHotAreas test
523 * @tc.type: FUNC
524 */
525 HWTEST_F(WindowPropertyTest, SetTouchHotAreas028, TestSize.Level1)
526 {
527 WindowProperty winPropSrc;
528 std::vector<Rect> rects;
529 winPropSrc.SetTouchHotAreas(rects);
530 winPropSrc.GetTouchHotAreas(rects);
531 ASSERT_EQ(rects, winPropSrc.touchHotAreas_);
532 }
533
534 /**
535 * @tc.name: SetAspectRatio029
536 * @tc.desc: SetAspectRatio test
537 * @tc.type: FUNC
538 */
539 HWTEST_F(WindowPropertyTest, SetAspectRatio029, TestSize.Level1)
540 {
541 WindowProperty winPropSrc;
542 float ratio = 1;
543 winPropSrc.SetAspectRatio(ratio);
544 float res = winPropSrc.GetAspectRatio();
545 ASSERT_EQ(res, ratio);
546 }
547
548 /**
549 * @tc.name: SetMaximizeMode030
550 * @tc.desc: SetMaximizeMode test
551 * @tc.type: FUNC
552 */
553 HWTEST_F(WindowPropertyTest, SetMaximizeMode030, TestSize.Level1)
554 {
555 WindowProperty winPropSrc;
556 MaximizeMode maximizeMode = { MaximizeMode::MODE_RECOVER };
557 winPropSrc.SetMaximizeMode(maximizeMode);
558 MaximizeMode res = winPropSrc.GetMaximizeMode();
559 ASSERT_EQ(res, maximizeMode);
560 }
561
562 /**
563 * @tc.name: GetAccessTokenId031
564 * @tc.desc: GetAccessTokenId test
565 * @tc.type: FUNC
566 */
567 HWTEST_F(WindowPropertyTest, GetAccessTokenId031, TestSize.Level1)
568 {
569 WindowProperty winPropSrc;
570 uint32_t accessTokenId = 1;
571 winPropSrc.SetAccessTokenId(accessTokenId);
572 uint32_t res = winPropSrc.GetAccessTokenId();
573 ASSERT_EQ(res, accessTokenId);
574 }
575
576 /**
577 * @tc.name: SetWindowGravity032
578 * @tc.desc: SetWindowGravity test
579 * @tc.type: FUNC
580 */
581 HWTEST_F(WindowPropertyTest, GetAccessTokenId032, TestSize.Level1)
582 {
583 WindowProperty winPropSrc;
584 WindowGravity gravity = WindowGravity::WINDOW_GRAVITY_FLOAT;
585 uint32_t percent = 1;
586 winPropSrc.SetWindowGravity(gravity, percent);
587 winPropSrc.GetWindowGravity(gravity, percent);
588 ASSERT_EQ(gravity, winPropSrc.windowGravity_);
589 ASSERT_EQ(percent, winPropSrc.windowGravitySizePercent_);
590 }
591
592 /**
593 * @tc.name: Write033
594 * @tc.desc: Write test
595 * @tc.type: FUNC
596 */
597 HWTEST_F(WindowPropertyTest, Write033, TestSize.Level1)
598 {
599 WindowProperty winPropDst;
600 Parcel parcel;
601 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_PRIVACY_MODE));
602 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_SYSTEM_PRIVACY_MODE));
603 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_SNAPSHOT_SKIP));
604 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO));
605 ASSERT_EQ(true, winPropDst.Write(parcel, PropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE));
606 }
607
608 /**
609 * @tc.name: Read034
610 * @tc.desc: Read test
611 * @tc.type: FUNC
612 */
613 HWTEST_F(WindowPropertyTest, Read034, TestSize.Level1)
614 {
615 WindowProperty winPropSrc;
616 winPropSrc.SetPrivacyMode(true);
617 winPropSrc.SetTransparent(true);
618
619 Parcel parcel;
620 winPropSrc.Marshalling(parcel);
621
622 WindowProperty winPropDst;
623 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_SNAPSHOT_SKIP);
624 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_ASPECT_RATIO);
625 winPropDst.Read(parcel, PropertyChangeAction::ACTION_UPDATE_MAXIMIZE_STATE);
626
627 ASSERT_EQ(false, winPropDst.GetPrivacyMode());
628 ASSERT_EQ(false, winPropDst.GetTransparent());
629 }
630
631 /**
632 * @tc.name: GetTextFieldPositionY035
633 * @tc.desc: GetTextFieldPositionY test
634 * @tc.type: FUNC
635 */
636 HWTEST_F(WindowPropertyTest, GetTextFieldPositionY035, TestSize.Level1)
637 {
638 WindowProperty winPropSrc;
639 double textFieldPositionY = 1;
640 winPropSrc.SetTextFieldPositionY(textFieldPositionY);
641 double res = winPropSrc.GetTextFieldPositionY();
642 ASSERT_EQ(res, textFieldPositionY);
643 }
644
645 /**
646 * @tc.name: GetTextFieldHeight036
647 * @tc.desc: GetTextFieldHeight test
648 * @tc.type: FUNC
649 */
650 HWTEST_F(WindowPropertyTest, GetTextFieldHeight36, TestSize.Level1)
651 {
652 WindowProperty winPropSrc;
653 double textFieldHeight = 1;
654 winPropSrc.SetTextFieldHeight(textFieldHeight);
655 double res = winPropSrc.GetTextFieldHeight();
656 ASSERT_EQ(res, textFieldHeight);
657 }
658
659 /**
660 * @tc.name: GetFollowScreenChange37
661 * @tc.desc: GetFollowScreenChange test
662 * @tc.type: FUNC
663 */
664 HWTEST_F(WindowPropertyTest, GetFollowScreenChange37, TestSize.Level1)
665 {
666 WindowProperty winPropSrc;
667 bool isFollowScreenChange = true;
668 winPropSrc.SetFollowScreenChange(isFollowScreenChange);
669 bool res = winPropSrc.GetFollowScreenChange();
670 ASSERT_EQ(res, isFollowScreenChange);
671 }
672 }
673 } // namespace Rosen
674 } // namespace OHOS