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 25 namespace OHOS { 26 namespace WuKong { 27 class SpecialTestFlow : public TestFlow { 28 public: 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 44 private: 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 49 /** 50 * @brief check if the '-c' and 'T' is exist at the same time 51 * @param option command letter. 52 * @return Return ERR_OK on success, others on failure. 53 */ 54 ErrCode CheckArgument(const int option); 55 56 /** 57 * @brief registered timer to monitor test time 58 */ 59 void RegisterTimer(); 60 61 /** 62 * @brief the callback function of the timer 63 */ 64 void TestTimeout(); 65 66 /** 67 * @brief set the type of input accord to arguments 68 * @return the type of input,refer to [InputType] . 69 */ 70 InputType DistrbuteInputType(); 71 72 /** 73 * @brief check if the touch params or swap params is valid 74 * @param argumentlist the list of touch params or swap params 75 * @return return ERR_OK is valid, others is invalid. 76 */ 77 ErrCode CheckPosition(std::vector<std::string> argumentlist); 78 79 /** 80 * @brief launcher app of component event 81 * @return return ERR_OK is valid, others is invalid. 82 */ 83 ErrCode LauncherApp(); 84 85 uint32_t timerId_ = 0; 86 int countArgs_ = 10; 87 88 // the interval time of test 89 int intervalArgs_ = 1500; 90 91 // the total count of test 92 int totalCount_ = 10; 93 94 // the total time of test 95 float totalTime_ = 10.0; 96 97 std::string specialRecordName_; 98 99 // the list of touch params 100 std::vector<std::string> touchParam_; 101 102 // the list of the start point of swap 103 std::vector<std::string> swapStartPoint_; 104 105 // the bundle of component event 106 std::vector<std::string> bundleName_; 107 108 // the list of the end point of swap 109 std::vector<std::string> swapEndPoint_; 110 std::shared_ptr<Utils::Timer> timer_ = nullptr; 111 std::shared_ptr<SpcialTestObject> specialTestObject_ = nullptr; 112 }; 113 } // namespace WuKong 114 } // namespace OHOS 115 #endif // TEST_WUKONG_SPECIAL_TEST_H 116