1f6603c60Sopenharmony_ci/* 2f6603c60Sopenharmony_ci * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development 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, software 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 "DrawingNativeCanvasCommon.h" 19f6603c60Sopenharmony_ci#include "drawing_bitmap.h" 20f6603c60Sopenharmony_ci#include "drawing_brush.h" 21f6603c60Sopenharmony_ci#include "drawing_canvas.h" 22f6603c60Sopenharmony_ci#include "drawing_color.h" 23f6603c60Sopenharmony_ci#include "drawing_color_filter.h" 24f6603c60Sopenharmony_ci#include "drawing_filter.h" 25f6603c60Sopenharmony_ci#include "drawing_font.h" 26f6603c60Sopenharmony_ci#include "drawing_image.h" 27f6603c60Sopenharmony_ci#include "drawing_mask_filter.h" 28f6603c60Sopenharmony_ci#include "drawing_matrix.h" 29f6603c60Sopenharmony_ci#include "drawing_memory_stream.h" 30f6603c60Sopenharmony_ci#include "drawing_path.h" 31f6603c60Sopenharmony_ci#include "drawing_pen.h" 32f6603c60Sopenharmony_ci#include "drawing_point.h" 33f6603c60Sopenharmony_ci#include "drawing_rect.h" 34f6603c60Sopenharmony_ci#include "drawing_region.h" 35f6603c60Sopenharmony_ci#include "drawing_round_rect.h" 36f6603c60Sopenharmony_ci#include "drawing_sampling_options.h" 37f6603c60Sopenharmony_ci#include "drawing_shader_effect.h" 38f6603c60Sopenharmony_ci#include "drawing_text_blob.h" 39f6603c60Sopenharmony_ci#include "drawing_typeface.h" 40f6603c60Sopenharmony_ci 41f6603c60Sopenharmony_ciusing namespace testing; 42f6603c60Sopenharmony_ciusing namespace testing::ext; 43f6603c60Sopenharmony_ci 44f6603c60Sopenharmony_cinamespace OHOS { 45f6603c60Sopenharmony_cinamespace Rosen { 46f6603c60Sopenharmony_cinamespace Drawing { 47f6603c60Sopenharmony_ci 48f6603c60Sopenharmony_ci/* 49f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1900 50f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawOvalNormal 51f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawOvalNormal. 52f6603c60Sopenharmony_ci * @tc.size : SmallTest 53f6603c60Sopenharmony_ci * @tc.type : Function 54f6603c60Sopenharmony_ci * @tc.level : Level 0 55f6603c60Sopenharmony_ci */ 56f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawOvalNormal, TestSize.Level0) { 57f6603c60Sopenharmony_ci // 1. Create OH_Drawing_Canvas 58f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 59f6603c60Sopenharmony_ci 60f6603c60Sopenharmony_ci // 2. Create OH_Drawing_Rect 61f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100); 62f6603c60Sopenharmony_ci 63f6603c60Sopenharmony_ci // 3. Draw oval on canvas 64f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect); 65f6603c60Sopenharmony_ci 66f6603c60Sopenharmony_ci // 4. Free memory 67f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 68f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 69f6603c60Sopenharmony_ci} 70f6603c60Sopenharmony_ci 71f6603c60Sopenharmony_ci/* 72f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1901 73f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawOvalNull 74f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawOvalNull. 75f6603c60Sopenharmony_ci * @tc.size : SmallTest 76f6603c60Sopenharmony_ci * @tc.type : Function 77f6603c60Sopenharmony_ci * @tc.level : Level 3 78f6603c60Sopenharmony_ci */ 79f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawOvalNull, TestSize.Level3) { 80f6603c60Sopenharmony_ci // 1. Create OH_Drawing_Canvas 81f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 82f6603c60Sopenharmony_ci // 2. Create OH_Drawing_Rect 83f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 200, 200); 84f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasDrawOval with nullptr as the first parameter 85f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(nullptr, rect); 86f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasDrawOval with OH_Drawing_Rect created with 0 for left, top, right, and bottom 87f6603c60Sopenharmony_ci OH_Drawing_Rect *rect2 = OH_Drawing_RectCreate(0, 200, 200, 200); 88f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect2); 89f6603c60Sopenharmony_ci rect2 = OH_Drawing_RectCreate(200, 0, 200, 200); 90f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect2); 91f6603c60Sopenharmony_ci rect2 = OH_Drawing_RectCreate(200, 200, 0, 200); 92f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect2); 93f6603c60Sopenharmony_ci rect2 = OH_Drawing_RectCreate(200, 200, 200, 0); 94f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect2); 95f6603c60Sopenharmony_ci // 5. OH_Drawing_CanvasDrawOval with OH_Drawing_Rect created with all 0 values 96f6603c60Sopenharmony_ci OH_Drawing_Rect *rect3 = OH_Drawing_RectCreate(0, 0, 0, 0); 97f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect3); 98f6603c60Sopenharmony_ci // 6. OH_Drawing_CanvasDrawOval with nullptr as the second parameter 99f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, nullptr); 100f6603c60Sopenharmony_ci // 7. Free memory 101f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 102f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 103f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect2); 104f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect3); 105f6603c60Sopenharmony_ci} 106f6603c60Sopenharmony_ci 107f6603c60Sopenharmony_ci/* 108f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1902 109f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawOvalAbnormal 110f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawOvalAbnormal. 111f6603c60Sopenharmony_ci * @tc.size : SmallTest 112f6603c60Sopenharmony_ci * @tc.type : Function 113f6603c60Sopenharmony_ci * @tc.level : Level 3 114f6603c60Sopenharmony_ci */ 115f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawOvalAbnormal, TestSize.Level3) { 116f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 117f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 118f6603c60Sopenharmony_ci // 2. Create OH_Drawing_Rect with left, top, right, and bottom values as negative numbers 119f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(-100, 100, 200, 200); 120f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect); 121f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(100, -100, 200, 200); 122f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect); 123f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(100, 100, -200, 200); 124f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect); 125f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(100, 100, 200, -200); 126f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect); 127f6603c60Sopenharmony_ci // 3. Create OH_Drawing_Rect with the horizontal coordinate of the top-left corner equal to the horizontal 128f6603c60Sopenharmony_ci // coordinate of the bottom-right corner, or the vertical coordinate of the top-left corner equal to the vertical 129f6603c60Sopenharmony_ci // coordinate of the bottom-right corner 130f6603c60Sopenharmony_ci OH_Drawing_Rect *rect2 = OH_Drawing_RectCreate(100, 0, 100, 100); 131f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect2); 132f6603c60Sopenharmony_ci OH_Drawing_Rect *rect3 = OH_Drawing_RectCreate(0, 100, 100, 100); 133f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect3); 134f6603c60Sopenharmony_ci // 4. Create OH_Drawing_Rect with the top-left corner coordinates equal to the bottom-right corner coordinates 135f6603c60Sopenharmony_ci OH_Drawing_Rect *rect4 = OH_Drawing_RectCreate(100, 100, 100, 100); 136f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect4); 137f6603c60Sopenharmony_ci // 5. Create OH_Drawing_Rect with the top-left corner coordinates greater than the bottom-right corner coordinates 138f6603c60Sopenharmony_ci OH_Drawing_Rect *rect5 = OH_Drawing_RectCreate(200, 200, 100, 100); 139f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect5); 140f6603c60Sopenharmony_ci // 6. Free memory 141f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 142f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 143f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect2); 144f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect3); 145f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect4); 146f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect5); 147f6603c60Sopenharmony_ci} 148f6603c60Sopenharmony_ci 149f6603c60Sopenharmony_ci/* 150f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1903 151f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawOvalMaximum 152f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawOvalMaximum. 153f6603c60Sopenharmony_ci * @tc.size : SmallTest 154f6603c60Sopenharmony_ci * @tc.type : Function 155f6603c60Sopenharmony_ci * @tc.level : Level 3 156f6603c60Sopenharmony_ci */ 157f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawOvalMaximum, TestSize.Level3) { 158f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 159f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 160f6603c60Sopenharmony_ci // 2. Create OH_Drawing_Rect with FLT_MAX as the values for left, top, right, and bottom 161f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(FLT_MAX, 0, 0, 0); 162f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect); 163f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(0, FLT_MAX, 0, 0); 164f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect); 165f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(0, 0, FLT_MAX, 0); 166f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect); 167f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(0, 0, 0, FLT_MAX); 168f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawOval(canvas, rect); 169f6603c60Sopenharmony_ci // 3. Free memory 170f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 171f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 172f6603c60Sopenharmony_ci} 173f6603c60Sopenharmony_ci 174f6603c60Sopenharmony_ci/* 175f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_1904 176f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawOvalInputDestroyed 177f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawOvalInputDestroyed. 178f6603c60Sopenharmony_ci * @tc.size : SmallTest 179f6603c60Sopenharmony_ci * @tc.type : Function 180f6603c60Sopenharmony_ci * @tc.level : Level 3 181f6603c60Sopenharmony_ci */ 182f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawOvalInputDestroyed, TestSize.Level3) { 183f6603c60Sopenharmony_ci // Deprecated 184f6603c60Sopenharmony_ci} 185f6603c60Sopenharmony_ci 186f6603c60Sopenharmony_ci/* 187f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2000 188f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawArcNormal 189f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawArcNormal. 190f6603c60Sopenharmony_ci * @tc.size : SmallTest 191f6603c60Sopenharmony_ci * @tc.type : Function 192f6603c60Sopenharmony_ci * @tc.level : Level 0 193f6603c60Sopenharmony_ci */ 194f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawArcNormal, TestSize.Level0) { 195f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 196f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 197f6603c60Sopenharmony_ci // 2. OH_Drawing_RectCreate 198f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100); 199f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasDrawArc with startAngle iterating over 0°, 180°, and 360° 200f6603c60Sopenharmony_ci float startAngles[] = {0.0f, 180.0f, 360.0f}; 201f6603c60Sopenharmony_ci for (float startAngle : startAngles) { 202f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, startAngle, 90.0f); 203f6603c60Sopenharmony_ci } 204f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasDrawArc with sweepAngle iterating over 0°, 180°, and 360° 205f6603c60Sopenharmony_ci float sweepAngles[] = {0.0f, 180.0f, 360.0f}; 206f6603c60Sopenharmony_ci for (float sweepAngle : sweepAngles) { 207f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, 0.0f, sweepAngle); 208f6603c60Sopenharmony_ci } 209f6603c60Sopenharmony_ci // 5. Free memory 210f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 211f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 212f6603c60Sopenharmony_ci} 213f6603c60Sopenharmony_ci 214f6603c60Sopenharmony_ci/* 215f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2001 216f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawArcNull 217f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawArcNull. 218f6603c60Sopenharmony_ci * @tc.size : SmallTest 219f6603c60Sopenharmony_ci * @tc.type : Function 220f6603c60Sopenharmony_ci * @tc.level : Level 3 221f6603c60Sopenharmony_ci */ 222f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawArcNull, TestSize.Level3) { 223f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 224f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 225f6603c60Sopenharmony_ci // 2. OH_Drawing_RectCreate 226f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(0, 0, 100, 100); 227f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasDrawArc with nullptr as the first parameter 228f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(nullptr, rect, 0.0f, 90.0f); 229f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasDrawArc with OH_Drawing_Rect created with 0 for left, top, right, and bottom 230f6603c60Sopenharmony_ci OH_Drawing_Rect *rect2 = OH_Drawing_RectCreate(0, 100, 200, 200); 231f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect2, 0.0f, 90.0f); 232f6603c60Sopenharmony_ci rect2 = OH_Drawing_RectCreate(100, 0, 200, 200); 233f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect2, 0.0f, 90.0f); 234f6603c60Sopenharmony_ci rect2 = OH_Drawing_RectCreate(100, 100, 0, 200); 235f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect2, 0.0f, 90.0f); 236f6603c60Sopenharmony_ci rect2 = OH_Drawing_RectCreate(100, 100, 200, 0); 237f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect2, 0.0f, 90.0f); 238f6603c60Sopenharmony_ci // 5. OH_Drawing_CanvasDrawArc with OH_Drawing_Rect created with all 0 values 239f6603c60Sopenharmony_ci OH_Drawing_Rect *rect3 = OH_Drawing_RectCreate(0, 0, 0, 0); 240f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect3, 0.0f, 90.0f); 241f6603c60Sopenharmony_ci // 6. OH_Drawing_CanvasDrawArc with nullptr as the second parameter 242f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, nullptr, 0.0f, 90.0f); 243f6603c60Sopenharmony_ci // 7. Free memory 244f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 245f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 246f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect2); 247f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect3); 248f6603c60Sopenharmony_ci} 249f6603c60Sopenharmony_ci 250f6603c60Sopenharmony_ci/* 251f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2002 252f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawArcAbnormal 253f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawArcAbnormal. 254f6603c60Sopenharmony_ci * @tc.size : SmallTest 255f6603c60Sopenharmony_ci * @tc.type : Function 256f6603c60Sopenharmony_ci * @tc.level : Level 3 257f6603c60Sopenharmony_ci */ 258f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawArcAbnormal, TestSize.Level3) { 259f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 260f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 261f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasDrawArc with OH_Drawing_Rect created with negative values for left, top, right, and bottom 262f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(-100, -100, -200, -200); 263f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, 0.0f, 90.0f); 264f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(-100, 100, 200, 200); 265f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, 0.0f, 90.0f); 266f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(100, -100, 200, 200); 267f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, 0.0f, 90.0f); 268f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(100, 100, -200, 200); 269f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, 0.0f, 90.0f); 270f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(100, 100, 200, -200); 271f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, 0.0f, 90.0f); 272f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasDrawArc with OH_Drawing_Rect created with the horizontal coordinate of the top-left corner 273f6603c60Sopenharmony_ci // equal to the horizontal coordinate of the bottom-right corner, or the vertical coordinate of the top-left corner 274f6603c60Sopenharmony_ci // equal to the vertical coordinate of the bottom-right corner 275f6603c60Sopenharmony_ci OH_Drawing_Rect *rect2 = OH_Drawing_RectCreate(100, 0, 100, 100); 276f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect2, 0.0f, 90.0f); 277f6603c60Sopenharmony_ci OH_Drawing_Rect *rect3 = OH_Drawing_RectCreate(0, 100, 100, 100); 278f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect3, 0.0f, 90.0f); 279f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasDrawArc with OH_Drawing_Rect created with the top-left corner coordinates equal to the 280f6603c60Sopenharmony_ci // bottom-right corner coordinates 281f6603c60Sopenharmony_ci OH_Drawing_Rect *rect4 = OH_Drawing_RectCreate(100, 100, 100, 100); 282f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect4, 0.0f, 90.0f); 283f6603c60Sopenharmony_ci // 5. OH_Drawing_CanvasDrawArc with OH_Drawing_Rect created with the top-left corner coordinates greater than the 284f6603c60Sopenharmony_ci // bottom-right corner coordinates 285f6603c60Sopenharmony_ci OH_Drawing_Rect *rect5 = OH_Drawing_RectCreate(200, 200, 100, 100); 286f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect5, 0.0f, 90.0f); 287f6603c60Sopenharmony_ci // 6. OH_Drawing_CanvasDrawArc with negative startAngle 288f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, -90.0f, 90.0f); 289f6603c60Sopenharmony_ci // 7. OH_Drawing_CanvasDrawArc with startAngle greater than 360° 290f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, 400.0f, 90.0f); 291f6603c60Sopenharmony_ci // 8. OH_Drawing_CanvasDrawArc with negative sweepAngle 292f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, 0.0f, -90.0f); 293f6603c60Sopenharmony_ci // 9. OH_Drawing_CanvasDrawArc with sweepAngle greater than 360° 294f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, 0.0f, 400.0f); 295f6603c60Sopenharmony_ci // 10. Free memory 296f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 297f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 298f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect2); 299f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect3); 300f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect4); 301f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect5); 302f6603c60Sopenharmony_ci} 303f6603c60Sopenharmony_ci 304f6603c60Sopenharmony_ci/* 305f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2003 306f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawArcMaximum 307f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawArcMaximum. 308f6603c60Sopenharmony_ci * @tc.size : SmallTest 309f6603c60Sopenharmony_ci * @tc.type : Function 310f6603c60Sopenharmony_ci * @tc.level : Level 3 311f6603c60Sopenharmony_ci */ 312f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawArcMaximum, TestSize.Level3) { 313f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 314f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 315f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasDrawArc with OH_Drawing_Rect created with FLT_MAX as the values for left, top, right, and 316f6603c60Sopenharmony_ci // bottom 317f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(FLT_MAX, 0, 0, 0); 318f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, 0.0f, 90.0f); 319f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 320f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(0, FLT_MAX, 0, 0); 321f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, 0.0f, 90.0f); 322f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 323f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(0, 0, FLT_MAX, 0); 324f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, 0.0f, 90.0f); 325f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 326f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(0, 0, 0, FLT_MAX); 327f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, 0.0f, 90.0f); 328f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 329f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasDrawArc with startAngle FLT_MAX 330f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(0, 0, 100, 100); 331f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, FLT_MAX, 90.0f); 332f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 333f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasDrawArc with sweepAngle FLT_MAX 334f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(0, 0, 100, 100); 335f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawArc(canvas, rect, 0.0f, FLT_MAX); 336f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 337f6603c60Sopenharmony_ci // 5. Free memory 338f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 339f6603c60Sopenharmony_ci} 340f6603c60Sopenharmony_ci 341f6603c60Sopenharmony_ci/* 342f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2004 343f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawArcInputDestroyed 344f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawArcInputDestroyed. 345f6603c60Sopenharmony_ci * @tc.size : SmallTest 346f6603c60Sopenharmony_ci * @tc.type : Function 347f6603c60Sopenharmony_ci * @tc.level : Level 3 348f6603c60Sopenharmony_ci */ 349f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawArcInputDestroyed, TestSize.Level3) { 350f6603c60Sopenharmony_ci // Deprecated 351f6603c60Sopenharmony_ci} 352f6603c60Sopenharmony_ci 353f6603c60Sopenharmony_ci/* 354f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2100 355f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawRoundRectNormal 356f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawRoundRectNormal. 357f6603c60Sopenharmony_ci * @tc.size : SmallTest 358f6603c60Sopenharmony_ci * @tc.type : Function 359f6603c60Sopenharmony_ci * @tc.level : Level 0 360f6603c60Sopenharmony_ci */ 361f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawRoundRectNormal, TestSize.Level0) { 362f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 363f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 364f6603c60Sopenharmony_ci 365f6603c60Sopenharmony_ci // 2. OH_Drawing_RoundRectCreate 366f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(10, 100, 200, 300); 367f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rect, 1.0f, 1.0f); 368f6603c60Sopenharmony_ci 369f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasDrawRoundRect 370f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 371f6603c60Sopenharmony_ci 372f6603c60Sopenharmony_ci // 4. Free memory 373f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 374f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 375f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect); 376f6603c60Sopenharmony_ci} 377f6603c60Sopenharmony_ci 378f6603c60Sopenharmony_ci/* 379f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2101 380f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawRoundRectNull 381f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawRoundRectNull. 382f6603c60Sopenharmony_ci * @tc.size : SmallTest 383f6603c60Sopenharmony_ci * @tc.type : Function 384f6603c60Sopenharmony_ci * @tc.level : Level 3 385f6603c60Sopenharmony_ci */ 386f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawRoundRectNull, TestSize.Level3) { 387f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 388f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 389f6603c60Sopenharmony_ci 390f6603c60Sopenharmony_ci // 2. OH_Drawing_RoundRectCreate 391f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(10, 100, 200, 300); 392f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rect, 1.0f, 1.0f); 393f6603c60Sopenharmony_ci 394f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasDrawRoundRect with the first parameter being nullptr 395f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(nullptr, roundRect); 396f6603c60Sopenharmony_ci 397f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasDrawRoundRect with the second parameter being nullptr 398f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, nullptr); 399f6603c60Sopenharmony_ci 400f6603c60Sopenharmony_ci // 5. OH_Drawing_CanvasDrawRoundRect with the second parameter OH_Drawing_RoundRectCreate created with rect having 0 401f6603c60Sopenharmony_ci // in any of the four positions 402f6603c60Sopenharmony_ci OH_Drawing_Rect *rect2 = OH_Drawing_RectCreate(0, 100, 200, 300); 403f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect2 = OH_Drawing_RoundRectCreate(rect2, 1.0f, 1.0f); 404f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect2); 405f6603c60Sopenharmony_ci 406f6603c60Sopenharmony_ci OH_Drawing_Rect *rect3 = OH_Drawing_RectCreate(10, 0, 200, 300); 407f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect3 = OH_Drawing_RoundRectCreate(rect3, 1.0f, 1.0f); 408f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect3); 409f6603c60Sopenharmony_ci 410f6603c60Sopenharmony_ci OH_Drawing_Rect *rect4 = OH_Drawing_RectCreate(10, 100, 0, 300); 411f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect4 = OH_Drawing_RoundRectCreate(rect4, 1.0f, 1.0f); 412f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect4); 413f6603c60Sopenharmony_ci 414f6603c60Sopenharmony_ci OH_Drawing_Rect *rect5 = OH_Drawing_RectCreate(10, 100, 200, 0); 415f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect5 = OH_Drawing_RoundRectCreate(rect5, 1.0f, 1.0f); 416f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect5); 417f6603c60Sopenharmony_ci 418f6603c60Sopenharmony_ci // 6. OH_Drawing_CanvasDrawRoundRect with the second parameter OH_Drawing_RoundRectCreate created with rect having 419f6603c60Sopenharmony_ci // all positions as 0 420f6603c60Sopenharmony_ci OH_Drawing_Rect *rect6 = OH_Drawing_RectCreate(0, 0, 0, 0); 421f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect6 = OH_Drawing_RoundRectCreate(rect6, 1.0f, 1.0f); 422f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect6); 423f6603c60Sopenharmony_ci 424f6603c60Sopenharmony_ci // 7. OH_Drawing_CanvasDrawRoundRect with the second parameter OH_Drawing_RoundRectCreate created with xRad as 0 425f6603c60Sopenharmony_ci OH_Drawing_Rect *rect7 = OH_Drawing_RectCreate(10, 100, 200, 300); 426f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect7 = OH_Drawing_RoundRectCreate(rect7, 0.0f, 1.0f); 427f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect7); 428f6603c60Sopenharmony_ci 429f6603c60Sopenharmony_ci // 8. OH_Drawing_CanvasDrawRoundRect with the second parameter OH_Drawing_RoundRectCreate created with yRad as 0 430f6603c60Sopenharmony_ci OH_Drawing_Rect *rect8 = OH_Drawing_RectCreate(10, 100, 200, 300); 431f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect8 = OH_Drawing_RoundRectCreate(rect8, 1.0f, 0.0f); 432f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect8); 433f6603c60Sopenharmony_ci 434f6603c60Sopenharmony_ci // 9. Free memory 435f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 436f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 437f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect); 438f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect2); 439f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect2); 440f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect3); 441f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect3); 442f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect4); 443f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect4); 444f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect5); 445f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect5); 446f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect6); 447f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect6); 448f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect7); 449f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect7); 450f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect8); 451f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect8); 452f6603c60Sopenharmony_ci} 453f6603c60Sopenharmony_ci 454f6603c60Sopenharmony_ci/* 455f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2102 456f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawRoundRectAbnormal 457f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawRoundRectAbnormal. 458f6603c60Sopenharmony_ci * @tc.size : SmallTest 459f6603c60Sopenharmony_ci * @tc.type : Function 460f6603c60Sopenharmony_ci * @tc.level : Level 3 461f6603c60Sopenharmony_ci */ 462f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawRoundRectAbnormal, TestSize.Level3) { 463f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 464f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 465f6603c60Sopenharmony_ci 466f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasDrawRoundRect with OH_Drawing_RoundRectCreate creating rect with left, top, right, bottom 467f6603c60Sopenharmony_ci // being set to negative numbers 468f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(-10, 100, 200, 300); 469f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rect, 0.0f, 1.0f); 470f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 471f6603c60Sopenharmony_ci 472f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, -100, 200, 300); 473f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 0.0f, 1.0f); 474f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 475f6603c60Sopenharmony_ci 476f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 100, -200, 300); 477f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 0.0f, 1.0f); 478f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 479f6603c60Sopenharmony_ci 480f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 100, 200, -300); 481f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 0.0f, 1.0f); 482f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 483f6603c60Sopenharmony_ci 484f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasDrawRoundRect with OH_Drawing_CanvasDrawRoundRect creating rect with the horizontal 485f6603c60Sopenharmony_ci // coordinate of the top-left corner equal to the horizontal coordinate of the bottom-right corner, or the vertical 486f6603c60Sopenharmony_ci // coordinate of the top-left corner equal to the vertical coordinate of the bottom-right corner 487f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(100, 0, 100, 100); 488f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 0.0f, 1.0f); 489f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 490f6603c60Sopenharmony_ci 491f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(0, 100, 100, 100); 492f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 0.0f, 1.0f); 493f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 494f6603c60Sopenharmony_ci 495f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasDrawRoundRect with OH_Drawing_RoundRectCreate creating rect with the top-left corner 496f6603c60Sopenharmony_ci // coordinates equal to the bottom-right corner coordinates 497f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(100, 100, 100, 100); 498f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 0.0f, 1.0f); 499f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 500f6603c60Sopenharmony_ci 501f6603c60Sopenharmony_ci // 5. OH_Drawing_CanvasDrawRoundRect with OH_Drawing_RoundRectCreate creating rect with the top-left corner 502f6603c60Sopenharmony_ci // coordinates greater than the bottom-right corner coordinates 503f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(200, 200, 100, 100); 504f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 0.0f, 1.0f); 505f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 506f6603c60Sopenharmony_ci 507f6603c60Sopenharmony_ci // 6. OH_Drawing_CanvasDrawRoundRect with the second parameter OH_Drawing_RoundRectCreate creating roundRect with a 508f6603c60Sopenharmony_ci // negative xRad 509f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 100, 200, 300); 510f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, -1.0f, 1.0f); 511f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 512f6603c60Sopenharmony_ci 513f6603c60Sopenharmony_ci // 7. OH_Drawing_CanvasDrawRoundRect with the second parameter OH_Drawing_RoundRectCreate creating roundRect with a 514f6603c60Sopenharmony_ci // negative yRad 515f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 100, 200, 300); 516f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 0.0f, -1.0f); 517f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 518f6603c60Sopenharmony_ci 519f6603c60Sopenharmony_ci // 8. Free memory 520f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 521f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 522f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect); 523f6603c60Sopenharmony_ci} 524f6603c60Sopenharmony_ci 525f6603c60Sopenharmony_ci/* 526f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2103 527f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawRoundRectMaximum 528f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawRoundRectMaximum. 529f6603c60Sopenharmony_ci * @tc.size : SmallTest 530f6603c60Sopenharmony_ci * @tc.type : Function 531f6603c60Sopenharmony_ci * @tc.level : Level 3 532f6603c60Sopenharmony_ci */ 533f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawRoundRectMaximum, TestSize.Level3) { 534f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 535f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 536f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasDrawRoundRect with OH_Drawing_RoundRectCreate creating rect with left, top, right, bottom 537f6603c60Sopenharmony_ci // being set to FLT_MAX 538f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(FLT_MAX, 100, 200, 300); 539f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rect, 1.0f, 1.0f); 540f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 541f6603c60Sopenharmony_ci 542f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, FLT_MAX, 200, 300); 543f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 1.0f, 1.0f); 544f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 545f6603c60Sopenharmony_ci 546f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 100, FLT_MAX, 300); 547f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 1.0f, 1.0f); 548f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 549f6603c60Sopenharmony_ci 550f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 100, 200, FLT_MAX); 551f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 1.0f, 1.0f); 552f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 553f6603c60Sopenharmony_ci 554f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasDrawRoundRect with the second parameter OH_Drawing_RoundRectCreate created with xRad being 555f6603c60Sopenharmony_ci // set to FLT_MAX 556f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 100, 200, 300); 557f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, FLT_MAX, 1.0f); 558f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 559f6603c60Sopenharmony_ci 560f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasDrawRoundRect with the second parameter OH_Drawing_RoundRectCreate created with yRad being 561f6603c60Sopenharmony_ci // set to FLT_MAX 562f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 100, 200, 300); 563f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 1.0f, FLT_MAX); 564f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRoundRect(canvas, roundRect); 565f6603c60Sopenharmony_ci 566f6603c60Sopenharmony_ci // 5. Free memory 567f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 568f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 569f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect); 570f6603c60Sopenharmony_ci} 571f6603c60Sopenharmony_ci 572f6603c60Sopenharmony_ci/* 573f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2104 574f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawRoundRectInputDestroyed 575f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawRoundRectInputDestroyed. 576f6603c60Sopenharmony_ci * @tc.size : SmallTest 577f6603c60Sopenharmony_ci * @tc.type : Function 578f6603c60Sopenharmony_ci * @tc.level : Level 3 579f6603c60Sopenharmony_ci */ 580f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawRoundRectInputDestroyed, TestSize.Level3) { 581f6603c60Sopenharmony_ci // Deprecated 582f6603c60Sopenharmony_ci} 583f6603c60Sopenharmony_ci 584f6603c60Sopenharmony_ci/* 585f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2200 586f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawTextBlobNormal 587f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawTextBlobNormal. 588f6603c60Sopenharmony_ci * @tc.size : SmallTest 589f6603c60Sopenharmony_ci * @tc.type : Function 590f6603c60Sopenharmony_ci * @tc.level : Level 0 591f6603c60Sopenharmony_ci */ 592f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawTextBlobNormal, TestSize.Level0) { 593f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 594f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 595f6603c60Sopenharmony_ci 596f6603c60Sopenharmony_ci // 2. OH_Drawing_TextBlobCreateFromText 597f6603c60Sopenharmony_ci const char *str = "123456"; 598f6603c60Sopenharmony_ci 599f6603c60Sopenharmony_ci OH_Drawing_Font *font = OH_Drawing_FontCreate(); 600f6603c60Sopenharmony_ci OH_Drawing_TextBlob *textBlob = 601f6603c60Sopenharmony_ci OH_Drawing_TextBlobCreateFromText(str, strlen(str), font, OH_Drawing_TextEncoding::TEXT_ENCODING_UTF8); 602f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasDrawTextBlob 603f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawTextBlob(canvas, textBlob, 10, 10); 604f6603c60Sopenharmony_ci // 4. Free memory 605f6603c60Sopenharmony_ci OH_Drawing_TextBlobDestroy(textBlob); 606f6603c60Sopenharmony_ci 607f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 608f6603c60Sopenharmony_ci} 609f6603c60Sopenharmony_ci 610f6603c60Sopenharmony_ci/* 611f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2201 612f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawTextBlobNull 613f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawTextBlobNull. 614f6603c60Sopenharmony_ci * @tc.size : SmallTest 615f6603c60Sopenharmony_ci * @tc.type : Function 616f6603c60Sopenharmony_ci * @tc.level : Level 3 617f6603c60Sopenharmony_ci */ 618f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawTextBlobNull, TestSize.Level3) { 619f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 620f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 621f6603c60Sopenharmony_ci // 2. OH_Drawing_TextBlobCreateFromString 622f6603c60Sopenharmony_ci const char *str = "123456"; 623f6603c60Sopenharmony_ci 624f6603c60Sopenharmony_ci OH_Drawing_Font *font = OH_Drawing_FontCreate(); 625f6603c60Sopenharmony_ci OH_Drawing_TextBlob *textBlob = 626f6603c60Sopenharmony_ci OH_Drawing_TextBlobCreateFromText(str, strlen(str), font, OH_Drawing_TextEncoding::TEXT_ENCODING_UTF8); 627f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasDrawTextBlob with the first parameter being nullptr 628f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawTextBlob(nullptr, textBlob, 10, 10); 629f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasDrawTextBlob with the second parameter being nullptr 630f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawTextBlob(canvas, nullptr, 10, 10); 631f6603c60Sopenharmony_ci // 5. OH_Drawing_CanvasDrawTextBlob with the third parameter being 0 632f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawTextBlob(canvas, textBlob, 0, 10); 633f6603c60Sopenharmony_ci // 6. OH_Drawing_CanvasDrawTextBlob with the fourth parameter being 0 634f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawTextBlob(canvas, textBlob, 10, 0); 635f6603c60Sopenharmony_ci // 7. Free memory 636f6603c60Sopenharmony_ci OH_Drawing_TextBlobDestroy(textBlob); 637f6603c60Sopenharmony_ci 638f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 639f6603c60Sopenharmony_ci} 640f6603c60Sopenharmony_ci 641f6603c60Sopenharmony_ci/* 642f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2202 643f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawTextBlobAbnormal 644f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawTextBlobAbnormal. 645f6603c60Sopenharmony_ci * @tc.size : SmallTest 646f6603c60Sopenharmony_ci * @tc.type : Function 647f6603c60Sopenharmony_ci * @tc.level : Level 3 648f6603c60Sopenharmony_ci */ 649f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawTextBlobAbnormal, TestSize.Level3) { 650f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 651f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 652f6603c60Sopenharmony_ci // 2. Create OH_Drawing_TextBlob from text 653f6603c60Sopenharmony_ci const char *str = "123456"; 654f6603c60Sopenharmony_ci OH_Drawing_Font *font = OH_Drawing_FontCreate(); 655f6603c60Sopenharmony_ci OH_Drawing_TextBlob *textBlob = 656f6603c60Sopenharmony_ci OH_Drawing_TextBlobCreateFromText(str, strlen(str), font, OH_Drawing_TextEncoding::TEXT_ENCODING_UTF8); 657f6603c60Sopenharmony_ci // 3. Draw OH_Drawing_TextBlob on canvas with x-coordinate of the bottom left corner of the text object set to a 658f6603c60Sopenharmony_ci // negative value 659f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawTextBlob(canvas, textBlob, -10, 10); 660f6603c60Sopenharmony_ci // 4. Draw OH_Drawing_TextBlob on canvas with y-coordinate of the bottom left corner of the text object set to a 661f6603c60Sopenharmony_ci // negative value 662f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawTextBlob(canvas, textBlob, 10, -10); 663f6603c60Sopenharmony_ci // 5. Release memory 664f6603c60Sopenharmony_ci OH_Drawing_TextBlobDestroy(textBlob); 665f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 666f6603c60Sopenharmony_ci} 667f6603c60Sopenharmony_ci 668f6603c60Sopenharmony_ci/* 669f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2203 670f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawTextBlobMaximum 671f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawTextBlobMaximum. 672f6603c60Sopenharmony_ci * @tc.size : SmallTest 673f6603c60Sopenharmony_ci * @tc.type : Function 674f6603c60Sopenharmony_ci * @tc.level : Level 3 675f6603c60Sopenharmony_ci */ 676f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawTextBlobMaximum, TestSize.Level3) { 677f6603c60Sopenharmony_ci // 1. Create OH_Drawing_Canvas 678f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 679f6603c60Sopenharmony_ci // 2. Create OH_Drawing_TextBlob from text 680f6603c60Sopenharmony_ci const char *str = "123456"; 681f6603c60Sopenharmony_ci OH_Drawing_Font *font = OH_Drawing_FontCreate(); 682f6603c60Sopenharmony_ci OH_Drawing_TextBlob *textBlob = 683f6603c60Sopenharmony_ci OH_Drawing_TextBlobCreateFromText(str, strlen(str), font, OH_Drawing_TextEncoding::TEXT_ENCODING_UTF8); 684f6603c60Sopenharmony_ci // 3. Draw OH_Drawing_TextBlob on canvas with x-coordinate of the bottom left corner of the text object set to 685f6603c60Sopenharmony_ci // maximum value 686f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawTextBlob(canvas, textBlob, FLT_MAX, 10); 687f6603c60Sopenharmony_ci // 4. Draw OH_Drawing_TextBlob on canvas with y-coordinate of the bottom left corner of the text object set to 688f6603c60Sopenharmony_ci // maximum value 689f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawTextBlob(canvas, textBlob, 10, FLT_MAX); 690f6603c60Sopenharmony_ci // 5. Release memory 691f6603c60Sopenharmony_ci OH_Drawing_TextBlobDestroy(textBlob); 692f6603c60Sopenharmony_ci // 5. Release memory 693f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 694f6603c60Sopenharmony_ci} 695f6603c60Sopenharmony_ci 696f6603c60Sopenharmony_ci/* 697f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2204 698f6603c60Sopenharmony_ci * @tc.name: testCanvasDrawTextBlobInputDestroyed 699f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasDrawTextBlobInputDestroyed. 700f6603c60Sopenharmony_ci * @tc.size : SmallTest 701f6603c60Sopenharmony_ci * @tc.type : Function 702f6603c60Sopenharmony_ci * @tc.level : Level 3 703f6603c60Sopenharmony_ci */ 704f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasDrawTextBlobInputDestroyed, TestSize.Level3) { 705f6603c60Sopenharmony_ci // Deprecated 706f6603c60Sopenharmony_ci} 707f6603c60Sopenharmony_ci 708f6603c60Sopenharmony_ci/* 709f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2300 710f6603c60Sopenharmony_ci * @tc.name: testCanvasClipRectNormal 711f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipRectNormal. 712f6603c60Sopenharmony_ci * @tc.size : SmallTest 713f6603c60Sopenharmony_ci * @tc.type : Function 714f6603c60Sopenharmony_ci * @tc.level : Level 0 715f6603c60Sopenharmony_ci */ 716f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipRectNormal, TestSize.Level0) { 717f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 718f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 719f6603c60Sopenharmony_ci // 2. OH_Drawing_RectCreate 720f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(10, 10, 100, 100); 721f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasClipRect with clipOp and doAntiAlias parameters, iterate through enum values 722f6603c60Sopenharmony_ci OH_Drawing_CanvasClipOp clipOp[] = {OH_Drawing_CanvasClipOp::DIFFERENCE, OH_Drawing_CanvasClipOp::INTERSECT}; 723f6603c60Sopenharmony_ci bool doAntiAlias[] = {true, false}; 724f6603c60Sopenharmony_ci for (int i = 0; i < 2; i++) { 725f6603c60Sopenharmony_ci for (int j = 0; j < 2; j++) { 726f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect, clipOp[i], doAntiAlias[j]); 727f6603c60Sopenharmony_ci } 728f6603c60Sopenharmony_ci } 729f6603c60Sopenharmony_ci // 4. Free memory 730f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 731f6603c60Sopenharmony_ci} 732f6603c60Sopenharmony_ci 733f6603c60Sopenharmony_ci/* 734f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2301 735f6603c60Sopenharmony_ci * @tc.name: testCanvasClipRectNull 736f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipRectNull. 737f6603c60Sopenharmony_ci * @tc.size : SmallTest 738f6603c60Sopenharmony_ci * @tc.type : Function 739f6603c60Sopenharmony_ci * @tc.level : Level 3 740f6603c60Sopenharmony_ci */ 741f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipRectNull, TestSize.Level3) { 742f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 743f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 744f6603c60Sopenharmony_ci // 2. OH_Drawing_RectCreate 745f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(10, 10, 100, 100); 746f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasClipRect with the first parameter being nullptr 747f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(nullptr, rect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 748f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasClipRect with the second parameter OH_Drawing_Rect created with left, top, right, and bottom 749f6603c60Sopenharmony_ci // values being 0 750f6603c60Sopenharmony_ci OH_Drawing_Rect *rect2 = OH_Drawing_RectCreate(0, 10, 100, 100); 751f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect2, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 752f6603c60Sopenharmony_ci rect2 = OH_Drawing_RectCreate(10, 0, 100, 100); 753f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect2, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 754f6603c60Sopenharmony_ci rect2 = OH_Drawing_RectCreate(10, 10, 0, 100); 755f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect2, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 756f6603c60Sopenharmony_ci rect2 = OH_Drawing_RectCreate(10, 10, 100, 0); 757f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect2, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 758f6603c60Sopenharmony_ci // 5. OH_Drawing_CanvasClipRect with the second parameter OH_Drawing_Rect created with all values being 0 759f6603c60Sopenharmony_ci OH_Drawing_Rect *rect3 = OH_Drawing_RectCreate(0, 0, 0, 0); 760f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect3, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 761f6603c60Sopenharmony_ci // 6. OH_Drawing_CanvasClipRect with the second parameter being nullptr 762f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, nullptr, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 763f6603c60Sopenharmony_ci // 7. Free memory 764f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 765f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 766f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect2); 767f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect3); 768f6603c60Sopenharmony_ci} 769f6603c60Sopenharmony_ci 770f6603c60Sopenharmony_ci/* 771f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2302 772f6603c60Sopenharmony_ci * @tc.name: testCanvasClipRectAbnormal 773f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipRectAbnormal. 774f6603c60Sopenharmony_ci * @tc.size : SmallTest 775f6603c60Sopenharmony_ci * @tc.type : Function 776f6603c60Sopenharmony_ci * @tc.level : Level 3 777f6603c60Sopenharmony_ci */ 778f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipRectAbnormal, TestSize.Level3) { 779f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 780f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 781f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasClipRect with OH_Drawing_Rect created with negative values for left, top, right, and bottom 782f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(-10, 10, 100, 100); 783f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 784f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, -10, 100, 100); 785f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 786f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 10, -100, 100); 787f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 788f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 10, 100, -100); 789f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 790f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasClipRect with OH_Drawing_Rect created where the x-coordinate of the top-left corner is equal 791f6603c60Sopenharmony_ci // to the x-coordinate of the bottom-right corner, or the y-coordinate of the top-left corner is equal to the 792f6603c60Sopenharmony_ci // y-coordinate of the bottom-right corner 793f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(100, 10, 100, 100); 794f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 795f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 100, 100, 100); 796f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 797f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasClipRect with OH_Drawing_Rect created where the top-left corner coordinates are equal to the 798f6603c60Sopenharmony_ci // bottom-right corner coordinates 799f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(100, 100, 100, 100); 800f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 801f6603c60Sopenharmony_ci // 5. OH_Drawing_CanvasClipRect with OH_Drawing_Rect created where the top-left corner coordinates are greater than 802f6603c60Sopenharmony_ci // the bottom-right corner coordinates 803f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(200, 200, 100, 100); 804f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 805f6603c60Sopenharmony_ci // 6. Release memory 806f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 807f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 808f6603c60Sopenharmony_ci} 809f6603c60Sopenharmony_ci 810f6603c60Sopenharmony_ci/* 811f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2303 812f6603c60Sopenharmony_ci * @tc.name: testCanvasClipRectMaximum 813f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipRectMaximum. 814f6603c60Sopenharmony_ci * @tc.size : SmallTest 815f6603c60Sopenharmony_ci * @tc.type : Function 816f6603c60Sopenharmony_ci * @tc.level : Level 3 817f6603c60Sopenharmony_ci */ 818f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipRectMaximum, TestSize.Level3) { 819f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 820f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 821f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasClipRect with OH_Drawing_Rect created with extreme values for left, top, right, and bottom 822f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(FLT_MAX, 10, 100, 100); 823f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 824f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, FLT_MAX, 100, 100); 825f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 826f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 10, FLT_MAX, 100); 827f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 828f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 10, 100, FLT_MAX); 829f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRect(canvas, rect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 830f6603c60Sopenharmony_ci // 3. Release memory 831f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 832f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 833f6603c60Sopenharmony_ci} 834f6603c60Sopenharmony_ci 835f6603c60Sopenharmony_ci/* 836f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2304 837f6603c60Sopenharmony_ci * @tc.name: testCanvasClipRectInputDestroyed 838f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipRectInputDestroyed. 839f6603c60Sopenharmony_ci * @tc.size : SmallTest 840f6603c60Sopenharmony_ci * @tc.type : Function 841f6603c60Sopenharmony_ci * @tc.level : Level 3 842f6603c60Sopenharmony_ci */ 843f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipRectInputDestroyed, TestSize.Level3) { 844f6603c60Sopenharmony_ci // Deprecated 845f6603c60Sopenharmony_ci} 846f6603c60Sopenharmony_ci 847f6603c60Sopenharmony_ci/* 848f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2400 849f6603c60Sopenharmony_ci * @tc.name: testCanvasClipRoundRectNormal 850f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipRoundRectNormal. 851f6603c60Sopenharmony_ci * @tc.size : SmallTest 852f6603c60Sopenharmony_ci * @tc.type : Function 853f6603c60Sopenharmony_ci * @tc.level : Level 0 854f6603c60Sopenharmony_ci */ 855f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipRoundRectNormal, TestSize.Level0) { 856f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 857f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 858f6603c60Sopenharmony_ci // 2. OH_Drawing_RoundRectCreate 859f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(10, 10, 100, 100); 860f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rect, 10, 10); 861f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasClipRoundRect with parameters clipOp and doAntiAlias, iterate through the enumeration values 862f6603c60Sopenharmony_ci OH_Drawing_CanvasClipOp clipOp[] = {OH_Drawing_CanvasClipOp::DIFFERENCE, OH_Drawing_CanvasClipOp::INTERSECT}; 863f6603c60Sopenharmony_ci bool doAntiAlias[] = {true, false}; 864f6603c60Sopenharmony_ci for (int i = 0; i < 2; i++) { 865f6603c60Sopenharmony_ci for (int j = 0; j < 2; j++) { 866f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, clipOp[i], doAntiAlias[j]); 867f6603c60Sopenharmony_ci } 868f6603c60Sopenharmony_ci } 869f6603c60Sopenharmony_ci // 4. Free memory 870f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 871f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 872f6603c60Sopenharmony_ci} 873f6603c60Sopenharmony_ci 874f6603c60Sopenharmony_ci/* 875f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2401 876f6603c60Sopenharmony_ci * @tc.name: testCanvasClipRoundRectNull 877f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipRoundRectNull. 878f6603c60Sopenharmony_ci * @tc.size : SmallTest 879f6603c60Sopenharmony_ci * @tc.type : Function 880f6603c60Sopenharmony_ci * @tc.level : Level 3 881f6603c60Sopenharmony_ci */ 882f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipRoundRectNull, TestSize.Level3) { 883f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 884f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 885f6603c60Sopenharmony_ci // 2. OH_Drawing_RoundRectCreate 886f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(10, 10, 100, 100); 887f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rect, 10, 10); 888f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasClipRoundRect with the first parameter being null 889f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(nullptr, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 890f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasClipRoundRect with the second parameter being null 891f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, nullptr, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 892f6603c60Sopenharmony_ci // 5. OH_Drawing_CanvasClipRoundRect with the second parameter OH_Drawing_RoundRectCreate created with rect's left, 893f6603c60Sopenharmony_ci // top, right, and bottom values all set to 0 894f6603c60Sopenharmony_ci OH_Drawing_Rect *rect2 = OH_Drawing_RectCreate(0, 10, 100, 100); 895f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect2 = OH_Drawing_RoundRectCreate(rect2, 10, 10); 896f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect2, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 897f6603c60Sopenharmony_ci rect2 = OH_Drawing_RectCreate(10, 0, 100, 100); 898f6603c60Sopenharmony_ci roundRect2 = OH_Drawing_RoundRectCreate(rect2, 10, 10); 899f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect2, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 900f6603c60Sopenharmony_ci rect2 = OH_Drawing_RectCreate(10, 10, 0, 100); 901f6603c60Sopenharmony_ci roundRect2 = OH_Drawing_RoundRectCreate(rect2, 10, 10); 902f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect2, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 903f6603c60Sopenharmony_ci rect2 = OH_Drawing_RectCreate(10, 10, 100, 0); 904f6603c60Sopenharmony_ci roundRect2 = OH_Drawing_RoundRectCreate(rect2, 10, 10); 905f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect2, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 906f6603c60Sopenharmony_ci // 6. OH_Drawing_CanvasClipRoundRect with the second parameter OH_Drawing_RoundRectCreate created with all rect's 907f6603c60Sopenharmony_ci // left, top, right, and bottom values set to 0 908f6603c60Sopenharmony_ci rect2 = OH_Drawing_RectCreate(0, 0, 0, 0); 909f6603c60Sopenharmony_ci roundRect2 = OH_Drawing_RoundRectCreate(rect2, 10, 10); 910f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect2, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 911f6603c60Sopenharmony_ci // 7. OH_Drawing_CanvasClipRoundRect with the second parameter OH_Drawing_RoundRectCreate created with xRad set to 0 912f6603c60Sopenharmony_ci rect2 = OH_Drawing_RectCreate(10, 10, 100, 100); 913f6603c60Sopenharmony_ci roundRect2 = OH_Drawing_RoundRectCreate(rect2, 0, 10); 914f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect2, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 915f6603c60Sopenharmony_ci // 8. OH_Drawing_CanvasClipRoundRect with the second parameter OH_Drawing_RoundRectCreate created with yRad set to 0 916f6603c60Sopenharmony_ci rect2 = OH_Drawing_RectCreate(10, 10, 100, 100); 917f6603c60Sopenharmony_ci roundRect2 = OH_Drawing_RoundRectCreate(rect2, 10, 0); 918f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect2, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 919f6603c60Sopenharmony_ci // 9. Release memory 920f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 921f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 922f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect2); 923f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect); 924f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect2); 925f6603c60Sopenharmony_ci} 926f6603c60Sopenharmony_ci 927f6603c60Sopenharmony_ci/* 928f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2402 929f6603c60Sopenharmony_ci * @tc.name: testCanvasClipRoundRectAbnormal 930f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipRoundRectAbnormal. 931f6603c60Sopenharmony_ci * @tc.size : SmallTest 932f6603c60Sopenharmony_ci * @tc.type : Function 933f6603c60Sopenharmony_ci * @tc.level : Level 3 934f6603c60Sopenharmony_ci */ 935f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipRoundRectAbnormal, TestSize.Level3) { 936f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 937f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 938f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasClipRoundRect, pass negative values for left, top, right, and bottom when creating 939f6603c60Sopenharmony_ci // OH_Drawing_RoundRect 940f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(-10, 10, 100, 100); 941f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rect, 10, 10); 942f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 943f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, -10, 100, 100); 944f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 10, 10); 945f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 946f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 10, -100, 100); 947f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 10, 10); 948f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 949f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 10, 100, -100); 950f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 10, 10); 951f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 952f6603c60Sopenharmony_ci 953f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasClipRoundRect, pass OH_Drawing_RoundRect with left-top coordinates equal to right-bottom 954f6603c60Sopenharmony_ci // coordinates 955f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(100, 10, 100, 100); 956f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 10, 10); 957f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 958f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 100, 100, 100); 959f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 10, 10); 960f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 961f6603c60Sopenharmony_ci 962f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasClipRoundRect, pass OH_Drawing_RoundRect with left-top coordinates equal to right-bottom 963f6603c60Sopenharmony_ci // coordinates 964f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(100, 100, 100, 100); 965f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 10, 10); 966f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 967f6603c60Sopenharmony_ci 968f6603c60Sopenharmony_ci // 5. OH_Drawing_CanvasClipRoundRect, pass OH_Drawing_RoundRect with left-top coordinates greater than right-bottom 969f6603c60Sopenharmony_ci // coordinates 970f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(200, 200, 100, 100); 971f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 10, 10); 972f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 973f6603c60Sopenharmony_ci 974f6603c60Sopenharmony_ci // 6. OH_Drawing_CanvasClipRoundRect, pass OH_Drawing_RoundRect with negative xRad 975f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 10, 100, 100); 976f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, -10, 10); 977f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 978f6603c60Sopenharmony_ci 979f6603c60Sopenharmony_ci // 7. OH_Drawing_CanvasClipRoundRect, pass OH_Drawing_RoundRect with negative yRad 980f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 10, 100, 100); 981f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 10, -10); 982f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 983f6603c60Sopenharmony_ci 984f6603c60Sopenharmony_ci // 8. Release memory 985f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 986f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 987f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect); 988f6603c60Sopenharmony_ci} 989f6603c60Sopenharmony_ci 990f6603c60Sopenharmony_ci/* 991f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2403 992f6603c60Sopenharmony_ci * @tc.name: testCanvasClipRoundRectMaximum 993f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipRoundRectMaximum. 994f6603c60Sopenharmony_ci * @tc.size : SmallTest 995f6603c60Sopenharmony_ci * @tc.type : Function 996f6603c60Sopenharmony_ci * @tc.level : Level 3 997f6603c60Sopenharmony_ci */ 998f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipRoundRectMaximum, TestSize.Level3) { 999f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 1000f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1001f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasClipRoundRect, pass extreme values for left, top, right, and bottom when creating 1002f6603c60Sopenharmony_ci // OH_Drawing_RoundRect 1003f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(FLT_MAX, 10, 100, 100); 1004f6603c60Sopenharmony_ci OH_Drawing_RoundRect *roundRect = OH_Drawing_RoundRectCreate(rect, 10, 10); 1005f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 1006f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, FLT_MAX, 100, 100); 1007f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 10, 10); 1008f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 1009f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 10, FLT_MAX, 100); 1010f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 10, 10); 1011f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 1012f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 10, 100, FLT_MAX); 1013f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 10, 10); 1014f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 1015f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasClipRoundRect, pass FLT_MAX for xRad when creating OH_Drawing_RoundRect 1016f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 10, 100, 100); 1017f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, FLT_MAX, 10); 1018f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 1019f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasClipRoundRect, pass FLT_MAX for yRad when creating OH_Drawing_RoundRect 1020f6603c60Sopenharmony_ci rect = OH_Drawing_RectCreate(10, 10, 100, 100); 1021f6603c60Sopenharmony_ci roundRect = OH_Drawing_RoundRectCreate(rect, 10, FLT_MAX); 1022f6603c60Sopenharmony_ci OH_Drawing_CanvasClipRoundRect(canvas, roundRect, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 1023f6603c60Sopenharmony_ci // 5. Free memory 1024f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1025f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1026f6603c60Sopenharmony_ci OH_Drawing_RoundRectDestroy(roundRect); 1027f6603c60Sopenharmony_ci} 1028f6603c60Sopenharmony_ci 1029f6603c60Sopenharmony_ci/* 1030f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2404 1031f6603c60Sopenharmony_ci * @tc.name: testCanvasClipRoundRectInputDestroyed 1032f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipRoundRectInputDestroyed. 1033f6603c60Sopenharmony_ci * @tc.size : SmallTest 1034f6603c60Sopenharmony_ci * @tc.type : Function 1035f6603c60Sopenharmony_ci * @tc.level : Level 3 1036f6603c60Sopenharmony_ci */ 1037f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipRoundRectInputDestroyed, TestSize.Level3) { 1038f6603c60Sopenharmony_ci // Deprecated 1039f6603c60Sopenharmony_ci} 1040f6603c60Sopenharmony_ci 1041f6603c60Sopenharmony_ci/* 1042f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2500 1043f6603c60Sopenharmony_ci * @tc.name: testCanvasClipPathNormal 1044f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipPathNormal. 1045f6603c60Sopenharmony_ci * @tc.size : SmallTest 1046f6603c60Sopenharmony_ci * @tc.type : Function 1047f6603c60Sopenharmony_ci * @tc.level : Level 0 1048f6603c60Sopenharmony_ci */ 1049f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipPathNormal, TestSize.Level0) { 1050f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 1051f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1052f6603c60Sopenharmony_ci // 2. OH_Drawing_PathCreate 1053f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1054f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1055f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 0); 1056f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1057f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 0, 100); 1058f6603c60Sopenharmony_ci OH_Drawing_PathClose(path); 1059f6603c60Sopenharmony_ci // 3. OH_Drawing_PathAddRect 1060f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, 10, 10, 100, 100, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1061f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasClipPath 1062f6603c60Sopenharmony_ci OH_Drawing_CanvasClipOp clipOp[] = {OH_Drawing_CanvasClipOp::DIFFERENCE, OH_Drawing_CanvasClipOp::INTERSECT}; 1063f6603c60Sopenharmony_ci bool doAntiAlias[] = {true, false}; 1064f6603c60Sopenharmony_ci for (int i = 0; i < 2; i++) { 1065f6603c60Sopenharmony_ci for (int j = 0; j < 2; j++) { 1066f6603c60Sopenharmony_ci OH_Drawing_CanvasClipPath(canvas, path, clipOp[i], doAntiAlias[j]); 1067f6603c60Sopenharmony_ci } 1068f6603c60Sopenharmony_ci } 1069f6603c60Sopenharmony_ci // 5. Free memory 1070f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1071f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1072f6603c60Sopenharmony_ci} 1073f6603c60Sopenharmony_ci 1074f6603c60Sopenharmony_ci/* 1075f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2501 1076f6603c60Sopenharmony_ci * @tc.name: testCanvasClipPathNull 1077f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipPathNull. 1078f6603c60Sopenharmony_ci * @tc.size : SmallTest 1079f6603c60Sopenharmony_ci * @tc.type : Function 1080f6603c60Sopenharmony_ci * @tc.level : Level 3 1081f6603c60Sopenharmony_ci */ 1082f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipPathNull, TestSize.Level3) { 1083f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 1084f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1085f6603c60Sopenharmony_ci // 2. OH_Drawing_PathCreate 1086f6603c60Sopenharmony_ci OH_Drawing_Path *path = OH_Drawing_PathCreate(); 1087f6603c60Sopenharmony_ci OH_Drawing_PathMoveTo(path, 0, 0); 1088f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 0); 1089f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 100, 100); 1090f6603c60Sopenharmony_ci OH_Drawing_PathLineTo(path, 0, 100); 1091f6603c60Sopenharmony_ci OH_Drawing_PathClose(path); 1092f6603c60Sopenharmony_ci // 3. OH_Drawing_PathAddRect 1093f6603c60Sopenharmony_ci OH_Drawing_PathAddRect(path, 10, 10, 100, 100, OH_Drawing_PathDirection::PATH_DIRECTION_CW); 1094f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasClipPath with the first parameter being null 1095f6603c60Sopenharmony_ci OH_Drawing_CanvasClipPath(nullptr, path, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 1096f6603c60Sopenharmony_ci // 5. OH_Drawing_CanvasClipPath with the second parameter being null 1097f6603c60Sopenharmony_ci OH_Drawing_CanvasClipPath(canvas, nullptr, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 1098f6603c60Sopenharmony_ci // 6. OH_Drawing_CanvasClipPath with the second parameter being an empty path 1099f6603c60Sopenharmony_ci OH_Drawing_Path *path2 = OH_Drawing_PathCreate(); 1100f6603c60Sopenharmony_ci OH_Drawing_CanvasClipPath(canvas, path2, OH_Drawing_CanvasClipOp::DIFFERENCE, true); 1101f6603c60Sopenharmony_ci // 7. Free memory 1102f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path); 1103f6603c60Sopenharmony_ci OH_Drawing_PathDestroy(path2); 1104f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1105f6603c60Sopenharmony_ci} 1106f6603c60Sopenharmony_ci 1107f6603c60Sopenharmony_ci/* 1108f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2502 1109f6603c60Sopenharmony_ci * @tc.name: testCanvasClipPathInputDestroyed 1110f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasClipPathInputDestroyed. 1111f6603c60Sopenharmony_ci * @tc.size : SmallTest 1112f6603c60Sopenharmony_ci * @tc.type : Function 1113f6603c60Sopenharmony_ci * @tc.level : Level 3 1114f6603c60Sopenharmony_ci */ 1115f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasClipPathInputDestroyed, TestSize.Level3) { 1116f6603c60Sopenharmony_ci // Deprecated 1117f6603c60Sopenharmony_ci} 1118f6603c60Sopenharmony_ci 1119f6603c60Sopenharmony_ci/* 1120f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2600 1121f6603c60Sopenharmony_ci * @tc.name: testCanvasRotateNormal 1122f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasRotateNormal. 1123f6603c60Sopenharmony_ci * @tc.size : SmallTest 1124f6603c60Sopenharmony_ci * @tc.type : Function 1125f6603c60Sopenharmony_ci * @tc.level : Level 0 1126f6603c60Sopenharmony_ci */ 1127f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasRotateNormal, TestSize.Level0) { 1128f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 1129f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1130f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasRotate, rotate degrees with values 0, 180, 360 1131f6603c60Sopenharmony_ci float degrees[] = {0, 180, 360}; 1132f6603c60Sopenharmony_ci for (int i = 0; i < 3; i++) { 1133f6603c60Sopenharmony_ci OH_Drawing_CanvasRotate(canvas, degrees[i], 10, 10); 1134f6603c60Sopenharmony_ci } 1135f6603c60Sopenharmony_ci // 3. Call drawing class interface to draw a rectangle 1136f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(10, 10, 100, 100); 1137f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRect(canvas, rect); 1138f6603c60Sopenharmony_ci // 4. Free memory 1139f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1140f6603c60Sopenharmony_ci} 1141f6603c60Sopenharmony_ci 1142f6603c60Sopenharmony_ci/* 1143f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2601 1144f6603c60Sopenharmony_ci * @tc.name: testCanvasRotateNull 1145f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasRotateNull. 1146f6603c60Sopenharmony_ci * @tc.size : SmallTest 1147f6603c60Sopenharmony_ci * @tc.type : Function 1148f6603c60Sopenharmony_ci * @tc.level : Level 3 1149f6603c60Sopenharmony_ci */ 1150f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasRotateNull, TestSize.Level3) { 1151f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 1152f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1153f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasRotate with the first parameter being null 1154f6603c60Sopenharmony_ci OH_Drawing_CanvasRotate(nullptr, 0, 10, 10); 1155f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasRotate with the third parameter being 0 1156f6603c60Sopenharmony_ci OH_Drawing_CanvasRotate(canvas, 0, 0, 10); 1157f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasRotate with the fourth parameter being 0 1158f6603c60Sopenharmony_ci OH_Drawing_CanvasRotate(canvas, 0, 10, 0); 1159f6603c60Sopenharmony_ci // 5. Free memory 1160f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1161f6603c60Sopenharmony_ci} 1162f6603c60Sopenharmony_ci 1163f6603c60Sopenharmony_ci/* 1164f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2602 1165f6603c60Sopenharmony_ci * @tc.name: testCanvasRotateAbnormal 1166f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasRotateAbnormal. 1167f6603c60Sopenharmony_ci * @tc.size : SmallTest 1168f6603c60Sopenharmony_ci * @tc.type : Function 1169f6603c60Sopenharmony_ci * @tc.level : Level 3 1170f6603c60Sopenharmony_ci */ 1171f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasRotateAbnormal, TestSize.Level3) { 1172f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 1173f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1174f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasRotate with negative degrees input 1175f6603c60Sopenharmony_ci OH_Drawing_CanvasRotate(canvas, -180, 10, 10); 1176f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasRotate with degrees input greater than 360 1177f6603c60Sopenharmony_ci OH_Drawing_CanvasRotate(canvas, 370, 10, 10); 1178f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasRotate with negative px input for rotation center 1179f6603c60Sopenharmony_ci OH_Drawing_CanvasRotate(canvas, 180, -10, 10); 1180f6603c60Sopenharmony_ci // 5. OH_Drawing_CanvasRotate with negative py input for rotation center 1181f6603c60Sopenharmony_ci OH_Drawing_CanvasRotate(canvas, 180, 10, -10); 1182f6603c60Sopenharmony_ci // 6. Free memory 1183f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1184f6603c60Sopenharmony_ci} 1185f6603c60Sopenharmony_ci 1186f6603c60Sopenharmony_ci/* 1187f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2603 1188f6603c60Sopenharmony_ci * @tc.name: testCanvasRotateMaximum 1189f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasRotateMaximum. 1190f6603c60Sopenharmony_ci * @tc.size : SmallTest 1191f6603c60Sopenharmony_ci * @tc.type : Function 1192f6603c60Sopenharmony_ci * @tc.level : Level 3 1193f6603c60Sopenharmony_ci */ 1194f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasRotateMaximum, TestSize.Level3) { 1195f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 1196f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1197f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasRotate with maximum rotation angle degrees input 1198f6603c60Sopenharmony_ci OH_Drawing_CanvasRotate(canvas, FLT_MAX, 10, 10); 1199f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasRotate with maximum x-coordinate px input for rotation center 1200f6603c60Sopenharmony_ci OH_Drawing_CanvasRotate(canvas, 180, FLT_MAX, 10); 1201f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasRotate with maximum y-coordinate py input for rotation center 1202f6603c60Sopenharmony_ci OH_Drawing_CanvasRotate(canvas, 180, 10, FLT_MAX); 1203f6603c60Sopenharmony_ci // 5. Free memory 1204f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1205f6603c60Sopenharmony_ci} 1206f6603c60Sopenharmony_ci 1207f6603c60Sopenharmony_ci/* 1208f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2604 1209f6603c60Sopenharmony_ci * @tc.name: testCanvasRotateInputDestroyed 1210f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasRotateInputDestroyed. 1211f6603c60Sopenharmony_ci * @tc.size : SmallTest 1212f6603c60Sopenharmony_ci * @tc.type : Function 1213f6603c60Sopenharmony_ci * @tc.level : Level 3 1214f6603c60Sopenharmony_ci */ 1215f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasRotateInputDestroyed, TestSize.Level3) { 1216f6603c60Sopenharmony_ci // Deprecated 1217f6603c60Sopenharmony_ci} 1218f6603c60Sopenharmony_ci 1219f6603c60Sopenharmony_ci/* 1220f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2605 1221f6603c60Sopenharmony_ci * @tc.name: testCanvasRotateMultipleCalls 1222f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasRotateMultipleCalls. 1223f6603c60Sopenharmony_ci * @tc.size : SmallTest 1224f6603c60Sopenharmony_ci * @tc.type : Function 1225f6603c60Sopenharmony_ci * @tc.level : Level 3 1226f6603c60Sopenharmony_ci */ 1227f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasRotateMultipleCalls, TestSize.Level3) { 1228f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 1229f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1230f6603c60Sopenharmony_ci // 2. Call OH_Drawing_CanvasRotate 10 times, each time with different rotation angles and rotation center 1231f6603c60Sopenharmony_ci // coordinates 1232f6603c60Sopenharmony_ci for (int i = 0; i < 10; i++) { 1233f6603c60Sopenharmony_ci OH_Drawing_CanvasRotate(canvas, i * 10, i * 10, i * 10); 1234f6603c60Sopenharmony_ci // 3. Call drawing class interface 1235f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(10, 10, 100, 100); 1236f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRect(canvas, rect); 1237f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1238f6603c60Sopenharmony_ci } 1239f6603c60Sopenharmony_ci // 4. Free memory 1240f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1241f6603c60Sopenharmony_ci} 1242f6603c60Sopenharmony_ci 1243f6603c60Sopenharmony_ci/* 1244f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2700 1245f6603c60Sopenharmony_ci * @tc.name: testCanvasTranslateNormal 1246f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasTranslateNormal. 1247f6603c60Sopenharmony_ci * @tc.size : SmallTest 1248f6603c60Sopenharmony_ci * @tc.type : Function 1249f6603c60Sopenharmony_ci * @tc.level : Level 0 1250f6603c60Sopenharmony_ci */ 1251f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasTranslateNormal, TestSize.Level0) { 1252f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 1253f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1254f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasTranslate 1255f6603c60Sopenharmony_ci OH_Drawing_CanvasTranslate(canvas, 10, 10); 1256f6603c60Sopenharmony_ci // 3. Call drawing class interface to draw a rectangle 1257f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(10, 10, 100, 100); 1258f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRect(canvas, rect); 1259f6603c60Sopenharmony_ci // 4. Free memory 1260f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1261f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1262f6603c60Sopenharmony_ci} 1263f6603c60Sopenharmony_ci 1264f6603c60Sopenharmony_ci/* 1265f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2701 1266f6603c60Sopenharmony_ci * @tc.name: testCanvasTranslateNull 1267f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasTranslateNull. 1268f6603c60Sopenharmony_ci * @tc.size : SmallTest 1269f6603c60Sopenharmony_ci * @tc.type : Function 1270f6603c60Sopenharmony_ci * @tc.level : Level 3 1271f6603c60Sopenharmony_ci */ 1272f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasTranslateNull, TestSize.Level3) { 1273f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 1274f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1275f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasTranslate with the first parameter being null 1276f6603c60Sopenharmony_ci OH_Drawing_CanvasTranslate(nullptr, 10, 10); 1277f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasTranslate with the second parameter being 0 1278f6603c60Sopenharmony_ci OH_Drawing_CanvasTranslate(canvas, 0, 10); 1279f6603c60Sopenharmony_ci // 4. OH_Drawing_CanvasTranslate with the third parameter being 0 1280f6603c60Sopenharmony_ci OH_Drawing_CanvasTranslate(canvas, 10, 0); 1281f6603c60Sopenharmony_ci // 5. Free memory 1282f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1283f6603c60Sopenharmony_ci} 1284f6603c60Sopenharmony_ci 1285f6603c60Sopenharmony_ci/* 1286f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2702 1287f6603c60Sopenharmony_ci * @tc.name: testCanvasTranslateAbnormal 1288f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasTranslateAbnormal. 1289f6603c60Sopenharmony_ci * @tc.size : SmallTest 1290f6603c60Sopenharmony_ci * @tc.type : Function 1291f6603c60Sopenharmony_ci * @tc.level : Level 3 1292f6603c60Sopenharmony_ci */ 1293f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasTranslateAbnormal, TestSize.Level3) { 1294f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 1295f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1296f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasTranslate with negative movement distance dx in the x-axis direction 1297f6603c60Sopenharmony_ci OH_Drawing_CanvasTranslate(canvas, -10, 10); 1298f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasTranslate with negative movement distance dy in the y-axis direction 1299f6603c60Sopenharmony_ci OH_Drawing_CanvasTranslate(canvas, 10, -10); 1300f6603c60Sopenharmony_ci // 4. Free memory 1301f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1302f6603c60Sopenharmony_ci} 1303f6603c60Sopenharmony_ci 1304f6603c60Sopenharmony_ci/* 1305f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2703 1306f6603c60Sopenharmony_ci * @tc.name: testCanvasTranslateMaximum 1307f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasTranslateMaximum. 1308f6603c60Sopenharmony_ci * @tc.size : SmallTest 1309f6603c60Sopenharmony_ci * @tc.type : Function 1310f6603c60Sopenharmony_ci * @tc.level : Level 3 1311f6603c60Sopenharmony_ci */ 1312f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasTranslateMaximum, TestSize.Level3) { 1313f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 1314f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1315f6603c60Sopenharmony_ci // 2. OH_Drawing_CanvasTranslate with the movement distance dx in the x-axis direction being the maximum value 1316f6603c60Sopenharmony_ci OH_Drawing_CanvasTranslate(canvas, FLT_MAX, 10); 1317f6603c60Sopenharmony_ci // 3. OH_Drawing_CanvasTranslate with the movement distance dy in the y-axis direction being the maximum value 1318f6603c60Sopenharmony_ci OH_Drawing_CanvasTranslate(canvas, 10, FLT_MAX); 1319f6603c60Sopenharmony_ci // 4. Free memory 1320f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1321f6603c60Sopenharmony_ci} 1322f6603c60Sopenharmony_ci 1323f6603c60Sopenharmony_ci/* 1324f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2704 1325f6603c60Sopenharmony_ci * @tc.name: testCanvasTranslateInputDestroyed 1326f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasTranslateInputDestroyed. 1327f6603c60Sopenharmony_ci * @tc.size : SmallTest 1328f6603c60Sopenharmony_ci * @tc.type : Function 1329f6603c60Sopenharmony_ci * @tc.level : Level 3 1330f6603c60Sopenharmony_ci */ 1331f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasTranslateInputDestroyed, TestSize.Level3) { 1332f6603c60Sopenharmony_ci // Deprecated 1333f6603c60Sopenharmony_ci} 1334f6603c60Sopenharmony_ci 1335f6603c60Sopenharmony_ci/* 1336f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2705 1337f6603c60Sopenharmony_ci * @tc.name: testCanvasTranslateMultipleCalls 1338f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasTranslateMultipleCalls. 1339f6603c60Sopenharmony_ci * @tc.size : SmallTest 1340f6603c60Sopenharmony_ci * @tc.type : Function 1341f6603c60Sopenharmony_ci * @tc.level : Level 3 1342f6603c60Sopenharmony_ci */ 1343f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasTranslateMultipleCalls, TestSize.Level3) { 1344f6603c60Sopenharmony_ci // 1. OH_Drawing_CanvasCreate 1345f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1346f6603c60Sopenharmony_ci // 2. Call OH_Drawing_CanvasTranslate 10 times, each time with different movement distances 1347f6603c60Sopenharmony_ci for (int i = 0; i < 10; i++) { 1348f6603c60Sopenharmony_ci OH_Drawing_CanvasTranslate(canvas, i * 10, i * 10); 1349f6603c60Sopenharmony_ci // 3. Call drawing class interface 1350f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(10, 10, 100, 100); 1351f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRect(canvas, rect); 1352f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1353f6603c60Sopenharmony_ci } 1354f6603c60Sopenharmony_ci // 4. Free memory 1355f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1356f6603c60Sopenharmony_ci} 1357f6603c60Sopenharmony_ci 1358f6603c60Sopenharmony_ci/* 1359f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2800 1360f6603c60Sopenharmony_ci * @tc.name: testCanvasScaleNormal 1361f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasScaleNormal. 1362f6603c60Sopenharmony_ci * @tc.size : SmallTest 1363f6603c60Sopenharmony_ci * @tc.type : Function 1364f6603c60Sopenharmony_ci * @tc.level : Level 0 1365f6603c60Sopenharmony_ci */ 1366f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasScaleNormal, TestSize.Level0) { 1367f6603c60Sopenharmony_ci // 1. Create a canvas 1368f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1369f6603c60Sopenharmony_ci 1370f6603c60Sopenharmony_ci // 2. Scale the canvas 1371f6603c60Sopenharmony_ci OH_Drawing_CanvasScale(canvas, 2.0, 2.0); 1372f6603c60Sopenharmony_ci 1373f6603c60Sopenharmony_ci // 3. Call drawing class interface 1374f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(10, 10, 100, 100); 1375f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRect(canvas, rect); 1376f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1377f6603c60Sopenharmony_ci 1378f6603c60Sopenharmony_ci // 4. Free memory 1379f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1380f6603c60Sopenharmony_ci} 1381f6603c60Sopenharmony_ci 1382f6603c60Sopenharmony_ci/* 1383f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2801 1384f6603c60Sopenharmony_ci * @tc.name: testCanvasScaleNull 1385f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasScaleNull. 1386f6603c60Sopenharmony_ci * @tc.size : SmallTest 1387f6603c60Sopenharmony_ci * @tc.type : Function 1388f6603c60Sopenharmony_ci * @tc.level : Level 3 1389f6603c60Sopenharmony_ci */ 1390f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasScaleNull, TestSize.Level3) { 1391f6603c60Sopenharmony_ci // 1. Create a canvas 1392f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1393f6603c60Sopenharmony_ci 1394f6603c60Sopenharmony_ci // 2. Scale the canvas, with the first parameter being null 1395f6603c60Sopenharmony_ci OH_Drawing_CanvasScale(NULL, 2.0, 2.0); 1396f6603c60Sopenharmony_ci 1397f6603c60Sopenharmony_ci // 3. Scale the canvas, with the second parameter being 0 1398f6603c60Sopenharmony_ci OH_Drawing_CanvasScale(canvas, 0, 2.0); 1399f6603c60Sopenharmony_ci 1400f6603c60Sopenharmony_ci // 4. Scale the canvas, with the third parameter being 0 1401f6603c60Sopenharmony_ci OH_Drawing_CanvasScale(canvas, 2.0, 0); 1402f6603c60Sopenharmony_ci 1403f6603c60Sopenharmony_ci // 5. Free memory 1404f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1405f6603c60Sopenharmony_ci} 1406f6603c60Sopenharmony_ci 1407f6603c60Sopenharmony_ci/* 1408f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2802 1409f6603c60Sopenharmony_ci * @tc.name: testCanvasScaleAbnormal 1410f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasScaleAbnormal. 1411f6603c60Sopenharmony_ci * @tc.size : SmallTest 1412f6603c60Sopenharmony_ci * @tc.type : Function 1413f6603c60Sopenharmony_ci * @tc.level : Level 3 1414f6603c60Sopenharmony_ci */ 1415f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasScaleAbnormal, TestSize.Level3) { 1416f6603c60Sopenharmony_ci // 1. Create a canvas 1417f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1418f6603c60Sopenharmony_ci 1419f6603c60Sopenharmony_ci // 2. Scale the canvas, with a negative scale ratio in the x-axis 1420f6603c60Sopenharmony_ci OH_Drawing_CanvasScale(canvas, -2.0, 2.0); 1421f6603c60Sopenharmony_ci 1422f6603c60Sopenharmony_ci // 3. Scale the canvas, with a negative scale ratio in the y-axis 1423f6603c60Sopenharmony_ci OH_Drawing_CanvasScale(canvas, 2.0, -2.0); 1424f6603c60Sopenharmony_ci 1425f6603c60Sopenharmony_ci // 4. Free memory 1426f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1427f6603c60Sopenharmony_ci} 1428f6603c60Sopenharmony_ci 1429f6603c60Sopenharmony_ci/* 1430f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2803 1431f6603c60Sopenharmony_ci * @tc.name: testCanvasScaleMaximum 1432f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasScaleMaximum. 1433f6603c60Sopenharmony_ci * @tc.size : SmallTest 1434f6603c60Sopenharmony_ci * @tc.type : Function 1435f6603c60Sopenharmony_ci * @tc.level : Level 3 1436f6603c60Sopenharmony_ci */ 1437f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasScaleMaximum, TestSize.Level3) { 1438f6603c60Sopenharmony_ci // 1. Create a canvas 1439f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1440f6603c60Sopenharmony_ci 1441f6603c60Sopenharmony_ci // 2. Scale the canvas, with the maximum scale ratio in the x-axis 1442f6603c60Sopenharmony_ci OH_Drawing_CanvasScale(canvas, DBL_MAX, 2.0); 1443f6603c60Sopenharmony_ci 1444f6603c60Sopenharmony_ci // 3. Scale the canvas, with the maximum scale ratio in the y-axis 1445f6603c60Sopenharmony_ci OH_Drawing_CanvasScale(canvas, 2.0, DBL_MAX); 1446f6603c60Sopenharmony_ci 1447f6603c60Sopenharmony_ci // 4. Free memory 1448f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1449f6603c60Sopenharmony_ci} 1450f6603c60Sopenharmony_ci 1451f6603c60Sopenharmony_ci/* 1452f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2804 1453f6603c60Sopenharmony_ci * @tc.name: testCanvasScaleInputDestroyed 1454f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasScaleInputDestroyed. 1455f6603c60Sopenharmony_ci * @tc.size : SmallTest 1456f6603c60Sopenharmony_ci * @tc.type : Function 1457f6603c60Sopenharmony_ci * @tc.level : Level 3 1458f6603c60Sopenharmony_ci */ 1459f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasScaleInputDestroyed, TestSize.Level3) { 1460f6603c60Sopenharmony_ci // Deprecated 1461f6603c60Sopenharmony_ci} 1462f6603c60Sopenharmony_ci 1463f6603c60Sopenharmony_ci/* 1464f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_CANVAS_2805 1465f6603c60Sopenharmony_ci * @tc.name: testCanvasScaleMultipleCalls 1466f6603c60Sopenharmony_ci * @tc.desc: test for testCanvasScaleMultipleCalls. 1467f6603c60Sopenharmony_ci * @tc.size : SmallTest 1468f6603c60Sopenharmony_ci * @tc.type : Function 1469f6603c60Sopenharmony_ci * @tc.level : Level 3 1470f6603c60Sopenharmony_ci */ 1471f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeCanvasTest, testCanvasScaleMultipleCalls, TestSize.Level3) { 1472f6603c60Sopenharmony_ci // 1. Create a canvas 1473f6603c60Sopenharmony_ci OH_Drawing_Canvas *canvas = OH_Drawing_CanvasCreate(); 1474f6603c60Sopenharmony_ci 1475f6603c60Sopenharmony_ci // 2. Call OH_Drawing_CanvasScale 10 times, each time with different compression ratios 1476f6603c60Sopenharmony_ci for (int i = 1; i <= 10; i++) { 1477f6603c60Sopenharmony_ci OH_Drawing_CanvasScale(canvas, i * 1.0, i * 1.0); 1478f6603c60Sopenharmony_ci } 1479f6603c60Sopenharmony_ci 1480f6603c60Sopenharmony_ci // 3. Call drawing class interface 1481f6603c60Sopenharmony_ci OH_Drawing_Rect *rect = OH_Drawing_RectCreate(10, 10, 100, 100); 1482f6603c60Sopenharmony_ci OH_Drawing_CanvasDrawRect(canvas, rect); 1483f6603c60Sopenharmony_ci OH_Drawing_RectDestroy(rect); 1484f6603c60Sopenharmony_ci 1485f6603c60Sopenharmony_ci // 4. Free memory 1486f6603c60Sopenharmony_ci OH_Drawing_CanvasDestroy(canvas); 1487f6603c60Sopenharmony_ci} 1488f6603c60Sopenharmony_ci 1489f6603c60Sopenharmony_ci} // namespace Drawing 1490f6603c60Sopenharmony_ci} // namespace Rosen 1491f6603c60Sopenharmony_ci} // namespace OHOS