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_FOCUS_MANAGER_H 17 #define UI_TEST_FOCUS_MANAGER_H 18 19 #include "graphic_config.h" 20 #if defined(ENABLE_FOCUS_MANAGER) && ENABLE_FOCUS_MANAGER 21 #include "components/ui_label_button.h" 22 #include "components/ui_scroll_view.h" 23 #include "dock/focus_manager.h" 24 #include "ui_test.h" 25 26 namespace OHOS { 27 constexpr char* UI_TEST_TOWRADS_LEFT = "towards_left"; 28 constexpr char* UI_TEST_TOWRADS_RIGHT = "towards_right"; 29 constexpr char* UI_TEST_TOWRADS_UP = "towards_up"; 30 constexpr char* UI_TEST_TOWRADS_DOWN = "towards_down"; 31 constexpr char* UI_TEST_2_FOCUSABLE = "2_focusable"; 32 constexpr char* UI_TEST_2_UNFOCUSABLE = "2_unfocusable"; 33 constexpr char* UI_TEST_4_INTERCEPT = "4_intercept"; 34 constexpr char* UI_TEST_4_CANCEL_INTERCEPT = "4_cancel_intercept"; 35 constexpr char* UI_TEST_RESET_FOCUS = "reset_focus"; 36 constexpr char* UI_TEST_CLEAR_FOCUS = "clear_focus"; 37 38 class UITestFocusManager : public UITest { 39 public: UITestFocusManager()40 UITestFocusManager() {} ~UITestFocusManager()41 ~UITestFocusManager() {} 42 void SetUp() override; 43 void TearDown() override; 44 const UIView* GetTestView() override; 45 46 void UIKitFocusManagerTest001(); 47 48 private: 49 void CreateLabels(UIViewGroup* viewGroup, UIViewGroup* viewGroup1); 50 void InitListeners(UIViewGroup* viewGroup1, UIViewGroup* viewGroup5, UIView* view2); 51 void TearDownListeners001(); 52 UIView* CreateTestUILabel(UIViewGroup* parent, int16_t x, int16_t y, 53 const char* text, bool focusable); 54 UIViewGroup* CreateTestUIViewGroup(UIViewGroup* parent, bool focusable, bool interceptFocus); 55 UILabelButton* SetUpButton(const char* title, int16_t x, int16_t y, UIViewGroup* viewGroup, 56 UIView::OnClickListener* listener, const char* id); 57 UIScrollView* container_ = nullptr; 58 UIView::OnFocusListener* testOnFocusListener_ = nullptr; 59 UIView::OnClickListener* requestFocusByDirectionLeftListener_ = nullptr; 60 UIView::OnClickListener* requestFocusByDirectionRightListener_ = nullptr; 61 UIView::OnClickListener* requestFocusByDirectionUpListener_ = nullptr; 62 UIView::OnClickListener* requestFocusByDirectionDownListener_ = nullptr; 63 UIView::OnClickListener* setFocusableViewListener_ = nullptr; 64 UIView::OnClickListener* setFocusableViewListener1_ = nullptr; 65 UIView::OnClickListener* setGroupInterceptListener_ = nullptr; 66 UIView::OnClickListener* setGroupInterceptListener1_ = nullptr; 67 UIView::OnClickListener* resetFocusListener_ = nullptr; 68 UIView::OnClickListener* clearFocusListener_ = nullptr; 69 }; 70 } // namespace OHOS 71 #endif 72 #endif // UI_TEST_FOCUS_MANAGER_H 73