• 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_SPECAIL_TEST_OBJECT_H
17 #define TEST_WUKONG_SPECAIL_TEST_OBJECT_H
18 
19 #include <cstdio>
20 #include <sstream>
21 #include <string>
22 #include <vector>
23 
24 #include "securec.h"
25 
26 namespace OHOS {
27 namespace WuKong {
28 class SpcialTestObject {
29 public:
SpcialTestObject()30     SpcialTestObject()
31     {
32     }
~SpcialTestObject()33     virtual ~SpcialTestObject()
34     {
35     }
36     // convert coordinates to string
toString()37     virtual std::string toString()
38     {
39         return std::to_string(objectType_);
40     }
41     int objectType_ = -1;
42     bool isAllFinished_ = false;
43 };
44 class SwapParam : public SpcialTestObject {
45 public:
SwapParam()46     SwapParam()
47     {
48     }
~SwapParam()49     virtual ~SwapParam()
50     {
51     }
52 
toString()53     virtual std::string toString()
54     {
55         char buffer[50];
56         int result = -1;
57         if (isBack_) {
58             result = sprintf_s(buffer, sizeof(buffer), "Swap: (%d, %d) -> (%d, %d)", endX_, endY_, startX_, startY_);
59         } else {
60             result = sprintf_s(buffer, sizeof(buffer), "Swap: (%d, %d) -> (%d, %d)", startX_, startY_, endX_, endY_);
61         }
62         if (result < 0) {
63             return SpcialTestObject::toString();
64         }
65         return std::string(buffer);
66     }
67     int startX_ = -1;
68     int startY_ = -1;
69     int endX_ = -1;
70     int endY_ = -1;
71     bool isGoBack_ = false;
72     bool isBack_ = false;
73 };
74 class TouchParam : public SpcialTestObject {
75 public:
TouchParam()76     TouchParam()
77     {
78     }
~TouchParam()79     virtual ~TouchParam()
80     {
81     }
toString()82     virtual std::string toString()
83     {
84         char buffer[50];
85         int result = sprintf_s(buffer, sizeof(buffer), "Point: (%d, %d)", x_, y_);
86         if (result < 0) {
87             return SpcialTestObject::toString();
88         }
89         return std::string(buffer);
90     }
91     int x_ = -1;
92     int y_ = -1;
93 };
94 class AppSwitchParam : public SpcialTestObject {
95 public:
AppSwitchParam()96     AppSwitchParam()
97     {
98     }
~AppSwitchParam()99     virtual ~AppSwitchParam()
100     {
101     }
toString()102     virtual std::string toString()
103     {
104         char buffer[50];
105         int result = sprintf_s(buffer, sizeof(buffer), "Bundlename: (%s)", bundlename_.c_str());
106         if (result < 0) {
107             return SpcialTestObject::toString();
108         }
109         return std::string(buffer);
110     }
111     std::string bundlename_ = " ";
112 };
113 class ComponentParam : public SpcialTestObject {
114 public:
ComponentParam()115     ComponentParam()
116     {
117         bundleName_.clear();
118         bundleRunning_.clear();
119         bundleFinish_.clear();
120     }
~ComponentParam()121     virtual ~ComponentParam()
122     {
123     }
toString()124     virtual std::string toString()
125     {
126         std::stringstream ss;
127         ss << "Bundle : ";
128         for (uint32_t index = 0; index < bundleName_.size(); index++) {
129             ss << "[" << bundleName_[index] << ":" << bundleRunning_[index] << ":" << bundleFinish_[index] << "]";
130         }
131         ss << "AllFinished: " << isAllFinished_;
132         return ss.str();
133     }
134 
PushBundleName(const std::string & name)135     void PushBundleName(const std::string& name)
136     {
137         bundleName_.push_back(name);
138         bundleRunning_.push_back(false);
139         bundleFinish_.push_back(false);
140         pageBack_.push_back(0);
141         lanuchCount_.push_back(0);
142     }
143     std::vector<std::string> bundleName_;
144     std::vector<bool> bundleRunning_;
145     std::vector<bool> bundleFinish_;
146     std::vector<uint32_t> pageBack_;
147     std::vector<uint32_t> lanuchCount_;
148 };
149 class RecordParam : public SpcialTestObject {
150 public:
RecordParam()151     RecordParam()
152     {
153     }
~RecordParam()154     virtual ~RecordParam()
155     {
156     }
157     std::string recordName_;
158     bool recordStatus_ = false;
159 };
160 }  // namespace WuKong
161 }  // namespace OHOS
162 #endif
163