123b3eb3cSopenharmony_ci/*
223b3eb3cSopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd.
323b3eb3cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
423b3eb3cSopenharmony_ci * you may not use this file except in compliance with the License.
523b3eb3cSopenharmony_ci * You may obtain a copy of the License at
623b3eb3cSopenharmony_ci *
723b3eb3cSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
823b3eb3cSopenharmony_ci *
923b3eb3cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
1023b3eb3cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
1123b3eb3cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1223b3eb3cSopenharmony_ci * See the License for the specific language governing permissions and
1323b3eb3cSopenharmony_ci * limitations under the License.
1423b3eb3cSopenharmony_ci */
1523b3eb3cSopenharmony_ci
1623b3eb3cSopenharmony_ci#include <cstdint>
1723b3eb3cSopenharmony_ci#include "gtest/gtest.h"
1823b3eb3cSopenharmony_ci#include "native_animate.h"
1923b3eb3cSopenharmony_ci#include "native_node.h"
2023b3eb3cSopenharmony_ci#include "native_type.h"
2123b3eb3cSopenharmony_ci#include "node_model.h"
2223b3eb3cSopenharmony_ci#include "native_interface.h"
2323b3eb3cSopenharmony_ci#include "error_code.h"
2423b3eb3cSopenharmony_ci#include "core/interfaces/arkoala/arkoala_api.h"
2523b3eb3cSopenharmony_ci
2623b3eb3cSopenharmony_ciusing namespace testing;
2723b3eb3cSopenharmony_ciusing namespace testing::ext;
2823b3eb3cSopenharmony_cinamespace OHOS::Ace {
2923b3eb3cSopenharmony_ciclass NodeAnimateTest : public testing::Test {
3023b3eb3cSopenharmony_cipublic:
3123b3eb3cSopenharmony_ci    static void SetUpTestCase() {};
3223b3eb3cSopenharmony_ci    static void TearDownTestCase() {};
3323b3eb3cSopenharmony_ci};
3423b3eb3cSopenharmony_ci
3523b3eb3cSopenharmony_cifloat InterpolateCallback(float fraction, void* userData)
3623b3eb3cSopenharmony_ci{
3723b3eb3cSopenharmony_ci    return fraction;
3823b3eb3cSopenharmony_ci}
3923b3eb3cSopenharmony_ci
4023b3eb3cSopenharmony_civoid AnimationCallback(void* userData)
4123b3eb3cSopenharmony_ci{
4223b3eb3cSopenharmony_ci}
4323b3eb3cSopenharmony_ci
4423b3eb3cSopenharmony_civoid AnimatorOnFrameEventCallback(ArkUI_AnimatorOnFrameEvent* event)
4523b3eb3cSopenharmony_ci{
4623b3eb3cSopenharmony_ci}
4723b3eb3cSopenharmony_ci
4823b3eb3cSopenharmony_civoid AnimatorEventCallback(ArkUI_AnimatorEvent* event)
4923b3eb3cSopenharmony_ci{
5023b3eb3cSopenharmony_ci}
5123b3eb3cSopenharmony_ci
5223b3eb3cSopenharmony_ci/**
5323b3eb3cSopenharmony_ci * @tc.name: NodeAnimateTest001
5423b3eb3cSopenharmony_ci * @tc.desc: Test AnimateOption function.
5523b3eb3cSopenharmony_ci * @tc.type: FUNC
5623b3eb3cSopenharmony_ci */
5723b3eb3cSopenharmony_ciHWTEST_F(NodeAnimateTest, NodeAnimateTest001, TestSize.Level1)
5823b3eb3cSopenharmony_ci{
5923b3eb3cSopenharmony_ci    ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
6023b3eb3cSopenharmony_ci    ArkUI_AnimateOption* animation = OH_ArkUI_AnimateOption_Create();
6123b3eb3cSopenharmony_ci    ASSERT_NE(animation, nullptr);
6223b3eb3cSopenharmony_ci
6323b3eb3cSopenharmony_ci    float negativeFloat = -1.0f;
6423b3eb3cSopenharmony_ci    float normalFloat = 1.0f;
6523b3eb3cSopenharmony_ci    int32_t negativeInt = -2;
6623b3eb3cSopenharmony_ci    int32_t normalInt = 1;
6723b3eb3cSopenharmony_ci    int32_t largeInt = 1000;
6823b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_SetDuration(animation, negativeInt);
6923b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_SetDuration(animation, normalInt);
7023b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_SetTempo(animation, negativeFloat);
7123b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_SetTempo(animation, normalFloat);
7223b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_SetCurve(animation, static_cast<ArkUI_AnimationCurve>(negativeInt));
7323b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_SetCurve(animation, static_cast<ArkUI_AnimationCurve>(largeInt));
7423b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_SetCurve(animation, ArkUI_AnimationCurve::ARKUI_CURVE_LINEAR);
7523b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_SetDelay(animation, normalInt);
7623b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_SetIterations(animation, negativeInt);
7723b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_SetIterations(animation, normalInt);
7823b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_SetPlayMode(animation, static_cast<ArkUI_AnimationPlayMode>(negativeInt));
7923b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_SetPlayMode(animation, static_cast<ArkUI_AnimationPlayMode>(largeInt));
8023b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_SetPlayMode(animation, ArkUI_AnimationPlayMode::ARKUI_ANIMATION_PLAY_MODE_NORMAL);
8123b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimateOption_GetDuration(nullptr), 0);
8223b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimateOption_GetDuration(animation), normalInt);
8323b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimateOption_GetTempo(nullptr), 0.0f);
8423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimateOption_GetTempo(animation), normalFloat);
8523b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimateOption_GetCurve(nullptr), static_cast<ArkUI_AnimationCurve>(-1));
8623b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimateOption_GetCurve(animation), ArkUI_AnimationCurve::ARKUI_CURVE_LINEAR);
8723b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimateOption_GetDelay(nullptr), 0);
8823b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimateOption_GetDelay(animation), normalInt);
8923b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimateOption_GetIterations(nullptr), 0);
9023b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimateOption_GetIterations(animation), normalInt);
9123b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimateOption_GetPlayMode(nullptr), static_cast<ArkUI_AnimationPlayMode>(-1));
9223b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimateOption_GetPlayMode(animation), ArkUI_AnimationPlayMode::ARKUI_ANIMATION_PLAY_MODE_NORMAL);
9323b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimateOption_GetExpectedFrameRateRange(nullptr), nullptr);
9423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimateOption_GetExpectedFrameRateRange(animation), nullptr);
9523b3eb3cSopenharmony_ci
9623b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_Dispose(nullptr);
9723b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_Dispose(animation);
9823b3eb3cSopenharmony_ci}
9923b3eb3cSopenharmony_ci
10023b3eb3cSopenharmony_ci/**
10123b3eb3cSopenharmony_ci * @tc.name: NodeAnimateTest002
10223b3eb3cSopenharmony_ci * @tc.desc: Test ICurve function.
10323b3eb3cSopenharmony_ci * @tc.type: FUNC
10423b3eb3cSopenharmony_ci */
10523b3eb3cSopenharmony_ciHWTEST_F(NodeAnimateTest, NodeAnimateTest002, TestSize.Level1)
10623b3eb3cSopenharmony_ci{
10723b3eb3cSopenharmony_ci    ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
10823b3eb3cSopenharmony_ci    ArkUI_AnimateOption* animation = OH_ArkUI_AnimateOption_Create();
10923b3eb3cSopenharmony_ci    ASSERT_NE(animation, nullptr);
11023b3eb3cSopenharmony_ci    auto icurve = OH_ArkUI_Curve_CreateCurveByType(ArkUI_AnimationCurve::ARKUI_CURVE_LINEAR);
11123b3eb3cSopenharmony_ci    auto stepCurve = OH_ArkUI_Curve_CreateStepsCurve(1, true);
11223b3eb3cSopenharmony_ci    auto cubicBezierCurve = OH_ArkUI_Curve_CreateCubicBezierCurve(0.0f, 0.0f, 0.0f, 0.0f);
11323b3eb3cSopenharmony_ci    auto springCurve = OH_ArkUI_Curve_CreateSpringCurve(0.0f, 0.0f, 0.0f, 0.0f);
11423b3eb3cSopenharmony_ci    auto springMotion = OH_ArkUI_Curve_CreateSpringMotion(0.5f, 0.5f, 0.5f);
11523b3eb3cSopenharmony_ci    auto responsiveSpringMotion = OH_ArkUI_Curve_CreateResponsiveSpringMotion(0.5f, 0.5f, 0.5f);
11623b3eb3cSopenharmony_ci    auto interpolatingSpring = OH_ArkUI_Curve_CreateInterpolatingSpring(0.5f, 0.5f, 0.5f, 0.5f);
11723b3eb3cSopenharmony_ci    auto customCurve = OH_ArkUI_Curve_CreateCustomCurve(nullptr, InterpolateCallback);
11823b3eb3cSopenharmony_ci    ASSERT_NE(icurve, nullptr);
11923b3eb3cSopenharmony_ci    ASSERT_NE(stepCurve, nullptr);
12023b3eb3cSopenharmony_ci    ASSERT_NE(cubicBezierCurve, nullptr);
12123b3eb3cSopenharmony_ci    ASSERT_NE(springCurve, nullptr);
12223b3eb3cSopenharmony_ci    ASSERT_NE(springMotion, nullptr);
12323b3eb3cSopenharmony_ci    ASSERT_NE(responsiveSpringMotion, nullptr);
12423b3eb3cSopenharmony_ci    ASSERT_NE(interpolatingSpring, nullptr);
12523b3eb3cSopenharmony_ci    ASSERT_NE(customCurve, nullptr);
12623b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_SetICurve(animation, icurve);
12723b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimateOption_GetICurve(nullptr), nullptr);
12823b3eb3cSopenharmony_ci    ASSERT_NE(OH_ArkUI_AnimateOption_GetICurve(animation), nullptr);
12923b3eb3cSopenharmony_ci    ArkUI_KeyframeAnimateOption* animateOption = OH_ArkUI_KeyframeAnimateOption_Create(1);
13023b3eb3cSopenharmony_ci    ASSERT_NE(animateOption, nullptr);
13123b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetCurve(nullptr, icurve, 0), ARKUI_ERROR_CODE_PARAM_INVALID);
13223b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetCurve(animateOption, icurve, -1), ARKUI_ERROR_CODE_PARAM_INVALID);
13323b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetCurve(animateOption, icurve, 1), ARKUI_ERROR_CODE_PARAM_INVALID);
13423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetCurve(animateOption, nullptr, 0), ARKUI_ERROR_CODE_PARAM_INVALID);
13523b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetCurve(animateOption, springMotion, 0), ARKUI_ERROR_CODE_PARAM_INVALID);
13623b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetCurve(animateOption, responsiveSpringMotion, 0),
13723b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
13823b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetCurve(animateOption, interpolatingSpring, 0),
13923b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
14023b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetCurve(animateOption, icurve, 0), ARKUI_ERROR_CODE_NO_ERROR);
14123b3eb3cSopenharmony_ci    EXPECT_NE(OH_ArkUI_KeyframeAnimateOption_GetCurve(animateOption, 0), nullptr);
14223b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_GetCurve(nullptr, 0), nullptr);
14323b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_GetCurve(animateOption, -1), nullptr);
14423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_GetCurve(animateOption, 1), nullptr);
14523b3eb3cSopenharmony_ci    OH_ArkUI_AnimateOption_Dispose(animation);
14623b3eb3cSopenharmony_ci    OH_ArkUI_KeyframeAnimateOption_Dispose(animateOption);
14723b3eb3cSopenharmony_ci    OH_ArkUI_Curve_DisposeCurve(icurve);
14823b3eb3cSopenharmony_ci    OH_ArkUI_Curve_DisposeCurve(stepCurve);
14923b3eb3cSopenharmony_ci    OH_ArkUI_Curve_DisposeCurve(cubicBezierCurve);
15023b3eb3cSopenharmony_ci    OH_ArkUI_Curve_DisposeCurve(springCurve);
15123b3eb3cSopenharmony_ci    OH_ArkUI_Curve_DisposeCurve(springMotion);
15223b3eb3cSopenharmony_ci    OH_ArkUI_Curve_DisposeCurve(responsiveSpringMotion);
15323b3eb3cSopenharmony_ci    OH_ArkUI_Curve_DisposeCurve(customCurve);
15423b3eb3cSopenharmony_ci}
15523b3eb3cSopenharmony_ci
15623b3eb3cSopenharmony_ci/**
15723b3eb3cSopenharmony_ci * @tc.name: NodeAnimateTest003
15823b3eb3cSopenharmony_ci * @tc.desc: Test KeyframeAnimateOption normalfunction.
15923b3eb3cSopenharmony_ci * @tc.type: FUNC
16023b3eb3cSopenharmony_ci */
16123b3eb3cSopenharmony_ciHWTEST_F(NodeAnimateTest, NodeAnimateTest003, TestSize.Level1)
16223b3eb3cSopenharmony_ci{
16323b3eb3cSopenharmony_ci    ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
16423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_Create(-1), nullptr);
16523b3eb3cSopenharmony_ci    ArkUI_KeyframeAnimateOption* animateOption = OH_ArkUI_KeyframeAnimateOption_Create(1);
16623b3eb3cSopenharmony_ci    ASSERT_NE(animateOption, nullptr);
16723b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetDelay(nullptr, 1), ARKUI_ERROR_CODE_PARAM_INVALID);
16823b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetDelay(animateOption, 1), ARKUI_ERROR_CODE_NO_ERROR);
16923b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_GetDelay(animateOption), 1);
17023b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetIterations(nullptr, 1), ARKUI_ERROR_CODE_PARAM_INVALID);
17123b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetIterations(animateOption, -2), ARKUI_ERROR_CODE_PARAM_INVALID);
17223b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetIterations(animateOption, 1), ARKUI_ERROR_CODE_NO_ERROR);
17323b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_GetIterations(animateOption), 1);
17423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetDuration(nullptr, 1, 1), ARKUI_ERROR_CODE_PARAM_INVALID);
17523b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetDuration(animateOption, 1, -1), ARKUI_ERROR_CODE_PARAM_INVALID);
17623b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetDuration(animateOption, 1, 1), ARKUI_ERROR_CODE_PARAM_INVALID);
17723b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetDuration(animateOption, -1, 0), ARKUI_ERROR_CODE_NO_ERROR);
17823b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_SetDuration(animateOption, 1, 0), ARKUI_ERROR_CODE_NO_ERROR);
17923b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_GetDuration(animateOption, 0), 1);
18023b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_GetDuration(nullptr, 0), 0);
18123b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_GetDuration(animateOption, -1), 0);
18223b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_GetDuration(animateOption, 1), 0);
18323b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_RegisterOnFinishCallback(animateOption, nullptr, AnimationCallback),
18423b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_NO_ERROR);
18523b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback(nullptr, nullptr, AnimationCallback, 0),
18623b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
18723b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback(animateOption, nullptr, AnimationCallback, -1),
18823b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
18923b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback(animateOption, nullptr, AnimationCallback, 1),
19023b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
19123b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_KeyframeAnimateOption_RegisterOnEventCallback(animateOption, nullptr, AnimationCallback, 0),
19223b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_NO_ERROR);
19323b3eb3cSopenharmony_ci    OH_ArkUI_KeyframeAnimateOption_Dispose(animateOption);
19423b3eb3cSopenharmony_ci}
19523b3eb3cSopenharmony_ci
19623b3eb3cSopenharmony_ci/**
19723b3eb3cSopenharmony_ci * @tc.name: NodeAnimateTest004
19823b3eb3cSopenharmony_ci * @tc.desc: Test AnimatorOption function.
19923b3eb3cSopenharmony_ci * @tc.type: FUNC
20023b3eb3cSopenharmony_ci */
20123b3eb3cSopenharmony_ciHWTEST_F(NodeAnimateTest, NodeAnimateTest004, TestSize.Level1)
20223b3eb3cSopenharmony_ci{
20323b3eb3cSopenharmony_ci    ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
20423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_Create(-1), nullptr);
20523b3eb3cSopenharmony_ci    ArkUI_AnimatorOption* animatorOption = OH_ArkUI_AnimatorOption_Create(0);
20623b3eb3cSopenharmony_ci    ASSERT_NE(animatorOption, nullptr);
20723b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetDuration(animatorOption, -1), ARKUI_ERROR_CODE_PARAM_INVALID);
20823b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetDuration(animatorOption, 1), ARKUI_ERROR_CODE_NO_ERROR);
20923b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetDuration(nullptr), -1);
21023b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetDuration(animatorOption), 1);
21123b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetDelay(animatorOption, 1), ARKUI_ERROR_CODE_NO_ERROR);
21223b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetDelay(nullptr), -1);
21323b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetDelay(animatorOption), 1);
21423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetIterations(animatorOption, -2), ARKUI_ERROR_CODE_NO_ERROR);
21523b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetIterations(animatorOption, 1), ARKUI_ERROR_CODE_NO_ERROR);
21623b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetIterations(nullptr), -1);
21723b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetIterations(animatorOption), 1);
21823b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetFill(animatorOption, static_cast<ArkUI_AnimationFillMode>(-1)),
21923b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
22023b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetFill(animatorOption, static_cast<ArkUI_AnimationFillMode>(1000)),
22123b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
22223b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetFill(animatorOption, ARKUI_ANIMATION_FILL_MODE_NONE),
22323b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_NO_ERROR);
22423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetFill(nullptr), static_cast<ArkUI_AnimationFillMode>(-1));
22523b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetFill(animatorOption), ARKUI_ANIMATION_FILL_MODE_NONE);
22623b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetDirection(animatorOption, static_cast<ArkUI_AnimationDirection>(-1)),
22723b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
22823b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetDirection(animatorOption, static_cast<ArkUI_AnimationDirection>(1000)),
22923b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
23023b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetDirection(animatorOption, ARKUI_ANIMATION_DIRECTION_NORMAL),
23123b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_NO_ERROR);
23223b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetDirection(nullptr), static_cast<ArkUI_AnimationDirection>(-1));
23323b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetDirection(animatorOption), ARKUI_ANIMATION_DIRECTION_NORMAL);
23423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetBegin(animatorOption, 0.0f), ARKUI_ERROR_CODE_NO_ERROR);
23523b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetBegin(nullptr), 0.0f);
23623b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetBegin(animatorOption), 0.0f);
23723b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetEnd(animatorOption, 1.0f), ARKUI_ERROR_CODE_NO_ERROR);
23823b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetEnd(nullptr), 1.0f);
23923b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetEnd(animatorOption), 1.0f);
24023b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetKeyframe(animatorOption, -1.0f, 0.0f, 0), ARKUI_ERROR_CODE_PARAM_INVALID);
24123b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetKeyframe(animatorOption, 2.0f, 0.0f, 0), ARKUI_ERROR_CODE_PARAM_INVALID);
24223b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetKeyframe(animatorOption, 0.5f, 0.0f, -1), ARKUI_ERROR_CODE_PARAM_INVALID);
24323b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetKeyframe(animatorOption, 0.5f, 0.0f, 0), ARKUI_ERROR_CODE_PARAM_INVALID);
24423b3eb3cSopenharmony_ci    auto range = new ArkUI_ExpectedFrameRateRange({1, 100, 50});
24523b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetExpectedFrameRateRange(animatorOption, range), ARKUI_ERROR_CODE_NO_ERROR);
24623b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetExpectedFrameRateRange(nullptr), nullptr);
24723b3eb3cSopenharmony_ci    EXPECT_NE(OH_ArkUI_AnimatorOption_GetExpectedFrameRateRange(animatorOption), nullptr);
24823b3eb3cSopenharmony_ci    OH_ArkUI_AnimatorOption_Dispose(animatorOption);
24923b3eb3cSopenharmony_ci    delete range;
25023b3eb3cSopenharmony_ci    range = nullptr;
25123b3eb3cSopenharmony_ci}
25223b3eb3cSopenharmony_ci
25323b3eb3cSopenharmony_ci/**
25423b3eb3cSopenharmony_ci * @tc.name: NodeAnimateTest005
25523b3eb3cSopenharmony_ci * @tc.desc: Test AnimatorOption Curve function.
25623b3eb3cSopenharmony_ci * @tc.type: FUNC
25723b3eb3cSopenharmony_ci */
25823b3eb3cSopenharmony_ciHWTEST_F(NodeAnimateTest, NodeAnimateTest005, TestSize.Level1)
25923b3eb3cSopenharmony_ci{
26023b3eb3cSopenharmony_ci    ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
26123b3eb3cSopenharmony_ci    ArkUI_AnimatorOption* animatorOption = OH_ArkUI_AnimatorOption_Create(0);
26223b3eb3cSopenharmony_ci    ArkUI_AnimatorOption* animatorKeyFrameOption = OH_ArkUI_AnimatorOption_Create(1);
26323b3eb3cSopenharmony_ci    ASSERT_NE(animatorOption, nullptr);
26423b3eb3cSopenharmony_ci    ASSERT_NE(animatorKeyFrameOption, nullptr);
26523b3eb3cSopenharmony_ci    auto icurve = OH_ArkUI_Curve_CreateCurveByType(ArkUI_AnimationCurve::ARKUI_CURVE_LINEAR);
26623b3eb3cSopenharmony_ci    auto springCurve = OH_ArkUI_Curve_CreateSpringCurve(0.0f, 0.0f, 0.0f, 0.0f);
26723b3eb3cSopenharmony_ci    auto springMotion = OH_ArkUI_Curve_CreateSpringMotion(0.5f, 0.5f, 0.5f);
26823b3eb3cSopenharmony_ci    auto responsiveSpringMotion = OH_ArkUI_Curve_CreateResponsiveSpringMotion(0.5f, 0.5f, 0.5f);
26923b3eb3cSopenharmony_ci    auto interpolatingSpring = OH_ArkUI_Curve_CreateInterpolatingSpring(0.5f, 0.5f, 0.5f, 0.5f);
27023b3eb3cSopenharmony_ci    auto customCurve = OH_ArkUI_Curve_CreateCustomCurve(nullptr, InterpolateCallback);
27123b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetCurve(animatorOption, springCurve), ARKUI_ERROR_CODE_PARAM_INVALID);
27223b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetCurve(animatorOption, springMotion), ARKUI_ERROR_CODE_PARAM_INVALID);
27323b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetCurve(animatorOption, responsiveSpringMotion), ARKUI_ERROR_CODE_PARAM_INVALID);
27423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetCurve(animatorOption, interpolatingSpring), ARKUI_ERROR_CODE_PARAM_INVALID);
27523b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetCurve(animatorOption, customCurve), ARKUI_ERROR_CODE_PARAM_INVALID);
27623b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetCurve(animatorOption, icurve), ARKUI_ERROR_CODE_NO_ERROR);
27723b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetCurve(nullptr), nullptr);
27823b3eb3cSopenharmony_ci    EXPECT_NE(OH_ArkUI_AnimatorOption_GetCurve(animatorOption), nullptr);
27923b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetKeyframeCurve(animatorKeyFrameOption, springCurve, 0),
28023b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
28123b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetKeyframeCurve(animatorKeyFrameOption, springMotion, 0),
28223b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
28323b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetKeyframeCurve(animatorKeyFrameOption, responsiveSpringMotion, 0),
28423b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
28523b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetKeyframeCurve(animatorKeyFrameOption, interpolatingSpring, 0),
28623b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
28723b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetKeyframeCurve(animatorKeyFrameOption, customCurve, 0),
28823b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
28923b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetKeyframeCurve(animatorKeyFrameOption, nullptr, -1),
29023b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
29123b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetKeyframeCurve(animatorKeyFrameOption, nullptr, 1),
29223b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
29323b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetKeyframeCurve(animatorKeyFrameOption, icurve, 0), ARKUI_ERROR_CODE_NO_ERROR);
29423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetKeyframeCurve(nullptr, 0), nullptr);
29523b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetKeyframeCurve(nullptr, -1), nullptr);
29623b3eb3cSopenharmony_ci    OH_ArkUI_Curve_DisposeCurve(icurve);
29723b3eb3cSopenharmony_ci    OH_ArkUI_Curve_DisposeCurve(springCurve);
29823b3eb3cSopenharmony_ci    OH_ArkUI_Curve_DisposeCurve(springMotion);
29923b3eb3cSopenharmony_ci    OH_ArkUI_Curve_DisposeCurve(responsiveSpringMotion);
30023b3eb3cSopenharmony_ci    OH_ArkUI_Curve_DisposeCurve(customCurve);
30123b3eb3cSopenharmony_ci    OH_ArkUI_AnimatorOption_Dispose(animatorOption);
30223b3eb3cSopenharmony_ci    OH_ArkUI_AnimatorOption_Dispose(animatorKeyFrameOption);
30323b3eb3cSopenharmony_ci}
30423b3eb3cSopenharmony_ci
30523b3eb3cSopenharmony_ci/**
30623b3eb3cSopenharmony_ci * @tc.name: NodeAnimateTest006
30723b3eb3cSopenharmony_ci * @tc.desc: Test AnimatorOption Keyframe function.
30823b3eb3cSopenharmony_ci * @tc.type: FUNC
30923b3eb3cSopenharmony_ci */
31023b3eb3cSopenharmony_ciHWTEST_F(NodeAnimateTest, NodeAnimateTest006, TestSize.Level1)
31123b3eb3cSopenharmony_ci{
31223b3eb3cSopenharmony_ci    ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
31323b3eb3cSopenharmony_ci    ArkUI_AnimatorOption* animatorOption = OH_ArkUI_AnimatorOption_Create(1);
31423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_SetKeyframe(animatorOption, 0.5f, 0.0f, 0), ARKUI_ERROR_CODE_NO_ERROR);
31523b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetKeyframeTime(nullptr, 0), -1.0f);
31623b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetKeyframeTime(animatorOption, -1), -1.0f);
31723b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetKeyframeTime(animatorOption, 1), -1.0f);
31823b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetKeyframeTime(animatorOption, 0), 0.5f);
31923b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetKeyframeValue(nullptr, 0), -1.0f);
32023b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetKeyframeValue(animatorOption, -1), -1.0f);
32123b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetKeyframeValue(animatorOption, 1), -1.0f);
32223b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_GetKeyframeValue(animatorOption, 0), 0.0f);
32323b3eb3cSopenharmony_ci    OH_ArkUI_AnimatorOption_Dispose(animatorOption);
32423b3eb3cSopenharmony_ci}
32523b3eb3cSopenharmony_ci
32623b3eb3cSopenharmony_ci/**
32723b3eb3cSopenharmony_ci * @tc.name: NodeAnimateTest007
32823b3eb3cSopenharmony_ci * @tc.desc: Test Animator function.
32923b3eb3cSopenharmony_ci * @tc.type: FUNC
33023b3eb3cSopenharmony_ci */
33123b3eb3cSopenharmony_ciHWTEST_F(NodeAnimateTest, NodeAnimateTest007, TestSize.Level1)
33223b3eb3cSopenharmony_ci{
33323b3eb3cSopenharmony_ci    auto animateAPI = reinterpret_cast<ArkUI_NativeAnimateAPI_1*>(
33423b3eb3cSopenharmony_ci        OH_ArkUI_QueryModuleInterfaceByName(ARKUI_NATIVE_ANIMATE, "ArkUI_NativeAnimateAPI_1"));
33523b3eb3cSopenharmony_ci    struct ArkUI_Context context= {1};
33623b3eb3cSopenharmony_ci    ArkUI_AnimatorOption* animatorOption = OH_ArkUI_AnimatorOption_Create(1);
33723b3eb3cSopenharmony_ci    auto handle = animateAPI->createAnimator(&context, animatorOption);
33823b3eb3cSopenharmony_ci    ASSERT_NE(handle, nullptr);
33923b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_Animator_ResetAnimatorOption(handle, animatorOption), ARKUI_ERROR_CODE_PARAM_INVALID);
34023b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_Animator_Play(handle), ARKUI_ERROR_CODE_PARAM_INVALID);
34123b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_Animator_Finish(handle), ARKUI_ERROR_CODE_PARAM_INVALID);
34223b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_Animator_Pause(handle), ARKUI_ERROR_CODE_PARAM_INVALID);
34323b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_Animator_Cancel(handle), ARKUI_ERROR_CODE_PARAM_INVALID);
34423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_Animator_Reverse(handle), ARKUI_ERROR_CODE_PARAM_INVALID);
34523b3eb3cSopenharmony_ci    OH_ArkUI_AnimatorOption_Dispose(animatorOption);
34623b3eb3cSopenharmony_ci    animateAPI->disposeAnimator(handle);
34723b3eb3cSopenharmony_ci}
34823b3eb3cSopenharmony_ci
34923b3eb3cSopenharmony_ci/**
35023b3eb3cSopenharmony_ci * @tc.name: NodeAnimateTest008
35123b3eb3cSopenharmony_ci * @tc.desc: Test AnimatorEvent function.
35223b3eb3cSopenharmony_ci * @tc.type: FUNC
35323b3eb3cSopenharmony_ci */
35423b3eb3cSopenharmony_ciHWTEST_F(NodeAnimateTest, NodeAnimateTest008, TestSize.Level1)
35523b3eb3cSopenharmony_ci{
35623b3eb3cSopenharmony_ci    ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl());
35723b3eb3cSopenharmony_ci    ArkUI_AnimatorOption* animatorOption = OH_ArkUI_AnimatorOption_Create(1);
35823b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_RegisterOnFrameCallback(nullptr, nullptr, nullptr),
35923b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
36023b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_RegisterOnFrameCallback(animatorOption, nullptr, nullptr),
36123b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
36223b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_RegisterOnFrameCallback(animatorOption, nullptr, AnimatorOnFrameEventCallback),
36323b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_NO_ERROR);
36423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_RegisterOnFinishCallback(nullptr, nullptr, nullptr),
36523b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
36623b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_RegisterOnFinishCallback(animatorOption, nullptr, nullptr),
36723b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
36823b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_RegisterOnFinishCallback(animatorOption, nullptr, AnimatorEventCallback),
36923b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_NO_ERROR);
37023b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_RegisterOnCancelCallback(nullptr, nullptr, nullptr),
37123b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
37223b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_RegisterOnCancelCallback(animatorOption, nullptr, nullptr),
37323b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
37423b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_RegisterOnCancelCallback(animatorOption, nullptr, AnimatorEventCallback),
37523b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_NO_ERROR);
37623b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_RegisterOnRepeatCallback(nullptr, nullptr, nullptr),
37723b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
37823b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_RegisterOnRepeatCallback(animatorOption, nullptr, nullptr),
37923b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_PARAM_INVALID);
38023b3eb3cSopenharmony_ci    EXPECT_EQ(OH_ArkUI_AnimatorOption_RegisterOnRepeatCallback(animatorOption, nullptr, AnimatorEventCallback),
38123b3eb3cSopenharmony_ci        ARKUI_ERROR_CODE_NO_ERROR);
38223b3eb3cSopenharmony_ci    OH_ArkUI_AnimatorOption_Dispose(animatorOption);
38323b3eb3cSopenharmony_ci}
38423b3eb3cSopenharmony_ci} // namespace OHOS::Ace