• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 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 #ifndef UI_TEST_IMAGE_ANIMATOR_H
17 #define UI_TEST_IMAGE_ANIMATOR_H
18 
19 #include "components/ui_image_animator.h"
20 #include "components/ui_label.h"
21 #include "components/ui_label_button.h"
22 #include "components/ui_scroll_view.h"
23 #include "layout/grid_layout.h"
24 #include "ui_test.h"
25 
26 namespace OHOS {
27 class TestAnimatorStopListener : public UIImageAnimatorView::AnimatorStopListener {
28 public:
TestAnimatorStopListener(UIViewGroup * viewGroup)29     explicit TestAnimatorStopListener(UIViewGroup* viewGroup) : viewGroup_(viewGroup)
30     {
31         viewGroup_ = viewGroup;
32     }
~TestAnimatorStopListener()33     ~TestAnimatorStopListener() {}
34 
Init()35     void Init()
36     {
37         label_ = new UILabel();
38         viewGroup_->Add(label_);
39         label_->SetPosition(24, 50, 200, 29); // 24: position x 50: position y 200: width 29: height
40         label_->SetText("OnAnimatorStop");
41         label_->SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
42         label_->SetStyle(STYLE_TEXT_COLOR, Color::Black().full);
43         label_->SetStyle(STYLE_BACKGROUND_COLOR, Color::White().full);
44         label_->SetStyle(STYLE_BACKGROUND_OPA, 255); // 255: value
45         label_->SetVisible(false);
46     }
47 
OnAnimatorStop(UIView & view)48     void OnAnimatorStop(UIView& view) override
49     {
50         label_->SetVisible(true);
51         label_->Invalidate();
52     }
53 
54 private:
55     UILabel* label_ = nullptr;
56     UIViewGroup* viewGroup_ = nullptr;
57 };
58 
59 class UITestImageAnimator : public UITest, public UIView::OnClickListener {
60 public:
UITestImageAnimator()61     UITestImageAnimator() {}
~UITestImageAnimator()62     ~UITestImageAnimator() {}
63     void SetUp() override;
64     void TearDown() override;
65     const UIView* GetTestView() override;
66 
67     void SetUpButton(UILabelButton* btn, const char* title);
68 
69     bool OnClick(UIView& view, const ClickEvent& event) override;
70 
71     void UIKitImageAnimatorTestStart001();
72     void UIKitImageAnimatorTestStop002();
73     void UIKitImageAnimatorTestPause003();
74     void UIKitImageAnimatorTestResume004();
75     void UIKitImageAnimatorTestSetImageAnimatorSrc005();
76     void UIKitImageAnimatorTestSetTickOfUpdate006();
77     void UIKitImageAnimatorTestSetSizeFixed007();
78     void UIKitImageAnimatorTestSetRepeat008();
79     void UIKitImageAnimatorTestSetReverse009();
80     void UIKitImageAnimatorTestSetAnimatorStopListener010();
81     void UIKitImageAnimatorTestSetRepeatTimes011();
82     void UIKitImageAnimatorTestSetFillModeTrueForward012();
83     void UIKitImageAnimatorTestSetFillModeTrueBackward013();
84     void UIKitImageAnimatorTestSetFillModeFalseForward014();
85     void UIKitImageAnimatorTestSetFillModeFalseBackward015();
86     void UIKitImageAnimatorTestSetImageInfo016();
87 
88 private:
89     void InitImageInfo();
90     UIScrollView* container_ = nullptr;
91     GridLayout* layout_ = nullptr;
92     UIImageAnimatorView* imageAnimator_ = nullptr;
93     TestAnimatorStopListener* listener_ = nullptr;
94 
95     UILabelButton* startBtn_ = nullptr;
96     UILabelButton* stopBtn_ = nullptr;
97     UILabelButton* pauseBtn_ = nullptr;
98     UILabelButton* resumeBtn_ = nullptr;
99     UILabelButton* setImageBtn_ = nullptr;
100     UILabelButton* setSpeedBtn_ = nullptr;
101     UILabelButton* fixedBtn_ = nullptr;
102     UILabelButton* repeatBtn_ = nullptr;
103     UILabelButton* noRepeatBtn_ = nullptr;
104     UILabelButton* reverseOrderBtn_ = nullptr;
105     UILabelButton* positiveOrderBtn_ = nullptr;
106     UILabelButton* listenerBtn_ = nullptr;
107     UILabelButton* repeatTimesBtn_ = nullptr;
108     UILabelButton* fillModeTrueForwardBtn_ = nullptr;
109     UILabelButton* fillModeTrueBackwardBtn_ = nullptr;
110     UILabelButton* fillModeFalseForwardBtn_ = nullptr;
111     UILabelButton* fillModeFalseBackwardBtn_ = nullptr;
112     UILabelButton* setImageInfoBtn_ = nullptr;
113 
114     ImageInfo* imageInfo1_ = nullptr;
115     ImageInfo* imageInfo2_ = nullptr;
116     ImageInfo* imageInfo3_ = nullptr;
117     ImageAnimatorInfo imageAnimatorImageInfo_[3] = { 0 };
118 };
119 } // namespace OHOS
120 #endif // UI_TEST_IMAGE_ANIMATOR_H
121