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#include <cmath> 16f6603c60Sopenharmony_ci 17f6603c60Sopenharmony_ci#include "gtest/gtest.h" 18f6603c60Sopenharmony_ci 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_shadow_layer.h" 39f6603c60Sopenharmony_ci#include "drawing_text_blob.h" 40f6603c60Sopenharmony_ci#include "drawing_typeface.h" 41f6603c60Sopenharmony_ci 42f6603c60Sopenharmony_ciusing namespace testing; 43f6603c60Sopenharmony_ciusing namespace testing::ext; 44f6603c60Sopenharmony_ci 45f6603c60Sopenharmony_cinamespace OHOS { 46f6603c60Sopenharmony_cinamespace Rosen { 47f6603c60Sopenharmony_cinamespace Drawing { 48f6603c60Sopenharmony_ciclass DrawingNativeBrushTest : public testing::Test {}; 49f6603c60Sopenharmony_ci 50f6603c60Sopenharmony_ci/* 51f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0100 52f6603c60Sopenharmony_ci * @tc.name: testBrushCreateNormal 53f6603c60Sopenharmony_ci * @tc.desc: test for testBrushCreateNormal. 54f6603c60Sopenharmony_ci * @tc.size : SmallTest 55f6603c60Sopenharmony_ci * @tc.type : Function 56f6603c60Sopenharmony_ci * @tc.level : Level 0 57f6603c60Sopenharmony_ci */ 58f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushCreateNormal, TestSize.Level0) { 59f6603c60Sopenharmony_ci // 1. Call OH_Drawing_BrushCreate to create a brush object 60f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 61f6603c60Sopenharmony_ci // 2. Free memory 62f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 63f6603c60Sopenharmony_ci} 64f6603c60Sopenharmony_ci 65f6603c60Sopenharmony_ci/* 66f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0200 67f6603c60Sopenharmony_ci * @tc.name: testBrushCopyNormal 68f6603c60Sopenharmony_ci * @tc.desc: test for testBrushCopyNormal. 69f6603c60Sopenharmony_ci * @tc.size : SmallTest 70f6603c60Sopenharmony_ci * @tc.type : Function 71f6603c60Sopenharmony_ci * @tc.level : Level 0 72f6603c60Sopenharmony_ci */ 73f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushCopyNormal, TestSize.Level0) { 74f6603c60Sopenharmony_ci // 1. Create a brush object 1 by calling OH_Drawing_BrushCreate 75f6603c60Sopenharmony_ci OH_Drawing_Brush *brush1 = OH_Drawing_BrushCreate(); 76f6603c60Sopenharmony_ci // 2. Set the color of brush 1 by calling OH_Drawing_BrushSetColor 77f6603c60Sopenharmony_ci OH_Drawing_BrushSetColor(brush1, 0x12345678); 78f6603c60Sopenharmony_ci // 3. Copy brush 1 to create brush object 2 by calling OH_Drawing_BrushCopy 79f6603c60Sopenharmony_ci OH_Drawing_Brush *brush2 = OH_Drawing_BrushCopy(brush1); 80f6603c60Sopenharmony_ci // 4. Get the color of brush object 2 by calling OH_Drawing_BrushGetColor 81f6603c60Sopenharmony_ci uint32_t color = OH_Drawing_BrushGetColor(brush2); 82f6603c60Sopenharmony_ci EXPECT_EQ(color, 0x12345678); 83f6603c60Sopenharmony_ci // 5. Modify the color of brush object 1 by calling OH_Drawing_BrushSetColor 84f6603c60Sopenharmony_ci OH_Drawing_BrushSetColor(brush1, 0x87654321); 85f6603c60Sopenharmony_ci // 6. Get the color of brush object 2 again by calling OH_Drawing_BrushGetColor 86f6603c60Sopenharmony_ci color = OH_Drawing_BrushGetColor(brush2); 87f6603c60Sopenharmony_ci EXPECT_EQ(color, 0x12345678); 88f6603c60Sopenharmony_ci // 7. Free memory 89f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush1); 90f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush2); 91f6603c60Sopenharmony_ci} 92f6603c60Sopenharmony_ci 93f6603c60Sopenharmony_ci/* 94f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0201 95f6603c60Sopenharmony_ci * @tc.name: testBrushCopyNull 96f6603c60Sopenharmony_ci * @tc.desc: test for testBrushCopyNull. 97f6603c60Sopenharmony_ci * @tc.size : SmallTest 98f6603c60Sopenharmony_ci * @tc.type : Function 99f6603c60Sopenharmony_ci * @tc.level : Level 3 100f6603c60Sopenharmony_ci */ 101f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushCopyNull, TestSize.Level3) { 102f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 103f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 104f6603c60Sopenharmony_ci // 2. Copy a brush object by calling OH_Drawing_BrushCopy with nullptr as parameter 105f6603c60Sopenharmony_ci OH_Drawing_Brush *brushCopy = OH_Drawing_BrushCopy(nullptr); 106f6603c60Sopenharmony_ci // 3. Free memory 107f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 108f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brushCopy); 109f6603c60Sopenharmony_ci} 110f6603c60Sopenharmony_ci 111f6603c60Sopenharmony_ci/* 112f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0202 113f6603c60Sopenharmony_ci * @tc.name: testBrushCopyInputDestroyed 114f6603c60Sopenharmony_ci * @tc.desc: test for testBrushCopyInputDestroyed. 115f6603c60Sopenharmony_ci * @tc.size : SmallTest 116f6603c60Sopenharmony_ci * @tc.type : Function 117f6603c60Sopenharmony_ci * @tc.level : Level 3 118f6603c60Sopenharmony_ci */ 119f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushCopyInputDestroyed, TestSize.Level3) { 120f6603c60Sopenharmony_ci // 1. Call OH_Drawing_BrushCreate to create a brush object 1 121f6603c60Sopenharmony_ci OH_Drawing_Brush *brush1 = OH_Drawing_BrushCreate(); 122f6603c60Sopenharmony_ci // 2. Copy brush object 1 to create brush object 2 by calling OH_Drawing_BrushCopy 123f6603c60Sopenharmony_ci OH_Drawing_Brush *brush2 = OH_Drawing_BrushCopy(brush1); 124f6603c60Sopenharmony_ci // 3. Destroy brush object 1 by calling OH_Drawing_BrushDestroy 125f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush1); 126f6603c60Sopenharmony_ci // 4. Set the color of brush object 2 by calling OH_Drawing_BrushSetColor 127f6603c60Sopenharmony_ci OH_Drawing_BrushSetColor(brush2, 0x12345678); 128f6603c60Sopenharmony_ci // 5. Get the color of brush object 2 by calling OH_Drawing_BrushGetColor 129f6603c60Sopenharmony_ci uint32_t color = OH_Drawing_BrushGetColor(brush2); 130f6603c60Sopenharmony_ci EXPECT_EQ(color, 0x12345678); 131f6603c60Sopenharmony_ci // 6. Free memory 132f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush2); 133f6603c60Sopenharmony_ci} 134f6603c60Sopenharmony_ci 135f6603c60Sopenharmony_ci/* 136f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0203 137f6603c60Sopenharmony_ci * @tc.name: testBrushCopyMultipleCalls 138f6603c60Sopenharmony_ci * @tc.desc: test for testBrushCopyMultipleCalls. 139f6603c60Sopenharmony_ci * @tc.size : SmallTest 140f6603c60Sopenharmony_ci * @tc.type : Function 141f6603c60Sopenharmony_ci * @tc.level : Level 3 142f6603c60Sopenharmony_ci */ 143f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushCopyMultipleCalls, TestSize.Level3) { 144f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 145f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 146f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushCopy ten times in a loop 147f6603c60Sopenharmony_ci for (int i = 0; i < 10; i++) { 148f6603c60Sopenharmony_ci OH_Drawing_Brush *brushCopy = OH_Drawing_BrushCopy(brush); 149f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brushCopy); 150f6603c60Sopenharmony_ci } 151f6603c60Sopenharmony_ci // 3. Free memory 152f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 153f6603c60Sopenharmony_ci} 154f6603c60Sopenharmony_ci 155f6603c60Sopenharmony_ci/* 156f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0300 157f6603c60Sopenharmony_ci * @tc.name: testBrushDestroyNormal 158f6603c60Sopenharmony_ci * @tc.desc: test for testBrushDestroyNormal. 159f6603c60Sopenharmony_ci * @tc.size : SmallTest 160f6603c60Sopenharmony_ci * @tc.type : Function 161f6603c60Sopenharmony_ci * @tc.level : Level 0 162f6603c60Sopenharmony_ci */ 163f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushDestroyNormal, TestSize.Level0) { 164f6603c60Sopenharmony_ci // 1. Call OH_Drawing_BrushCreate to create a brush object 165f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 166f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushDestroy to destroy the object 167f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 168f6603c60Sopenharmony_ci} 169f6603c60Sopenharmony_ci 170f6603c60Sopenharmony_ci/* 171f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0301 172f6603c60Sopenharmony_ci * @tc.name: testBrushDestroyNull 173f6603c60Sopenharmony_ci * @tc.desc: test for testBrushDestroyNull. 174f6603c60Sopenharmony_ci * @tc.size : SmallTest 175f6603c60Sopenharmony_ci * @tc.type : Function 176f6603c60Sopenharmony_ci * @tc.level : Level 3 177f6603c60Sopenharmony_ci */ 178f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushDestroyNull, TestSize.Level3) { 179f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 180f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 181f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushDestroy with nullptr as parameter 182f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(nullptr); 183f6603c60Sopenharmony_ci // 3. Free memory 184f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 185f6603c60Sopenharmony_ci} 186f6603c60Sopenharmony_ci 187f6603c60Sopenharmony_ci/* 188f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0400 189f6603c60Sopenharmony_ci * @tc.name: testBrushIsAntiAliasNormal 190f6603c60Sopenharmony_ci * @tc.desc: test for testBrushIsAntiAliasNormal. 191f6603c60Sopenharmony_ci * @tc.size : SmallTest 192f6603c60Sopenharmony_ci * @tc.type : Function 193f6603c60Sopenharmony_ci * @tc.level : Level 0 194f6603c60Sopenharmony_ci */ 195f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushIsAntiAliasNormal, TestSize.Level0) { 196f6603c60Sopenharmony_ci // 1. Call OH_Drawing_BrushCreate to create a brush object 197f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 198f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushSetAntiAlias to set the anti-aliasing property to true 199f6603c60Sopenharmony_ci OH_Drawing_BrushSetAntiAlias(brush, true); 200f6603c60Sopenharmony_ci // 3. Call OH_Drawing_BrushIsAntiAlias to check the return value 201f6603c60Sopenharmony_ci bool isAntiAlias = OH_Drawing_BrushIsAntiAlias(brush); 202f6603c60Sopenharmony_ci EXPECT_EQ(isAntiAlias, true); 203f6603c60Sopenharmony_ci // 4. Free memory 204f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 205f6603c60Sopenharmony_ci} 206f6603c60Sopenharmony_ci 207f6603c60Sopenharmony_ci/* 208f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0401 209f6603c60Sopenharmony_ci * @tc.name: testBrushIsAntiAliasNull 210f6603c60Sopenharmony_ci * @tc.desc: test for testBrushIsAntiAliasNull. 211f6603c60Sopenharmony_ci * @tc.size : SmallTest 212f6603c60Sopenharmony_ci * @tc.type : Function 213f6603c60Sopenharmony_ci * @tc.level : Level 3 214f6603c60Sopenharmony_ci */ 215f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushIsAntiAliasNull, TestSize.Level3) { 216f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 217f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 218f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushIsAntiAlias with nullptr as parameter 219f6603c60Sopenharmony_ci OH_Drawing_BrushIsAntiAlias(nullptr); 220f6603c60Sopenharmony_ci // 3. Free memory 221f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 222f6603c60Sopenharmony_ci} 223f6603c60Sopenharmony_ci 224f6603c60Sopenharmony_ci/* 225f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0500 226f6603c60Sopenharmony_ci * @tc.name: testBrushSetAntiAliasNormal 227f6603c60Sopenharmony_ci * @tc.desc: test for testBrushSetAntiAliasNormal. 228f6603c60Sopenharmony_ci * @tc.size: SmallTest 229f6603c60Sopenharmony_ci * @tc.type: Function 230f6603c60Sopenharmony_ci * @tc.level: Level 0 231f6603c60Sopenharmony_ci */ 232f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetAntiAliasNormal, TestSize.Level0) { 233f6603c60Sopenharmony_ci // 1. Call OH_Drawing_BrushCreate to create a brush object 234f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 235f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushSetAntiAlias to set the anti-aliasing property to true 236f6603c60Sopenharmony_ci OH_Drawing_BrushSetAntiAlias(brush, true); 237f6603c60Sopenharmony_ci // 3. Call OH_Drawing_BrushIsAntiAlias to check the return value 238f6603c60Sopenharmony_ci bool isAntiAlias = OH_Drawing_BrushIsAntiAlias(brush); 239f6603c60Sopenharmony_ci EXPECT_EQ(isAntiAlias, true); 240f6603c60Sopenharmony_ci // 4. Free memory 241f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 242f6603c60Sopenharmony_ci} 243f6603c60Sopenharmony_ci 244f6603c60Sopenharmony_ci/* 245f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0501 246f6603c60Sopenharmony_ci * @tc.name: testBrushSetAntiAliasNull 247f6603c60Sopenharmony_ci * @tc.desc: test for testBrushSetAntiAliasNull. 248f6603c60Sopenharmony_ci * @tc.size: SmallTest 249f6603c60Sopenharmony_ci * @tc.type: Function 250f6603c60Sopenharmony_ci * @tc.level: Level 3 251f6603c60Sopenharmony_ci */ 252f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetAntiAliasNull, TestSize.Level3) { 253f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 254f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 255f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushSetAntiAlias with nullptr as the first parameter 256f6603c60Sopenharmony_ci OH_Drawing_BrushSetAntiAlias(nullptr, true); 257f6603c60Sopenharmony_ci // 3. Free memory 258f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 259f6603c60Sopenharmony_ci} 260f6603c60Sopenharmony_ci 261f6603c60Sopenharmony_ci/* 262f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0600 263f6603c60Sopenharmony_ci * @tc.name: testBrushGetColorNormal 264f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushGetColorNormal. 265f6603c60Sopenharmony_ci * @tc.size: SmallTest 266f6603c60Sopenharmony_ci * @tc.type: Function 267f6603c60Sopenharmony_ci * @tc.level: Level 0 268f6603c60Sopenharmony_ci */ 269f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushGetColorNormal, TestSize.Level0) { 270f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 271f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 272f6603c60Sopenharmony_ci // 2. Set the color of the brush object by calling OH_Drawing_BrushSetColor 273f6603c60Sopenharmony_ci OH_Drawing_BrushSetColor(brush, 0x12345678); 274f6603c60Sopenharmony_ci // 3. Get the color of the brush object by calling OH_Drawing_BrushGetColor 275f6603c60Sopenharmony_ci uint32_t color = OH_Drawing_BrushGetColor(brush); 276f6603c60Sopenharmony_ci EXPECT_EQ(color, 0x12345678); 277f6603c60Sopenharmony_ci // 4. Free memory 278f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 279f6603c60Sopenharmony_ci} 280f6603c60Sopenharmony_ci 281f6603c60Sopenharmony_ci/* 282f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0601 283f6603c60Sopenharmony_ci * @tc.name: testBrushGetColorNull 284f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushGetColorNull. 285f6603c60Sopenharmony_ci * @tc.size: SmallTest 286f6603c60Sopenharmony_ci * @tc.type: Function 287f6603c60Sopenharmony_ci * @tc.level: Level 3 288f6603c60Sopenharmony_ci */ 289f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushGetColorNull, TestSize.Level3) { 290f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 291f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 292f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushGetColor with nullptr as parameter 293f6603c60Sopenharmony_ci OH_Drawing_BrushGetColor(nullptr); 294f6603c60Sopenharmony_ci // 3. Free memory 295f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 296f6603c60Sopenharmony_ci} 297f6603c60Sopenharmony_ci 298f6603c60Sopenharmony_ci/* 299f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0700 300f6603c60Sopenharmony_ci * @tc.name: testBrushSetColorNormal 301f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetColorNormal. 302f6603c60Sopenharmony_ci * @tc.size: SmallTest 303f6603c60Sopenharmony_ci * @tc.type: Function 304f6603c60Sopenharmony_ci * @tc.level: Level 0 305f6603c60Sopenharmony_ci */ 306f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetColorNormal, TestSize.Level0) { 307f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 308f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 309f6603c60Sopenharmony_ci // 2. Set the color of the brush object by calling OH_Drawing_BrushSetColor 310f6603c60Sopenharmony_ci OH_Drawing_BrushSetColor(brush, 0x12345678); 311f6603c60Sopenharmony_ci // 3. Get the color of the brush object by calling OH_Drawing_BrushGetColor 312f6603c60Sopenharmony_ci uint32_t color = OH_Drawing_BrushGetColor(brush); 313f6603c60Sopenharmony_ci EXPECT_EQ(color, 0x12345678); 314f6603c60Sopenharmony_ci // 4. Free memory 315f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 316f6603c60Sopenharmony_ci} 317f6603c60Sopenharmony_ci 318f6603c60Sopenharmony_ci/* 319f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0701 320f6603c60Sopenharmony_ci * @tc.name: testBrushSetColorNull 321f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetColorNull. 322f6603c60Sopenharmony_ci * @tc.size: SmallTest 323f6603c60Sopenharmony_ci * @tc.type: Function 324f6603c60Sopenharmony_ci * @tc.level: Level 3 325f6603c60Sopenharmony_ci */ 326f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetColorNull, TestSize.Level3) { 327f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 328f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 329f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushSetColor with nullptr as the first parameter 330f6603c60Sopenharmony_ci OH_Drawing_BrushSetColor(nullptr, 0x12345678); 331f6603c60Sopenharmony_ci // 3. Call OH_Drawing_BrushSetColor with 0 as the second parameter 332f6603c60Sopenharmony_ci OH_Drawing_BrushSetColor(brush, 0); 333f6603c60Sopenharmony_ci // 4. Call OH_Drawing_BrushGetColor to get the brush color 334f6603c60Sopenharmony_ci uint32_t color = OH_Drawing_BrushGetColor(brush); 335f6603c60Sopenharmony_ci EXPECT_EQ(color, 0); 336f6603c60Sopenharmony_ci // 5. Free memory 337f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 338f6603c60Sopenharmony_ci} 339f6603c60Sopenharmony_ci 340f6603c60Sopenharmony_ci/* 341f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0702 342f6603c60Sopenharmony_ci * @tc.name: testBrushSetColorAbnormal 343f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetColorAbnormal. 344f6603c60Sopenharmony_ci * @tc.size: SmallTest 345f6603c60Sopenharmony_ci * @tc.type: Function 346f6603c60Sopenharmony_ci * @tc.level: Level 3 347f6603c60Sopenharmony_ci */ 348f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetColorAbnormal, TestSize.Level3) { 349f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 350f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 351f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushSetColor with a negative number or a non-uint32_t type parameter as the second argument 352f6603c60Sopenharmony_ci OH_Drawing_BrushSetColor(brush, -1); 353f6603c60Sopenharmony_ci // Ignoring the test for passing a floating-point number, as it will result in an error 354f6603c60Sopenharmony_ci // 3. Call OH_Drawing_BrushGetColor to get the brush color 355f6603c60Sopenharmony_ci uint32_t color = OH_Drawing_BrushGetColor(brush); 356f6603c60Sopenharmony_ci EXPECT_EQ(color, std::pow(2, 32) - 1); 357f6603c60Sopenharmony_ci // 4. Free memory 358f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 359f6603c60Sopenharmony_ci} 360f6603c60Sopenharmony_ci 361f6603c60Sopenharmony_ci/* 362f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0703 363f6603c60Sopenharmony_ci * @tc.name: testBrushSetColorMaximum 364f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetColorMaximum. 365f6603c60Sopenharmony_ci * @tc.size: SmallTest 366f6603c60Sopenharmony_ci * @tc.type: Function 367f6603c60Sopenharmony_ci * @tc.level: Level 3 368f6603c60Sopenharmony_ci */ 369f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetColorMaximum, TestSize.Level3) { 370f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 371f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 372f6603c60Sopenharmony_ci // 2. Set the color of the brush object by calling OH_Drawing_BrushSetColor with a value greater than the maximum 373f6603c60Sopenharmony_ci // value of uint32_t (0xFFFFFFFF) 374f6603c60Sopenharmony_ci OH_Drawing_BrushSetColor(brush, 0xFFFFFFFF + 1); 375f6603c60Sopenharmony_ci // 3. Get the color of the brush object by calling OH_Drawing_BrushGetColor 376f6603c60Sopenharmony_ci uint32_t color = OH_Drawing_BrushGetColor(brush); 377f6603c60Sopenharmony_ci EXPECT_EQ(color, 0); 378f6603c60Sopenharmony_ci // 4. Free memory 379f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 380f6603c60Sopenharmony_ci} 381f6603c60Sopenharmony_ci 382f6603c60Sopenharmony_ci/* 383f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0800 384f6603c60Sopenharmony_ci * @tc.name: testBrushGetAlphaNormal 385f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushGetAlphaNormal. 386f6603c60Sopenharmony_ci * @tc.size: SmallTest 387f6603c60Sopenharmony_ci * @tc.type: Function 388f6603c60Sopenharmony_ci * @tc.level: Level 0 389f6603c60Sopenharmony_ci */ 390f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushGetAlphaNormal, TestSize.Level0) { 391f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 392f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 393f6603c60Sopenharmony_ci // 2. Set the alpha value of the brush object by calling OH_Drawing_BrushSetAlpha 394f6603c60Sopenharmony_ci OH_Drawing_BrushSetAlpha(brush, 128); 395f6603c60Sopenharmony_ci // 3. Get the alpha value of the brush object by calling OH_Drawing_BrushGetAlpha 396f6603c60Sopenharmony_ci uint8_t alpha = OH_Drawing_BrushGetAlpha(brush); 397f6603c60Sopenharmony_ci EXPECT_EQ(alpha, 128); 398f6603c60Sopenharmony_ci // 4. Free memory 399f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 400f6603c60Sopenharmony_ci} 401f6603c60Sopenharmony_ci 402f6603c60Sopenharmony_ci/* 403f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0801 404f6603c60Sopenharmony_ci * @tc.name: testBrushGetAlphaNull 405f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushGetAlphaNull. 406f6603c60Sopenharmony_ci * @tc.size: SmallTest 407f6603c60Sopenharmony_ci * @tc.type: Function 408f6603c60Sopenharmony_ci * @tc.level: Level 3 409f6603c60Sopenharmony_ci */ 410f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushGetAlphaNull, TestSize.Level3) { 411f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 412f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 413f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushGetAlpha with nullptr as parameter 414f6603c60Sopenharmony_ci OH_Drawing_BrushGetAlpha(nullptr); 415f6603c60Sopenharmony_ci // 3. Free memory 416f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 417f6603c60Sopenharmony_ci} 418f6603c60Sopenharmony_ci 419f6603c60Sopenharmony_ci/* 420f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0900 421f6603c60Sopenharmony_ci * @tc.name: testBrushSetAlphaNormal 422f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetAlphaNormal. 423f6603c60Sopenharmony_ci * @tc.size: SmallTest 424f6603c60Sopenharmony_ci * @tc.type: Function 425f6603c60Sopenharmony_ci * @tc.level: Level 0 426f6603c60Sopenharmony_ci */ 427f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetAlphaNormal, TestSize.Level0) { 428f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 429f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 430f6603c60Sopenharmony_ci // 2. Set the alpha value of the brush object by calling OH_Drawing_BrushSetAlpha 431f6603c60Sopenharmony_ci OH_Drawing_BrushSetAlpha(brush, 128); 432f6603c60Sopenharmony_ci // 3. Get the alpha value of the brush object by calling OH_Drawing_BrushGetAlpha 433f6603c60Sopenharmony_ci uint8_t alpha = OH_Drawing_BrushGetAlpha(brush); 434f6603c60Sopenharmony_ci EXPECT_EQ(alpha, 128); 435f6603c60Sopenharmony_ci // 4. Free memory 436f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 437f6603c60Sopenharmony_ci} 438f6603c60Sopenharmony_ci 439f6603c60Sopenharmony_ci/* 440f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0901 441f6603c60Sopenharmony_ci * @tc.name: testBrushSetAlphaNull 442f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetAlphaNull. 443f6603c60Sopenharmony_ci * @tc.size: SmallTest 444f6603c60Sopenharmony_ci * @tc.type: Function 445f6603c60Sopenharmony_ci * @tc.level: Level 3 446f6603c60Sopenharmony_ci */ 447f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetAlphaNull, TestSize.Level3) { 448f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 449f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 450f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushSetAlpha with nullptr as the first parameter 451f6603c60Sopenharmony_ci OH_Drawing_BrushSetAlpha(nullptr, 128); 452f6603c60Sopenharmony_ci // 3. Call OH_Drawing_BrushSetAlpha with 0 as the second parameter 453f6603c60Sopenharmony_ci OH_Drawing_BrushSetAlpha(brush, 0); 454f6603c60Sopenharmony_ci // 4. Free memory 455f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 456f6603c60Sopenharmony_ci} 457f6603c60Sopenharmony_ci 458f6603c60Sopenharmony_ci/* 459f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0902 460f6603c60Sopenharmony_ci * @tc.name: testBrushSetAlphaAbnormal 461f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetAlphaAbnormal. 462f6603c60Sopenharmony_ci * @tc.size: SmallTest 463f6603c60Sopenharmony_ci * @tc.type: Function 464f6603c60Sopenharmony_ci * @tc.level: Level 3 465f6603c60Sopenharmony_ci */ 466f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetAlphaAbnormal, TestSize.Level3) { 467f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 468f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 469f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushSetAlpha with a negative number or a non-uint8_t type parameter as the second argument 470f6603c60Sopenharmony_ci OH_Drawing_BrushSetAlpha(brush, -1); 471f6603c60Sopenharmony_ci // 3. Call OH_Drawing_BrushGetAlpha to get the alpha value 472f6603c60Sopenharmony_ci uint8_t alpha = OH_Drawing_BrushGetAlpha(brush); 473f6603c60Sopenharmony_ci EXPECT_EQ(alpha, 0xff); 474f6603c60Sopenharmony_ci // 4. Free memory 475f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 476f6603c60Sopenharmony_ci} 477f6603c60Sopenharmony_ci 478f6603c60Sopenharmony_ci/* 479f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_0903 480f6603c60Sopenharmony_ci * @tc.name: testBrushSetAlphaMaximum 481f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetAlphaMaximum. 482f6603c60Sopenharmony_ci * @tc.size: SmallTest 483f6603c60Sopenharmony_ci * @tc.type: Function 484f6603c60Sopenharmony_ci * @tc.level: Level 3 485f6603c60Sopenharmony_ci */ 486f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetAlphaMaximum, TestSize.Level3) { 487f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 488f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 489f6603c60Sopenharmony_ci // 2. Set the alpha value of the brush object by calling OH_Drawing_BrushSetAlpha with a value greater than the 490f6603c60Sopenharmony_ci // maximum value of uint8_t (0xFFFFFFFF + 1) 491f6603c60Sopenharmony_ci OH_Drawing_BrushSetAlpha(brush, 0xFFFFFFFF + 1); 492f6603c60Sopenharmony_ci // 3. Get the alpha value of the brush object by calling OH_Drawing_BrushGetAlpha 493f6603c60Sopenharmony_ci uint8_t alpha = OH_Drawing_BrushGetAlpha(brush); 494f6603c60Sopenharmony_ci EXPECT_EQ(alpha, 0); 495f6603c60Sopenharmony_ci // 4. Free memory 496f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 497f6603c60Sopenharmony_ci} 498f6603c60Sopenharmony_ci 499f6603c60Sopenharmony_ci/* 500f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_1000 501f6603c60Sopenharmony_ci * @tc.name: testBrushSetShaderEffectNormal 502f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetShaderEffectNormal. 503f6603c60Sopenharmony_ci * @tc.size: SmallTest 504f6603c60Sopenharmony_ci * @tc.type: Function 505f6603c60Sopenharmony_ci * @tc.level: Level 0 506f6603c60Sopenharmony_ci */ 507f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetShaderEffectNormal, TestSize.Level0) { 508f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 509f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 510f6603c60Sopenharmony_ci // 2. Create a shader object by calling OH_Drawing_ShaderEffectCreate 511f6603c60Sopenharmony_ci OH_Drawing_Point *startPt = OH_Drawing_PointCreate(100, 400); 512f6603c60Sopenharmony_ci OH_Drawing_Point *endPt = OH_Drawing_PointCreate(200, 500); 513f6603c60Sopenharmony_ci uint32_t color[] = {0xffff0000, 0xff00ff00}; 514f6603c60Sopenharmony_ci float pos[] = {0., 1.0}; 515f6603c60Sopenharmony_ci OH_Drawing_ShaderEffect *linearGradient = 516f6603c60Sopenharmony_ci OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, color, pos, 2, OH_Drawing_TileMode::CLAMP); 517f6603c60Sopenharmony_ci // 3. Set the shader effect for the brush object by calling OH_Drawing_BrushSetShaderEffect 518f6603c60Sopenharmony_ci OH_Drawing_BrushSetShaderEffect(brush, linearGradient); 519f6603c60Sopenharmony_ci // 4. Free memory 520f6603c60Sopenharmony_ci OH_Drawing_ShaderEffectDestroy(linearGradient); 521f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(startPt); 522f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(endPt); 523f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 524f6603c60Sopenharmony_ci} 525f6603c60Sopenharmony_ci 526f6603c60Sopenharmony_ci/* 527f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_1001 528f6603c60Sopenharmony_ci * @tc.name: testBrushSetShaderEffectNull 529f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetShaderEffectNull. 530f6603c60Sopenharmony_ci * @tc.size: SmallTest 531f6603c60Sopenharmony_ci * @tc.type: Function 532f6603c60Sopenharmony_ci * @tc.level: Level 3 533f6603c60Sopenharmony_ci */ 534f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetShaderEffectNull, TestSize.Level3) { 535f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 536f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 537f6603c60Sopenharmony_ci OH_Drawing_Point *startPt = OH_Drawing_PointCreate(100, 400); 538f6603c60Sopenharmony_ci OH_Drawing_Point *endPt = OH_Drawing_PointCreate(200, 500); 539f6603c60Sopenharmony_ci uint32_t color[] = {0xffff0000, 0xff00ff00}; 540f6603c60Sopenharmony_ci float pos[] = {0., 1.0}; 541f6603c60Sopenharmony_ci OH_Drawing_ShaderEffect *linearGradient = 542f6603c60Sopenharmony_ci OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, color, pos, 2, OH_Drawing_TileMode::CLAMP); 543f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushSetShaderEffect with nullptr as the first parameter 544f6603c60Sopenharmony_ci OH_Drawing_BrushSetShaderEffect(nullptr, linearGradient); 545f6603c60Sopenharmony_ci // 3. Call OH_Drawing_BrushSetShaderEffect with nullptr as the second parameter 546f6603c60Sopenharmony_ci OH_Drawing_BrushSetShaderEffect(brush, nullptr); 547f6603c60Sopenharmony_ci // 4. Free memory 548f6603c60Sopenharmony_ci OH_Drawing_ShaderEffectDestroy(linearGradient); 549f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(startPt); 550f6603c60Sopenharmony_ci OH_Drawing_PointDestroy(endPt); 551f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 552f6603c60Sopenharmony_ci} 553f6603c60Sopenharmony_ci 554f6603c60Sopenharmony_ci/* 555f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_1100 556f6603c60Sopenharmony_ci * @tc.name: testBrushSetShadowLayerNormal 557f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetShadowLayerNormal. 558f6603c60Sopenharmony_ci * @tc.size: SmallTest 559f6603c60Sopenharmony_ci * @tc.type: Function 560f6603c60Sopenharmony_ci * @tc.level: Level 0 561f6603c60Sopenharmony_ci */ 562f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetShadowLayerNormal, TestSize.Level0) { 563f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 564f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 565f6603c60Sopenharmony_ci // 2. Create a shadow layer object by calling OH_Drawing_ShadowLayerCreate 566f6603c60Sopenharmony_ci OH_Drawing_ShadowLayer *shadowLayer = OH_Drawing_ShadowLayerCreate(10, 10, 10, 0x12345678); 567f6603c60Sopenharmony_ci // 3. Set the shadow layer for the brush object by calling OH_Drawing_BrushSetShadowLayer 568f6603c60Sopenharmony_ci OH_Drawing_BrushSetShadowLayer(brush, shadowLayer); 569f6603c60Sopenharmony_ci // 4. Free memory 570f6603c60Sopenharmony_ci OH_Drawing_ShadowLayerDestroy(shadowLayer); 571f6603c60Sopenharmony_ci} 572f6603c60Sopenharmony_ci 573f6603c60Sopenharmony_ci/* 574f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_1101 575f6603c60Sopenharmony_ci * @tc.name: testBrushSetShadowLayerNull 576f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetShadowLayerNull. 577f6603c60Sopenharmony_ci * @tc.size: SmallTest 578f6603c60Sopenharmony_ci * @tc.type: Function 579f6603c60Sopenharmony_ci * @tc.level: Level 3 580f6603c60Sopenharmony_ci */ 581f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetShadowLayerNull, TestSize.Level3) { 582f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 583f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 584f6603c60Sopenharmony_ci OH_Drawing_ShadowLayer *shadowLayer = OH_Drawing_ShadowLayerCreate(10, 10, 10, 0x12345678); 585f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushSetShadowLayer with nullptr as the first parameter 586f6603c60Sopenharmony_ci OH_Drawing_BrushSetShadowLayer(nullptr, shadowLayer); 587f6603c60Sopenharmony_ci // 3. Call OH_Drawing_BrushSetShadowLayer with nullptr as the second parameter 588f6603c60Sopenharmony_ci OH_Drawing_BrushSetShadowLayer(brush, nullptr); 589f6603c60Sopenharmony_ci // 4. Free memory 590f6603c60Sopenharmony_ci OH_Drawing_ShadowLayerDestroy(shadowLayer); 591f6603c60Sopenharmony_ci} 592f6603c60Sopenharmony_ci 593f6603c60Sopenharmony_ci/* 594f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_1200 595f6603c60Sopenharmony_ci * @tc.name: testBrushSetFilterNormal 596f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetFilterNormal. 597f6603c60Sopenharmony_ci * @tc.size: SmallTest 598f6603c60Sopenharmony_ci * @tc.type: Function 599f6603c60Sopenharmony_ci * @tc.level: Level 0 600f6603c60Sopenharmony_ci */ 601f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetFilterNormal, TestSize.Level0) { 602f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 603f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 604f6603c60Sopenharmony_ci // 2. Create a filter object by calling OH_Drawing_FilterCreate 605f6603c60Sopenharmony_ci OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); 606f6603c60Sopenharmony_ci // 3. Set the filter for the brush object by calling OH_Drawing_BrushSetFilter 607f6603c60Sopenharmony_ci OH_Drawing_BrushSetFilter(brush, filter); 608f6603c60Sopenharmony_ci // 4. Free memory 609f6603c60Sopenharmony_ci OH_Drawing_FilterDestroy(filter); 610f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 611f6603c60Sopenharmony_ci} 612f6603c60Sopenharmony_ci 613f6603c60Sopenharmony_ci/* 614f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_1201 615f6603c60Sopenharmony_ci * @tc.name: testBrushSetFilterNull 616f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetFilterNull. 617f6603c60Sopenharmony_ci * @tc.size: SmallTest 618f6603c60Sopenharmony_ci * @tc.type: Function 619f6603c60Sopenharmony_ci * @tc.level: Level 3 620f6603c60Sopenharmony_ci */ 621f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetFilterNull, TestSize.Level3) { 622f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 623f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 624f6603c60Sopenharmony_ci OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); 625f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushSetFilter with nullptr as the first parameter 626f6603c60Sopenharmony_ci OH_Drawing_BrushSetFilter(nullptr, filter); 627f6603c60Sopenharmony_ci // 3. Call OH_Drawing_BrushSetFilter with nullptr as the second parameter 628f6603c60Sopenharmony_ci OH_Drawing_BrushSetFilter(brush, nullptr); 629f6603c60Sopenharmony_ci // 4. Free memory 630f6603c60Sopenharmony_ci OH_Drawing_FilterDestroy(filter); 631f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 632f6603c60Sopenharmony_ci} 633f6603c60Sopenharmony_ci 634f6603c60Sopenharmony_ci/* 635f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_1300 636f6603c60Sopenharmony_ci * @tc.name: testBrushGetFilterNormal 637f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushGetFilterNormal. 638f6603c60Sopenharmony_ci * @tc.size: SmallTest 639f6603c60Sopenharmony_ci * @tc.type: Function 640f6603c60Sopenharmony_ci * @tc.level: Level 0 641f6603c60Sopenharmony_ci */ 642f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushGetFilterNormal, TestSize.Level0) { 643f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 644f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 645f6603c60Sopenharmony_ci // 2. Create a filter object by calling OH_Drawing_FilterCreate 646f6603c60Sopenharmony_ci OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); 647f6603c60Sopenharmony_ci // 3. Set the filter for the brush object by calling OH_Drawing_BrushSetFilter 648f6603c60Sopenharmony_ci OH_Drawing_BrushSetFilter(brush, filter); 649f6603c60Sopenharmony_ci // 4. Get the filter by calling OH_Drawing_BrushGetFilter 650f6603c60Sopenharmony_ci OH_Drawing_Filter *tmpFilter = OH_Drawing_FilterCreate(); 651f6603c60Sopenharmony_ci OH_Drawing_BrushGetFilter(brush, tmpFilter); 652f6603c60Sopenharmony_ci // 5. Free memory 653f6603c60Sopenharmony_ci OH_Drawing_FilterDestroy(filter); 654f6603c60Sopenharmony_ci OH_Drawing_FilterDestroy(tmpFilter); 655f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 656f6603c60Sopenharmony_ci} 657f6603c60Sopenharmony_ci 658f6603c60Sopenharmony_ci/* 659f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_1301 660f6603c60Sopenharmony_ci * @tc.name: testBrushGetFilterNull 661f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushGetFilterNull. 662f6603c60Sopenharmony_ci * @tc.size: SmallTest 663f6603c60Sopenharmony_ci * @tc.type: Function 664f6603c60Sopenharmony_ci * @tc.level: Level 3 665f6603c60Sopenharmony_ci */ 666f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushGetFilterNull, TestSize.Level3) { 667f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 668f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 669f6603c60Sopenharmony_ci OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); 670f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushGetFilter with nullptr as the first parameter 671f6603c60Sopenharmony_ci OH_Drawing_BrushGetFilter(nullptr, filter); 672f6603c60Sopenharmony_ci // 3. Call OH_Drawing_BrushGetFilter with nullptr as the second parameter 673f6603c60Sopenharmony_ci OH_Drawing_BrushGetFilter(brush, nullptr); 674f6603c60Sopenharmony_ci // 4. Free memory 675f6603c60Sopenharmony_ci OH_Drawing_FilterDestroy(filter); 676f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 677f6603c60Sopenharmony_ci} 678f6603c60Sopenharmony_ci 679f6603c60Sopenharmony_ci/* 680f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_1400 681f6603c60Sopenharmony_ci * @tc.name: testBrushSetBlendModeNormal 682f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetBlendModeNormal. 683f6603c60Sopenharmony_ci * @tc.size: SmallTest 684f6603c60Sopenharmony_ci * @tc.type: Function 685f6603c60Sopenharmony_ci * @tc.level: Level 0 686f6603c60Sopenharmony_ci */ 687f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetBlendModeNormal, TestSize.Level0) { 688f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 689f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 690f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushSetBlendMode with the second parameter being an enumeration 691f6603c60Sopenharmony_ci OH_Drawing_BlendMode blendMode[] = { 692f6603c60Sopenharmony_ci BLEND_MODE_CLEAR, BLEND_MODE_SRC, BLEND_MODE_DST, BLEND_MODE_SRC_OVER, 693f6603c60Sopenharmony_ci BLEND_MODE_DST_OVER, BLEND_MODE_SRC_IN, BLEND_MODE_DST_IN, BLEND_MODE_SRC_OUT, 694f6603c60Sopenharmony_ci BLEND_MODE_DST_OUT, BLEND_MODE_SRC_ATOP, BLEND_MODE_DST_ATOP, BLEND_MODE_XOR, 695f6603c60Sopenharmony_ci BLEND_MODE_PLUS, BLEND_MODE_MODULATE, BLEND_MODE_SCREEN, BLEND_MODE_OVERLAY, 696f6603c60Sopenharmony_ci BLEND_MODE_DARKEN, BLEND_MODE_LIGHTEN, BLEND_MODE_COLOR_DODGE, BLEND_MODE_COLOR_BURN, 697f6603c60Sopenharmony_ci BLEND_MODE_HARD_LIGHT, BLEND_MODE_SOFT_LIGHT, BLEND_MODE_DIFFERENCE, BLEND_MODE_EXCLUSION, 698f6603c60Sopenharmony_ci BLEND_MODE_MULTIPLY, BLEND_MODE_HUE, BLEND_MODE_SATURATION, BLEND_MODE_COLOR, 699f6603c60Sopenharmony_ci BLEND_MODE_LUMINOSITY, 700f6603c60Sopenharmony_ci }; 701f6603c60Sopenharmony_ci for (int i = 0; i < sizeof(blendMode) / sizeof(OH_Drawing_BlendMode); i++) { 702f6603c60Sopenharmony_ci OH_Drawing_BrushSetBlendMode(brush, blendMode[i]); 703f6603c60Sopenharmony_ci } 704f6603c60Sopenharmony_ci // 3. Free memory 705f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 706f6603c60Sopenharmony_ci} 707f6603c60Sopenharmony_ci 708f6603c60Sopenharmony_ci/* 709f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_1401 710f6603c60Sopenharmony_ci * @tc.name: testBrushSetBlendModeNull 711f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushSetBlendModeNull. 712f6603c60Sopenharmony_ci * @tc.size: SmallTest 713f6603c60Sopenharmony_ci * @tc.type: Function 714f6603c60Sopenharmony_ci * @tc.level: Level 3 715f6603c60Sopenharmony_ci */ 716f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushSetBlendModeNull, TestSize.Level3) { 717f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 718f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 719f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushSetBlendMode with nullptr as the first parameter 720f6603c60Sopenharmony_ci OH_Drawing_BrushSetBlendMode(nullptr, BLEND_MODE_CLEAR); 721f6603c60Sopenharmony_ci // 3. Free memory 722f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 723f6603c60Sopenharmony_ci} 724f6603c60Sopenharmony_ci 725f6603c60Sopenharmony_ci/* 726f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_1500 727f6603c60Sopenharmony_ci * @tc.name: testBrushResetNormal 728f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushResetNormal. 729f6603c60Sopenharmony_ci * @tc.size: SmallTest 730f6603c60Sopenharmony_ci * @tc.type: Function 731f6603c60Sopenharmony_ci * @tc.level: Level 0 732f6603c60Sopenharmony_ci */ 733f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushResetNormal, TestSize.Level0) { 734f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 735f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 736f6603c60Sopenharmony_ci uint32_t color1 = OH_Drawing_BrushGetColor(brush); 737f6603c60Sopenharmony_ci // 2. Set the color for the brush object by calling OH_Drawing_BrushSetColor 738f6603c60Sopenharmony_ci OH_Drawing_BrushSetColor(brush, 0x12345678); 739f6603c60Sopenharmony_ci // 3. Get the color of the brush object by calling OH_Drawing_BrushGetColor 740f6603c60Sopenharmony_ci uint32_t color2 = OH_Drawing_BrushGetColor(brush); 741f6603c60Sopenharmony_ci EXPECT_EQ(color2, 0x12345678); 742f6603c60Sopenharmony_ci // 4. Reset the state of the brush object by calling OH_Drawing_BrushReset 743f6603c60Sopenharmony_ci OH_Drawing_BrushReset(brush); 744f6603c60Sopenharmony_ci // 5. Get the color of the brush object by calling OH_Drawing_BrushGetColor 745f6603c60Sopenharmony_ci uint32_t color3 = OH_Drawing_BrushGetColor(brush); 746f6603c60Sopenharmony_ci EXPECT_EQ(color3, color1); 747f6603c60Sopenharmony_ci // 6. Free memory 748f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 749f6603c60Sopenharmony_ci} 750f6603c60Sopenharmony_ci 751f6603c60Sopenharmony_ci/* 752f6603c60Sopenharmony_ci * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_BRUSH_1501 753f6603c60Sopenharmony_ci * @tc.name: testBrushResetNull 754f6603c60Sopenharmony_ci * @tc.desc: Test for testBrushResetNull. 755f6603c60Sopenharmony_ci * @tc.size: SmallTest 756f6603c60Sopenharmony_ci * @tc.type: Function 757f6603c60Sopenharmony_ci * @tc.level: Level 3 758f6603c60Sopenharmony_ci */ 759f6603c60Sopenharmony_ciHWTEST_F(DrawingNativeBrushTest, testBrushResetNull, TestSize.Level3) { 760f6603c60Sopenharmony_ci // 1. Create a brush object by calling OH_Drawing_BrushCreate 761f6603c60Sopenharmony_ci OH_Drawing_Brush *brush = OH_Drawing_BrushCreate(); 762f6603c60Sopenharmony_ci // 2. Call OH_Drawing_BrushReset with nullptr as the parameter 763f6603c60Sopenharmony_ci OH_Drawing_BrushReset(nullptr); 764f6603c60Sopenharmony_ci // 3. Free memory 765f6603c60Sopenharmony_ci OH_Drawing_BrushDestroy(brush); 766f6603c60Sopenharmony_ci} 767f6603c60Sopenharmony_ci 768f6603c60Sopenharmony_ci} // namespace Drawing 769f6603c60Sopenharmony_ci} // namespace Rosen 770f6603c60Sopenharmony_ci} // namespace OHOS