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_FOCUS_TEST_H 17#define TEST_WUKONG_FOCUS_TEST_H 18 19#include <string> 20 21#include "input_factory.h" 22#include "test_flow.h" 23 24namespace OHOS { 25namespace WuKong { 26class FocusTestFlow : public TestFlow { 27public: 28 FocusTestFlow(WuKongShellCommand &shellcommand); 29 virtual ~FocusTestFlow(); 30 31 /** 32 * @brief to confirm the input of event percent is valid or not 33 * and distribute the event count randomly according to possibility. 34 * @return Return ERR_OK on success, others on failure. 35 */ 36 virtual ErrCode EnvInit() override; 37 38 /** 39 * @brief run the test according to shellCommand, output seed value, exec 40 * count and interval value. 41 * @return Return ERR_OK on success, others on failure. 42 */ 43 virtual ErrCode RunStep() override; 44 45private: 46 virtual const struct option* GetOptionArguments(std::string &shortOpts) override; 47 ErrCode HandleUnknownOption(const char optopt) override; 48 ErrCode HandleNormalOption(const int option) override; 49 ErrCode CheckArgumentOptionOfe(); 50 ErrCode CheckArgumentOptionOfE(); 51 ErrCode CheckArgumentOptionOfc(); 52 ErrCode CheckArgumentOptionOfT(); 53 54 /** 55 * @brief check if the '-c' and 'T' is exist at the same time 56 * @param option command letter. 57 * @return Return ERR_OK on success, others on failure. 58 */ 59 ErrCode CheckArgument(const int option); 60 61 /** 62 * @brief init event list percent. 63 * @return return ERR_OK on success, others on failure. 64 */ 65 ErrCode InitEventPercent(); 66 /** 67 * @brief shuffle the elements in event list 68 */ 69 void RandomShuffle(); 70 71 /** 72 * @brief registered timer to monitor test time 73 */ 74 void RegisterTimer(); 75 76 /** 77 * @brief the callback function of the timer 78 */ 79 void TestTimeout(); 80 81 /** 82 * @brief set number of input type 83 * @param option the param of test 84 */ 85 ErrCode SetInputPercent(const int option); 86 87 /** 88 * @brief set black white sheet 89 * @param option the param of test 90 */ 91 ErrCode SetBlackWhiteSheet(const int option); 92 93 /** 94 * @brief set running param 95 * @param option the param of test 96 */ 97 ErrCode SetRunningParam(const int option); 98 99 /** 100 * @brief set set running indicator 101 * @param option the param of test 102 */ 103 ErrCode SetRunningIndicator(const int option); 104 105 ErrCode InputScene(std::shared_ptr<InputAction> inputaction, bool inputFlag); 106 107 /** 108 * @brief protect the right ability 109 * @param inputaction the inputaction 110 * @param eventTypeId the eventTypeId 111 */ 112 ErrCode ProtectRightAbility(std::shared_ptr<InputAction> &inputaction, InputType &eventTypeId); 113 114 bool SetBlockPage(); 115 116 int countArgs_ = 10; 117 118 // the interval time of test 119 int intervalArgs_ = 1500; 120 121 // the seed value of test 122 int seedArgs_ = -1; 123 124 // the total count of test 125 int totalCount_ = 10; 126 127 // the total time of test 128 float totalTime_ = 10.0; 129 130 std::shared_ptr<Utils::Timer> timer_ = nullptr; 131 uint32_t timerId_ = 0; 132 std::vector<int> inputPercent_; 133 std::vector<int> eventList_; 134}; 135} // namespace WuKong 136} // namespace OHOS 137#endif // TEST_WUKONG_FOCUS_TEST_H 138