• 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 EVENT_TOUCH_EVENT_H
17 #define EVENT_TOUCH_EVENT_H
18 
19 #include <list>
20 #include <map>
21 #include "offset.h"
22 #include "ui_model.h"
23 
24 namespace OHOS::uitest {
25 using TimeStamp = std::chrono::high_resolution_clock::time_point;
26 
27 struct TouchPoint final {
28     int32_t id = 0;
29     int32_t x = 0;
30     int32_t y = 0;
31     TimeStamp downTime;
32 };
33 /**
34  * @brief TouchEvent contains the active change point and a list of all touch points.
35  */
36 struct TouchEventInfo final {
37     // the active changed point info
38     // The ID is used to identify the point of contact between the finger and the screen. Different fingers have
39     // different ids.
40     int32_t id = 0;
41     int32_t x = 0;
42     int32_t y = 0;
43     int32_t wx = 0;
44     int32_t wy = 0;
45     // nanosecond time stamp.
46     int64_t actionTime;
47     int64_t downTime;
48     double durationSeconds;
49     std::vector<std::string> attributes;
50     std::string bundleName;
51     std::string abilityName;
GetPointfinal52     Point GetPoint() const
53     {
54         return Point(x, y);
55     }
GetActionTimeStampfinal56     TimeStamp GetActionTimeStamp() const
57     {
58         TimeStamp time {std::chrono::duration_cast<TimeStamp::duration>(std::chrono::nanoseconds(actionTime * 1000))};
59         return time;
60     }
GetDownTimeStampfinal61     TimeStamp GetDownTimeStamp() const
62     {
63         TimeStamp time {std::chrono::duration_cast<TimeStamp::duration>(std::chrono::nanoseconds(downTime * 1000))};
64         return time;
65     }
Resetsfinal66     void Resets()
67     {
68         x = 0;
69         y = 0;
70         actionTime = GetCurrentMillisecond();
71         downTime = GetCurrentMillisecond();
72     }
73 };
74 } // namespace OHOS::uitest
75 #endif // EVENT_TOUCH_EVENT_H
76