@@ -23,31 +23,20 @@ TouchClickCommand::TouchClickCommand(const std::vector<std::string>& path_segmen
2323
2424TouchClickCommand::~TouchClickCommand () {}
2525
26- bool TouchClickCommand::Init (Response* const response) {
27- if (!TouchCommand::Init (response))
28- return false ;
29-
30- std::string element_name;
31- has_element_ = GetStringParameter (" element" , &element_name);
32-
33- if (has_element_) {
34- element_ = ElementId (element_name);
35- }
36-
37- if (!has_element_ ) {
38- response->SetError (new Error (
39- kBadRequest , " Invalid command arguments" ));
40- }
41-
42- return true ;
43- }
44-
4526void TouchClickCommand::ExecutePost (Response* const response) {
4627 Point location;
4728 Error* error;
48- printf (" Execute Touch Click Comman post\n " );
29+ std::string element_name;
30+
31+ if (!GetStringParameter (" element" , &element_name))
32+ {
33+ response->SetError (new Error (
34+ kBadRequest , " Invalid command arguments" ));
35+ }
36+
37+ ElementId element = ElementId (element_name);
4938
50- error = session_->GetElementLocationInView (element_ , &location);
39+ error = session_->GetElementLocationInView (element , &location);
5140 if (error) {
5241 response->SetError (error);
5342 return ;
@@ -67,32 +56,22 @@ TouchDoubleClickCommand::TouchDoubleClickCommand(const std::vector<std::string>&
6756
6857TouchDoubleClickCommand::~TouchDoubleClickCommand () {}
6958
70- bool TouchDoubleClickCommand::Init (Response* const response) {
71- if (!TouchCommand::Init (response))
72- return false ;
73-
74- std::string element_name;
75- has_element_ = GetStringParameter (" element" , &element_name);
76-
77- if (has_element_) {
78- element_ = ElementId (element_name);
79- }
80-
81- if (!has_element_ ) {
82- response->SetError (new Error (
83- kBadRequest , " Invalid command arguments" ));
84- }
85-
86- return true ;
87- }
8859
8960void TouchDoubleClickCommand::ExecutePost (Response *const response)
9061{
9162 Point location;
9263 Error* error;
93- printf (" Execute Touch Double Click Comman post\n " );
64+ std::string element_name;
65+
66+ if (!GetStringParameter (" element" , &element_name))
67+ {
68+ response->SetError (new Error (
69+ kBadRequest , " Invalid command arguments" ));
70+ }
71+
72+ ElementId element = ElementId (element_name);
9473
95- error = session_->GetElementLocationInView (element_ , &location);
74+ error = session_->GetElementLocationInView (element , &location);
9675 if (error) {
9776 response->SetError (error);
9877 return ;
@@ -115,9 +94,8 @@ TouchDownCommand::~TouchDownCommand() {}
11594void TouchDownCommand::ExecutePost (Response *const response)
11695{
11796 Error* error;
118- printf (" Execute Touch Down Comman post\n " );
119-
12097 int x, y;
98+
12199 if (!GetIntegerParameter (" x" , &x) ||
122100 !GetIntegerParameter (" y" , &y)) {
123101 response->SetError (new Error (
@@ -146,9 +124,8 @@ TouchUpCommand::~TouchUpCommand() {}
146124void TouchUpCommand::ExecutePost (Response *const response)
147125{
148126 Error* error;
149- printf (" Execute Touch Up Comman post\n " );
150-
151127 int x, y;
128+
152129 if (!GetIntegerParameter (" x" , &x) ||
153130 !GetIntegerParameter (" y" , &y)) {
154131 response->SetError (new Error (
@@ -177,9 +154,8 @@ TouchMoveCommand::~TouchMoveCommand() {}
177154void TouchMoveCommand::ExecutePost (Response *const response)
178155{
179156 Error* error;
180- printf (" Execute Touch Move Comman post\n " );
181-
182157 int x, y;
158+
183159 if (!GetIntegerParameter (" x" , &x) ||
184160 !GetIntegerParameter (" y" , &y)) {
185161 response->SetError (new Error (
@@ -208,9 +184,8 @@ TouchScrollCommand::~TouchScrollCommand() {}
208184void TouchScrollCommand::ExecutePost (Response *const response)
209185{
210186 Error* error;
211- printf (" Execute Scroll Comman post\n " );
212-
213187 int x, y;
188+
214189 if (!GetIntegerParameter (" xoffset" , &x) ||
215190 !GetIntegerParameter (" yoffset" , &y)) {
216191 response->SetError (new Error (
@@ -254,33 +229,21 @@ TouchLongClickCommand::TouchLongClickCommand(const std::vector<std::string>& pat
254229
255230TouchLongClickCommand::~TouchLongClickCommand () {}
256231
257- bool TouchLongClickCommand::Init (Response* const response) {
258- if (!TouchCommand::Init (response))
259- return false ;
260-
261- std::string element_name;
262- has_element_ = GetStringParameter (" element" , &element_name);
263-
264- if (has_element_) {
265- element_ = ElementId (element_name);
266- }
267-
268- if (!has_element_ ) {
269- response->SetError (new Error (
270- kBadRequest , " Invalid command arguments" ));
271- }
272-
273- return true ;
274- }
275-
276232void TouchLongClickCommand::ExecutePost (Response *const response)
277233{
278234 Error* error;
279- printf (" Execute Touch LongClick post\n " );
280-
281235 Point location;
236+ std::string element_name;
237+
238+ if (!GetStringParameter (" element" , &element_name))
239+ {
240+ response->SetError (new Error (
241+ kBadRequest , " Invalid command arguments" ));
242+ }
282243
283- error = session_->GetElementLocationInView (element_, &location);
244+ ElementId element = ElementId (element_name);
245+
246+ error = session_->GetElementLocationInView (element, &location);
284247 if (error) {
285248 response->SetError (error);
286249 return ;
@@ -304,11 +267,10 @@ TouchFlickCommand::~TouchFlickCommand() {}
304267void TouchFlickCommand::ExecutePost (Response *const response)
305268{
306269 Error* error;
307- printf (" Execute Touch Flick post\n " );
308-
309270 int xSpeed, ySpeed;
310271 int xoffset, yoffset, speed;
311272 std::string element_name;
273+
312274 if (GetIntegerParameter (" xspeed" , &xSpeed) &&
313275 GetIntegerParameter (" yspeed" , &ySpeed))
314276 {
@@ -323,8 +285,6 @@ void TouchFlickCommand::ExecutePost(Response *const response)
323285 }
324286 else
325287 {
326- if (GetStringParameter (" element" , &element_name))
327- printf (" ElementName\n " );
328288 response->SetError (new Error (
329289 kBadRequest ,
330290 " Missing or invalid parameters" ));
0 commit comments