• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, Hardware
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 "drawing_color.h"
19 #include "drawing_filter.h"
20 #include "drawing_mask_filter.h"
21 #include "drawing_rect.h"
22 #include "utils/scalar.h"
23 
24 using namespace testing;
25 using namespace testing::ext;
26 
27 namespace OHOS {
28 namespace Rosen {
29 namespace Drawing {
30 class NativeDrawingRectLargeValueTest : public testing::Test {
31 public:
32     static void SetUpTestCase();
33     static void TearDownTestCase();
34     void SetUp() override;
35     void TearDown() override;
36 };
37 
SetUpTestCase()38 void NativeDrawingRectLargeValueTest::SetUpTestCase() {}
TearDownTestCase()39 void NativeDrawingRectLargeValueTest::TearDownTestCase() {}
SetUp()40 void NativeDrawingRectLargeValueTest::SetUp() {}
TearDown()41 void NativeDrawingRectLargeValueTest::TearDown() {}
42 
43 /*
44  * @tc.name: NativeDrawingRectLargeValueTest_GetHeight003
45  * @tc.desc: test for get height of rect.
46  * @tc.size  : MediumTest
47  * @tc.type  : Function
48  * @tc.level : Level 1
49  */
50 HWTEST_F(NativeDrawingRectLargeValueTest, NativeDrawingRectLargeValueTest_GetHeight003, Function | MediumTest | Level1)
51 {
52     OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 2160, 4096);
53     float height = OH_Drawing_RectGetHeight(rect);
54     EXPECT_TRUE(IsScalarAlmostEqual(height, 4096)); // 4096 means height
55     OH_Drawing_RectDestroy(rect);
56 }
57 
58 /*
59  * @tc.name: NativeDrawingRectLargeValueTest_GetWidth004
60  * @tc.desc: test for get width of rect.
61  * @tc.size  : MediumTest
62  * @tc.type  : Function
63  * @tc.level : Level 1
64  */
65 HWTEST_F(NativeDrawingRectLargeValueTest, NativeDrawingRectLargeValueTest_GetWidth004, Function | MediumTest | Level1)
66 {
67     OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 2160, 4096);
68     float width = OH_Drawing_RectGetWidth(rect);
69     EXPECT_TRUE(IsScalarAlmostEqual(width, 2160)); // 2160 means width
70     OH_Drawing_RectDestroy(rect);
71 }
72 
73 /*
74  * @tc.name: NativeDrawingRectLargeValueTest_SetAndGetBoundary005
75  * @tc.desc: test for set and get of rect.
76  * @tc.size  : MediumTest
77  * @tc.type  : Function
78  * @tc.level : Level 1
79  */
80 HWTEST_F(NativeDrawingRectLargeValueTest, NativeDrawingRectLargeValueTest_SetAndGetBoundary005,
81     Function | MediumTest | Level1)
82 {
83     OH_Drawing_Rect* rect = OH_Drawing_RectCreate(0, 0, 400, 800);
84     OH_Drawing_RectSetLeft(rect, 10);
85     OH_Drawing_RectSetTop(rect, 10);
86     OH_Drawing_RectSetRight(rect, 2160);
87     OH_Drawing_RectSetBottom(rect, 4096);
88     float left = OH_Drawing_RectGetLeft(rect);
89     float top = OH_Drawing_RectGetTop(rect);
90     float right = OH_Drawing_RectGetRight(rect);
91     float bottom = OH_Drawing_RectGetBottom(rect);
92     EXPECT_TRUE(IsScalarAlmostEqual(left, 10)); // 10 means left
93     EXPECT_TRUE(IsScalarAlmostEqual(top, 10)); // 10 means top
94     EXPECT_TRUE(IsScalarAlmostEqual(right, 2160)); // 2160 means right
95     EXPECT_TRUE(IsScalarAlmostEqual(bottom, 4096)); // 4096 means bottom
96     OH_Drawing_RectDestroy(rect);
97 }
98 
99 /*
100  * @tc.name: NativeDrawingRectLargeValueTest_Copy006
101  * @tc.desc: test for Copy of rect.
102  * @tc.size  : MediumTest
103  * @tc.type  : Function
104  * @tc.level : Level 1
105  */
106 HWTEST_F(NativeDrawingRectLargeValueTest, NativeDrawingRectLargeValueTest_Copy006, Function | MediumTest | Level1)
107 {
108     OH_Drawing_Rect* rectSrc = OH_Drawing_RectCreate(0, 0, 400, 800);
109     OH_Drawing_Rect* rectDst = OH_Drawing_RectCreate(11, 22, 2160, 4096);
110     OH_Drawing_RectCopy(rectDst, rectSrc);
111     float left = OH_Drawing_RectGetLeft(rectSrc);
112     float top = OH_Drawing_RectGetTop(rectSrc);
113     float right = OH_Drawing_RectGetRight(rectSrc);
114     float bottom = OH_Drawing_RectGetBottom(rectSrc);
115     EXPECT_TRUE(IsScalarAlmostEqual(left, 11)); // 11 means left
116     EXPECT_TRUE(IsScalarAlmostEqual(top, 22)); // 22 means top
117     EXPECT_TRUE(IsScalarAlmostEqual(right, 2160)); // 2160 means right
118     EXPECT_TRUE(IsScalarAlmostEqual(bottom, 4096)); // 4096 means bottom
119     OH_Drawing_RectDestroy(rectSrc);
120     OH_Drawing_RectDestroy(rectDst);
121 }
122 } // namespace Drawing
123 } // namespace Rosen
124 } // namespace OHOS