/*
 * 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 "include/DrawingNativePenTest.h"
#include "include/OhosCommonTest.h"

#define DRAWING_NUMBER_1 1
#define DRAWING_NUMBER_2 2
#define DRAWING_NUMBER_3 3
#define DRAWING_NUMBER_10 10
#define DRAWING_NUMBER_50 50
#define DRAWING_NUMBER_100 100
#define DRAWING_NUMBER_200 200
#define DRAWING_NUMBER_400 400
#define DRAWING_NUMBER_500 500
#define DRAWING_NUMBER_4096 4096
#define DRAWING_NUMBER_0XFF 0xFF

namespace OHOS {
namespace Rosen {
namespace Drawing {

void DrawingNativePenTestSetUp()
{
    std::cout << "DrawingNativePenTest Setup code called before each test case." << std::endl;
    OH_Drawing_ErrorCodeReset();
    std::cout << "DrawingNativePenTest errorCodeReset before each test case." << std::endl;
}

void DrawingNativePenTestTearDown()
{
    std::cout << "DrawingNativePenTest Setup code called after each test case." << std::endl;
    OH_Drawing_ErrorCodeReset();
    std::cout << "DrawingNativePenTest errorCodeReset after each test case." << std::endl;
}

int TestPenCreateNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Free the memory using OH_Drawing_PenDestroy
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenCopyNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object 1 using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen1 = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen1, nullptr);
    // 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);
    // add assert
    EXPECT_NE(pen2, nullptr);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenCopyNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Copy pen object with nullptr using OH_Drawing_PenCopy
    OH_Drawing_Pen *pen2 = OH_Drawing_PenCopy(nullptr);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 3. Free the memory
    OH_Drawing_PenDestroy(pen);
    OH_Drawing_PenDestroy(pen2);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenCopyInputDestroyed()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object 1 using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen1 = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen1, nullptr);
    // 2. Copy pen 1 to pen 2 using OH_Drawing_PenCopy
    OH_Drawing_Pen *pen2 = OH_Drawing_PenCopy(pen1);
    // add assert
    EXPECT_NE(pen2, nullptr);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenDestroyNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Destroy the object using OH_Drawing_PenDestroy
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenDestroyNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Destroy the object with nullptr using OH_Drawing_PenDestroy
    OH_Drawing_PenDestroy(nullptr);
    // 3. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenIsAntiAliasNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenIsAntiAliasNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetAntiAliasNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetAntiAliasNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Set anti-aliasing for the pen using OH_Drawing_PenSetAntiAlias
    OH_Drawing_PenSetAntiAlias(nullptr, true);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 3. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetColorNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetColorNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Call OH_Drawing_PenGetColor with nullptr as parameter
    OH_Drawing_PenGetColor(nullptr);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 3. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetColorNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetColorNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Set color for the pen using OH_Drawing_PenSetColor with nullptr as the first parameter
    OH_Drawing_PenSetColor(nullptr, 0x00000000);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetColorAbnormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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<uint32_t>(-1), color);
    // 4. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetColorMaximum()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetAlphaNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetAlphaNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Call OH_Drawing_PenGetAlpha with nullptr as parameter
    OH_Drawing_PenGetAlpha(nullptr);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 3. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetAlphaNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetAlphaNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Set the alpha value for the pen using OH_Drawing_PenSetAlpha with nullptr as the first parameter
    OH_Drawing_PenSetAlpha(nullptr, 0xff);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetAlphaAbnormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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<uint8_t>(-1), alpha);
    // 4. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetAlphaMaximum()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetWidthNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Set the pen width using OH_Drawing_PenSetWidth
    OH_Drawing_PenSetWidth(pen, 1.0f);
    // 3. Get the pen width using OH_Drawing_PenGetWidth
    float width = OH_Drawing_PenGetWidth(pen);
    EXPECT_EQ(width, 1.0f);
    // 4. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetWidthNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Call OH_Drawing_PenGetWidth with nullptr as parameter
    OH_Drawing_PenGetWidth(nullptr);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 3. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetWidthBoundary()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Set the pen width using OH_Drawing_PenSetWidth
    float width = DRAWING_NUMBER_4096;
    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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetWidthNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Set the pen width using OH_Drawing_PenSetWidth
    OH_Drawing_PenSetWidth(pen, 1.0f);
    // 3. Get the pen width using OH_Drawing_PenGetWidth
    float width = OH_Drawing_PenGetWidth(pen);
    EXPECT_EQ(width, 1.0f);
    // 4. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetWidthNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Call OH_Drawing_PenSetWidth with nullptr as the first parameter
    OH_Drawing_PenSetWidth(nullptr, 1.00f);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 3. Call OH_Drawing_PenSetWidth with 0.00 as the second parameter
    OH_Drawing_PenSetWidth(pen, 0.00f);
    // 4. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetWidthAbnormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Set the pen width using OH_Drawing_PenSetWidth with an integer or character data as the second parameter
    int width = DRAWING_NUMBER_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<float>(1), width2);
    // 4. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetWidthMultipleCalls()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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.0f);
    }
    // 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.0f);
    }
    // 4. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetWidthMultipleCallsBoundary()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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.0f);
    }
    // 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.0f);
    }
    // 4. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetMiterLimitNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Set the miter limit for the pen using OH_Drawing_PenSetMiterLimit
    OH_Drawing_PenSetMiterLimit(pen, 1.0f);
    // 3. Get the miter limit using OH_Drawing_PenGetMiterLimit
    float miterLimit = OH_Drawing_PenGetMiterLimit(pen);
    EXPECT_EQ(miterLimit, 1.0f);
    // 4. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetMiterLimitNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Call OH_Drawing_PenGetMiterLimit with nullptr as parameter
    OH_Drawing_PenGetMiterLimit(nullptr);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 3. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetMiterLimitNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Set the miter limit for the pen using OH_Drawing_PenSetMiterLimit
    OH_Drawing_PenSetMiterLimit(pen, 1.0f);
    // 3. Get the miter limit using OH_Drawing_PenGetMiterLimit
    float miterLimit = OH_Drawing_PenGetMiterLimit(pen);
    EXPECT_EQ(miterLimit, 1.0f);
    // 4. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetMiterLimitNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Call OH_Drawing_PenSetMiterLimit with nullptr as the first parameter
    OH_Drawing_PenSetMiterLimit(nullptr, 1.0f);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 3. Call OH_Drawing_PenSetMiterLimit with 0.0 as the second parameter
    OH_Drawing_PenSetMiterLimit(pen, 0.0f);
    // 4. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetMiterLimitAbnormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Set the miter limit for the pen using OH_Drawing_PenSetMiterLimit with an integer or character data as the
    // second parameter
    int miterLimit = DRAWING_NUMBER_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<float>(1), miterLimit2);
    // 4. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetMiterLimitMultipleCalls()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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.0f);
    }
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetCapNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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);

    OH_Drawing_PenSetCap(pen, LINE_SQUARE_CAP);
    cap = OH_Drawing_PenGetCap(pen);
    EXPECT_EQ(cap, LINE_SQUARE_CAP);

    OH_Drawing_PenSetCap(pen, LINE_ROUND_CAP);
    cap = OH_Drawing_PenGetCap(pen);
    EXPECT_EQ(cap, LINE_ROUND_CAP);
    // 4. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetCapNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Call OH_Drawing_PenGetCap with nullptr as parameter
    OH_Drawing_PenGetCap(nullptr);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 3. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetCapNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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 < DRAWING_NUMBER_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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetCapNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Call OH_Drawing_PenSetCap with nullptr as the first parameter
    OH_Drawing_PenSetCap(nullptr, LINE_FLAT_CAP);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 3. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetCapMultipleCalls()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetJoinNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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);

    OH_Drawing_PenSetJoin(pen, LINE_ROUND_JOIN);
    join = OH_Drawing_PenGetJoin(pen);
    EXPECT_EQ(join, LINE_ROUND_JOIN);

    OH_Drawing_PenSetJoin(pen, LINE_BEVEL_JOIN);
    join = OH_Drawing_PenGetJoin(pen);
    EXPECT_EQ(join, LINE_BEVEL_JOIN);
    // 4. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetJoinNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Call OH_Drawing_PenGetJoin with nullptr as parameter
    OH_Drawing_PenGetJoin(nullptr);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 3. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetJoinNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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 < DRAWING_NUMBER_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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetJoinNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Call OH_Drawing_PenSetJoin with nullptr as the first parameter
    OH_Drawing_PenSetJoin(nullptr, LINE_MITER_JOIN);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 3. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetJoinMultipleCalls()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetShaderEffectNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Create a shader object using OH_Drawing_ShaderEffectCreate
    OH_Drawing_Point *startPt = OH_Drawing_PointCreate(DRAWING_NUMBER_100, DRAWING_NUMBER_400);
    // add assert
    EXPECT_NE(startPt, nullptr);
    OH_Drawing_Point *endPt = OH_Drawing_PointCreate(DRAWING_NUMBER_200, DRAWING_NUMBER_500);
    // add assert
    EXPECT_NE(endPt, nullptr);
    uint32_t color[] = {0xffff0000, 0xff00ff00};
    float pos[] = {0., 1.0f};
    OH_Drawing_ShaderEffect *linearGradient =
        OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, color, pos, DRAWING_NUMBER_2,
            OH_Drawing_TileMode::CLAMP);
    // add assert
    EXPECT_NE(linearGradient, nullptr);
    // 3. Set the shader effect for the pen using OH_Drawing_PenSetShaderEffect
    OH_Drawing_PenSetShaderEffect(pen, linearGradient);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
    // 4. Free the memory
    OH_Drawing_PointDestroy(startPt);
    OH_Drawing_PointDestroy(endPt);
    OH_Drawing_ShaderEffectDestroy(linearGradient);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetShaderEffectNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Create a shader object using OH_Drawing_ShaderEffectCreate
    OH_Drawing_Point *startPt = OH_Drawing_PointCreate(DRAWING_NUMBER_100, DRAWING_NUMBER_400);
    // add assert
    EXPECT_NE(startPt, nullptr);
    OH_Drawing_Point *endPt = OH_Drawing_PointCreate(DRAWING_NUMBER_200, DRAWING_NUMBER_500);
    // add assert
    EXPECT_NE(endPt, nullptr);
    uint32_t color[] = {0xffff0000, 0xff00ff00};
    float pos[] = {0., 1.0f};
    OH_Drawing_ShaderEffect *linearGradient =
        OH_Drawing_ShaderEffectCreateLinearGradient(startPt, endPt, color, pos, DRAWING_NUMBER_2,
            OH_Drawing_TileMode::CLAMP);
    // add assert
    EXPECT_NE(linearGradient, nullptr);
    // 3. Call OH_Drawing_PenSetShaderEffect with nullptr as the first parameter
    OH_Drawing_PenSetShaderEffect(nullptr, linearGradient);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetShadowLayerNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Create a shadow layer object using OH_Drawing_ShadowLayerCreate
    OH_Drawing_ShadowLayer *shadowLayer = OH_Drawing_ShadowLayerCreate(10, 10, 10, 0xff000000);
    // add assert
    EXPECT_NE(shadowLayer, nullptr);
    // 3. Set the shadow layer for the pen using OH_Drawing_PenSetShadowLayer
    OH_Drawing_PenSetShadowLayer(pen, shadowLayer);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
    // 4. Free the memory
    OH_Drawing_ShadowLayerDestroy(shadowLayer);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetShadowLayerNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Create a shadow layer object using OH_Drawing_ShadowLayerCreate
    OH_Drawing_ShadowLayer *shadowLayer = OH_Drawing_ShadowLayerCreate(10, 10, 10, 0xff000000);
    // add assert
    EXPECT_NE(shadowLayer, nullptr);
    // 3. Set the shadow layer for the pen using OH_Drawing_PenSetShadowLayer with nullptr as the first parameter
    OH_Drawing_PenSetShadowLayer(nullptr, shadowLayer);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetPathEffectNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Create a path effect object using OH_Drawing_PathEffectCreate
    float intervals[] = {1, 1, 1};
    OH_Drawing_PathEffect *pathEffect = OH_Drawing_CreateDashPathEffect(intervals, DRAWING_NUMBER_3, 0.0f);
    // add assert
    EXPECT_NE(pathEffect, nullptr);
    // 3. Set the path effect for the pen using OH_Drawing_PenSetPathEffect
    OH_Drawing_PenSetPathEffect(pen, pathEffect);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
    // 4. Free the memory
    OH_Drawing_PathEffectDestroy(pathEffect);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetPathEffectNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Create a path effect object using OH_Drawing_PathEffectCreate
    float intervals[] = {1, 1, 1};
    OH_Drawing_PathEffect *pathEffect = OH_Drawing_CreateDashPathEffect(intervals, DRAWING_NUMBER_3, 0.0f);
    // add assert
    EXPECT_NE(pathEffect, nullptr);
    // 3. Set the path effect for the pen with nullptr as the first parameter
    OH_Drawing_PenSetPathEffect(nullptr, pathEffect);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetFilterNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Create a filter object using OH_Drawing_FilterCreate
    OH_Drawing_Filter *filter = OH_Drawing_FilterCreate();
    // add assert
    EXPECT_NE(filter, nullptr);
    // 3. Set the filter effect for the pen using OH_Drawing_PenSetFilter
    OH_Drawing_PenSetFilter(pen, filter);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
    // 4. Get the filter effect for the pen using OH_Drawing_PenGetFilter
    OH_Drawing_Filter *filter2 = OH_Drawing_FilterCreate();
    // add assert
    EXPECT_NE(filter2, nullptr);
    OH_Drawing_PenGetFilter(pen, filter2);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
    // 5. Free the memory
    OH_Drawing_FilterDestroy(filter);
    OH_Drawing_FilterDestroy(filter2);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetFilterNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Create a filter object using OH_Drawing_FilterCreate
    OH_Drawing_Filter *filter = OH_Drawing_FilterCreate();
    // add assert
    EXPECT_NE(filter, nullptr);
    // 3. Call OH_Drawing_PenSetFilter with nullptr as the first parameter
    OH_Drawing_PenSetFilter(nullptr, filter);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetFilterNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Create a filter object using OH_Drawing_FilterCreate
    OH_Drawing_Filter *filter = OH_Drawing_FilterCreate();
    // add assert
    EXPECT_NE(filter, nullptr);
    // 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();
    // add assert
    EXPECT_NE(filter2, nullptr);
    OH_Drawing_PenGetFilter(pen, filter2);
    // 5. Free the memory
    OH_Drawing_FilterDestroy(filter);
    OH_Drawing_FilterDestroy(filter2);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetFilterNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Create a filter object using OH_Drawing_FilterCreate
    OH_Drawing_Filter *filter = OH_Drawing_FilterCreate();
    // add assert
    EXPECT_NE(filter, nullptr);
    // 3. Call OH_Drawing_PenGetFilter with nullptr as the first parameter
    OH_Drawing_PenGetFilter(nullptr, filter);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    OH_Drawing_ErrorCodeReset();
    // 4. Call OH_Drawing_PenGetFilter with nullptr as the second parameter
    OH_Drawing_PenGetFilter(pen, nullptr);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 5. Free the memory
    OH_Drawing_FilterDestroy(filter);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetBlendModeNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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 < DRAWING_NUMBER_3; i++) {
        OH_Drawing_ErrorCodeReset();
        OH_Drawing_PenSetBlendMode(pen, modes[i]);
        // add assert
        EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
    }
    // 3. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenSetBlendModeNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Call OH_Drawing_PenSetBlendMode with nullptr as the first parameter
    OH_Drawing_PenSetBlendMode(nullptr, BLEND_MODE_CLEAR);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 3. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetFillPathNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    float penWidth = DRAWING_NUMBER_10;
    OH_Drawing_PenSetWidth(pen, penWidth);
    // 2. Create a source path object using OH_Drawing_PathCreate
    OH_Drawing_Path *srcPath = OH_Drawing_PathCreate();
    // add assert
    EXPECT_NE(srcPath, nullptr);
    OH_Drawing_PathMoveTo(srcPath, DRAWING_NUMBER_50, DRAWING_NUMBER_50);
    OH_Drawing_PathLineTo(srcPath, DRAWING_NUMBER_100, DRAWING_NUMBER_50);
    OH_Drawing_PathLineTo(srcPath, DRAWING_NUMBER_100, DRAWING_NUMBER_100);
    OH_Drawing_PathClose(srcPath);
    // 3. Create a destination path object using OH_Drawing_PathCreate
    OH_Drawing_Path *dstPath = OH_Drawing_PathCreate();
    // add assert
    EXPECT_NE(dstPath, nullptr);
    // 4. Create a rectangle object using OH_Drawing_RectCreate
    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(DRAWING_NUMBER_100, DRAWING_NUMBER_100, DRAWING_NUMBER_200,
        DRAWING_NUMBER_200);
    // add assert
    EXPECT_NE(rect, nullptr);
    // 5. Create a matrix object using OH_Drawing_MatrixCreate
    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
    // add assert
    EXPECT_NE(matrix, nullptr);
    // 6. Call OH_Drawing_PenGetFillPath
    bool isSuccess = OH_Drawing_PenGetFillPath(pen, srcPath, dstPath, rect, matrix);
    // add assert
    EXPECT_EQ(isSuccess, true);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
    // 7. Free the memory
    OH_Drawing_PathDestroy(srcPath);
    OH_Drawing_PathDestroy(dstPath);
    OH_Drawing_RectDestroy(rect);
    OH_Drawing_MatrixDestroy(matrix);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetFillPathNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Create a source path object using OH_Drawing_PathCreate
    OH_Drawing_Path *srcPath = OH_Drawing_PathCreate();
    // add assert
    EXPECT_NE(srcPath, nullptr);
    // 3. Create a destination path object using OH_Drawing_PathCreate
    OH_Drawing_Path *dstPath = OH_Drawing_PathCreate();
    // add assert
    EXPECT_NE(dstPath, nullptr);
    // 4. Create a rectangle object using OH_Drawing_RectCreate
    OH_Drawing_Rect *rect = OH_Drawing_RectCreate(DRAWING_NUMBER_100, DRAWING_NUMBER_100, DRAWING_NUMBER_200,
        DRAWING_NUMBER_200);
    // add assert
    EXPECT_NE(rect, nullptr);
    // 5. Create a matrix object using OH_Drawing_MatrixCreate
    OH_Drawing_Matrix *matrix = OH_Drawing_MatrixCreate();
    // add assert
    EXPECT_NE(matrix, nullptr);
    // 6. Call OH_Drawing_PenGetFillPath with nullptr as the first parameter
    bool isSuccess = OH_Drawing_PenGetFillPath(nullptr, srcPath, dstPath, rect, matrix);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    EXPECT_EQ(isSuccess, false);
    OH_Drawing_ErrorCodeReset();
    // 7. Call OH_Drawing_PenGetFillPath with nullptr as the second parameter
    isSuccess = OH_Drawing_PenGetFillPath(pen, nullptr, dstPath, rect, matrix);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    EXPECT_EQ(isSuccess, false);
    OH_Drawing_ErrorCodeReset();
    // 8. Call OH_Drawing_PenGetFillPath with nullptr as the third parameter
    isSuccess = OH_Drawing_PenGetFillPath(pen, srcPath, nullptr, rect, matrix);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    EXPECT_EQ(isSuccess, false);
    // 9. Call OH_Drawing_PenGetFillPath with nullptr as the fourth parameter
    isSuccess = OH_Drawing_PenGetFillPath(pen, srcPath, dstPath, nullptr, matrix);
    // add assert
    EXPECT_EQ(isSuccess, false);
    // 10. Call OH_Drawing_PenGetFillPath with nullptr as the fifth parameter
    isSuccess = OH_Drawing_PenGetFillPath(pen, srcPath, dstPath, rect, nullptr);
    // add assert
    EXPECT_EQ(isSuccess, false);
    // 11. Free the memory
    OH_Drawing_PathDestroy(srcPath);
    OH_Drawing_PathDestroy(dstPath);
    OH_Drawing_RectDestroy(rect);
    OH_Drawing_MatrixDestroy(matrix);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenResetNormal()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_SUCCESS);
    // 5. Get the pen color using OH_Drawing_PenGetColor
    color = OH_Drawing_PenGetColor(pen);
    OH_Drawing_Pen *pen2 = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen2, nullptr);
    uint32_t color2 = OH_Drawing_PenGetColor(pen2);
    EXPECT_EQ(color2, color);
    // 6. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenResetNull()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 2. Call OH_Drawing_PenReset with nullptr as the parameter
    OH_Drawing_PenReset(nullptr);
    // add assert
    EXPECT_EQ(OH_Drawing_ErrorCodeGet(), OH_Drawing_ErrorCode::OH_DRAWING_ERROR_INVALID_PARAMETER);
    // 3. Free the memory
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenResetMultipleCalls()
{
    DrawingNativePenTestSetUp();
    // 1. Create a pen object using OH_Drawing_PenCreate
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    // add assert
    EXPECT_NE(pen, nullptr);
    // 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);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}

int TestPenGetAlphaFloatNormal()
{
    DrawingNativePenTestSetUp();
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    float a = 0.0f;
    OH_Drawing_PenSetWidth(pen, DRAWING_NUMBER_10);
    OH_Drawing_PenSetColor4f(pen, 1.0f, 0.4f, 1.0f, 0.2f, nullptr);
    EXPECT_EQ(OH_Drawing_PenGetAlphaFloat(pen, &a), OH_DRAWING_SUCCESS);
    EXPECT_EQ(a, 1.0f);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}
int TestPenGetAlphaFloatAbnormal()
{
    DrawingNativePenTestSetUp();
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    float a = 0.0f;
    OH_Drawing_PenSetWidth(pen, DRAWING_NUMBER_10);
    OH_Drawing_PenSetColor4f(pen, 1.0f, 0.4f, 1.0f, 0.2f, nullptr);
    EXPECT_EQ(OH_Drawing_PenGetAlphaFloat(nullptr, &a), OH_DRAWING_ERROR_INVALID_PARAMETER);
    EXPECT_EQ(OH_Drawing_PenGetAlphaFloat(pen, 0), OH_DRAWING_ERROR_INVALID_PARAMETER);
    EXPECT_EQ(OH_Drawing_PenGetAlphaFloat(pen, NULL), OH_DRAWING_ERROR_INVALID_PARAMETER);
    EXPECT_EQ(a, 0.0f);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}
int TestPenGetRedFloatNormal()
{
    DrawingNativePenTestSetUp();
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    float r = 0.0f;
    OH_Drawing_PenSetWidth(pen, DRAWING_NUMBER_10);
    OH_Drawing_PenSetColor4f(pen, 1.0f, 0.4f, 1.0f, 0.2f, nullptr);
    EXPECT_EQ(OH_Drawing_PenGetRedFloat(pen, &r), OH_DRAWING_SUCCESS);
    EXPECT_EQ(r, 0.4f);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}
int TestPenGetRedFloatAbnormal()
{
    DrawingNativePenTestSetUp();
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    float r = 0.0f;
    OH_Drawing_PenSetWidth(pen, DRAWING_NUMBER_10);
    OH_Drawing_PenSetColor4f(pen, 1.0f, 0.4f, 1.0f, 0.2f, nullptr);
    EXPECT_EQ(OH_Drawing_PenGetRedFloat(nullptr, &r), OH_DRAWING_ERROR_INVALID_PARAMETER);
    EXPECT_EQ(OH_Drawing_PenGetRedFloat(pen, 0), OH_DRAWING_ERROR_INVALID_PARAMETER);
    EXPECT_EQ(OH_Drawing_PenGetRedFloat(pen, NULL), OH_DRAWING_ERROR_INVALID_PARAMETER);
    EXPECT_EQ(r, 0.0f);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}
int TestPenGetGreenFloatNormal()
{
    DrawingNativePenTestSetUp();
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    float g = 0.0f;
    OH_Drawing_PenSetWidth(pen, DRAWING_NUMBER_10);
    OH_Drawing_PenSetColor4f(pen, 1.0f, 0.4f, 1.0f, 0.2f, nullptr);
    EXPECT_EQ(OH_Drawing_PenGetGreenFloat(pen, &g), OH_DRAWING_SUCCESS);
    EXPECT_EQ(g, 1.0f);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}
int TestPenGetGreenFloatAbnormal()
{
    DrawingNativePenTestSetUp();
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    float g = 0.0f;
    OH_Drawing_PenSetWidth(pen, DRAWING_NUMBER_10);
    OH_Drawing_PenSetColor4f(pen, 1.0f, 0.4f, 1.0f, 0.2f, nullptr);
    EXPECT_EQ(OH_Drawing_PenGetGreenFloat(nullptr, &g), OH_DRAWING_ERROR_INVALID_PARAMETER);
    EXPECT_EQ(OH_Drawing_PenGetGreenFloat(pen, 0), OH_DRAWING_ERROR_INVALID_PARAMETER);
    EXPECT_EQ(OH_Drawing_PenGetGreenFloat(pen, NULL), OH_DRAWING_ERROR_INVALID_PARAMETER);
    EXPECT_EQ(g, 0.0f);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}
int TestPenGetBlueFloatNormal()
{
    DrawingNativePenTestSetUp();
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    float b = 0.0f;
    OH_Drawing_PenSetWidth(pen, DRAWING_NUMBER_10);
    OH_Drawing_PenSetColor4f(pen, 1.0f, 0.4f, 1.0f, 0.2f, nullptr);
    EXPECT_EQ(OH_Drawing_PenGetBlueFloat(pen, &b), OH_DRAWING_SUCCESS);
    EXPECT_EQ(b, 0.2f);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}
int TestPenGetBlueFloatAbnormal()
{
    DrawingNativePenTestSetUp();
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    float b = 0.0f;
    OH_Drawing_PenSetWidth(pen, DRAWING_NUMBER_10);
    OH_Drawing_PenSetColor4f(pen, 1.0f, 0.4f, 1.0f, 0.2f, nullptr);
    EXPECT_EQ(OH_Drawing_PenGetBlueFloat(nullptr, &b), OH_DRAWING_ERROR_INVALID_PARAMETER);
    EXPECT_EQ(OH_Drawing_PenGetBlueFloat(pen, 0), OH_DRAWING_ERROR_INVALID_PARAMETER);
    EXPECT_EQ(OH_Drawing_PenGetBlueFloat(pen, NULL), OH_DRAWING_ERROR_INVALID_PARAMETER);
    EXPECT_EQ(b, 0.0f);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}
int TestPenSetColor4FNormal()
{
    DrawingNativePenTestSetUp();
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    float a = 0.0f;
    float r = 0.0f;
    float g = 0.0f;
    float b = 0.0f;
    OH_Drawing_PenSetWidth(pen, DRAWING_NUMBER_10);
    OH_Drawing_ErrorCode errorCode = OH_Drawing_PenSetColor4f(pen, 1.0f, 0.4f, 1.0f, 0.2f, nullptr);
    OH_Drawing_PenGetAlphaFloat(pen, &a);
    OH_Drawing_PenGetRedFloat(pen, &r);
    OH_Drawing_PenGetGreenFloat(pen, &g);
    OH_Drawing_PenGetBlueFloat(pen, &b);
    EXPECT_EQ(a, 1.0f);
    EXPECT_EQ(r, 0.4f);
    EXPECT_EQ(g, 1.0f);
    EXPECT_EQ(b, 0.2f);
    EXPECT_EQ(errorCode, OH_DRAWING_SUCCESS);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}
int TestPenSetColor4FNull()
{
    DrawingNativePenTestSetUp();
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    float a = 0.0f;
    float r = 0.0f;
    float g = 0.0f;
    float b = 0.0f;
    OH_Drawing_PenSetWidth(pen, DRAWING_NUMBER_10);
    OH_Drawing_ErrorCode errorCode = OH_Drawing_PenSetColor4f(nullptr, 1.0f, 0.4f, 1.0f, 0.2f, nullptr);
    EXPECT_EQ(errorCode, OH_DRAWING_ERROR_INVALID_PARAMETER);
    errorCode = OH_Drawing_PenSetColor4f(pen, 0.0f, 0.4f, 1.0f, 0.2f, nullptr);
    OH_Drawing_PenGetAlphaFloat(pen, &a);
    EXPECT_EQ(errorCode, OH_DRAWING_SUCCESS);
    EXPECT_EQ(a, 0.0f);
    errorCode = OH_Drawing_PenSetColor4f(pen, 1.0f, 0.0f, 1.0f, 0.2f, nullptr);
    OH_Drawing_PenGetRedFloat(pen, &r);
    EXPECT_EQ(errorCode, OH_DRAWING_SUCCESS);
    EXPECT_EQ(r, 0.0f);
    errorCode = OH_Drawing_PenSetColor4f(pen, 1.0f, 1.0f, 0.0f, 1.0f, nullptr);
    OH_Drawing_PenGetGreenFloat(pen, &g);
    EXPECT_EQ(errorCode, OH_DRAWING_SUCCESS);
    EXPECT_EQ(g, 0.0f);
    errorCode = OH_Drawing_PenSetColor4f(pen, 1.0f, 0.4f, 1.0f, 0.0f, nullptr);
    OH_Drawing_PenGetBlueFloat(pen, &b);
    EXPECT_EQ(errorCode, OH_DRAWING_SUCCESS);
    EXPECT_EQ(b, 0.0f);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}
int TestPenSetColor4FAbnormal()
{
    DrawingNativePenTestSetUp();
    OH_Drawing_Pen *pen = OH_Drawing_PenCreate();
    float a = 0.0f;
    float r = 0.0f;
    float g = 0.0f;
    float b = 0.0f;
    OH_Drawing_PenSetWidth(pen, DRAWING_NUMBER_10);
    OH_Drawing_ErrorCode errorCode1 = OH_Drawing_PenSetColor4f(pen, 2.0f, 0.4f, 1.0f, 0.2f, nullptr);
    OH_Drawing_PenGetAlphaFloat(pen, &a);
    EXPECT_EQ(a, 1.0f);
    OH_Drawing_ErrorCode errorCode2 = OH_Drawing_PenSetColor4f(pen, -1.0f, 0.4f, 1.0f, 0.2f, nullptr);
    OH_Drawing_PenGetAlphaFloat(pen, &a);
    EXPECT_EQ(a, 0.0f);
    OH_Drawing_ErrorCode errorCode3 = OH_Drawing_PenSetColor4f(pen, 1.0f, 2.0f, 1.0f, 0.2f, nullptr);
    OH_Drawing_PenGetRedFloat(pen, &r);
    EXPECT_EQ(r, 1.0f);
    OH_Drawing_ErrorCode errorCode4 = OH_Drawing_PenSetColor4f(pen, 1.0f, -1.0f, 1.0f, 0.2f, nullptr);
    OH_Drawing_PenGetRedFloat(pen, &r);
    EXPECT_EQ(r, 0.0f);
    OH_Drawing_ErrorCode errorCode5 = OH_Drawing_PenSetColor4f(pen, 1.0f, 0.4f, 2.0f, 0.2f, nullptr);
    OH_Drawing_PenGetGreenFloat(pen, &g);
    EXPECT_EQ(g, 1.0f);
    OH_Drawing_ErrorCode errorCode6 = OH_Drawing_PenSetColor4f(pen, 1.0f, 0.4f, -1.0f, 0.2f, nullptr);
    OH_Drawing_PenGetGreenFloat(pen, &g);
    EXPECT_EQ(g, 0.0f);
    OH_Drawing_ErrorCode errorCode7 = OH_Drawing_PenSetColor4f(pen, 1.0f, 0.4f, 1.0f, 2.0f, nullptr);
    OH_Drawing_PenGetBlueFloat(pen, &b);
    EXPECT_EQ(b, 1.0f);
    OH_Drawing_ErrorCode errorCode8 = OH_Drawing_PenSetColor4f(pen, 1.0f, 0.4f, 1.0f, -1.0f, nullptr);
    OH_Drawing_PenGetBlueFloat(pen, &b);
    EXPECT_EQ(b, 0.0f);
    EXPECT_EQ(errorCode1, OH_DRAWING_SUCCESS);
    EXPECT_EQ(errorCode2, OH_DRAWING_SUCCESS);
    EXPECT_EQ(errorCode3, OH_DRAWING_SUCCESS);
    EXPECT_EQ(errorCode4, OH_DRAWING_SUCCESS);
    EXPECT_EQ(errorCode5, OH_DRAWING_SUCCESS);
    EXPECT_EQ(errorCode6, OH_DRAWING_SUCCESS);
    EXPECT_EQ(errorCode7, OH_DRAWING_SUCCESS);
    EXPECT_EQ(errorCode8, OH_DRAWING_SUCCESS);
    OH_Drawing_PenDestroy(pen);
    DrawingNativePenTestTearDown();
    return OH_DRAWING_SUCCESS;
}
} // namespace Drawing
} // namespace Rosen
} // namespace OHOS