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_UI_PICKER_H 17 #define UI_TEST_UI_PICKER_H 18 19 #include "components/text_adapter.h" 20 #include "components/ui_label.h" 21 #include "components/ui_label_button.h" 22 #include "components/ui_picker.h" 23 #include "components/ui_scroll_view.h" 24 #include "components/ui_time_picker.h" 25 #include "ui_test.h" 26 27 namespace OHOS { 28 constexpr char* UI_TEST_START_LOOP = "start_loop"; 29 constexpr char* UI_TEST_STOP_LOOP = "stop_loop"; 30 constexpr char* UI_TEST_GO_TO_THE_FIFTH = "go_to_the_fifth"; 31 constexpr char* UI_TEST_FROM_LEFT_TO_RIGHT = "from_left_to_right"; 32 constexpr char* UI_TEST_FROM_RIGHT_TO_LEFT = "from_right_to_left"; 33 constexpr char* UI_TEST_PICKER_ADD_MARGIN = "add_margin"; 34 35 class UITestUIPicker : public UITest, UIView::OnClickListener, UIPicker::SelectedListener, 36 UITimePicker::SelectedListener { 37 public: UITestUIPicker()38 UITestUIPicker() {} ~UITestUIPicker()39 ~UITestUIPicker() {} 40 void SetUp() override; 41 void TearDown() override; 42 bool OnClick(UIView& view, const ClickEvent& event) override; 43 const UIView* GetTestView() override; 44 void OnPickerStoped(UIPicker& picker) override; 45 void OnTimePickerStoped(UITimePicker& picker) override; 46 void CreatButtons(); 47 void UIKitPickerTestBase001(); 48 void UIKitPickerTestBase002(); 49 void UIKitPickerTestTimePicker001(); 50 51 private: 52 void SetLastPos(UIView* view); 53 void SetUpButton(UILabelButton* btn, const char* title, const char* id); 54 UILabelButton* setLoopBtn_ = nullptr; 55 UILabelButton* setLoopOffBtn_ = nullptr; 56 UILabelButton* setSelectBtn_ = nullptr; 57 UILabelButton* setLeftToRightBtn_ = nullptr; 58 UILabelButton* setRightToLeftBtn_ = nullptr; 59 UILabelButton* setMarginBtn_ = nullptr; 60 UILabel* selectIndex_ = nullptr; 61 UILabel* selectTime_ = nullptr; 62 UIScrollView* container_ = nullptr; 63 UIPicker* picker1_ = nullptr; 64 UIPicker* picker3_ = nullptr; 65 UITimePicker* picker2_ = nullptr; 66 int16_t lastX_ = 0; 67 int16_t lastY_ = 0; 68 int16_t margin_ = 0; 69 }; 70 } // namespace OHOS 71 #endif // UI_TEST_UI_PICKER_H 72