• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 set running param
58      * @param option the param of test
59      */
60     ErrCode SetRunningParam(const int option);
61 
62     /**
63      * @brief set set running indicator
64      * @param option the param of test
65      */
66     ErrCode SetRunningIndicator(const int option);
67 
68     /**
69      * @brief registered timer to monitor test time
70      */
71     void RegisterTimer();
72 
73     /**
74      * @brief the callback function of the timer
75      */
76     void TestTimeout();
77 
78     /**
79      * @brief set the type of input accord to arguments
80      * @return the type of input,refer to [InputType] .
81      */
82     InputType DistrbuteInputType();
83 
84     /**
85      * @brief check if the touch params or swap params is valid
86      * @param argumentlist the list of touch params or swap params
87      * @return return ERR_OK is valid, others is invalid.
88      */
89     ErrCode CheckPosition(std::vector<std::string> argumentlist);
90 
91     /**
92      * @brief launcher app of component event
93      * @return return ERR_OK is valid, others is invalid.
94      */
95     ErrCode LauncherApp();
96 
97     /**
98      * @brief protect the right ability
99      * @return return ERR_OK is valid, others is invalid.
100      */
101     ErrCode ProtectRightAbility();
102 
103     uint32_t timerId_ = 0;
104     int countArgs_ = 10;
105 
106     // the interval time of test
107     int intervalArgs_ = 1500;
108 
109     // the total count of test
110     int totalCount_ = 10;
111 
112     // the total time of test
113     float totalTime_ = 10.0;
114 
115     std::string specialRecordName_;
116 
117     // the list of touch params
118     std::vector<std::string> touchParam_;
119 
120     // the list of the start point of swap
121     std::vector<std::string> swapStartPoint_;
122 
123     // the bundle of component event
124     std::vector<std::string> bundleName_;
125 
126     // the list of the end point of swap
127     std::vector<std::string> swapEndPoint_;
128     std::shared_ptr<Utils::Timer> timer_ = nullptr;
129     std::shared_ptr<SpcialTestObject> specialTestObject_ = nullptr;
130 };
131 }  // namespace WuKong
132 }  // namespace OHOS
133 #endif  // TEST_WUKONG_SPECIAL_TEST_H
134