1/* 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16#include "animate_impl.h" 17#include "core/interfaces/arkoala/arkoala_api.h" 18#include "error_code.h" 19#include "event_converter.h" 20#include "gtest/gtest.h" 21#include "native_animate.h" 22#include "native_interface.h" 23#include "native_node.h" 24#include "node_extened.h" 25#include "node_model.h" 26 27using namespace testing; 28using namespace testing::ext; 29using namespace OHOS::Ace::AnimateModel; 30 31class AnimateImplTest : public testing::Test { 32public: 33 static void SetUpTestCase() {}; 34 static void TearDownTestCase() {}; 35}; 36 37float InterpolateCallback(float fraction, void* userData) 38{ 39 return fraction; 40} 41 42void AnimateCompleteCallback(void* userData) {} 43 44/** 45 * @tc.name: AnimateImplTest001 46 * @tc.desc: Test InitCurve function. 47 * @tc.type: FUNC 48 */ 49HWTEST_F(AnimateImplTest, AnimateImplTest001, TestSize.Level1) 50{ 51 ArkUI_CurveHandle curve = InitCurve(ArkUI_AnimationCurve::ARKUI_CURVE_EASE); 52 ASSERT_EQ(curve, nullptr); 53 54 DisposeCurve(curve); 55} 56 57/** 58 * @tc.name: AnimateImplTest002 59 * @tc.desc: Test CubicBezierCurve function. 60 * @tc.type: FUNC 61 */ 62HWTEST_F(AnimateImplTest, AnimateImplTest002, TestSize.Level1) 63{ 64 ArkUI_CurveHandle curve = CubicBezierCurve(0.0f, 0.0f, 0.0f, 0.0f); 65 ASSERT_EQ(curve, nullptr); 66} 67 68/** 69 * @tc.name: AnimateImplTest003 70 * @tc.desc: Test SpringCurve function. 71 * @tc.type: FUNC 72 */ 73HWTEST_F(AnimateImplTest, AnimateImplTest003, TestSize.Level1) 74{ 75 ArkUI_CurveHandle curve = SpringCurve(0.0f, 0.0f, 0.0f, 0.0f); 76 ASSERT_EQ(curve, nullptr); 77} 78 79/** 80 * @tc.name: AnimateImplTest004 81 * @tc.desc: Test SpringMotion function. 82 * @tc.type: FUNC 83 */ 84HWTEST_F(AnimateImplTest, AnimateImplTest004, TestSize.Level1) 85{ 86 ArkUI_CurveHandle curve = SpringMotion(0.0f, 0.0f, 0.0f); 87 ASSERT_EQ(curve, nullptr); 88} 89 90/** 91 * @tc.name: AnimateImplTest005 92 * @tc.desc: Test InterpolatingSpring function. 93 * @tc.type: FUNC 94 */ 95HWTEST_F(AnimateImplTest, AnimateImplTest005, TestSize.Level1) 96{ 97 ArkUI_CurveHandle curve = InterpolatingSpring(0.0f, 0.0f, 0.0f, 0.0f); 98 ASSERT_EQ(curve, nullptr); 99} 100 101/** 102 * @tc.name: AnimateImplTest006 103 * @tc.desc: Test ResponsiveSpringMotion function. 104 * @tc.type: FUNC 105 */ 106HWTEST_F(AnimateImplTest, AnimateImplTest006, TestSize.Level1) 107{ 108 ArkUI_CurveHandle curve = ResponsiveSpringMotion(0.0f, 0.0f, 0.0f); 109 ASSERT_EQ(curve, nullptr); 110} 111 112/** 113 * @tc.name: AnimateImplTest007 114 * @tc.desc: Test CustomCurve function. 115 * @tc.type: FUNC 116 */ 117HWTEST_F(AnimateImplTest, AnimateImplTest007, TestSize.Level1) 118{ 119 ArkUI_CurveHandle curve = CustomCurve(nullptr, InterpolateCallback); 120 ASSERT_EQ(curve, nullptr); 121} 122 123/** 124 * @tc.name: AnimateImplTest008 125 * @tc.desc: Test InitCurve function. 126 * @tc.type: FUNC 127 */ 128HWTEST_F(AnimateImplTest, AnimateImplTest008, TestSize.Level1) 129{ 130 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 131 ArkUI_CurveHandle curve = InitCurve(ArkUI_AnimationCurve::ARKUI_CURVE_EASE); 132 ASSERT_NE(curve, nullptr); 133 134 DisposeCurve(curve); 135 curve = nullptr; 136} 137 138/** 139 * @tc.name: AnimateImplTest009 140 * @tc.desc: Test StepsCurve function. 141 * @tc.type: FUNC 142 */ 143HWTEST_F(AnimateImplTest, AnimateImplTest009, TestSize.Level1) 144{ 145 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 146 ArkUI_CurveHandle curve = StepsCurve(0, true); 147 ASSERT_EQ(curve, nullptr); 148} 149 150/** 151 * @tc.name: AnimateImplTest010 152 * @tc.desc: Test StepsCurve function. 153 * @tc.type: FUNC 154 */ 155HWTEST_F(AnimateImplTest, AnimateImplTest010, TestSize.Level1) 156{ 157 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 158 ArkUI_CurveHandle curve = StepsCurve(1, true); 159 ASSERT_NE(curve, nullptr); 160 161 DisposeCurve(curve); 162 curve = nullptr; 163} 164 165/** 166 * @tc.name: AnimateImplTest011 167 * @tc.desc: Test CubicBezierCurve function. 168 * @tc.type: FUNC 169 */ 170HWTEST_F(AnimateImplTest, AnimateImplTest011, TestSize.Level1) 171{ 172 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 173 ArkUI_CurveHandle curve = CubicBezierCurve(0.0f, 0.0f, 0.0f, 0.0f); 174 ASSERT_NE(curve, nullptr); 175 176 DisposeCurve(curve); 177 curve = nullptr; 178} 179 180/** 181 * @tc.name: AnimateImplTest012 182 * @tc.desc: Test SpringCurve function. 183 * @tc.type: FUNC 184 */ 185HWTEST_F(AnimateImplTest, AnimateImplTest012, TestSize.Level1) 186{ 187 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 188 ArkUI_CurveHandle curve = SpringCurve(0.0f, 0.0f, 0.0f, 0.0f); 189 ASSERT_NE(curve, nullptr); 190 191 DisposeCurve(curve); 192 curve = nullptr; 193} 194 195/** 196 * @tc.name: AnimateImplTest013 197 * @tc.desc: Test SpringCurve function. 198 * @tc.type: FUNC 199 */ 200HWTEST_F(AnimateImplTest, AnimateImplTest013, TestSize.Level1) 201{ 202 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 203 ArkUI_CurveHandle curve = SpringCurve(0.5f, 0.5f, 0.5f, 0.5f); 204 ASSERT_NE(curve, nullptr); 205 206 DisposeCurve(curve); 207 curve = nullptr; 208} 209 210/** 211 * @tc.name: AnimateImplTest014 212 * @tc.desc: Test SpringMotion function. 213 * @tc.type: FUNC 214 */ 215HWTEST_F(AnimateImplTest, AnimateImplTest014, TestSize.Level1) 216{ 217 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 218 ArkUI_CurveHandle curve = SpringMotion(0.5f, 0.5f, 0.5f); 219 ASSERT_NE(curve, nullptr); 220 221 DisposeCurve(curve); 222 curve = nullptr; 223} 224 225/** 226 * @tc.name: AnimateImplTest015 227 * @tc.desc: Test SpringMotion function. 228 * @tc.type: FUNC 229 */ 230HWTEST_F(AnimateImplTest, AnimateImplTest015, TestSize.Level1) 231{ 232 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 233 ArkUI_CurveHandle curve = SpringMotion(-1.0f, -1.0f, -1.0f); 234 ASSERT_NE(curve, nullptr); 235 236 DisposeCurve(curve); 237 curve = nullptr; 238} 239 240/** 241 * @tc.name: AnimateImplTest016 242 * @tc.desc: Test ResponsiveSpringMotion function. 243 * @tc.type: FUNC 244 */ 245HWTEST_F(AnimateImplTest, AnimateImplTest016, TestSize.Level1) 246{ 247 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 248 ArkUI_CurveHandle curve = ResponsiveSpringMotion(-1.0f, -1.0f, -1.0f); 249 ASSERT_NE(curve, nullptr); 250 251 DisposeCurve(curve); 252 curve = nullptr; 253} 254 255/** 256 * @tc.name: AnimateImplTest017 257 * @tc.desc: Test ResponsiveSpringMotion function. 258 * @tc.type: FUNC 259 */ 260HWTEST_F(AnimateImplTest, AnimateImplTest017, TestSize.Level1) 261{ 262 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 263 ArkUI_CurveHandle curve = ResponsiveSpringMotion(0.5f, 0.5f, 0.5f); 264 ASSERT_NE(curve, nullptr); 265 266 DisposeCurve(curve); 267 curve = nullptr; 268} 269 270/** 271 * @tc.name: AnimateImplTest018 272 * @tc.desc: Test InterpolatingSpring function. 273 * @tc.type: FUNC 274 */ 275HWTEST_F(AnimateImplTest, AnimateImplTest018, TestSize.Level1) 276{ 277 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 278 ArkUI_CurveHandle curve = InterpolatingSpring(0.5f, 0.5f, 0.5f, 0.5f); 279 ASSERT_NE(curve, nullptr); 280 281 DisposeCurve(curve); 282 curve = nullptr; 283} 284 285/** 286 * @tc.name: AnimateImplTest019 287 * @tc.desc: Test InterpolatingSpring function. 288 * @tc.type: FUNC 289 */ 290HWTEST_F(AnimateImplTest, AnimateImplTest019, TestSize.Level1) 291{ 292 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 293 ArkUI_CurveHandle curve = InterpolatingSpring(0.0f, 0.0f, 0.0f, 0.0f); 294 ASSERT_NE(curve, nullptr); 295 296 DisposeCurve(curve); 297 curve = nullptr; 298} 299 300/** 301 * @tc.name: AnimateImplTest020 302 * @tc.desc: Test CustomCurve function. 303 * @tc.type: FUNC 304 */ 305HWTEST_F(AnimateImplTest, AnimateImplTest020, TestSize.Level1) 306{ 307 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 308 ArkUI_CurveHandle curve = CustomCurve(nullptr, InterpolateCallback); 309 ASSERT_NE(curve, nullptr); 310 311 DisposeCurve(curve); 312 curve = nullptr; 313} 314 315/** 316 * @tc.name: AnimateImplTest021 317 * @tc.desc: Test CreateAnimator function. 318 * @tc.type: FUNC 319 */ 320HWTEST_F(AnimateImplTest, AnimateImplTest021, TestSize.Level1) 321{ 322 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 323 struct ArkUI_Context context= {1}; 324 ArkUI_AnimatorOption* option = new ArkUI_AnimatorOption(); 325 ArkUI_AnimatorHandle animatorHandle = CreateAnimator(&context, option); 326 ASSERT_NE(animatorHandle, nullptr); 327 328 DisposeAnimator(animatorHandle); 329 animatorHandle = nullptr; 330 delete option; 331} 332 333/** 334 * @tc.name: AnimateImplTest022 335 * @tc.desc: Test CreateAnimator function. 336 * @tc.type: FUNC 337 */ 338HWTEST_F(AnimateImplTest, AnimateImplTest022, TestSize.Level1) 339{ 340 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 341 ArkUI_AnimatorHandle animatorHandle = CreateAnimator(nullptr, nullptr); 342 ASSERT_EQ(animatorHandle, nullptr); 343 344 DisposeAnimator(animatorHandle); 345} 346 347/** 348 * @tc.name: AnimateImplTest023 349 * @tc.desc: Test AnimatorReset function. 350 * @tc.type: FUNC 351 */ 352HWTEST_F(AnimateImplTest, AnimateImplTest023, TestSize.Level1) 353{ 354 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 355 int32_t ret = AnimatorReset(nullptr, nullptr); 356 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID); 357} 358 359/** 360 * @tc.name: AnimateImplTest024 361 * @tc.desc: Test AnimatorReset function. 362 * @tc.type: FUNC 363 */ 364HWTEST_F(AnimateImplTest, AnimateImplTest024, TestSize.Level1) 365{ 366 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 367 struct ArkUI_Context context= {1}; 368 ArkUI_AnimatorOption* option = new ArkUI_AnimatorOption(); 369 ArkUI_AnimatorHandle animatorHandle = CreateAnimator(&context, option); 370 ASSERT_NE(animatorHandle, nullptr); 371 ArkUIAnimatorHandle animator = new ArkUIAnimator(); 372 animatorHandle->animator = animator; 373 int32_t ret = AnimatorReset(animatorHandle, option); 374 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR); 375 376 DisposeAnimator(animatorHandle); 377 animatorHandle = nullptr; 378 delete option; 379} 380 381/** 382 * @tc.name: AnimateImplTest025 383 * @tc.desc: Test AnimatorReset function. 384 * @tc.type: FUNC 385 */ 386HWTEST_F(AnimateImplTest, AnimateImplTest025, TestSize.Level1) 387{ 388 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 389 struct ArkUI_Context context= {1}; 390 ArkUI_AnimatorOption* option = new ArkUI_AnimatorOption(); 391 struct ArkUI_Keyframe keyframe = {0.0f, 0.0f, nullptr}; 392 option->keyframes.push_back(keyframe); 393 ArkUI_AnimatorHandle animatorHandle = CreateAnimator(&context, option); 394 ASSERT_NE(animatorHandle, nullptr); 395 ArkUIAnimatorHandle animator = new ArkUIAnimator(); 396 animatorHandle->animator = animator; 397 int32_t ret = AnimatorReset(animatorHandle, option); 398 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR); 399 400 DisposeAnimator(animatorHandle); 401 animatorHandle = nullptr; 402 delete option; 403} 404 405/** 406 * @tc.name: AnimateImplTest026 407 * @tc.desc: Test AnimatorPlay function. 408 * @tc.type: FUNC 409 */ 410HWTEST_F(AnimateImplTest, AnimateImplTest026, TestSize.Level1) 411{ 412 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 413 int32_t ret = AnimatorPlay(nullptr); 414 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID); 415} 416 417/** 418 * @tc.name: AnimateImplTest027 419 * @tc.desc: Test AnimatorPlay function. 420 * @tc.type: FUNC 421 */ 422HWTEST_F(AnimateImplTest, AnimateImplTest027, TestSize.Level1) 423{ 424 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 425 struct ArkUI_Context context= {1}; 426 ArkUI_AnimatorOption* option = new ArkUI_AnimatorOption(); 427 ArkUI_AnimatorHandle animatorHandle = CreateAnimator(&context, option); 428 ASSERT_NE(animatorHandle, nullptr); 429 ArkUIAnimatorHandle animator = new ArkUIAnimator(); 430 animatorHandle->animator = animator; 431 int32_t ret = AnimatorPlay(animatorHandle); 432 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR); 433 434 DisposeAnimator(animatorHandle); 435 animatorHandle = nullptr; 436 delete option; 437} 438 439/** 440 * @tc.name: AnimateImplTest028 441 * @tc.desc: Test AnimatorFinish function. 442 * @tc.type: FUNC 443 */ 444HWTEST_F(AnimateImplTest, AnimateImplTest028, TestSize.Level1) 445{ 446 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 447 int32_t ret = AnimatorFinish(nullptr); 448 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID); 449} 450 451/** 452 * @tc.name: AnimateImplTest029 453 * @tc.desc: Test AnimatorFinish function. 454 * @tc.type: FUNC 455 */ 456HWTEST_F(AnimateImplTest, AnimateImplTest029, TestSize.Level1) 457{ 458 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 459 struct ArkUI_Context context= {1}; 460 ArkUI_AnimatorOption* option = new ArkUI_AnimatorOption(); 461 ArkUI_AnimatorHandle animatorHandle = CreateAnimator(&context, option); 462 ASSERT_NE(animatorHandle, nullptr); 463 ArkUIAnimatorHandle animator = new ArkUIAnimator(); 464 animatorHandle->animator = animator; 465 int32_t ret = AnimatorFinish(animatorHandle); 466 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR); 467 468 DisposeAnimator(animatorHandle); 469 animatorHandle = nullptr; 470 delete option; 471} 472 473/** 474 * @tc.name: AnimateImplTest030 475 * @tc.desc: Test AnimatorPause function. 476 * @tc.type: FUNC 477 */ 478HWTEST_F(AnimateImplTest, AnimateImplTest030, TestSize.Level1) 479{ 480 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 481 int32_t ret = AnimatorPause(nullptr); 482 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID); 483} 484 485/** 486 * @tc.name: AnimateImplTest031 487 * @tc.desc: Test AnimatorPause function. 488 * @tc.type: FUNC 489 */ 490HWTEST_F(AnimateImplTest, AnimateImplTest031, TestSize.Level1) 491{ 492 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 493 struct ArkUI_Context context= {1}; 494 ArkUI_AnimatorOption* option = new ArkUI_AnimatorOption(); 495 ArkUI_AnimatorHandle animatorHandle = CreateAnimator(&context, option); 496 ASSERT_NE(animatorHandle, nullptr); 497 ArkUIAnimatorHandle animator = new ArkUIAnimator(); 498 animatorHandle->animator = animator; 499 int32_t ret = AnimatorPause(animatorHandle); 500 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR); 501 502 DisposeAnimator(animatorHandle); 503 animatorHandle = nullptr; 504 delete option; 505} 506 507/** 508 * @tc.name: AnimateImplTest032 509 * @tc.desc: Test AnimatorCancel function. 510 * @tc.type: FUNC 511 */ 512HWTEST_F(AnimateImplTest, AnimateImplTest032, TestSize.Level1) 513{ 514 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 515 int32_t ret = AnimatorCancel(nullptr); 516 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID); 517} 518 519/** 520 * @tc.name: AnimateImplTest033 521 * @tc.desc: Test AnimatorCancel function. 522 * @tc.type: FUNC 523 */ 524HWTEST_F(AnimateImplTest, AnimateImplTest033, TestSize.Level1) 525{ 526 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 527 struct ArkUI_Context context= {1}; 528 ArkUI_AnimatorOption* option = new ArkUI_AnimatorOption(); 529 ArkUI_AnimatorHandle animatorHandle = CreateAnimator(&context, option); 530 ASSERT_NE(animatorHandle, nullptr); 531 ArkUIAnimatorHandle animator = new ArkUIAnimator(); 532 animatorHandle->animator = animator; 533 int32_t ret = AnimatorCancel(animatorHandle); 534 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR); 535 536 DisposeAnimator(animatorHandle); 537 animatorHandle = nullptr; 538 delete option; 539} 540 541/** 542 * @tc.name: AnimateImplTest034 543 * @tc.desc: Test AnimatorReverse function. 544 * @tc.type: FUNC 545 */ 546HWTEST_F(AnimateImplTest, AnimateImplTest034, TestSize.Level1) 547{ 548 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 549 int32_t ret = AnimatorReverse(nullptr); 550 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID); 551} 552 553/** 554 * @tc.name: AnimateImplTest035 555 * @tc.desc: Test AnimatorReverse function. 556 * @tc.type: FUNC 557 */ 558HWTEST_F(AnimateImplTest, AnimateImplTest035, TestSize.Level1) 559{ 560 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 561 struct ArkUI_Context context= {1}; 562 ArkUI_AnimatorOption* option = new ArkUI_AnimatorOption(); 563 ArkUI_AnimatorHandle animatorHandle = CreateAnimator(&context, option); 564 ASSERT_NE(animatorHandle, nullptr); 565 ArkUIAnimatorHandle animator = new ArkUIAnimator(); 566 animatorHandle->animator = animator; 567 int32_t ret = AnimatorReverse(animatorHandle); 568 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR); 569 570 DisposeAnimator(animatorHandle); 571 animatorHandle = nullptr; 572 delete option; 573} 574 575/** 576 * @tc.name: AnimateImplTest036 577 * @tc.desc: Test KeyframeAnimateTo function. 578 * @tc.type: FUNC 579 */ 580HWTEST_F(AnimateImplTest, AnimateImplTest036, TestSize.Level1) 581{ 582 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 583 int32_t ret = KeyframeAnimateTo(nullptr, nullptr); 584 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID); 585} 586 587/** 588 * @tc.name: AnimateImplTest037 589 * @tc.desc: Test KeyframeAnimateTo function. 590 * @tc.type: FUNC 591 */ 592HWTEST_F(AnimateImplTest, AnimateImplTest037, TestSize.Level1) 593{ 594 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 595 struct ArkUI_Context context= {1}; 596 ArkUI_KeyframeAnimateOption* option = new ArkUI_KeyframeAnimateOption(); 597 struct ArkUI_KeyframeState keyframe = {0, nullptr, nullptr, nullptr}; 598 option->keyframes.push_back(keyframe); 599 int32_t ret = KeyframeAnimateTo(&context, option); 600 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR); 601 delete option; 602} 603 604/** 605 * @tc.name: AnimateImplTest038 606 * @tc.desc: Test AnimateTo function. 607 * @tc.type: FUNC 608 */ 609HWTEST_F(AnimateImplTest, AnimateImplTest038, TestSize.Level1) 610{ 611 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 612 int32_t ret = AnimateTo(nullptr, nullptr, nullptr, nullptr); 613 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_PARAM_INVALID); 614} 615 616/** 617 * @tc.name: AnimateImplTest039 618 * @tc.desc: Test AnimateTo function. 619 * @tc.type: FUNC 620 */ 621HWTEST_F(AnimateImplTest, AnimateImplTest039, TestSize.Level1) 622{ 623 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 624 struct ArkUI_Context context= {1}; 625 ArkUI_AnimateOption* option = new ArkUI_AnimateOption(); 626 ArkUI_ContextCallback* update = new ArkUI_ContextCallback(); 627 update->callback = AnimateCompleteCallback; 628 ArkUI_AnimateCompleteCallback* complete = new ArkUI_AnimateCompleteCallback(); 629 int32_t ret = AnimateTo(&context, option, update, complete); 630 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR); 631 delete option; 632 delete update; 633 delete complete; 634} 635 636/** 637 * @tc.name: AnimateImplTest040 638 * @tc.desc: Test AnimateTo function. 639 * @tc.type: FUNC 640 */ 641HWTEST_F(AnimateImplTest, AnimateImplTest040, TestSize.Level1) 642{ 643 ASSERT_TRUE(OHOS::Ace::NodeModel::InitialFullImpl()); 644 struct ArkUI_Context context= {1}; 645 ArkUI_AnimateOption* option = new ArkUI_AnimateOption(); 646 ArkUI_CurveHandle curve = new ArkUI_Curve(); 647 ArkUI_ExpectedFrameRateRange* expectedFrameRateRange = new ArkUI_ExpectedFrameRateRange(); 648 option->iCurve = curve; 649 option->expectedFrameRateRange = expectedFrameRateRange; 650 ArkUI_ContextCallback* update = new ArkUI_ContextCallback(); 651 update->callback = AnimateCompleteCallback; 652 ArkUI_AnimateCompleteCallback* complete = new ArkUI_AnimateCompleteCallback(); 653 complete->type = ARKUI_FINISH_CALLBACK_LOGICALLY; 654 complete->callback = AnimateCompleteCallback; 655 void* userData = malloc(100); 656 complete->userData = userData; 657 int32_t ret = AnimateTo(&context, option, update, complete); 658 ASSERT_EQ(ret, OHOS::Ace::ERROR_CODE_NO_ERROR); 659 free(userData); 660 delete option; 661 delete curve; 662 delete update; 663 delete complete; 664}