1/* 2 * Copyright (c) 2022 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 TEST_WUKONG_INPUT_ACTION_H 17#define TEST_WUKONG_INPUT_ACTION_H 18 19#include <string> 20#include <unistd.h> 21 22#include "app_manager.h" 23#include "input_manager.h" 24#include "special_test_object.h" 25#include "wukong_define.h" 26#include "wukong_util.h" 27 28namespace OHOS { 29namespace WuKong { 30enum InputType { 31 INPUTTYPE_TOUCHINPUT, // input touch event 32 INPUTTYPE_SWAPINPUT, // input swap event 33 INPUTTYPE_MOUSEINPUT, // input mouse event 34 INPUTTYPE_KEYBOARDINPUT, // input keyboard event 35 INPUTTYPE_ELEMENTINPUT, // input element event 36 INPUTTYPE_APPSWITCHINPUT, // input appswitch event 37 INPUTTYPE_HARDKEYINPUT, // input power event 38 INPUTTYPE_ROTATEINPUT, // input rotate event 39 INPUTTYPE_INVALIDINPUT, // input invaild event 40 INPUTTYPE_RECORDINPUT, // input record event 41 INPUTTYPE_REPPLAYINPUT // input replay event 42}; 43 44/** 45 * @brief Input base class, provide the "Random, Next, Report" function for input action. 46 */ 47class InputAction { 48public: 49 InputAction() 50 { 51 } 52 virtual ~InputAction() 53 { 54 } 55 virtual ErrCode OrderInput(const std::shared_ptr<SpcialTestObject>& specialTestObject) 56 { 57 return OHOS::ERR_INVALID_VALUE; 58 } 59 /** 60 * @brief input a touch event in random test. 61 * @return Return ERR_OK on success, others on failure. 62 */ 63 virtual ErrCode RandomInput() 64 { 65 return OHOS::ERR_INVALID_VALUE; 66 } 67 /** 68 * @brief input a touch event in random test for uri and uriType. 69 * @return Return ERR_OK on success, others on failure. 70 */ 71 virtual ErrCode RandomInput(const std::string &uri, const std::string &uriType) 72 { 73 return OHOS::ERR_INVALID_VALUE; 74 } 75 /** 76 * @brief input a touch event in random test for uri and abilityname. 77 * @return Return ERR_OK on success, others on failure. 78 */ 79 virtual ErrCode RandomInput(const std::string &uri, const std::vector<std::string> &abilityName) 80 { 81 return OHOS::ERR_INVALID_VALUE; 82 } 83 84 /** 85 * @brief input a touch event in focus test for a certain times. 86 * @return Return ERR_OK on success, others on failure. 87 */ 88 virtual ErrCode FocusInput(bool shouldScreenCap) 89 { 90 return OHOS::ERR_INVALID_VALUE; 91 } 92 93 virtual InputType GetInputInfo() 94 { 95 return INPUTTYPE_INVALIDINPUT; 96 } 97}; 98} // namespace WuKong 99} // namespace OHOS 100#endif // TEST_WUKONG_INPUT_ACTION_H 101