/* * Copyright (c) 2024 Shenzhen Kaihong Digital Industry Development Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "gtest/gtest.h" #include "drawing_color.h" #include "drawing_color_filter.h" #include "drawing_filter.h" #include "drawing_matrix.h" #include "drawing_path.h" #include "drawing_path_effect.h" #include "drawing_pen.h" #include "drawing_point.h" #include "drawing_rect.h" #include "drawing_shader_effect.h" #include "drawing_shadow_layer.h" using namespace testing; using namespace testing::ext; namespace OHOS { namespace Rosen { namespace Drawing { class DrawingNativePenTest : public testing::Test {}; /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0100 * @tc.name: testPenCreateNormal * @tc.desc: Test for testPenCreateNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenCreateNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Free the memory using OH_Drawing_PenDestroy OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0200 * @tc.name: testPenCopyNormal * @tc.desc: Test for testPenCopyNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenCopyNormal, TestSize.Level0) { // 1. Create a pen object 1 using OH_Drawing_PenCreate OH_Drawing_Pen *pen1 = OH_Drawing_PenCreate(); // 2. Set color for pen 1 using OH_Drawing_PenSetColor OH_Drawing_PenSetColor(pen1, 0x00000000); // 3. Copy pen 1 to pen 2 using OH_Drawing_PenCopy OH_Drawing_Pen *pen2 = OH_Drawing_PenCopy(pen1); // 4. Get color of pen 2 using OH_Drawing_PenGetColor uint32_t color = OH_Drawing_PenGetColor(pen2); EXPECT_EQ(color, 0x00000000); // 5. Modify color of pen 1 using OH_Drawing_PenSetColor OH_Drawing_PenSetColor(pen1, 0x00FF0000); // 6. Get color of pen 2 using OH_Drawing_PenGetColor uint32_t color2 = OH_Drawing_PenGetColor(pen2); EXPECT_EQ(color2, 0x00000000); // 7. Free the memory OH_Drawing_PenDestroy(pen1); OH_Drawing_PenDestroy(pen2); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0201 * @tc.name: testPenCopyNull * @tc.desc: Test for testPenCopyNull. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenCopyNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Copy pen object with nullptr using OH_Drawing_PenCopy OH_Drawing_Pen *pen2 = OH_Drawing_PenCopy(nullptr); // 3. Free the memory OH_Drawing_PenDestroy(pen); OH_Drawing_PenDestroy(pen2); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0202 * @tc.name: testPenCopyInputDestroyed * @tc.desc: Test for testPenCopyInputDestroyed. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenCopyInputDestroyed, TestSize.Level3) { // 1. Create a pen object 1 using OH_Drawing_PenCreate OH_Drawing_Pen *pen1 = OH_Drawing_PenCreate(); // 2. Copy pen 1 to pen 2 using OH_Drawing_PenCopy OH_Drawing_Pen *pen2 = OH_Drawing_PenCopy(pen1); // 3. Destroy pen 1 using OH_Drawing_PenDestroy OH_Drawing_PenDestroy(pen1); // 4. Set color for pen 2 using OH_Drawing_PenSetColor OH_Drawing_PenSetColor(pen2, 0x00000000); // 5. Get color of pen 2 using OH_Drawing_PenGetColor uint32_t color = OH_Drawing_PenGetColor(pen2); EXPECT_EQ(color, 0x00000000); // 6. Free the memory OH_Drawing_PenDestroy(pen2); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0300 * @tc.name: testPenDestroyNormal * @tc.desc: Test for testPenDestroyNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenDestroyNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Destroy the object using OH_Drawing_PenDestroy OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0301 * @tc.name: testPenDestroyNull * @tc.desc: Test for testPenDestroyNull. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenDestroyNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Destroy the object with nullptr using OH_Drawing_PenDestroy OH_Drawing_PenDestroy(nullptr); // 3. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0400 * @tc.name: testPenIsAntiAliasNormal * @tc.desc: Test for testPenIsAntiAliasNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenIsAntiAliasNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set anti-aliasing for the pen using OH_Drawing_PenSetAntiAlias OH_Drawing_PenSetAntiAlias(pen, true); // 3. Get the anti-aliasing status of the pen using OH_Drawing_PenIsAntiAlias bool isAntiAlias = OH_Drawing_PenIsAntiAlias(pen); EXPECT_EQ(isAntiAlias, true); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0401 * @tc.name: testPenIsAntiAliasNull * @tc.desc: Test for testPenIsAntiAliasNull. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenIsAntiAliasNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Call OH_Drawing_PenIsAntiAlias with nullptr as parameter bool isAntiAlias = OH_Drawing_PenIsAntiAlias(nullptr); EXPECT_EQ(isAntiAlias, false); // 3. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0500 * @tc.name: testPenSetAntiAliasNormal * @tc.desc: Test for testPenSetAntiAliasNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenSetAntiAliasNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set anti-aliasing for the pen using OH_Drawing_PenSetAntiAlias OH_Drawing_PenSetAntiAlias(pen, true); // 3. Get the anti-aliasing status of the pen using OH_Drawing_PenIsAntiAlias bool isAntiAlias = OH_Drawing_PenIsAntiAlias(pen); EXPECT_EQ(isAntiAlias, true); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0501 * @tc.name: testPenSetAntiAliasNull * @tc.desc: Test for testPenSetAntiAliasNull. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetAntiAliasNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set anti-aliasing for the pen using OH_Drawing_PenSetAntiAlias OH_Drawing_PenSetAntiAlias(nullptr, true); // 3. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0600 * @tc.name: testPenGetColorNormal * @tc.desc: Test for testPenGetColorNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenGetColorNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set color for the pen using OH_Drawing_PenSetColor OH_Drawing_PenSetColor(pen, 0x00000000); // 3. Get color of the pen using OH_Drawing_PenGetColor uint32_t color = OH_Drawing_PenGetColor(pen); EXPECT_EQ(color, 0x00000000); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0601 * @tc.name: testPenGetColorNull * @tc.desc: Test for testPenGetColorNull. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenGetColorNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Call OH_Drawing_PenGetColor with nullptr as parameter OH_Drawing_PenGetColor(nullptr); // 3. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0700 * @tc.name: testPenSetColorNormal * @tc.desc: Test for testPenSetColorNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenSetColorNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set color for the pen using OH_Drawing_PenSetColor OH_Drawing_PenSetColor(pen, 0x00000000); // 3. Get color of the pen using OH_Drawing_PenGetColor uint32_t color = OH_Drawing_PenGetColor(pen); EXPECT_EQ(color, 0x00000000); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0701 * @tc.name: testPenSetColorNull * @tc.desc: Test for testPenSetColorNull. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetColorNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set color for the pen using OH_Drawing_PenSetColor with nullptr as the first parameter OH_Drawing_PenSetColor(nullptr, 0x00000000); // 3. Set color for the pen using OH_Drawing_PenSetColor with 0x00000000 as the second parameter OH_Drawing_PenSetColor(pen, 0x00000000); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0702 * @tc.name: testPenSetColorAbnormal * @tc.desc: Test for testPenSetColorAbnormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetColorAbnormal, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the second parameter of OH_Drawing_PenSetColor to a negative number or a floating-point number OH_Drawing_PenSetColor(pen, -1); // 3. Call OH_Drawing_PenGetColor uint32_t color = OH_Drawing_PenGetColor(pen); EXPECT_EQ(static_cast(-1), color); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0703 * @tc.name: testPenSetColorMaximum * @tc.desc: Test for testPenSetColorMaximum. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetColorMaximum, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the second parameter of OH_Drawing_PenSetColor to a maximum value of 0xFFFFFFFF + 1 OH_Drawing_PenSetColor(pen, 0xFFFFFFFF + 1); // 3. Get the color of the pen using OH_Drawing_PenGetColor uint32_t color = OH_Drawing_PenGetColor(pen); EXPECT_EQ(0xFFFFFFFF + 1, color); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0800 * @tc.name: testPenGetAlphaNormal * @tc.desc: Test for testPenGetAlphaNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenGetAlphaNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the alpha value for the pen using OH_Drawing_PenSetAlpha OH_Drawing_PenSetAlpha(pen, 0x00); // 3. Get the alpha value of the pen using OH_Drawing_PenGetAlpha uint8_t alpha = OH_Drawing_PenGetAlpha(pen); EXPECT_EQ(alpha, 0x00); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0801 * @tc.name: testPenGetAlphaNull * @tc.desc: Test for testPenGetAlphaNull. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenGetAlphaNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Call OH_Drawing_PenGetAlpha with nullptr as parameter OH_Drawing_PenGetAlpha(nullptr); // 3. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0900 * @tc.name: testPenSetAlphaNormal * @tc.desc: Test for testPenSetAlphaNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenSetAlphaNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the alpha value for the pen using OH_Drawing_PenSetAlpha OH_Drawing_PenSetAlpha(pen, 0x00); // 3. Get the alpha value of the pen using OH_Drawing_PenGetAlpha uint8_t alpha = OH_Drawing_PenGetAlpha(pen); EXPECT_EQ(alpha, 0x00); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0901 * @tc.name: testPenSetAlphaNull * @tc.desc: Test for testPenSetAlphaNull. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetAlphaNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the alpha value for the pen using OH_Drawing_PenSetAlpha with nullptr as the first parameter OH_Drawing_PenSetAlpha(nullptr, 0xff); // 3. Set the alpha value for the pen using OH_Drawing_PenSetAlpha with 0x00 as the second parameter OH_Drawing_PenSetAlpha(pen, 0x00); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0902 * @tc.name: testPenSetAlphaAbnormal * @tc.desc: Test for testPenSetAlphaAbnormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetAlphaAbnormal, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the second parameter of OH_Drawing_PenSetAlpha to a negative number or a floating-point number OH_Drawing_PenSetAlpha(pen, -1); // 3. Call OH_Drawing_PenGetAlpha uint8_t alpha = OH_Drawing_PenGetAlpha(pen); EXPECT_EQ(static_cast(-1), alpha); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_0903 * @tc.name: testPenSetAlphaMaximum * @tc.desc: Test for testPenSetAlphaMaximum. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetAlphaMaximum, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the second parameter of OH_Drawing_PenSetAlpha to a maximum value of 0xFF + 1 uint8_t alpha1 = 0xFF; OH_Drawing_PenSetAlpha(pen, alpha1 + 1); // 3. Call OH_Drawing_PenGetAlpha uint8_t alpha2 = OH_Drawing_PenGetAlpha(pen); EXPECT_EQ(alpha2, 0); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1000 * @tc.name: testPenGetWidthNormal * @tc.desc: Test for testPenGetWidthNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenGetWidthNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the pen width using OH_Drawing_PenSetWidth OH_Drawing_PenSetWidth(pen, 1.0); // 3. Get the pen width using OH_Drawing_PenGetWidth float width = OH_Drawing_PenGetWidth(pen); EXPECT_EQ(width, 1.0); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1001 * @tc.name: testPenGetWidthNull * @tc.desc: Test for testPenGetWidthNull. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenGetWidthNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Call OH_Drawing_PenGetWidth with nullptr as parameter OH_Drawing_PenGetWidth(nullptr); // 3. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1002 * @tc.name: testPenGetWidthBoundary * @tc.desc: Test for testPenGetWidthBoundary. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenGetWidthBoundary, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the pen width using OH_Drawing_PenSetWidth float width = 4096.0; OH_Drawing_PenSetWidth(pen, width); // 3. Get the pen width using OH_Drawing_PenGetWidth float getWidth = OH_Drawing_PenGetWidth(pen); EXPECT_EQ(width, getWidth); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1100 * @tc.name: testPenSetWidthNormal * @tc.desc: Test for testPenSetWidthNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenSetWidthNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the pen width using OH_Drawing_PenSetWidth OH_Drawing_PenSetWidth(pen, 1.0); // 3. Get the pen width using OH_Drawing_PenGetWidth float width = OH_Drawing_PenGetWidth(pen); EXPECT_EQ(width, 1.0); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1101 * @tc.name: testPenSetWidthNull * @tc.desc: Test for testPenSetWidthNull. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetWidthNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Call OH_Drawing_PenSetWidth with nullptr as the first parameter OH_Drawing_PenSetWidth(nullptr, 1.00); // 3. Call OH_Drawing_PenSetWidth with 0.00 as the second parameter OH_Drawing_PenSetWidth(pen, 0.00); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1102 * @tc.name: testPenSetWidthAbnormal * @tc.desc: Test for testPenSetWidthAbnormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetWidthAbnormal, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the pen width using OH_Drawing_PenSetWidth with an integer or character data as the second parameter int width = 1; OH_Drawing_PenSetWidth(pen, width); // 3. Get the pen width using OH_Drawing_PenGetWidth float width2 = OH_Drawing_PenGetWidth(pen); EXPECT_EQ(static_cast(1), width2); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1103 * @tc.name: testPenSetWidthMultipleCalls * @tc.desc: Test for testPenSetWidthMultipleCalls. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetWidthMultipleCalls, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Loop through 10 times and set the pen width using OH_Drawing_PenSetWidth for (int i = 0; i < 10; i++) { OH_Drawing_PenSetWidth(pen, 1.0); } // 3. Loop through 10 times and get the pen width using OH_Drawing_PenGetWidth for (int i = 0; i < 10; i++) { float width = OH_Drawing_PenGetWidth(pen); EXPECT_EQ(width, 1.0); } // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1104 * @tc.name: testPenSetWidthMultipleCallsBoundary * @tc.desc: Test for testPenSetWidthMultipleCallsBoundary. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetWidthMultipleCallsBoundary, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Loop through 10 times and set the pen width using OH_Drawing_PenSetWidth for (int i = 0; i < 10; i++) { OH_Drawing_PenSetWidth(pen, 4096.0); } // 3. Loop through 10 times and get the pen width using OH_Drawing_PenGetWidth for (int i = 0; i < 10; i++) { float width = OH_Drawing_PenGetWidth(pen); EXPECT_EQ(width, 4096.0); } // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1200 * @tc.name: testPenGetMiterLimitNormal * @tc.desc: Test for testPenGetMiterLimitNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenGetMiterLimitNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the miter limit for the pen using OH_Drawing_PenSetMiterLimit OH_Drawing_PenSetMiterLimit(pen, 1.0); // 3. Get the miter limit using OH_Drawing_PenGetMiterLimit float miterLimit = OH_Drawing_PenGetMiterLimit(pen); EXPECT_EQ(miterLimit, 1.0); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1201 * @tc.name: testPenGetMiterLimitNull * @tc.desc: Test for testPenGetMiterLimitNull. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenGetMiterLimitNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Call OH_Drawing_PenGetMiterLimit with nullptr as parameter OH_Drawing_PenGetMiterLimit(nullptr); // 3. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1300 * @tc.name: testPenSetMiterLimitNormal * @tc.desc: Test for testPenSetMiterLimitNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenSetMiterLimitNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the miter limit for the pen using OH_Drawing_PenSetMiterLimit OH_Drawing_PenSetMiterLimit(pen, 1.0); // 3. Get the miter limit using OH_Drawing_PenGetMiterLimit float miterLimit = OH_Drawing_PenGetMiterLimit(pen); EXPECT_EQ(miterLimit, 1.0); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1301 * @tc.name: testPenSetMiterLimitNull * @tc.desc: Test for testPenSetMiterLimitNull. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetMiterLimitNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Call OH_Drawing_PenSetMiterLimit with nullptr as the first parameter OH_Drawing_PenSetMiterLimit(nullptr, 1.0); // 3. Call OH_Drawing_PenSetMiterLimit with 0.0 as the second parameter OH_Drawing_PenSetMiterLimit(pen, 0.0); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1302 * @tc.name: testPenSetMiterLimitAbnormal * @tc.desc: Test for testPenSetMiterLimitAbnormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetMiterLimitAbnormal, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the miter limit for the pen using OH_Drawing_PenSetMiterLimit with an integer or character data as the // second parameter int miterLimit = 1; OH_Drawing_PenSetMiterLimit(pen, miterLimit); // 3. Get the miter limit using OH_Drawing_PenGetMiterLimit float miterLimit2 = OH_Drawing_PenGetMiterLimit(pen); EXPECT_EQ(static_cast(1), miterLimit2); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1303 * @tc.name: testPenSetMiterLimitMultipleCalls * @tc.desc: Test for testPenSetMiterLimitMultipleCalls. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetMiterLimitMultipleCalls, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Loop through 10 times and set the miter limit for the pen using OH_Drawing_PenSetMiterLimit for (int i = 0; i < 10; i++) { OH_Drawing_PenSetMiterLimit(pen, 1.0); } // 3. Loop through 10 times and get the miter limit using OH_Drawing_PenGetMiterLimit for (int i = 0; i < 10; i++) { OH_Drawing_PenGetMiterLimit(pen); } // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1400 * @tc.name: testPenGetCapNormal * @tc.desc: Test for testPenGetCapNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenGetCapNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the pen cap style using OH_Drawing_PenSetCap OH_Drawing_PenSetCap(pen, LINE_FLAT_CAP); // 3. Get the pen cap style using OH_Drawing_PenGetCap OH_Drawing_PenLineCapStyle cap = OH_Drawing_PenGetCap(pen); EXPECT_EQ(cap, LINE_FLAT_CAP); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1401 * @tc.name: testPenGetCapNull * @tc.desc: Test for testPenGetCapNull. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenGetCapNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Call OH_Drawing_PenGetCap with nullptr as parameter OH_Drawing_PenGetCap(nullptr); // 3. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1500 * @tc.name: testPenSetCapNormal * @tc.desc: Test for testPenSetCapNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenSetCapNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Call OH_Drawing_PenSetCap with the second parameter as an enumeration by looping through the styles array OH_Drawing_PenLineCapStyle styles[] = {LINE_FLAT_CAP, LINE_SQUARE_CAP, LINE_ROUND_CAP}; for (int i = 0; i < 3; i++) { OH_Drawing_PenSetCap(pen, styles[i]); // 3. Get the pen cap style using OH_Drawing_PenGetCap OH_Drawing_PenLineCapStyle cap = OH_Drawing_PenGetCap(pen); EXPECT_EQ(cap, styles[i]); } // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1501 * @tc.name: testPenSetCapNull * @tc.desc: Test for testPenSetCapNull. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetCapNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Call OH_Drawing_PenSetCap with nullptr as the first parameter OH_Drawing_PenSetCap(nullptr, LINE_FLAT_CAP); // 3. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1502 * @tc.name: testPenSetCapMultipleCalls * @tc.desc: Test for testPenSetCapMultipleCalls. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetCapMultipleCalls, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Loop through 10 times and set the pen cap style using OH_Drawing_PenSetCap for (int i = 0; i < 10; i++) { OH_Drawing_PenSetCap(pen, LINE_FLAT_CAP); } // 3. Loop through 10 times and get the pen cap style using OH_Drawing_PenGetCap for (int i = 0; i < 10; i++) { OH_Drawing_PenGetCap(pen); } // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1600 * @tc.name: testPenGetJoinNormal * @tc.desc: Test for testPenGetJoinNormal. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 0 */ HWTEST_F(DrawingNativePenTest, testPenGetJoinNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the join style for the pen using OH_Drawing_PenSetJoin OH_Drawing_PenSetJoin(pen, LINE_MITER_JOIN); // 3. Get the join style using OH_Drawing_PenGetJoin OH_Drawing_PenLineJoinStyle join = OH_Drawing_PenGetJoin(pen); EXPECT_EQ(join, LINE_MITER_JOIN); // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1601 * @tc.name: testPenGetJoinNull * @tc.desc: Test for testPenGetJoinNull. * @tc.size: SmallTest * @tc.type: Function * @tc.level: Level 3 */ HWTEST_F(DrawingNativePenTest, testPenGetJoinNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Call OH_Drawing_PenGetJoin with nullptr as parameter OH_Drawing_PenGetJoin(nullptr); // 3. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1700 * @tc.name: testPenSetJoinNormal * @tc.desc: test for testPenSetJoinNormal. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 0 */ HWTEST_F(DrawingNativePenTest, testPenSetJoinNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Call OH_Drawing_PenSetJoin with the second parameter as an enumeration by looping through the styles array OH_Drawing_PenLineJoinStyle styles[] = {LINE_MITER_JOIN, LINE_ROUND_JOIN, LINE_BEVEL_JOIN}; for (int i = 0; i < 3; i++) { OH_Drawing_PenSetJoin(pen, styles[i]); // 3. Get the join style using OH_Drawing_PenGetJoin OH_Drawing_PenLineJoinStyle join = OH_Drawing_PenGetJoin(pen); EXPECT_EQ(join, styles[i]); } // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1701 * @tc.name: testPenSetJoinNull * @tc.desc: test for testPenSetJoinNull. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetJoinNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Call OH_Drawing_PenSetJoin with nullptr as the first parameter OH_Drawing_PenSetJoin(nullptr, LINE_MITER_JOIN); // 3. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1702 * @tc.name: testPenSetJoinMultipleCalls * @tc.desc: test for testPenSetJoinMultipleCalls. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetJoinMultipleCalls, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Loop through 10 times and set the pen join style using OH_Drawing_PenSetJoin for (int i = 0; i < 10; i++) { OH_Drawing_PenSetJoin(pen, LINE_MITER_JOIN); } // 3. Loop through 10 times and get the pen join style using OH_Drawing_PenGetJoin for (int i = 0; i < 10; i++) { OH_Drawing_PenGetJoin(pen); } // 4. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1800 * @tc.name: testPenSetShaderEffectNormal * @tc.desc: test for testPenSetShaderEffectNormal. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 0 */ HWTEST_F(DrawingNativePenTest, testPenSetShaderEffectNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Create a shader object using OH_Drawing_ShaderEffectCreate OH_Drawing_Point *startPt = OH_Drawing_PointCreate(100, 400); OH_Drawing_Point *endPt = OH_Drawing_PointCreate(200, 500); uint32_t color[] = {0xffff0000, 0xff00ff00}; float pos[] = {0., 1.0}; OH_Drawing_ShaderEffect *linearGradient = OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, color, pos, 2, OH_Drawing_TileMode::CLAMP); // 3. Set the shader effect for the pen using OH_Drawing_PenSetShaderEffect OH_Drawing_PenSetShaderEffect(pen, linearGradient); // 4. Free the memory OH_Drawing_PointDestroy(startPt); OH_Drawing_PointDestroy(endPt); OH_Drawing_ShaderEffectDestroy(linearGradient); OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1801 * @tc.name: testPenSetShaderEffectNull * @tc.desc: test for testPenSetShaderEffectNull. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetShaderEffectNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Create a shader object using OH_Drawing_ShaderEffectCreate OH_Drawing_Point *startPt = OH_Drawing_PointCreate(100, 400); OH_Drawing_Point *endPt = OH_Drawing_PointCreate(200, 500); uint32_t color[] = {0xffff0000, 0xff00ff00}; float pos[] = {0., 1.0}; OH_Drawing_ShaderEffect *linearGradient = OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, color, pos, 2, OH_Drawing_TileMode::CLAMP); // 3. Call OH_Drawing_PenSetShaderEffect with nullptr as the first parameter OH_Drawing_PenSetShaderEffect(nullptr, linearGradient); // 4. Call OH_Drawing_PenSetShaderEffect with nullptr as the second parameter OH_Drawing_PenSetShaderEffect(pen, nullptr); // 5. Free the memory OH_Drawing_PointDestroy(startPt); OH_Drawing_PointDestroy(endPt); OH_Drawing_ShaderEffectDestroy(linearGradient); OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1900 * @tc.name: testPenSetShadowLayerNormal * @tc.desc: test for testPenSetShadowLayerNormal. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 0 */ HWTEST_F(DrawingNativePenTest, testPenSetShadowLayerNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Create a shadow layer object using OH_Drawing_ShadowLayerCreate OH_Drawing_ShadowLayer *shadowLayer = OH_Drawing_ShadowLayerCreate(10, 10, 10, 0xff000000); // 3. Set the shadow layer for the pen using OH_Drawing_PenSetShadowLayer OH_Drawing_PenSetShadowLayer(pen, shadowLayer); // 4. Free the memory OH_Drawing_ShadowLayerDestroy(shadowLayer); OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_1901 * @tc.name: testPenSetShadowLayerNull * @tc.desc: test for testPenSetShadowLayerNull. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetShadowLayerNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Create a shadow layer object using OH_Drawing_ShadowLayerCreate OH_Drawing_ShadowLayer *shadowLayer = OH_Drawing_ShadowLayerCreate(10, 10, 10, 0xff000000); // 3. Set the shadow layer for the pen using OH_Drawing_PenSetShadowLayer with nullptr as the first parameter OH_Drawing_PenSetShadowLayer(nullptr, shadowLayer); // 4. Set the shadow layer for the pen using OH_Drawing_PenSetShadowLayer with nullptr as the second parameter OH_Drawing_PenSetShadowLayer(pen, nullptr); // 5. Free the memory OH_Drawing_ShadowLayerDestroy(shadowLayer); OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2000 * @tc.name: testPenSetPathEffectNormal * @tc.desc: test for testPenSetPathEffectNormal. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 0 */ HWTEST_F(DrawingNativePenTest, testPenSetPathEffectNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Create a path effect object using OH_Drawing_PathEffectCreate float intervals[] = {1, 1, 1}; OH_Drawing_PathEffect *pathEffect = OH_Drawing_CreateDashPathEffect(intervals, 3, 0.0); // 3. Set the path effect for the pen using OH_Drawing_PenSetPathEffect OH_Drawing_PenSetPathEffect(pen, pathEffect); // 4. Free the memory OH_Drawing_PathEffectDestroy(pathEffect); OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2001 * @tc.name: testPenSetPathEffectNull * @tc.desc: test for testPenSetPathEffectNull. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetPathEffectNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Create a path effect object using OH_Drawing_PathEffectCreate float intervals[] = {1, 1, 1}; OH_Drawing_PathEffect *pathEffect = OH_Drawing_CreateDashPathEffect(intervals, 3, 0.0); // 3. Set the path effect for the pen with nullptr as the first parameter OH_Drawing_PenSetPathEffect(nullptr, pathEffect); // 4. Set the path effect for the pen with nullptr as the second parameter OH_Drawing_PenSetPathEffect(pen, nullptr); // 5. Free the memory OH_Drawing_PathEffectDestroy(pathEffect); OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2100 * @tc.name: testPenSetFilterNormal * @tc.desc: test for testPenSetFilterNormal. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 0 */ HWTEST_F(DrawingNativePenTest, testPenSetFilterNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Create a filter object using OH_Drawing_FilterCreate OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); // 3. Set the filter effect for the pen using OH_Drawing_PenSetFilter OH_Drawing_PenSetFilter(pen, filter); // 4. Get the filter effect for the pen using OH_Drawing_PenGetFilter OH_Drawing_Filter *filter2 = OH_Drawing_FilterCreate(); OH_Drawing_PenGetFilter(pen, filter2); // 5. Free the memory OH_Drawing_FilterDestroy(filter); OH_Drawing_FilterDestroy(filter2); OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2101 * @tc.name: testPenSetFilterNull * @tc.desc: test for testPenSetFilterNull. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetFilterNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Create a filter object using OH_Drawing_FilterCreate OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); // 3. Call OH_Drawing_PenSetFilter with nullptr as the first parameter OH_Drawing_PenSetFilter(nullptr, filter); // 4. Call OH_Drawing_PenSetFilter with nullptr as the second parameter OH_Drawing_PenSetFilter(pen, nullptr); // 5. Free the memory OH_Drawing_FilterDestroy(filter); OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2200 * @tc.name: testPenGetFilterNormal * @tc.desc: test for testPenGetFilterNormal. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 0 */ HWTEST_F(DrawingNativePenTest, testPenGetFilterNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Create a filter object using OH_Drawing_FilterCreate OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); // 3. Set the filter effect for the pen using OH_Drawing_PenSetFilter OH_Drawing_PenSetFilter(pen, filter); // 4. Get the filter effect for the pen using OH_Drawing_PenGetFilter OH_Drawing_Filter *filter2 = OH_Drawing_FilterCreate(); OH_Drawing_PenGetFilter(pen, filter2); // 5. Free the memory OH_Drawing_FilterDestroy(filter); OH_Drawing_FilterDestroy(filter2); OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2201 * @tc.name: testPenGetFilterNull * @tc.desc: test for testPenGetFilterNull. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 3 */ HWTEST_F(DrawingNativePenTest, testPenGetFilterNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Create a filter object using OH_Drawing_FilterCreate OH_Drawing_Filter *filter = OH_Drawing_FilterCreate(); // 3. Call OH_Drawing_PenGetFilter with nullptr as the first parameter OH_Drawing_PenGetFilter(nullptr, filter); // 4. Call OH_Drawing_PenGetFilter with nullptr as the second parameter OH_Drawing_PenGetFilter(pen, nullptr); // 5. Free the memory OH_Drawing_FilterDestroy(filter); OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2300 * @tc.name: testPenSetBlendModeNormal * @tc.desc: test for testPenSetBlendModeNormal. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 0 */ HWTEST_F(DrawingNativePenTest, testPenSetBlendModeNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Use a loop to iterate through the enum values of OH_Drawing_BlendMode and call OH_Drawing_PenSetBlendMode with // the second parameter OH_Drawing_BlendMode modes[] = {BLEND_MODE_CLEAR, BLEND_MODE_SRC, BLEND_MODE_DST}; for (int i = 0; i < 3; i++) { OH_Drawing_PenSetBlendMode(pen, modes[i]); } // 3. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2301 * @tc.name: testPenSetBlendModeNull * @tc.desc: test for testPenSetBlendModeNull. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 3 */ HWTEST_F(DrawingNativePenTest, testPenSetBlendModeNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Call OH_Drawing_PenSetBlendMode with nullptr as the first parameter OH_Drawing_PenSetBlendMode(nullptr, BLEND_MODE_CLEAR); // 3. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2400 * @tc.name: testPenGetFillPathNormal * @tc.desc: test for testPenGetFillPathNormal. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 0 */ HWTEST_F(DrawingNativePenTest, testPenGetFillPathNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Create a source path object using OH_Drawing_PathCreate OH_Drawing_Path *srcPath = OH_Drawing_PathCreate(); // 3. Create a destination path object using OH_Drawing_PathCreate OH_Drawing_Path *dstPath = OH_Drawing_PathCreate(); // 4. Create a rectangle object using OH_Drawing_RectCreate OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); // 5. Create a matrix object using OH_Drawing_MatrixCreate OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); // 6. Call OH_Drawing_PenGetFillPath OH_Drawing_PenGetFillPath(pen, srcPath, dstPath, rect, matrix); // 7. Free the memory OH_Drawing_PathDestroy(srcPath); OH_Drawing_PathDestroy(dstPath); OH_Drawing_RectDestroy(rect); OH_Drawing_MatrixDestroy(matrix); OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2401 * @tc.name: testPenGetFillPathNull * @tc.desc: test for testPenGetFillPathNull. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 3 */ HWTEST_F(DrawingNativePenTest, testPenGetFillPathNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Create a source path object using OH_Drawing_PathCreate OH_Drawing_Path *srcPath = OH_Drawing_PathCreate(); // 3. Create a destination path object using OH_Drawing_PathCreate OH_Drawing_Path *dstPath = OH_Drawing_PathCreate(); // 4. Create a rectangle object using OH_Drawing_RectCreate OH_Drawing_Rect *rect = OH_Drawing_RectCreate(100, 100, 200, 200); // 5. Create a matrix object using OH_Drawing_MatrixCreate OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate(); // 6. Call OH_Drawing_PenGetFillPath with nullptr as the first parameter OH_Drawing_PenGetFillPath(nullptr, srcPath, dstPath, rect, matrix); // 7. Call OH_Drawing_PenGetFillPath with nullptr as the second parameter OH_Drawing_PenGetFillPath(pen, nullptr, dstPath, rect, matrix); // 8. Call OH_Drawing_PenGetFillPath with nullptr as the third parameter OH_Drawing_PenGetFillPath(pen, srcPath, nullptr, rect, matrix); // 9. Call OH_Drawing_PenGetFillPath with nullptr as the fourth parameter OH_Drawing_PenGetFillPath(pen, srcPath, dstPath, nullptr, matrix); // 10. Call OH_Drawing_PenGetFillPath with nullptr as the fifth parameter OH_Drawing_PenGetFillPath(pen, srcPath, dstPath, rect, nullptr); // 11. Free the memory OH_Drawing_PathDestroy(srcPath); OH_Drawing_PathDestroy(dstPath); OH_Drawing_RectDestroy(rect); OH_Drawing_MatrixDestroy(matrix); OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2500 * @tc.name: testPenResetNormal * @tc.desc: test for testPenResetNormal. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 0 */ HWTEST_F(DrawingNativePenTest, testPenResetNormal, TestSize.Level0) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Set the pen color using OH_Drawing_PenSetColor OH_Drawing_PenSetColor(pen, 0xff0000ff); // 3. Get the pen color using OH_Drawing_PenGetColor uint32_t color = OH_Drawing_PenGetColor(pen); EXPECT_EQ(0xff0000ff, color); // 4. Reset the pen state using OH_Drawing_PenReset OH_Drawing_PenReset(pen); // 5. Get the pen color using OH_Drawing_PenGetColor color = OH_Drawing_PenGetColor(pen); OH_Drawing_Pen *pen2 = OH_Drawing_PenCreate(); uint32_t color2 = OH_Drawing_PenGetColor(pen2); EXPECT_EQ(color2, color); // 6. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2501 * @tc.name: testPenResetNull * @tc.desc: test for testPenResetNull. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 3 */ HWTEST_F(DrawingNativePenTest, testPenResetNull, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Call OH_Drawing_PenReset with nullptr as the parameter OH_Drawing_PenReset(nullptr); // 3. Free the memory OH_Drawing_PenDestroy(pen); } /* * @tc.number: SUB_BASIC_GRAPHICS_SPECIAL_API_C_DRAWING_PEN_2502 * @tc.name: testPenResetMultipleCalls * @tc.desc: test for testPenResetMultipleCalls. * @tc.size : SmallTest * @tc.type : Function * @tc.level : Level 3 */ HWTEST_F(DrawingNativePenTest, testPenResetMultipleCalls, TestSize.Level3) { // 1. Create a pen object using OH_Drawing_PenCreate OH_Drawing_Pen *pen = OH_Drawing_PenCreate(); // 2. Use a loop to call OH_Drawing_PenSetColor and set the pen color 10 times for (int i = 0; i < 10; i++) { OH_Drawing_PenSetColor(pen, 0xff0000ff); } // 3. Use a loop to call OH_Drawing_PenGetColor and get the pen color 10 times for (int i = 0; i < 10; i++) { OH_Drawing_PenGetColor(pen); } // 4. Use a loop to call OH_Drawing_PenReset and reset the pen state 10 times for (int i = 0; i < 10; i++) { OH_Drawing_PenReset(pen); } // 5. Use a loop to call OH_Drawing_PenGetColor and get the pen color 10 times for (int i = 0; i < 10; i++) { OH_Drawing_PenGetColor(pen); } // 6. Free the memory OH_Drawing_PenDestroy(pen); } } // namespace Drawing } // namespace Rosen } // namespace OHOS