Skip to content

Commit 0f7065b

Browse files
committed
Add support of touch commmands for web
1 parent 38efcf0 commit 0f7065b

File tree

10 files changed

+763
-0
lines changed

10 files changed

+763
-0
lines changed

inc/commands/touch_commands.h

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
#ifndef TOUCH_COMMANDS_H
2+
#define TOUCH_COMMANDS_H
3+
4+
#include <string>
5+
#include <vector>
6+
7+
#include "commands/element_commands.h"
8+
#include "webdriver_element_id.h"
9+
10+
namespace base {
11+
class DictionaryValue;
12+
}
13+
14+
namespace webdriver {
15+
16+
class Response;
17+
18+
class TouchCommand : public ElementCommand {
19+
public:
20+
TouchCommand(const std::vector<std::string>& path_segments,
21+
const base::DictionaryValue* const parameters);
22+
virtual ~TouchCommand();
23+
24+
virtual bool DoesPost() const OVERRIDE;
25+
26+
private:
27+
DISALLOW_COPY_AND_ASSIGN(TouchCommand);
28+
};
29+
30+
/// Single tap on the touch enabled device.
31+
/// https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/touch/click
32+
class TouchClickCommand : public TouchCommand {
33+
public:
34+
TouchClickCommand(const std::vector<std::string>& path_segments,
35+
const base::DictionaryValue* const parameters);
36+
virtual ~TouchClickCommand();
37+
38+
virtual void ExecutePost(Response* const response) OVERRIDE;
39+
40+
DISALLOW_COPY_AND_ASSIGN(TouchClickCommand);
41+
};
42+
43+
/// Finger down on the screen.
44+
/// https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/touch/down
45+
class TouchDownCommand : public TouchCommand {
46+
public:
47+
TouchDownCommand(const std::vector<std::string>& path_segments,
48+
const base::DictionaryValue* const parameters);
49+
virtual ~TouchDownCommand();
50+
51+
virtual void ExecutePost(Response* const response) OVERRIDE;
52+
53+
private:
54+
DISALLOW_COPY_AND_ASSIGN(TouchDownCommand);
55+
};
56+
57+
58+
/// Finger up on the screen.
59+
/// https://code.google.com/p/selenium/wiki/JsonWireProtocol#/session/:sessionId/touch/up
60+
class TouchUpCommand : public TouchCommand {
61+
public:
62+
TouchUpCommand(const std::vector<std::string>& path_segments,
63+
const base::DictionaryValue* const parameters);
64+
virtual ~TouchUpCommand();
65+
66+
virtual void ExecutePost(Response* const response) OVERRIDE;
67+
68+
private:
69+
DISALLOW_COPY_AND_ASSIGN(TouchUpCommand);
70+
};
71+
72+
/// Double tap on the touch screen using finger motion events.
73+
/// https://code.google.com/p/selenium/wiki/JsonWireProtocol#session/:sessionId/touch/doubleclick
74+
class TouchDoubleClickCommand : public TouchCommand {
75+
public:
76+
TouchDoubleClickCommand(const std::vector<std::string>& ps,
77+
const base::DictionaryValue* const parameters);
78+
virtual ~TouchDoubleClickCommand();
79+
80+
virtual void ExecutePost(Response* const response) OVERRIDE;
81+
82+
DISALLOW_COPY_AND_ASSIGN(TouchDoubleClickCommand);
83+
};
84+
85+
/// Finger move on the screen.
86+
/// https://code.google.com/p/selenium/wiki/JsonWireProtocol#session/:sessionId/touch/move
87+
class TouchMoveCommand : public TouchCommand {
88+
public:
89+
TouchMoveCommand(const std::vector<std::string>& path_segments,
90+
const base::DictionaryValue* const parameters);
91+
virtual ~TouchMoveCommand();
92+
93+
virtual void ExecutePost(Response* const response) OVERRIDE;
94+
95+
private:
96+
DISALLOW_COPY_AND_ASSIGN(TouchMoveCommand);
97+
};
98+
99+
/// Scroll on the touch screen using finger based motion events.
100+
/// https://code.google.com/p/selenium/wiki/JsonWireProtocol#session/:sessionId/touch/scroll
101+
class TouchScrollCommand : public TouchCommand {
102+
public:
103+
TouchScrollCommand(const std::vector<std::string>& path_segments,
104+
const base::DictionaryValue* const parameters);
105+
virtual ~TouchScrollCommand();
106+
107+
virtual void ExecutePost(Response* const response) OVERRIDE;
108+
109+
private:
110+
DISALLOW_COPY_AND_ASSIGN(TouchScrollCommand);
111+
};
112+
113+
/// Long press on the touch screen using finger motion events.
114+
/// https://code.google.com/p/selenium/wiki/JsonWireProtocol#session/:sessionId/touch/longclick
115+
class TouchLongClickCommand : public TouchCommand {
116+
public:
117+
TouchLongClickCommand(const std::vector<std::string>& path_segments,
118+
const base::DictionaryValue* const parameters);
119+
virtual ~TouchLongClickCommand();
120+
virtual void ExecutePost(Response* const response) OVERRIDE;
121+
122+
DISALLOW_COPY_AND_ASSIGN(TouchLongClickCommand);
123+
};
124+
125+
/// Flick on the touch screen using finger motion events.
126+
/// https://code.google.com/p/selenium/wiki/JsonWireProtocol#session/:sessionId/touch/flick
127+
class TouchFlickCommand : public TouchCommand {
128+
public:
129+
TouchFlickCommand(const std::vector<std::string>& path_segments,
130+
const base::DictionaryValue* const parameters);
131+
virtual ~TouchFlickCommand();
132+
133+
virtual void ExecutePost(Response* const response) OVERRIDE;
134+
135+
private:
136+
DISALLOW_COPY_AND_ASSIGN(TouchFlickCommand);
137+
};
138+
139+
} // namespace webdriver
140+
141+
#endif // TOUCH_COMMANDS_H

