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_SPECIAL_TEST_H 17#define TEST_WUKONG_SPECIAL_TEST_H 18 19#include <string> 20 21#include "input_factory.h" 22#include "special_test_object.h" 23#include "test_flow.h" 24 25namespace OHOS { 26namespace WuKong { 27class SpecialTestFlow : public TestFlow { 28public: 29 SpecialTestFlow(WuKongShellCommand &shellcommand); 30 virtual ~SpecialTestFlow(); 31 32 /** 33 * @brief set the params of special test to special object 34 * @return Return ERR_OK on success, others on failure. 35 */ 36 virtual ErrCode EnvInit() override; 37 38 /** 39 * @brief run the test 40 * @return Return ERR_OK on success, others on failure. 41 */ 42 virtual ErrCode RunStep() override; 43 44private: 45 virtual const struct option *GetOptionArguments(std::string &shortOpts) override; 46 virtual ErrCode HandleUnknownOption(const char optopt) override; 47 virtual ErrCode HandleNormalOption(const int option) override; 48 ErrCode CheckArgumentOptionOfc(); 49 ErrCode CheckArgumentOptionOfT(); 50 /** 51 * @brief check if the '-c' and 'T' is exist at the same time 52 * @param option command letter. 53 * @return Return ERR_OK on success, others on failure. 54 */ 55 ErrCode CheckArgument(const int option); 56 57 /** 58 * @brief set running param 59 * @param option the param of test 60 */ 61 ErrCode SetRunningParam(const int option); 62 63 /** 64 * @brief set set running indicator 65 * @param option the param of test 66 */ 67 ErrCode SetRunningIndicator(const int option); 68 69 /** 70 * @brief registered timer to monitor test time 71 */ 72 void RegisterTimer(); 73 74 /** 75 * @brief the callback function of the timer 76 */ 77 void TestTimeout(); 78 79 /** 80 * @brief set the type of input accord to arguments 81 * @return the type of input,refer to [InputType] . 82 */ 83 InputType DistrbuteInputType(); 84 85 /** 86 * @brief check if the touch params or swap params is valid 87 * @param argumentlist the list of touch params or swap params 88 * @return return ERR_OK is valid, others is invalid. 89 */ 90 ErrCode CheckPosition(std::vector<std::string> argumentlist); 91 92 /** 93 * @brief launcher app of component event 94 * @return return ERR_OK is valid, others is invalid. 95 */ 96 ErrCode LauncherApp(); 97 98 /** 99 * @brief protect the right ability 100 * @return return ERR_OK is valid, others is invalid. 101 */ 102 ErrCode ProtectRightAbility(); 103 104 uint32_t timerId_ = 0; 105 int countArgs_ = 10; 106 107 // the interval time of test 108 int intervalArgs_ = 1500; 109 110 // the total count of test 111 int totalCount_ = 10; 112 113 // the total time of test 114 float totalTime_ = 10.0; 115 116 std::string specialRecordName_; 117 118 // the list of touch params 119 std::vector<std::string> touchParam_; 120 121 // the list of the start point of swap 122 std::vector<std::string> swapStartPoint_; 123 124 // the bundle of component event 125 std::vector<std::string> bundleName_; 126 127 // the list of the end point of swap 128 std::vector<std::string> swapEndPoint_; 129 std::shared_ptr<Utils::Timer> timer_ = nullptr; 130 std::shared_ptr<SpcialTestObject> specialTestObject_ = nullptr; 131}; 132} // namespace WuKong 133} // namespace OHOS 134#endif // TEST_WUKONG_SPECIAL_TEST_H 135