• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "screen_property.h"
17 #include <gtest/gtest.h>
18 
19 // using namespace FRAME_TRACE;
20 using namespace testing;
21 using namespace testing::ext;
22 namespace OHOS {
23 namespace Rosen {
24 class ScreenPropertyTest : public testing::Test {
25   public:
ScreenPropertyTest()26     ScreenPropertyTest() {}
~ScreenPropertyTest()27     ~ScreenPropertyTest() {}
28 };
29 
30 namespace {
31 /**
32  * @tc.name: SetScreenRotation
33  * @tc.desc: normal function
34  * @tc.type: FUNC
35  */
36 HWTEST_F(ScreenPropertyTest, SetScreenRotation, TestSize.Level0)
37 {
38     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetScreenRotation start";
39     ScreenProperty* property = new(std::nothrow) ScreenProperty();
40     int64_t ret = 0;
41     Rotation rotation = Rotation::ROTATION_0;
42     property->SetScreenRotation(rotation);
43 
44     rotation = Rotation::ROTATION_90;
45     property->SetScreenRotation(rotation);
46 
47     rotation = Rotation::ROTATION_180;
48     property->SetScreenRotation(rotation);
49 
50     rotation = Rotation::ROTATION_270;
51     property->SetScreenRotation(rotation);
52     ASSERT_EQ(ret, 0);
53     delete property;
54     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetScreenRotation end";
55 }
56 
57 /**
58  * @tc.name: SetRotationAndScreenRotationOnly001
59  * @tc.desc: SetRotationAndScreenRotationOnly001 test
60  * @tc.type: FUNC
61  */
62 HWTEST_F(ScreenPropertyTest, SetRotationAndScreenRotationOnly001, Function | SmallTest | Level2)
63 {
64     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetRotationAndScreenRotationOnly001 start";
65     ScreenProperty* property = new(std::nothrow) ScreenProperty();
66     ASSERT_NE(property, nullptr);
67     Rotation ret = Rotation::ROTATION_0;
68     Rotation rotation = Rotation::ROTATION_0;
69     property->SetRotationAndScreenRotationOnly(rotation);
70     ret = property->GetScreenRotation();
71     ASSERT_EQ(ret, rotation);
72 
73     rotation = Rotation::ROTATION_90;
74     property->SetRotationAndScreenRotationOnly(rotation);
75     ret = property->GetScreenRotation();
76     ASSERT_EQ(ret, rotation);
77 
78     rotation = Rotation::ROTATION_180;
79     property->SetRotationAndScreenRotationOnly(rotation);
80     ret = property->GetScreenRotation();
81     ASSERT_EQ(ret, rotation);
82 
83     rotation = Rotation::ROTATION_270;
84     property->SetRotationAndScreenRotationOnly(rotation);
85     ret = property->GetScreenRotation();
86     ASSERT_EQ(ret, rotation);
87     delete property;
88     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetRotationAndScreenRotationOnly001 end";
89 }
90 
91 /**
92  * @tc.name: UpdateDeviceRotation
93  * @tc.desc: normal function
94  * @tc.type: FUNC
95  */
96 HWTEST_F(ScreenPropertyTest, UpdateDeviceRotation, TestSize.Level1)
97 {
98     GTEST_LOG_(INFO) << "ScreenPropertyTest: UpdateDeviceRotation start";
99     ScreenProperty* property = new(std::nothrow) ScreenProperty();
100     Rotation ret = Rotation::ROTATION_0;
101     Rotation rotation = Rotation::ROTATION_0;
102     property->UpdateDeviceRotation(rotation);
103     ret = property->GetDeviceRotation();
104     ASSERT_EQ(ret, rotation);
105 
106     rotation = Rotation::ROTATION_90;
107     property->UpdateDeviceRotation(rotation);
108     ret = property->GetDeviceRotation();
109     ASSERT_EQ(ret, rotation);
110 
111     rotation = Rotation::ROTATION_180;
112     property->UpdateDeviceRotation(rotation);
113     ret = property->GetDeviceRotation();
114     ASSERT_EQ(ret, rotation);
115 
116     rotation = Rotation::ROTATION_270;
117     property->UpdateDeviceRotation(rotation);
118     ret = property->GetDeviceRotation();
119     ASSERT_EQ(ret, rotation);
120     delete property;
121     GTEST_LOG_(INFO) << "ScreenPropertyTest: UpdateDeviceRotation end";
122 }
123 
124 /**
125  * @tc.name: SetDeviceOrientation
126  * @tc.desc: normal function
127  * @tc.type: FUNC
128  */
129 HWTEST_F(ScreenPropertyTest, SetDeviceOrientation, TestSize.Level1)
130 {
131     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetDeviceOrientation start";
132     ScreenProperty* property = new(std::nothrow) ScreenProperty();
133     DisplayOrientation ret = DisplayOrientation::PORTRAIT;
134     DisplayOrientation displayOrientation = DisplayOrientation::PORTRAIT;
135     property->SetDeviceOrientation(displayOrientation);
136     ret = property->GetDeviceOrientation();
137     ASSERT_EQ(ret, displayOrientation);
138 
139     displayOrientation = DisplayOrientation::LANDSCAPE;
140     property->SetDeviceOrientation(displayOrientation);
141     ret = property->GetDeviceOrientation();
142     ASSERT_EQ(ret, displayOrientation);
143 
144     displayOrientation = DisplayOrientation::PORTRAIT_INVERTED;
145     property->SetDeviceOrientation(displayOrientation);
146     ret = property->GetDeviceOrientation();
147     ASSERT_EQ(ret, displayOrientation);
148 
149     displayOrientation = DisplayOrientation::LANDSCAPE_INVERTED;
150     property->SetDeviceOrientation(displayOrientation);
151     ret = property->GetDeviceOrientation();
152     ASSERT_EQ(ret, displayOrientation);
153     delete property;
154     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetDeviceOrientation end";
155 }
156 
157 /**
158  * @tc.name: UpdateScreenRotation
159  * @tc.desc: UpdateScreenRotation test
160  * @tc.type: FUNC
161  */
162 HWTEST_F(ScreenPropertyTest, UpdateScreenRotation, Function | SmallTest | Level2)
163 {
164     GTEST_LOG_(INFO) << "ScreenPropertyTest: UpdateScreenRotation start";
165     ScreenProperty* property = new(std::nothrow) ScreenProperty();
166     ASSERT_NE(property, nullptr);
167     Rotation ret = Rotation::ROTATION_0;
168     Rotation rotation = Rotation::ROTATION_0;
169     property->UpdateScreenRotation(rotation);
170     ret = property->GetScreenRotation();
171     ASSERT_EQ(ret, rotation);
172 
173     rotation = Rotation::ROTATION_90;
174     property->UpdateScreenRotation(rotation);
175     ret = property->GetScreenRotation();
176     ASSERT_EQ(ret, rotation);
177 
178     rotation = Rotation::ROTATION_180;
179     property->UpdateScreenRotation(rotation);
180     ret = property->GetScreenRotation();
181     ASSERT_EQ(ret, rotation);
182 
183     rotation = Rotation::ROTATION_270;
184     property->UpdateScreenRotation(rotation);
185     ret = property->GetScreenRotation();
186     ASSERT_EQ(ret, rotation);
187     delete property;
188     GTEST_LOG_(INFO) << "ScreenPropertyTest: UpdateScreenRotation end";
189 }
190 
191 /**
192  * @tc.name: SetOrientation
193  * @tc.desc: SetOrientation test
194  * @tc.type: FUNC
195  */
196 HWTEST_F(ScreenPropertyTest, SetOrientation, Function | SmallTest | Level2)
197 {
198     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetOrientation start";
199     ScreenProperty* property = new(std::nothrow) ScreenProperty();
200     ASSERT_NE(property, nullptr);
201     Orientation ret = Orientation::BEGIN;
202     Orientation orientation = Orientation::SENSOR;
203     property->SetOrientation(orientation);
204     ret = property->orientation_;
205     ASSERT_EQ(ret, orientation);
206     delete property;
207     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetOrientation end";
208 }
209 
210 /**
211  * @tc.name: GetOrientation
212  * @tc.desc: normal function
213  * @tc.type: FUNC
214  */
215 HWTEST_F(ScreenPropertyTest, GetOrientation, Function | SmallTest | Level2)
216 {
217     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetOrientation start";
218     ScreenProperty* property = new(std::nothrow) ScreenProperty();
219     ASSERT_NE(property, nullptr);
220     Orientation ret = Orientation::BEGIN;
221     Orientation orientation = Orientation::SENSOR;
222     property->SetOrientation(orientation);
223     ret = property->GetOrientation();
224     ASSERT_EQ(ret, orientation);
225     delete property;
226     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetOrientation end";
227 }
228 
229 /**
230  * @tc.name: UpdateVirtualPixelRatio
231  * @tc.desc: normal function
232  * @tc.type: FUNC
233  */
234 HWTEST_F(ScreenPropertyTest, UpdateVirtualPixelRatio, TestSize.Level1)
235 {
236     GTEST_LOG_(INFO) << "ScreenPropertyTest: UpdateVirtualPixelRatio start";
237     ScreenProperty* property = new(std::nothrow) ScreenProperty();
238     int64_t ret = 0;
239     RRect bounds;
240     bounds.rect_.width_ = 1344;
241     bounds.rect_.height_ = 2772;
242 
243     property->UpdateVirtualPixelRatio(bounds);
244 
245     bounds.rect_.height_ = 1111;
246     property->UpdateVirtualPixelRatio(bounds);
247 
248     bounds.rect_.width_ = 1111;
249     bounds.rect_.height_ = 2772;
250     property->UpdateVirtualPixelRatio(bounds);
251 
252     bounds.rect_.width_ = 1111;
253     bounds.rect_.height_ = 1111;
254     property->UpdateVirtualPixelRatio(bounds);
255     ASSERT_EQ(ret, 0);
256     delete property;
257     GTEST_LOG_(INFO) << "ScreenPropertyTest: UpdateVirtualPixelRatio end";
258 }
259 
260 /**
261  * @tc.name: SetBounds
262  * @tc.desc: normal function
263  * @tc.type: FUNC
264  */
265 HWTEST_F(ScreenPropertyTest, SetBounds, TestSize.Level1)
266 {
267     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetBounds start";
268     ScreenProperty* property = new(std::nothrow) ScreenProperty();
269     int64_t ret = 0;
270     RRect bounds;
271     bounds.rect_.width_ = 1344;
272     bounds.rect_.height_ = 2772;
273 
274     uint32_t phyWidth = UINT32_MAX;
275     property->SetPhyWidth(phyWidth);
276     uint32_t phyHeigth = UINT32_MAX;
277     property->SetPhyHeight(phyHeigth);
278     property->SetBounds(bounds);
279 
280     bounds.rect_.width_ = 2772;
281     bounds.rect_.height_ = 1344;
282 
283     uint32_t phyWidth1 = 2772;
284     property->SetPhyWidth(phyWidth1);
285     uint32_t phyHeigth1 = 1344;
286     property->SetPhyHeight(phyHeigth1);
287     property->SetBounds(bounds);
288     ASSERT_EQ(ret, 0);
289     delete property;
290     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetBounds end";
291 }
292 
293 /**
294  * @tc.name: CalculateXYDpi
295  * @tc.desc: normal function
296  * @tc.type: FUNC
297  */
298 HWTEST_F(ScreenPropertyTest, CalculateXYDpi, TestSize.Level1)
299 {
300     GTEST_LOG_(INFO) << "ScreenPropertyTest: CalculateXYDpi start";
301     ScreenProperty* property = new(std::nothrow) ScreenProperty();
302     uint32_t phyWidth = 0;
303     uint32_t phyHeight = 0;
304     int ret = 0;
305     property->CalculateXYDpi(phyWidth, phyHeight);
306     phyWidth = 1;
307     phyHeight = 1;
308     property->CalculateXYDpi(phyWidth, phyHeight);
309     ASSERT_EQ(ret, 0);
310     delete property;
311     GTEST_LOG_(INFO) << "ScreenPropertyTest: CalculateXYDpi end";
312 }
313 
314 /**
315  * @tc.name: SetOffsetX
316  * @tc.desc: normal function
317  * @tc.type: FUNC
318  */
319 HWTEST_F(ScreenPropertyTest, SetOffsetX, TestSize.Level0)
320 {
321     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetOffsetX start";
322     ScreenProperty* property = new(std::nothrow) ScreenProperty();
323     int32_t offsetX = 0;
324     property->SetOffsetX(offsetX);
325     int32_t ret = property->GetOffsetX();
326     ASSERT_EQ(ret, offsetX);
327     delete property;
328     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetOffsetX end";
329 }
330 
331 /**
332  * @tc.name: SetOffsetY
333  * @tc.desc: normal function
334  * @tc.type: FUNC
335  */
336 HWTEST_F(ScreenPropertyTest, SetOffsetY, TestSize.Level0)
337 {
338     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetOffsetY start";
339     ScreenProperty* property = new(std::nothrow) ScreenProperty();
340     int32_t offsetY = 0;
341     property->SetOffsetY(offsetY);
342     int32_t ret = property->GetOffsetY();
343     ASSERT_EQ(ret, offsetY);
344     delete property;
345     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetOffsetY end";
346 }
347 
348 /**
349  * @tc.name: SetOffset
350  * @tc.desc: normal function
351  * @tc.type: FUNC
352  */
353 HWTEST_F(ScreenPropertyTest, SetOffset, TestSize.Level0)
354 {
355     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetOffset start";
356     ScreenProperty* property = new(std::nothrow) ScreenProperty();
357     int32_t offsetX = 0;
358     int32_t offsetY = 0;
359     property->SetOffset(offsetX, offsetY);
360     int32_t ret_x = property->GetOffsetX();
361     int32_t ret_y = property->GetOffsetY();
362     ASSERT_EQ(ret_x, offsetX);
363     ASSERT_EQ(ret_y, offsetY);
364     delete property;
365     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetOffset end";
366 }
367 
368 /**
369  * @tc.name: SetScreenRequestedOrientation
370  * @tc.desc: normal function
371  * @tc.type: FUNC
372  */
373 HWTEST_F(ScreenPropertyTest, SetScreenRequestedOrientation, TestSize.Level0)
374 {
375     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetScreenRequestedOrientation start";
376     ScreenProperty* property = new(std::nothrow) ScreenProperty();
377     Orientation orientation = Orientation::UNSPECIFIED;
378     property->SetScreenRequestedOrientation(orientation);
379     Orientation ret = property->GetScreenRequestedOrientation();
380     ASSERT_EQ(ret, orientation);
381     delete property;
382     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetScreenRequestedOrientation end";
383 }
384 
385 /**
386  * @tc.name: GetPhyHeight
387  * @tc.desc: normal function
388  * @tc.type: FUNC
389  */
390 HWTEST_F(ScreenPropertyTest, GetPhyHeight, TestSize.Level0)
391 {
392     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPhyHeight start";
393     ScreenProperty* property = new(std::nothrow) ScreenProperty();
394     uint32_t phyHeight = 1;
395     property->SetPhyHeight(phyHeight);
396     int32_t ret = property->GetPhyHeight();
397     ASSERT_EQ(ret, phyHeight);
398     delete property;
399     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPhyHeight end";
400 }
401 
402 /**
403  * @tc.name: SetRotation
404  * @tc.desc: normal function
405  * @tc.type: FUNC
406  */
407 HWTEST_F(ScreenPropertyTest, SetRotation, TestSize.Level0)
408 {
409     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetRotation start";
410     ScreenProperty* property = new(std::nothrow) ScreenProperty();
411     ASSERT_NE(property, nullptr);
412     float rotation = 2.0f;
413     property->SetRotation(rotation);
414     ASSERT_EQ(property->rotation_, rotation);
415     delete property;
416     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetRotation end";
417 }
418 
419 /**
420  * @tc.name: GetRotation
421  * @tc.desc: normal function
422  * @tc.type: FUNC
423  */
424 HWTEST_F(ScreenPropertyTest, GetRotation, TestSize.Level0)
425 {
426     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetRotation start";
427     ScreenProperty* property = new(std::nothrow) ScreenProperty();
428     ASSERT_NE(property, nullptr);
429     float rotation = property->GetRotation();
430     ASSERT_EQ(property->rotation_, rotation);
431     delete property;
432     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetRotation end";
433 }
434 
435 /**
436  * @tc.name: SetPhysicalRotation
437  * @tc.desc: normal function
438  * @tc.type: FUNC
439  */
440 HWTEST_F(ScreenPropertyTest, SetPhysicalRotation, TestSize.Level1)
441 {
442     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetPhysicalRotation start";
443     ScreenProperty* property = new(std::nothrow) ScreenProperty();
444     ASSERT_NE(property, nullptr);
445     float rotation = 2.0f;
446     property->SetPhysicalRotation(rotation);
447     ASSERT_EQ(property->physicalRotation_, rotation);
448     delete property;
449     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetPhysicalRotation end";
450 }
451 
452 /**
453  * @tc.name: GetPhysicalRotation
454  * @tc.desc: normal function
455  * @tc.type: FUNC
456  */
457 HWTEST_F(ScreenPropertyTest, GetPhysicalRotation, TestSize.Level1)
458 {
459     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPhysicalRotation start";
460     ScreenProperty* property = new(std::nothrow) ScreenProperty();
461     ASSERT_NE(property, nullptr);
462     float rotation = property->GetPhysicalRotation();
463     ASSERT_EQ(property->physicalRotation_, rotation);
464     delete property;
465     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPhysicalRotation end";
466 }
467 
468 /**
469  * @tc.name: SetScreenComponentRotation
470  * @tc.desc: normal function
471  * @tc.type: FUNC
472  */
473 HWTEST_F(ScreenPropertyTest, SetScreenComponentRotation, TestSize.Level1)
474 {
475     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetScreenComponentRotation start";
476     ScreenProperty* property = new(std::nothrow) ScreenProperty();
477     ASSERT_NE(property, nullptr);
478     float rotation = 2.0f;
479     property->SetScreenComponentRotation(rotation);
480     ASSERT_EQ(property->screenComponentRotation_, rotation);
481     delete property;
482     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetScreenComponentRotation end";
483 }
484 
485 /**
486  * @tc.name: GetScreenComponentRotation
487  * @tc.desc: normal function
488  * @tc.type: FUNC
489  */
490 HWTEST_F(ScreenPropertyTest, GetScreenComponentRotation, TestSize.Level1)
491 {
492     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetScreenComponentRotation start";
493     ScreenProperty* property = new(std::nothrow) ScreenProperty();
494     ASSERT_NE(property, nullptr);
495     float rotation = property->GetScreenComponentRotation();
496     ASSERT_EQ(property->screenComponentRotation_, rotation);
497     delete property;
498     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetScreenComponentRotation end";
499 }
500 
501 /**
502  * @tc.name: GetBounds
503  * @tc.desc: normal function
504  * @tc.type: FUNC
505  */
506 HWTEST_F(ScreenPropertyTest, GetBounds, TestSize.Level1)
507 {
508     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetBounds start";
509     ScreenProperty* property = new(std::nothrow) ScreenProperty();
510     ASSERT_NE(property, nullptr);
511     RRect bounds = property->GetBounds();
512     ASSERT_EQ(property->bounds_, bounds);
513     delete property;
514     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetBounds end";
515 }
516 
517 /**
518  * @tc.name: SetPhyBounds
519  * @tc.desc: normal function
520  * @tc.type: FUNC
521  */
522 HWTEST_F(ScreenPropertyTest, SetPhyBounds, TestSize.Level1)
523 {
524     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetPhyBounds start";
525     ScreenProperty* property = new(std::nothrow) ScreenProperty();
526     ASSERT_NE(property, nullptr);
527     RRect phyBounds;
528     phyBounds.rect_.width_ = 1344;
529     phyBounds.rect_.height_ = 2772;
530     property->SetPhyBounds(phyBounds);
531     ASSERT_EQ(property->phyBounds_, phyBounds);
532     delete property;
533     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetPhyBounds end";
534 }
535 
536 /**
537  * @tc.name: GetPhyBounds
538  * @tc.desc: normal function
539  * @tc.type: FUNC
540  */
541 HWTEST_F(ScreenPropertyTest, GetPhyBounds, TestSize.Level1)
542 {
543     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPhyBounds start";
544     ScreenProperty* property = new(std::nothrow) ScreenProperty();
545     ASSERT_NE(property, nullptr);
546     RRect phyBounds = property->GetPhyBounds();
547     ASSERT_EQ(property->phyBounds_, phyBounds);
548     delete property;
549     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPhyBounds end";
550 }
551 
552 /**
553  * @tc.name: GetDensity
554  * @tc.desc: normal function
555  * @tc.type: FUNC
556  */
557 HWTEST_F(ScreenPropertyTest, GetDensity, TestSize.Level1)
558 {
559     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetDensity start";
560     ScreenProperty* property = new(std::nothrow) ScreenProperty();
561     ASSERT_NE(property, nullptr);
562     float virtualPixelRatio = 1.0f;
563     ASSERT_EQ(property->virtualPixelRatio_, virtualPixelRatio);
564     delete property;
565     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetDensity end";
566 }
567 
568 /**
569  * @tc.name: GetDefaultDensity
570  * @tc.desc: normal function
571  * @tc.type: FUNC
572  */
573 HWTEST_F(ScreenPropertyTest, GetDefaultDensity, TestSize.Level1)
574 {
575     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetDefaultDensity start";
576     ScreenProperty* property = new(std::nothrow) ScreenProperty();
577     ASSERT_NE(property, nullptr);
578     float defaultDensity = 1.0f;
579     ASSERT_EQ(property->GetDefaultDensity(), defaultDensity);
580     delete property;
581     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetDefaultDensity end";
582 }
583 
584 /**
585  * @tc.name: SetDefaultDensity
586  * @tc.desc: normal function
587  * @tc.type: FUNC
588  */
589 HWTEST_F(ScreenPropertyTest, SetDefaultDensity, TestSize.Level1)
590 {
591     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetDefaultDensity start";
592     ScreenProperty* property = new(std::nothrow) ScreenProperty();
593     ASSERT_NE(property, nullptr);
594     float defaultDensity = 1.0f;
595     property->SetDefaultDensity(defaultDensity);
596     ASSERT_EQ(property->defaultDensity_, defaultDensity);
597     delete property;
598     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetDefaultDensity end";
599 }
600 
601 /**
602  * @tc.name: GetDensityInCurResolution
603  * @tc.desc: normal function
604  * @tc.type: FUNC
605  */
606 HWTEST_F(ScreenPropertyTest, GetDensityInCurResolution, TestSize.Level1)
607 {
608     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetDensityInCurResolution start";
609     ScreenProperty* property = new(std::nothrow) ScreenProperty();
610     ASSERT_NE(property, nullptr);
611     float densityInCurResolution = 1.0f;
612     ASSERT_EQ(property->GetDensityInCurResolution(), densityInCurResolution);
613     delete property;
614     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetDensityInCurResolution end";
615 }
616 
617 /**
618  * @tc.name: SetDensityInCurResolution
619  * @tc.desc: normal function
620  * @tc.type: FUNC
621  */
622 HWTEST_F(ScreenPropertyTest, SetDensityInCurResolution, TestSize.Level1)
623 {
624     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetDensityInCurResolution start";
625     ScreenProperty* property = new(std::nothrow) ScreenProperty();
626     ASSERT_NE(property, nullptr);
627     float densityInCurResolution = 1.0f;
628     property->SetDensityInCurResolution(densityInCurResolution);
629     ASSERT_EQ(property->densityInCurResolution_, densityInCurResolution);
630     delete property;
631     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetDensityInCurResolution end";
632 }
633 
634 /**
635  * @tc.name: GetPropertyChangeReason
636  * @tc.desc: normal function
637  * @tc.type: FUNC
638  */
639 HWTEST_F(ScreenPropertyTest, GetPropertyChangeReason, TestSize.Level1)
640 {
641     ScreenProperty* property = new(std::nothrow) ScreenProperty();
642     ASSERT_NE(property, nullptr);
643     std::string propertyChangeReason = "a";
644     std::string propertyChangeReason_copy = property->GetPropertyChangeReason();
645     property->SetPropertyChangeReason(propertyChangeReason);
646     ASSERT_EQ(propertyChangeReason, property->GetPropertyChangeReason());
647     property->SetPropertyChangeReason(propertyChangeReason_copy);
648 }
649 
650 /**
651  * @tc.name: CalcDefaultDisplayOrientation
652  * @tc.desc: bounds_.rect_.width_ > bounds_.rect_.height_
653  * @tc.type: FUNC
654  */
655 HWTEST_F(ScreenPropertyTest, CalcDefaultDisplayOrientation, TestSize.Level1)
656 {
657     ScreenProperty* property = new(std::nothrow) ScreenProperty();
658     ASSERT_NE(property, nullptr);
659     RRect bounds_temp = property->GetBounds();
660     RRect bounds;
661     bounds.rect_.width_ = 2772;
662     bounds.rect_.height_ = 1344;
663     property->SetBounds(bounds);
664     property->CalcDefaultDisplayOrientation();
665     ASSERT_EQ(DisplayOrientation::LANDSCAPE, property->GetDisplayOrientation());
666     property->SetBounds(bounds_temp);
667 }
668 
669 /**
670  * @tc.name: SetStartX
671  * @tc.desc: normal function
672  * @tc.type: FUNC
673  */
674 HWTEST_F(ScreenPropertyTest, SetStartX, TestSize.Level1)
675 {
676     ScreenProperty* property = new(std::nothrow) ScreenProperty();
677     ASSERT_NE(property, nullptr);
678     uint32_t ret = 100;
679     uint32_t ret_copy = property->GetStartX();
680     property->SetStartX(ret);
681     ASSERT_EQ(ret, property->GetStartX());
682     property->SetStartX(ret_copy);
683 }
684 
685 /**
686  * @tc.name: SetStartY
687  * @tc.desc: normal function
688  * @tc.type: FUNC
689  */
690 HWTEST_F(ScreenPropertyTest, SetStartY, TestSize.Level1)
691 {
692     ScreenProperty* property = new(std::nothrow) ScreenProperty();
693     ASSERT_NE(property, nullptr);
694     uint32_t ret = 100;
695     uint32_t ret_copy = property->GetStartY();
696     property->SetStartY(ret);
697     ASSERT_EQ(ret, property->GetStartY());
698     property->SetStartY(ret_copy);
699 }
700 
701 /**
702  * @tc.name: SetStartPosition
703  * @tc.desc: normal function
704  * @tc.type: FUNC
705  */
706 HWTEST_F(ScreenPropertyTest, SetStartPosition, TestSize.Level1)
707 {
708     ScreenProperty* property = new(std::nothrow) ScreenProperty();
709     ASSERT_NE(property, nullptr);
710     uint32_t ret_x = 100;
711     uint32_t ret_y = 200;
712     uint32_t retx_copy = property->GetStartX();
713     uint32_t rety_copy = property->GetStartY();
714     property->SetStartPosition(ret_x, ret_y);
715     ASSERT_EQ(100, property->GetStartX());
716     ASSERT_EQ(200, property->GetStartY());
717     property->SetStartPosition(retx_copy, rety_copy);
718 }
719 
720 /**
721  * @tc.name: SetScreenShape
722  * @tc.desc: normal function
723  * @tc.type: FUNC
724  */
725 HWTEST_F(ScreenPropertyTest, SetScreenShape, TestSize.Level0)
726 {
727     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetScreenShape start";
728     ScreenProperty* property = new(std::nothrow) ScreenProperty();
729     ASSERT_NE(property, nullptr);
730     ScreenShape screenshape = ScreenShape::ROUND;
731     property->SetScreenShape(screenshape);
732     ASSERT_EQ(property->screenShape_, screenshape);
733     delete property;
734     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetScreenShape end";
735 }
736 
737 /**
738  * @tc.name: GetScreenShape
739  * @tc.desc: normal function
740  * @tc.type: FUNC
741  */
742 HWTEST_F(ScreenPropertyTest, GetScreenShape, TestSize.Level1)
743 {
744     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetScreenShape start";
745     ScreenProperty* property = new(std::nothrow) ScreenProperty();
746     ASSERT_NE(property, nullptr);
747     ScreenShape screenshape = ScreenShape::ROUND;
748     property->SetScreenShape(screenshape);
749     ASSERT_EQ(property->GetScreenShape(), screenshape);
750     delete property;
751     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetScreenShape end";
752 }
753 
754 /**
755  * @tc.name: SetPointerActiveWidth
756  * @tc.desc: normal function
757  * @tc.type: FUNC
758  */
759 HWTEST_F(ScreenPropertyTest, SetPointerActiveWidth, Function | SmallTest | Level2)
760 {
761     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetPointerActiveWidth start";
762     ScreenProperty* property = new(std::nothrow) ScreenProperty();
763     ASSERT_NE(property, nullptr);
764     uint32_t pointerActiveWidth = 123;
765     property->SetPointerActiveWidth(pointerActiveWidth);
766     ASSERT_EQ(property->pointerActiveWidth_, pointerActiveWidth);
767     delete property;
768     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetPointerActiveWidth end";
769 }
770 
771 /**
772  * @tc.name: GetPointerActiveWidth
773  * @tc.desc: normal function
774  * @tc.type: FUNC
775  */
776 HWTEST_F(ScreenPropertyTest, GetPointerActiveWidth, Function | SmallTest | Level2)
777 {
778     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPointerActiveWidth start";
779     ScreenProperty* property = new(std::nothrow) ScreenProperty();
780     ASSERT_NE(property, nullptr);
781     uint32_t pointerActiveWidth = 123;
782     property->SetPointerActiveWidth(pointerActiveWidth);
783     ASSERT_EQ(property->GetPointerActiveWidth(), pointerActiveWidth);
784     delete property;
785     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPointerActiveWidth end";
786 }
787 
788 /**
789  * @tc.name: SetPointerActiveHeight
790  * @tc.desc: normal function
791  * @tc.type: FUNC
792  */
793 HWTEST_F(ScreenPropertyTest, SetPointerActiveHeight, Function | SmallTest | Level2)
794 {
795     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetPointerActiveHeight start";
796     ScreenProperty* property = new(std::nothrow) ScreenProperty();
797     ASSERT_NE(property, nullptr);
798     uint32_t pointerActiveHeight = 321;
799     property->SetPointerActiveHeight(pointerActiveHeight);
800     ASSERT_EQ(property->pointerActiveHeight_, pointerActiveHeight);
801     delete property;
802     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetPointerActiveHeight end";
803 }
804 
805 /**
806  * @tc.name: GetPointerActiveHeight
807  * @tc.desc: normal function
808  * @tc.type: FUNC
809  */
810 HWTEST_F(ScreenPropertyTest, GetPointerActiveHeight, Function | SmallTest | Level2)
811 {
812     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPointerActiveHeight start";
813     ScreenProperty* property = new(std::nothrow) ScreenProperty();
814     ASSERT_NE(property, nullptr);
815     uint32_t pointerActiveHeight = 321;
816     property->SetPointerActiveHeight(pointerActiveHeight);
817     ASSERT_EQ(property->GetPointerActiveHeight(), pointerActiveHeight);
818     delete property;
819     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetPointerActiveHeight end";
820 }
821 
822 /**
823 * @tc.name: SetX
824 * @tc.desc: normal function
825 * @tc.type: FUNC
826 */
827 HWTEST_F(ScreenPropertyTest, SetX, TestSize.Level1)
828 {
829     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetX start";
830     ScreenProperty* property = new(std::nothrow) ScreenProperty();
831     ASSERT_NE(property, nullptr);
832     int32_t ret = -1000;
833     int32_t ret_copy = property->GetX();
834     property->SetX(ret);
835     ASSERT_EQ(ret, property->GetX());
836     property->SetX(ret_copy);
837     delete property;
838     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetX end";
839 }
840 
841 /**
842 * @tc.name: SetY
843 * @tc.desc: normal function
844 * @tc.type: FUNC
845 */
846 HWTEST_F(ScreenPropertyTest, SetY, TestSize.Level1)
847 {
848     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetY start";
849     ScreenProperty* property = new(std::nothrow) ScreenProperty();
850     ASSERT_NE(property, nullptr);
851     int32_t ret = -1000;
852     int32_t ret_copy = property->GetY();
853     property->SetY(ret);
854     ASSERT_EQ(ret, property->GetY());
855     property->SetY(ret_copy);
856     delete property;
857     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetY end";
858 }
859 
860 /**
861 * @tc.name: SetXYPosition
862 * @tc.desc: normal function
863 * @tc.type: FUNC
864 */
865 HWTEST_F(ScreenPropertyTest, SetXYPosition, TestSize.Level1)
866 {
867     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetXYPosition start";
868     ScreenProperty* property = new(std::nothrow) ScreenProperty();
869     ASSERT_NE(property, nullptr);
870     int32_t ret_x = 1000;
871     int32_t ret_y = 2000;
872     int32_t retx_copy = property->GetX();
873     int32_t rety_copy = property->GetY();
874     property->SetXYPosition(ret_x, ret_y);
875     ASSERT_EQ(1000, property->GetX());
876     ASSERT_EQ(2000, property->GetY());
877     property->SetXYPosition(retx_copy, rety_copy);
878     delete property;
879     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetXYPosition end";
880 }
881 
882 /**
883  * @tc.name: SetVirtualPixelRatio
884  * @tc.desc: SetVirtualPixelRatio test
885  * @tc.type: FUNC
886  */
887 HWTEST_F(ScreenPropertyTest, SetVirtualPixelRatio, Function | SmallTest | Level2)
888 {
889     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetVirtualPixelRatio start";
890     ScreenProperty* property = new(std::nothrow) ScreenProperty();
891     ASSERT_NE(property, nullptr);
892     float pixelRatio = 1.0f;
893     float pixelCopy = property->GetVirtualPixelRatio();
894     property->SetVirtualPixelRatio(pixelRatio);
895     ASSERT_EQ(property->virtualPixelRatio_, pixelRatio);
896     property->SetVirtualPixelRatio(pixelCopy);
897     delete property;
898     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetVirtualPixelRatio end";
899 }
900 
901 /**
902  * @tc.name: GetVirtualPixelRatio
903  * @tc.desc: GetVirtualPixelRatio test
904  * @tc.type: FUNC
905  */
906 HWTEST_F(ScreenPropertyTest, GetVirtualPixelRatio, Function | SmallTest | Level2)
907 {
908     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetVirtualPixelRatio start";
909     ScreenProperty* property = new(std::nothrow) ScreenProperty();
910     ASSERT_NE(property, nullptr);
911     float pixelRatio = 1.0f;
912     float pixelCopy = property->GetVirtualPixelRatio();
913     property->SetVirtualPixelRatio(pixelRatio);
914     ASSERT_EQ(property->GetVirtualPixelRatio(), pixelRatio);
915     property->SetVirtualPixelRatio(pixelCopy);
916     delete property;
917     GTEST_LOG_(INFO) << "ScreenPropertyTest: GetVirtualPixelRatio end";
918 }
919 
920 /**
921  * @tc.name: SetRotationAndScreenRotationOnly
922  * @tc.desc: SetRotationAndScreenRotationOnly test
923  * @tc.type: FUNC
924  */
925 HWTEST_F(ScreenPropertyTest, SetRotationAndScreenRotationOnly, Function | SmallTest | Level2)
926 {
927     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetRotationAndScreenRotationOnly start";
928     std::shared_ptr<ScreenProperty> property = std::make_shared<ScreenProperty>();
929     ASSERT_NE(property, nullptr);
930     property->SetRotationAndScreenRotationOnly(Rotation::ROTATION_0);
931     ASSERT_EQ(property->GetScreenRotation(), Rotation::ROTATION_0);
932 
933     property->SetRotationAndScreenRotationOnly(Rotation::ROTATION_90);
934     ASSERT_EQ(property->GetScreenRotation(), Rotation::ROTATION_90);
935 
936     property->SetRotationAndScreenRotationOnly(Rotation::ROTATION_180);
937     ASSERT_EQ(property->GetScreenRotation(), Rotation::ROTATION_180);
938 
939     property->SetRotationAndScreenRotationOnly(Rotation::ROTATION_270);
940     ASSERT_EQ(property->GetScreenRotation(), Rotation::ROTATION_270);
941     GTEST_LOG_(INFO) << "ScreenPropertyTest: SetRotationAndScreenRotationOnly end";
942 }
943 } // namespace
944 } // namespace Rosen
945 } // namespace OHOS
946