Skip to content

Commit eebd0c4

Browse files
committed
Fixed touch compilation for Qt5
1 parent b96ddb2 commit eebd0c4

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

src/chrome/test/webdriver/webdriver_automation.cc

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2046,19 +2046,26 @@ void Automation::TouchClick(const WebViewId &view_id, const Point &p, Error **er
20462046
touchPoint.setState(Qt::TouchPointPressed);
20472047
touchPoint.setPressure(1);
20482048
points.append(touchPoint);
2049+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
2050+
QTouchEvent *touchBeginEvent = new QTouchEvent(QEvent::TouchBegin, &touchDevice, Qt::NoModifier, Qt::TouchPointPressed, points);
2051+
#else
20492052
QTouchEvent *touchBeginEvent = new QTouchEvent(QEvent::TouchBegin, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointPressed, points);
2050-
2053+
#endif
20512054
points.clear();
20522055
touchPoint.setPos(point);
20532056
touchPoint.setScreenPos(view->mapToGlobal(point));
20542057
touchPoint.setStartScreenPos(view->mapToGlobal(point));
20552058
touchPoint.setState(Qt::TouchPointReleased);
20562059
touchPoint.setPressure(1);
20572060
points.append(touchPoint);
2061+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
2062+
QTouchEvent *touchEndEvent = new QTouchEvent(QEvent::TouchEnd, &touchDevice, Qt::NoModifier, Qt::TouchPointReleased, points);
2063+
#else
20582064
QTouchEvent *touchEndEvent = new QTouchEvent(QEvent::TouchEnd, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointReleased, points);
2065+
#endif
20592066

20602067
QApplication::postEvent(view, touchBeginEvent);
2061-
// QApplication::postEvent(view, touchEndEvent);
2068+
QApplication::postEvent(view, touchEndEvent);
20622069

20632070
//additional we send mouse event for QWebView
20642071
QMouseEvent *pressEvent = new QMouseEvent(QEvent::MouseButtonPress, point, Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
@@ -2129,7 +2136,11 @@ void Automation::TouchDown(const WebViewId &view_id, const Point &p, Error **err
21292136
touchPoint.setPressure(1);
21302137
points.append(touchPoint);
21312138

2139+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
2140+
QTouchEvent *touchBeginEvent = new QTouchEvent(QEvent::TouchBegin, &touchDevice, Qt::NoModifier, Qt::TouchPointPressed, points);
2141+
#else
21322142
QTouchEvent *touchBeginEvent = new QTouchEvent(QEvent::TouchBegin, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointPressed, points);
2143+
#endif
21332144

21342145
QApplication::postEvent(view, touchBeginEvent);
21352146

@@ -2154,7 +2165,12 @@ void Automation::TouchUp(const WebViewId &view_id, const Point &p, Error **error
21542165
touchPoint.setPressure(1);
21552166
points.append(touchPoint);
21562167

2168+
2169+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
2170+
QTouchEvent *touchEndEvent = new QTouchEvent(QEvent::TouchEnd, &touchDevice, Qt::NoModifier, Qt::TouchPointReleased, points);
2171+
#else
21572172
QTouchEvent *touchEndEvent = new QTouchEvent(QEvent::TouchEnd, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointReleased, points);
2173+
#endif
21582174

21592175
QApplication::postEvent(view, touchEndEvent);
21602176

@@ -2179,7 +2195,11 @@ void Automation::TouchMove(const WebViewId &view_id, const Point &p, Error **err
21792195
touchPoint.setPressure(1);
21802196
points.append(touchPoint);
21812197

2198+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
2199+
QTouchEvent *touchMoveEvent = new QTouchEvent(QEvent::TouchUpdate, &touchDevice, Qt::NoModifier, Qt::TouchPointMoved, points);
2200+
#else
21822201
QTouchEvent *touchMoveEvent = new QTouchEvent(QEvent::TouchUpdate, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointMoved, points);
2202+
#endif
21832203

21842204
QApplication::postEvent(view, touchMoveEvent);
21852205

src/chrome/test/webdriver/webdriver_automation.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#include <QtCore/QHash>
1818
#include <QtGui/QKeyEvent>
1919

20+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
21+
#include <QtGui/QTouchDevice>
22+
#endif
23+
2024
#include "base/command_line.h"
2125
#include "base/file_path.h"
2226
// #include "base/memory/ref_counted.h"
@@ -485,6 +489,10 @@ class Automation : public QObject {
485489
QMap<int, int> keyMap;
486490
QHash<QString, ElementMap* > windowsElementMap;
487491

492+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
493+
QTouchDevice touchDevice;
494+
#endif
495+
488496
DISALLOW_COPY_AND_ASSIGN(Automation);
489497

490498
private slots:

0 commit comments

Comments
 (0)