1 /*
2 * Copyright (c) 2023 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 <optional>
17 #include <string>
18 #include <vector>
19
20 #include "gtest/gtest.h"
21
22 #include "core/components_ng/pattern/animator/animator_model_ng.h"
23
24 using namespace testing;
25 using namespace testing::ext;
26
27 namespace OHOS::Ace::Framework {
Create(const std::string & animatorId)28 void AnimatorModelNG::Create(const std::string& animatorId) {}
29
GetAnimatorInfo(const std::string & animatorId)30 RefPtr<AnimatorInfo> AnimatorModelNG::GetAnimatorInfo(const std::string& animatorId)
31 {
32 auto animatorInfo = AceType::MakeRefPtr<AnimatorInfo>();
33 auto animator = AceType::MakeRefPtr<Animator>();
34 animatorInfo->SetAnimator(animator);
35 return animatorInfo;
36 }
37 } // namespace OHOS::Ace::Framework
38
39 namespace OHOS::Ace::NG {
40 class AnimatorTestNg : public testing::Test {};
41
42 /**
43 * @tc.name: Test001
44 * @tc.desc: Test
45 * @tc.type: FUNC
46 */
47 HWTEST_F(AnimatorTestNg, Test001, TestSize.Level1)
48 {
49 Framework::AnimatorModelNG aimatorModel;
50 aimatorModel.AddEventListener(nullptr, Framework::EventOperation::START, "-1");
51 aimatorModel.AddEventListener(nullptr, Framework::EventOperation::PAUSE, "-1");
52 aimatorModel.AddEventListener(nullptr, Framework::EventOperation::REPEAT, "-1");
53 aimatorModel.AddEventListener(nullptr, Framework::EventOperation::CANCEL, "-1");
54 aimatorModel.AddEventListener(nullptr, Framework::EventOperation::FINISH, "-1");
55 aimatorModel.AddEventListener(nullptr, Framework::EventOperation::NONE, "-1");
56 auto eventOperation = static_cast<Framework::EventOperation>(7); // 7 is not a valid EventOperation.
57 aimatorModel.AddEventListener(nullptr, eventOperation, "-1");
58
__anon42b62eeb0102() 59 auto event = []() {};
60 aimatorModel.AddEventListener(event, Framework::EventOperation::START, "-1");
61 aimatorModel.AddEventListener(event, Framework::EventOperation::PAUSE, "-1");
62 aimatorModel.AddEventListener(event, Framework::EventOperation::REPEAT, "-1");
63 aimatorModel.AddEventListener(event, Framework::EventOperation::CANCEL, "-1");
64 aimatorModel.AddEventListener(event, Framework::EventOperation::FINISH, "-1");
65 aimatorModel.AddEventListener(event, Framework::EventOperation::NONE, "-1");
66 aimatorModel.AddEventListener(event, eventOperation, "-1");
67
68 EXPECT_TRUE(true);
69 }
70 } // namespace OHOS::Ace::NG
71