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 UIKit_UILabel_Test_Display_001(); 38 void UIKit_UILabel_Test_Display_002(); 39 void UIKit_UILabel_Test_Display_003(); 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 69 void InnerTestTitle(const char* title); 70 UILabelButton* SetUpButton(const char* title, int16_t x, int16_t y, UIViewGroup* uiViewGroup, 71 int16_t width = 80, int16_t height = 40) 72 { 73 if (uiViewGroup == nullptr) { 74 return nullptr; 75 } 76 UILabelButton* btn = new UILabelButton(); 77 btn->SetPosition(x, y, width, height); 78 btn->SetText(title); 79 btn->SetFont(DEFAULT_VECTOR_FONT_FILENAME, BUTTON_LABEL_SIZE); 80 btn->SetOnClickListener(this); 81 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::RELEASED); 82 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::PRESSED); 83 btn->SetStyleForState(STYLE_BORDER_RADIUS, BUTTON_STYLE_BORDER_RADIUS_VALUE, UIButton::INACTIVE); 84 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::RELEASED); 85 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::PRESSED); 86 btn->SetStyleForState(STYLE_BACKGROUND_COLOR, BUTTON_STYLE_BACKGROUND_COLOR_VALUE, UIButton::INACTIVE); 87 uiViewGroup->Add(btn); 88 return btn; 89 } 90 }; 91 } // namespace OHOS 92 #endif // UI_TEST_LABEL_H 93