@@ -2130,16 +2130,8 @@ void Automation::TouchDown(const WebViewId &view_id, const Point &p, Error **err
21302130 points.append (touchPoint);
21312131
21322132 QTouchEvent *touchBeginEvent = new QTouchEvent (QEvent::TouchBegin, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointPressed, points);
2133- QTouchEvent *touchPressEvent = new QTouchEvent (QEvent::TouchUpdate, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointPressed, points);
2134- QTouchEvent *touchEndEvent = new QTouchEvent (QEvent::TouchEnd, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointPressed, points);
21352133
21362134 QApplication::postEvent (view, touchBeginEvent);
2137- QApplication::postEvent (view, touchPressEvent);
2138- QApplication::postEvent (view, touchEndEvent);
2139-
2140- // additional we send mouse event for QWebView
2141- QMouseEvent *pressEvent = new QMouseEvent (QEvent::MouseButtonPress, point, Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
2142- QApplication::postEvent (view, pressEvent);
21432135
21442136}
21452137
@@ -2162,17 +2154,34 @@ void Automation::TouchUp(const WebViewId &view_id, const Point &p, Error **error
21622154 touchPoint.setPressure (1 );
21632155 points.append (touchPoint);
21642156
2165- QTouchEvent *touchBeginEvent = new QTouchEvent (QEvent::TouchBegin, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointReleased, points);
2166- QTouchEvent *touchReleaseEvent = new QTouchEvent (QEvent::TouchUpdate, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointReleased, points);
21672157 QTouchEvent *touchEndEvent = new QTouchEvent (QEvent::TouchEnd, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointReleased, points);
21682158
2169- QApplication::postEvent (view, touchBeginEvent);
2170- QApplication::postEvent (view, touchReleaseEvent);
21712159 QApplication::postEvent (view, touchEndEvent);
21722160
2173- // additional we send mouse event for QWebView
2174- QMouseEvent *pressEvent = new QMouseEvent (QEvent::MouseButtonPress, point, Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
2175- QApplication::postEvent (view, pressEvent);
2161+ }
2162+
2163+ void Automation::TouchMove (const WebViewId &view_id, const Point &p, Error **error)
2164+ {
2165+ if (!checkView (view_id))
2166+ {
2167+ *error = new Error (kNoSuchWindow );
2168+ return ;
2169+ }
2170+
2171+ QWidget *view = view_id.GetView ();
2172+
2173+ QPoint point = ConvertPointToQPoint (p);
2174+
2175+ QList<QTouchEvent::TouchPoint> points;
2176+ QTouchEvent::TouchPoint touchPoint (1 );
2177+ touchPoint.setPos (point);
2178+ touchPoint.setState (Qt::TouchPointMoved);
2179+ touchPoint.setPressure (1 );
2180+ points.append (touchPoint);
2181+
2182+ QTouchEvent *touchMoveEvent = new QTouchEvent (QEvent::TouchUpdate, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointMoved, points);
2183+
2184+ QApplication::postEvent (view, touchMoveEvent);
21762185
21772186}
21782187
@@ -2217,6 +2226,65 @@ void Automation::TouchLongClick(const WebViewId &view_id, const Point &p, Error
22172226
22182227}
22192228
2229+ void Automation::TouchScroll (const WebViewId &view_id, const Point &offset, Error **error)
2230+ {
2231+ if (!checkView (view_id))
2232+ {
2233+ *error = new Error (kNoSuchWindow );
2234+ return ;
2235+ }
2236+
2237+ QWidget *view = view_id.GetView ();
2238+
2239+ QWebView *webView = qobject_cast<QWebView*>(view);
2240+ webView->page ()->mainFrame ()->scroll (offset.x (), offset.y ());
2241+ }
2242+
2243+ void Automation::TouchScrollElement (const WebViewId &view_id, const ElementId &element, const Point &offset, Error **error)
2244+ {
2245+ element;
2246+ if (!checkView (view_id))
2247+ {
2248+ *error = new Error (kNoSuchWindow );
2249+ return ;
2250+ }
2251+
2252+ QWidget *view = view_id.GetView ();
2253+
2254+ QWebView *webView = qobject_cast<QWebView*>(view);
2255+ webView->page ()->mainFrame ()->scroll (-offset.x (), -offset.y ());
2256+ }
2257+
2258+ void Automation::TouchFlick (const WebViewId &view_id, const int &xSpeed, const int &ySpeed, Error **error)
2259+ {
2260+ if (!checkView (view_id))
2261+ {
2262+ *error = new Error (kNoSuchWindow );
2263+ return ;
2264+ }
2265+
2266+ QWidget *view = view_id.GetView ();
2267+
2268+ QWebView *webView = qobject_cast<QWebView*>(view);
2269+ std::cout<<" Speed x= " <<xSpeed*3 <<" y=" <<ySpeed*3 <<std::endl;
2270+ webView->page ()->mainFrame ()->scroll (xSpeed*3 , ySpeed*3 );
2271+ }
2272+
2273+ void Automation::TouchFlickElement (const WebViewId &view_id, const ElementId &element, const Point &offset, const int &speed, Error **error)
2274+ {
2275+ element;
2276+ if (!checkView (view_id))
2277+ {
2278+ *error = new Error (kNoSuchWindow );
2279+ return ;
2280+ }
2281+
2282+ QWidget *view = view_id.GetView ();
2283+ std::cout<<" Offset x= " <<-offset.x ()*(speed+1 )<<" y=" <<-offset.y ()*(speed+1 )<<std::endl;
2284+ QWebView *webView = qobject_cast<QWebView*>(view);
2285+ webView->page ()->mainFrame ()->scroll (-offset.x ()*(speed+1 ), -offset.y ()*(speed+1 ));
2286+ }
2287+
22202288
22212289void Automation::OverrideGeolocation (const DictionaryValue* geolocation,
22222290 Error** error)
0 commit comments