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_LABEL_H
17 #define UI_TEST_LABEL_H
18 
19 #include "components/ui_label.h"
20 #include "components/ui_label_button.h"
21 #include "components/ui_scroll_view.h"
22 #include "ui_test.h"
23 
24 namespace OHOS {
25 class UITestLabel : public UITest, public UIView::OnClickListener {
26 public:
UITestLabel()27     UITestLabel() {}
~UITestLabel()28     ~UITestLabel() {}
29     void SetUp() override;
30     void TearDown() override;
31     const UIView* GetTestView() override;
32     void CreateLabels(UIViewGroup* uiViewGroup);
33 
34     /**
35      * @brief Test display dynamic text
36      */
37     void UIKitUILabelTestDisplay001();
38     void UIKitUILabeTestDisplay002();
39     void UIKitUILabeTestDisplay003();
40 
41     bool OnClick(UIView& view, const ClickEvent& event) override;
42     void ExpandClick(UIView& view, const ClickEvent& event) const;
43 
44 private:
45     UIScrollView* container_ = nullptr;
46     UILabel* uiLabel = nullptr;
47     UILabelButton* labelFontSizeBtn1_ = nullptr;
48     UILabelButton* labelFontSizeBtn2_ = nullptr;
49     UILabelButton* labelFontSizeBtn3_ = nullptr;
50     UILabelButton* labelHorAlignBtn1_ = nullptr;
51     UILabelButton* labelHorAlignBtn2_ = nullptr;
52     UILabelButton* labelHorAlignBtn3_ = nullptr;
53     UILabelButton* labelColorBtn1_ = nullptr;
54     UILabelButton* labelColorBtn2_ = nullptr;
55     UILabelButton* labelColorBtn3_ = nullptr;
56     UILabelButton* labelBeyondBtn1_ = nullptr;
57     UILabelButton* labelBeyondBtn2_ = nullptr;
58     UILabelButton* labelBeyondBtn3_ = nullptr;
59     UILabelButton* labelLineBtn1_ = nullptr;
60     UILabelButton* labelLineBtn2_ = nullptr;
61     UILabelButton* labelVerAlignlBtn1_ = nullptr;
62     UILabelButton* labelVerAlignlBtn2_ = nullptr;
63     UILabelButton* labelVerAlignlBtn3_ = nullptr;
64     UILabelButton* labelDirectionBtn1_ = nullptr;
65     UILabelButton* labelDirectionBtn2_ = nullptr;
66     UILabelButton* labelSizeBtn1_ = nullptr;
67     UILabelButton* labelSizeBtn2_ = nullptr;
68     UILabelButton* labelLineHeightBtn1_ = nullptr;
69     UILabelButton* labelLineHeightBtn2_ = nullptr;
70     UILabelButton* labelLineHeightBtn3_ = nullptr;
71 
72     void InnerTestTitle(const char* title);
73     UILabelButton* SetUpButton(const char* title, int16_t x, int16_t y, UIViewGroup* uiViewGroup,
74         int16_t width = 80, int16_t height = 40)
75     {
76         if (uiViewGroup == nullptr) {
77             return nullptr;
78         }
79         UILabelButton* btn = new UILabelButton();
80         btn->SetPosition(x, y, width, height);
81         btn->SetText(title);
82         btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_LABEL_SIZE);
83         btn->SetOnClickListener(this);
84         btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::RELEASED);
85         btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::PRESSED);
86         btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::INACTIVE);
87         btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::RELEASED);
88         btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED);
89         btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE);
90         uiViewGroup->Add(btn);
91         return btn;
92     }
93 };
94 } // namespace OHOS
95 #endif // UI_TEST_LABEL_H
96