inc/extension_qt/web_view_executor.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,16 @@ class QWebViewCmdExecutor : public QViewCmdExecutor {
137137
virtual void GetStorageSize(StorageType type, int* size, Error** error);
138138
virtual void GetGeoLocation(base::DictionaryValue** geolocation, Error** error) NOT_SUPPORTED_IMPL;
139139
virtual void SetGeoLocation(const base::DictionaryValue* geolocation, Error** error) NOT_SUPPORTED_IMPL;
140+
virtual void TouchClick(const ElementId& element, Error **error);
141+
virtual void TouchDoubleClick(const ElementId& element, Error **error);
142+
virtual void TouchDown(const int &x, const int &y, Error **error);
143+
virtual void TouchUp(const int &x, const int &y, Error **error);
144+
virtual void TouchMove(const int &x, const int &y, Error **error);
145+
virtual void TouchLongClick(const ElementId& element, Error **error);
146+
virtual void TouchScroll(const int &xoffset, const int &yoffset, Error **error);
147+
virtual void TouchScroll(const ElementId &element, const int &xoffset, const int &yoffset, Error **error);
148+
virtual void TouchFlick(const int &xSpeed, const int &ySpeed, Error **error);
149+
virtual void TouchFlick(const ElementId &element, const int &xoffset, const int &yoffset, const int &speed, Error **error);
140150

141151

142152
protected:

inc/extension_qt/widget_view_executor.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ class QWidgetViewCmdExecutor : public QViewCmdExecutor {
8383
virtual void GetStorageSize(StorageType type, int* size, Error** error) NOT_SUPPORTED_IMPL;
8484
virtual void GetGeoLocation(base::DictionaryValue** geolocation, Error** error) NOT_SUPPORTED_IMPL;
8585
virtual void SetGeoLocation(const base::DictionaryValue* geolocation, Error** error) NOT_SUPPORTED_IMPL;
86+
virtual void TouchClick(const ElementId& element, Error **error) NOT_SUPPORTED_IMPL;
87+
virtual void TouchDoubleClick(const ElementId& element, Error **error) NOT_SUPPORTED_IMPL;
88+
virtual void TouchDown(const int &x, const int &y, Error **error) NOT_SUPPORTED_IMPL;
89+
virtual void TouchUp(const int &x, const int &y, Error **error) NOT_SUPPORTED_IMPL;
90+
virtual void TouchMove(const int &x, const int &y, Error **error) NOT_SUPPORTED_IMPL;
91+
virtual void TouchLongClick(const ElementId& element, Error **error) NOT_SUPPORTED_IMPL;
92+
virtual void TouchScroll(const int &xoffset, const int &yoffset, Error **error) NOT_SUPPORTED_IMPL;
93+
virtual void TouchScroll(const ElementId &element, const int &xoffset, const int &yoffset, Error **error) NOT_SUPPORTED_IMPL;
94+
virtual void TouchFlick(const int &xSpeed, const int &ySpeed, Error **error) NOT_SUPPORTED_IMPL;
95+
virtual void TouchFlick(const ElementId &element, const int &xoffset, const int &yoffset, const int &speed, Error **error) NOT_SUPPORTED_IMPL;
8696

8797
protected:
8898
typedef QHash<QString, QWidget*> XMLElementMap;

inc/webdriver_route_patterns.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ class CommandRoutes {
8383
static const char kSessionStorageKey[];
8484
static const char kSessionStorageSize[];
8585
static const char kGetLocation[];
86+
static const char kTouchClick[];
87+
static const char kTouchDown[];
88+
static const char kTouchUp[];
89+
static const char kTouchMove[];
90+
static const char kTouchScroll[];
91+
static const char kTouchDoubleClick[];
92+
static const char kTouchLongClick[];
93+
static const char kTouchFlick[];
8694
static const char kXdrpc[];
8795

8896
private:

inc/webdriver_view_executor.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,17 @@ class ViewCmdExecutor {
153153
virtual void GetGeoLocation(base::DictionaryValue** geolocation, Error** error) = 0;
154154
/// Overrides the current geolocation.
155155
virtual void SetGeoLocation(const base::DictionaryValue* geolocation, Error** error) = 0;
156+
/// Touch commands emulation
157+
virtual void TouchClick(const ElementId& element, Error **error) = 0;
158+
virtual void TouchDoubleClick(const ElementId& element, Error **error) = 0;
159+
virtual void TouchDown(const int &x, const int &y, Error **error) = 0;
160+
virtual void TouchUp(const int &x, const int &y, Error **error) = 0;
161+
virtual void TouchMove(const int &x, const int &y, Error **error) = 0;
162+
virtual void TouchLongClick(const ElementId& element, Error **error) = 0;
163+
virtual void TouchScroll(const int &xoffset, const int &yoffset, Error **error) = 0;
164+
virtual void TouchScroll(const ElementId &element, const int &xoffset, const int &yoffset, Error **error) = 0;
165+
virtual void TouchFlick(const int &xSpeed, const int &ySpeed, Error **error) = 0;
166+
virtual void TouchFlick(const ElementId &element, const int &xoffset, const int &yoffset, const int &speed, Error **error) = 0;
156167

157168
protected:
158169
Session* session_;

0 commit comments

Comments
 (0)