• 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_TEXTURE_MAPPER_H
17 #define UI_TEST_TEXTURE_MAPPER_H
18 
19 #include "components/ui_label.h"
20 #include "components/ui_label_button.h"
21 #include "components/ui_scroll_view.h"
22 #include "components/ui_texture_mapper.h"
23 #include "layout/grid_layout.h"
24 #include "ui_test.h"
25 
26 namespace OHOS {
27 class TestTextureMapperStopListener : public UITextureMapper::AnimatorStopListener {
28 public:
TestTextureMapperStopListener(UIViewGroup * viewGroup)29     explicit TestTextureMapperStopListener(UIViewGroup* viewGroup)
30     {
31         if (viewGroup != nullptr) {
32             viewGroup_ = viewGroup;
33             viewGroup_->Add(&label_);
34             label_.SetPosition(0, 0, 200, TITLE_LABEL_DEFAULT_HEIGHT); // 200: width;
35             label_.SetText("OnAnimatorStop");
36             label_.SetFont(DEFAULT_VECTOR_FONT_FILENAME, FONT_DEFAULT_SIZE);
37             label_.SetStyle(STYLE_TEXT_COLOR, Color::Black().full);
38             label_.SetStyle(STYLE_BACKGROUND_COLOR, Color::White().full);
39             label_.SetStyle(STYLE_BACKGROUND_OPA, OPA_OPAQUE);
40             label_.SetVisible(false);
41         }
42     }
43 
~TestTextureMapperStopListener()44     ~TestTextureMapperStopListener()
45     {
46         if (viewGroup_ != nullptr) {
47             viewGroup_->Remove(&label_);
48         }
49     };
50 
OnAnimatorStop(UIView & view)51     void OnAnimatorStop(UIView& view) override
52     {
53         label_.SetVisible(true);
54         label_.Invalidate();
55     }
56 private:
57     UILabel label_;
58     UIViewGroup* viewGroup_ = nullptr;
59 };
60 
61 class UITestTextureMapper : public UITest, public UIView::OnClickListener {
62 public:
UITestTextureMapper()63     UITestTextureMapper() {}
~UITestTextureMapper()64     ~UITestTextureMapper() {};
65     void SetUp() override;
66     void TearDown() override;
67     const UIView* GetTestView() override;
68 
69     void SetUpButton(UILabelButton* btn, const char* title);
70 
71     bool OnClick(UIView& view, const ClickEvent& event) override;
72     bool ExpandClick(UIView& view, const ClickEvent& event);
73 
74     void UIKit_TextureMapper_Test_SetRotateEnd_001();
75     void UIKit_TextureMapper_Test_SetRotateStart_002();
76     void UIKit_TextureMapper_Test_SetScaleEnd_003();
77     void UIKit_TextureMapper_Test_SetScaleStart_004();
78     void UIKit_TextureMapper_Test_SetPivot_005();
79     void UIKit_TextureMapper_Test_Start_006();
80     void UIKit_TextureMapper_Test_Reset_007();
81     void UIKit_TextureMapper_Test_CancelAnimation_008();
82     void UIKit_TextureMapper_Test_SetAnimatorStopListener_009();
83 
84 private:
85     UIScrollView* container_ = nullptr;
86     GridLayout* layout_ = nullptr;
87     UITextureMapper* textureMapper_ = nullptr;
88     TestTextureMapperStopListener* listener_ = nullptr;
89 
90     UILabelButton* resetBtn_ = nullptr;
91 
92     UILabelButton* incRotateEndBtn_ = nullptr;
93     UILabelButton* decRotateEndBtn_ = nullptr;
94     UILabelButton* startAngleBtn_ = nullptr;
95 
96     UILabelButton* incScaleEndBtn_ = nullptr;
97     UILabelButton* decScaleEndBtn_ = nullptr;
98     UILabelButton* startScaleBtn_ = nullptr;
99 
100     UILabelButton* durationTimeBtn_ = nullptr;
101     UILabelButton* delayTimeBtn_ = nullptr;
102     UILabelButton* easingBtn_ = nullptr;
103 
104     UILabelButton* incPivotBtn_ = nullptr;
105     UILabelButton* decPivotBtn_ = nullptr;
106     UILabelButton* startBtn_ = nullptr;
107     UILabelButton* cancelBtn_ = nullptr;
108     UILabelButton* resetImageBtn_ = nullptr;
109     UILabelButton* listenerBtn_ = nullptr;
110 };
111 } // namespace OHOS
112 #endif // UI_TEST_TEXTURE_MAPPER_H
113