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