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_SWIPE_VIEW_H 17 #define UI_TEST_UI_SWIPE_VIEW_H 18 19 #include "components/ui_label_button.h" 20 #include "components/ui_scroll_view.h" 21 #include "components/ui_swipe_view.h" 22 #include "ui_test.h" 23 24 namespace OHOS { 25 constexpr char* UI_TEST_HOR_001_BUTTON1 = "hor_001_button1"; 26 constexpr char* UI_TEST_HOR_001_BUTTON2 = "hor_001_button2"; 27 28 constexpr char* UI_TEST_HOR_002_BUTTON1 = "hor_002_button1"; 29 constexpr char* UI_TEST_HOR_002_BUTTON2 = "hor_002_button2"; 30 constexpr char* UI_TEST_HOR_002_BUTTON3 = "hor_002_button3"; 31 32 constexpr char* UI_TEST_HOR_003_BUTTON1 = "hor_003_button1"; 33 constexpr char* UI_TEST_HOR_003_BUTTON2 = "hor_003_button2"; 34 constexpr char* UI_TEST_HOR_003_BUTTON3 = "hor_003_button3"; 35 36 constexpr char* UI_TEST_VER_001_BUTTON1 = "ver_001_button1"; 37 constexpr char* UI_TEST_VER_001_BUTTON2 = "ver_001_button2"; 38 39 constexpr char* UI_TEST_VER_002_BUTTON1 = "ver_002_button1"; 40 constexpr char* UI_TEST_VER_002_BUTTON2 = "ver_002_button2"; 41 constexpr char* UI_TEST_VER_003_BUTTON3 = "ver_002_button3"; 42 43 constexpr char* UI_TEST_ADD_TO_HEAD = "add_to_head"; 44 constexpr char* UI_TEST_ADD_TO_TAIL = "add_to_tail"; 45 constexpr char* UI_TEST_ADD_TO_BACK_OF_HEAD = "add_to_back_of_head"; 46 constexpr char* UI_TEST_DELETE_HEAD = "delete_head"; 47 constexpr char* UI_TEST_DELETE_MIDDLE = "delete_middle"; 48 constexpr char* UI_TEST_DELETE_ALL = "delete_all"; 49 constexpr char* UI_TEST_SET_CYCLE = "set_cycle"; 50 constexpr char* UI_TEST_SWITCH_PAGES = "switch_pages"; 51 52 53 class UITestUISwipeView : public UITest, UIView::OnClickListener { 54 public: UITestUISwipeView()55 UITestUISwipeView() {} ~UITestUISwipeView()56 ~UITestUISwipeView() {} 57 void SetUp() override; 58 void TearDown() override; 59 const UIView* GetTestView() override; 60 bool OnClick(UIView& view, const ClickEvent& event) override; 61 62 void UIKitSwipeViewTestHorizontal001(); 63 void UIKitSwipeViewTestHorizontal002(); 64 void UIKitSwipeViewTestHorizontal003(); 65 void UIKitSwipeViewTestVer001(); 66 void UIKitSwipeViewTestVer002(); 67 void UIKitSwipeViewTestRemove001(); 68 void UIKitSwipeViewTestAlign001(UISwipeView::AlignMode alignMode); 69 void UIKitSwipeViewTestSetCurrentPage(); 70 71 private: 72 void SetUpButton(UILabelButton* btn, const char* title, const char* id); 73 void SetLastPos(UIView* view); 74 UIScrollView* container_ = nullptr; 75 UISwipeView* currentSwipe_ = nullptr; 76 UILabelButton* addBtnInHead_ = nullptr; 77 UILabelButton* addBtnInTail_ = nullptr; 78 UILabelButton* addBtnInMid_ = nullptr; 79 UILabelButton* removeHeadBtn_ = nullptr; 80 UILabelButton* removeMidBtn_ = nullptr; 81 UILabelButton* removeAllBtn_ = nullptr; 82 UILabelButton* loopBtn_ = nullptr; 83 UILabelButton* changePageBtn_ = nullptr; 84 bool loop_ = false; 85 int16_t lastX_ = 0; 86 int16_t lastY_ = 0; 87 int16_t btnNum_ = 0; 88 }; 89 } // namespace OHOS 90 #endif // UI_TEST_UI_SWIPE_VIEW_H 91