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_EVENT_INJECTOR_H 17 #define UI_TEST_EVENT_INJECTOR_H 18 19 #include "graphic_config.h" 20 21 #if ENABLE_DEBUG 22 #include "components/root_view.h" 23 #include "components/ui_label.h" 24 #include "components/ui_label_button.h" 25 #include "components/ui_scroll_view.h" 26 #include "dock/input_device.h" 27 #include "ui_test.h" 28 #include "layout/grid_layout.h" 29 30 namespace OHOS { 31 class TestEventInjectorView; 32 class UITestEventInjector : public UITest, public UIView::OnClickListener { 33 public: UITestEventInjector()34 UITestEventInjector() {} ~UITestEventInjector()35 ~UITestEventInjector() {} 36 void SetUp() override; 37 void TearDown() override; 38 const UIView* GetTestView() override; 39 bool OnClick(UIView& view, const ClickEvent& event) override; 40 41 void UIKit_Event_Injector_Click_Event_001(); 42 void UIKit_Event_Injector_Drag_Event_002(); 43 void UIKit_Event_Injector_Long_Press_Event_003(); 44 void UIKit_Event_Injector_Key_Event_004(); 45 void UIKit_Event_Injector_Up_to_Down_005(); 46 void UIKit_Event_Injector_Down_to_Up_006(); 47 void UIKit_Event_Injector_Left_to_Right_007(); 48 void UIKit_Event_Injector_Right_to_Left_008(); 49 void UIKit_Event_Injector_ULeft_to_LRight_009(); 50 void UIKit_Event_Injector_LRight_to_ULeft_010(); 51 52 private: 53 UIScrollView* container_ = nullptr; 54 GridLayout* layout_ = nullptr; 55 UILabelButton* clickBtn_ = nullptr; 56 UILabelButton* dragBtn_ = nullptr; 57 UILabelButton* longPressBtn_ = nullptr; 58 UILabelButton* keyBtn_ = nullptr; 59 UILabelButton* upToDownBtn_ = nullptr; 60 UILabelButton* downToUpBtn_ = nullptr; 61 UILabelButton* leftToRightBtn_ = nullptr; 62 UILabelButton* rightToLeftBtn_ = nullptr; 63 UILabelButton* uLeftTolRightBtn_ = nullptr; 64 UILabelButton* lRightTouLeftBtn_ = nullptr; 65 UILabelButton* increaseDragTimeBtn_ = nullptr; 66 UILabelButton* decreaseDragTimeBtn_ = nullptr; 67 UILabelButton* DragTimeDisplayBtn_ = nullptr; 68 TestEventInjectorView* clickTestView_ = nullptr; 69 TestEventInjectorView* dragTestView_ = nullptr; 70 TestEventInjectorView* longPressTestView_ = nullptr; 71 TestEventInjectorView* KeyEventTestView_ = nullptr; 72 UIScrollView* scrollTestView_ = nullptr; 73 74 int16_t lastX_ = 0; 75 int16_t lastY_ = 0; 76 uint16_t dragTime_ = 100; // 100: 100ms 77 78 void InnerTest(const char* title, bool touchable, bool draggable, bool dragParent, 79 const char* btnTitle, UILabelButton* btn, TestEventInjectorView*& testView); 80 void SetLastPos(UIView* view); 81 void SetUpButton(UILabelButton* btn, const char* title); 82 void SetUpScrollView(); 83 void IncreaseDragTime(); 84 void DecreaseDragTime(); 85 void DragTimeDisplay(); 86 void SetDragTimeDisplay(uint16_t dragTime); 87 }; 88 } // namespace OHOS 89 #endif // UI_TEST_EVENT_INJECTOR_H 90 #endif // ENABLE_DEBUG 91