Skip to content

Commit b793fb1

Browse files
committed
Merge branch 'WD_1.X_dev' of https://portal-ua.globallogic.com/git/wd into WD_1.X_dev
2 parents ba3c4d2 + 2ca2cde commit b793fb1

File tree

11 files changed

+429
-99
lines changed

11 files changed

+429
-99
lines changed

do_if_modified.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
print ' do_if_modified <bin_file> <input_file> <output_file>'
88
exit()
99

10-
action_process = sys.argv[1]
11-
input_file = sys.argv[2]
12-
output_file = sys.argv[3]
10+
action_process = os.path.abspath(sys.argv[1])
11+
input_file = os.path.abspath(sys.argv[2])
12+
output_file = os.path.abspath(sys.argv[3])
1313

1414
need_update = True
1515

generate_wdversion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
versionfile = open (filename, 'w')
99
versionfile.write("namespace webdriver {\n")
1010
versionfile.write("extern const char kProductName[] = \"WebDriver-cisco-cmt\";\n")
11-
versionfile.write("extern const char kVersionNumber[] = \"1.1.0\";\n")
11+
versionfile.write("extern const char kVersionNumber[] = \"1.2.0\";\n")
1212
versionfile.write("extern const char kBuildTime[] = __TIME__;\n")
1313
versionfile.write("extern const char kBuildDate[] = __DATE__;\n")
1414
versionfile.write("extern const char kLastChanges[] = \"" + data.strip() + "\";\n")

inc/extension_qt/q_view_executor.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
#include <QtCore/QDebug>
1414
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
1515
#include <QtWidgets/QWidget>
16-
#include <QtGui/QTouchDevice>
16+
#include <QtGui/QTouchDevice>
1717
#else
1818
#include <QtGui/QWidget>
1919
#endif
20+
#include <QtGui/QTouchEvent>
2021

2122
namespace webdriver {
2223

@@ -48,7 +49,9 @@ class QViewCmdExecutor : public ViewCmdExecutor {
4849

4950
protected:
5051
QWidget* getView(const ViewId& viewId, Error** error);
51-
52+
QTouchEvent::TouchPoint createTouchPoint(Qt::TouchPointState state, QPointF &point);
53+
QTouchEvent* createSimpleTouchEvent(QEvent::Type eventType, Qt::TouchPointStates touchPointStates, QPointF point);
54+
QTouchEvent* createTouchEvent(QEvent::Type eventType, Qt::TouchPointStates touchPointStates, const QList<QTouchEvent::TouchPoint> &touchPoints);
5255
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
5356
QTouchDevice touchDevice;
5457
#endif

inc/extension_qt/widget_view_executor.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@ class QWidgetViewCmdExecutor : public QViewCmdExecutor {
128128
virtual void GetStorageSize(StorageType type, int* size, Error** error) NOT_SUPPORTED_IMPL;
129129
virtual void GetGeoLocation(base::DictionaryValue** geolocation, Error** error) NOT_SUPPORTED_IMPL;
130130
virtual void SetGeoLocation(const base::DictionaryValue* geolocation, Error** error) NOT_SUPPORTED_IMPL;
131-
virtual void TouchClick(const ElementId& element, Error **error) NOT_SUPPORTED_IMPL;
132-
virtual void TouchDoubleClick(const ElementId& element, Error **error) NOT_SUPPORTED_IMPL;
133-
virtual void TouchDown(const int &x, const int &y, Error **error) NOT_SUPPORTED_IMPL;
134-
virtual void TouchUp(const int &x, const int &y, Error **error) NOT_SUPPORTED_IMPL;
135-
virtual void TouchMove(const int &x, const int &y, Error **error) NOT_SUPPORTED_IMPL;
136-
virtual void TouchLongClick(const ElementId& element, Error **error) NOT_SUPPORTED_IMPL;
131+
virtual void TouchClick(const ElementId& element, Error **error);
132+
virtual void TouchDoubleClick(const ElementId& element, Error **error);
133+
virtual void TouchDown(const int &x, const int &y, Error **error);
134+
virtual void TouchUp(const int &x, const int &y, Error **error);
135+
virtual void TouchMove(const int &x, const int &y, Error **error);
136+
virtual void TouchLongClick(const ElementId& element, Error **error);
137137
virtual void TouchScroll(const int &xoffset, const int &yoffset, Error **error) NOT_SUPPORTED_IMPL;
138-
virtual void TouchScroll(const ElementId &element, const int &xoffset, const int &yoffset, Error **error) NOT_SUPPORTED_IMPL;
138+
virtual void TouchScroll(const ElementId &element, const int &xoffset, const int &yoffset, Error **error);
139139
virtual void TouchFlick(const int &xSpeed, const int &ySpeed, Error **error) NOT_SUPPORTED_IMPL;
140-
virtual void TouchFlick(const ElementId &element, const int &xoffset, const int &yoffset, const int &speed, Error **error) NOT_SUPPORTED_IMPL;
140+
virtual void TouchFlick(const ElementId &element, const int &xoffset, const int &yoffset, const int &speed, Error **error);
141141
virtual void GetPlayerState(const ElementId& element, PlayerState*, Error**error);
142142
virtual void SetPlayerState(const ElementId& element, PlayerState, Error**error);
143143
virtual void GetPlayerVolume(const ElementId& element, double*, Error**error);

src/Test/TouchTest.cc

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#include "TouchTest.h"
2+
3+
TouchTestWidget::TouchTestWidget(QWidget *parent) :
4+
QWidget(parent)
5+
{
6+
resize(400, 620);
7+
8+
touchPanel = new QFrame(this);
9+
touchPanel->installEventFilter(this);
10+
touchPanel->setObjectName("touchArea");
11+
touchPanel->setFrameShape(QFrame::Box);
12+
touchPanel->setAttribute(Qt::WA_AcceptTouchEvents);
13+
14+
resultLabel = new QLabel(this);
15+
resultLabel->setObjectName("resultLabel");
16+
QVBoxLayout* layout = new QVBoxLayout(this);
17+
layout->addWidget(resultLabel);
18+
layout->addWidget(touchPanel);
19+
setLayout(layout);
20+
21+
pressLabel = new QLabel(touchPanel);
22+
pressLabel->setText("Pressed");
23+
pressLabel->setObjectName("pressLabel");
24+
pressLabel->setVisible(false);
25+
26+
releaseLabel = new QLabel(touchPanel);
27+
releaseLabel->setText("Released");
28+
releaseLabel->setObjectName("releaseLabel");
29+
releaseLabel->setVisible(false);
30+
31+
moveLabel = new QLabel(touchPanel);
32+
moveLabel->setText("Move");
33+
moveLabel->setObjectName("moveLabel");
34+
moveLabel->setVisible(false);
35+
}
36+
37+
38+
bool TouchTestWidget::eventFilter(QObject *o, QEvent *e)
39+
{
40+
if (o == touchPanel)
41+
{
42+
if ((e->type() == QEvent::TouchBegin))
43+
{
44+
resultLabel->setText(resultLabel->text()+"Pressed");
45+
46+
QTouchEvent* te = static_cast<QTouchEvent*>(e);
47+
if (te)
48+
{
49+
pressLabel->setVisible(true);
50+
QPoint tpos = QPoint(te->touchPoints().at(0).pos().x(), te->touchPoints().at(0).pos().y());
51+
pressLabel->move(tpos);
52+
}
53+
54+
}
55+
if (e->type() == QEvent::TouchUpdate)
56+
{
57+
resultLabel->setText(resultLabel->text()+"Moved");
58+
59+
QTouchEvent* te = static_cast<QTouchEvent*>(e);
60+
if (te)
61+
{
62+
moveLabel->setVisible(true);
63+
QPoint tpos = QPoint(te->touchPoints().at(0).pos().x(), te->touchPoints().at(0).pos().y());
64+
moveLabel->move(tpos);
65+
moveLabel->resize(100, 20);
66+
moveLabel->raise();
67+
68+
}
69+
}
70+
if (e->type() == QEvent::TouchEnd)
71+
{
72+
resultLabel->setText(resultLabel->text()+"Released");
73+
74+
QTouchEvent* te = static_cast<QTouchEvent*>(e);
75+
if (te)
76+
{
77+
releaseLabel->setVisible(true);
78+
QPoint tpos = QPoint(te->touchPoints().at(0).pos().x(), te->touchPoints().at(0).pos().y());
79+
releaseLabel->move(tpos);
80+
qDebug()<<releaseLabel->geometry();
81+
}
82+
}
83+
}
84+
return false;
85+
}

src/Test/TouchTest.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#ifndef TOUCHTEST_H
2+
#define TOUCHTEST_H
3+
4+
#include "CommonQtTestHeaders.h"
5+
6+
class TouchTestWidget : public QWidget
7+
{
8+
public:
9+
explicit TouchTestWidget(QWidget *parent = 0);
10+
11+
protected:
12+
bool eventFilter(QObject *o, QEvent *e);
13+
14+
private:
15+
QFrame* touchPanel;
16+
QLabel* resultLabel;
17+
QLabel* pressLabel;
18+
QLabel* releaseLabel;
19+
QLabel* moveLabel;
20+
};
21+
22+
#endif // TOUCHTEST_H

src/Test/main.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ std::string tests::testDataFolder;
3535
#include "StaleElementReferenceTest.h"
3636
#include "VisibilityTest.h"
3737
#include "BasicMouseInterfaceTest.h"
38+
#include "TouchTest.h"
3839

3940
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
4041
#include "WindowWithDeclarativeViewTest.h"
@@ -140,6 +141,7 @@ int main(int argc, char *argv[])
140141
widgetCreator->RegisterViewClass<StaleElementReferenceTestWidget>("StaleElementReferenceTestWidget");
141142
widgetCreator->RegisterViewClass<VisibilityTestWidget>("VisibilityTestWidget");
142143
widgetCreator->RegisterViewClass<BasicMouseInterfaceTestWidget>("BasicMouseInterfaceTestWidget");
144+
widgetCreator->RegisterViewClass<TouchTestWidget>("TouchTestWidget");
143145
#if (QT_VERSION < QT_VERSION_CHECK(5, 0, 0))
144146
widgetCreator->RegisterViewClass<WindowWithDeclarativeViewTestWidget>("WindowWithDeclarativeViewTestWidget");
145147
#endif

src/webdriver/extension_qt/q_view_executor.cc

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <QtWidgets/QDesktopWidget>
1616
#include <QtWidgets/QMessageBox>
1717
#include <QtWidgets/QInputDialog>
18+
#include <QtCore/QDateTime>
1819
#ifdef OS_ANDROID
1920
#include <qpa/qplatformnativeinterface.h>
2021
#include <jni.h>
@@ -372,4 +373,42 @@ void QViewCmdExecutor::GetOrientation(std::string *orientation, Error **error)
372373
#endif
373374
}
374375

376+
QTouchEvent::TouchPoint QViewCmdExecutor::createTouchPoint(Qt::TouchPointState state, QPointF &point)
377+
{
378+
QTouchEvent::TouchPoint touchPoint(1);
379+
touchPoint.setPos(point);
380+
touchPoint.setState(state);
381+
touchPoint.setPressure(1);
382+
return touchPoint;
383+
}
384+
385+
QTouchEvent* QViewCmdExecutor::createSimpleTouchEvent(QEvent::Type eventType, Qt::TouchPointStates touchPointStates, QPointF point)
386+
{
387+
QList<QTouchEvent::TouchPoint> points;
388+
Qt::TouchPointState touchPointState;
389+
if (touchPointStates & Qt::TouchPointPressed)
390+
touchPointState = Qt::TouchPointPressed;
391+
else if (touchPointStates & Qt::TouchPointReleased)
392+
touchPointState = Qt::TouchPointReleased;
393+
else {
394+
touchPointState = Qt::TouchPointMoved;
395+
}
396+
QTouchEvent::TouchPoint touchPoint = createTouchPoint(touchPointState, point);
397+
points.append(touchPoint);
398+
return createTouchEvent(eventType, touchPointStates, points);
399+
}
400+
401+
QTouchEvent* QViewCmdExecutor::createTouchEvent(QEvent::Type eventType, Qt::TouchPointStates touchPointStates, const QList<QTouchEvent::TouchPoint> &touchPoints)
402+
{
403+
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
404+
QTouchEvent *touchEvent = new QTouchEvent(eventType, &touchDevice, Qt::NoModifier, touchPointStates, touchPoints);
405+
QDateTime current = QDateTime::currentDateTime();
406+
ulong timestame = current.toMSecsSinceEpoch() & (((qint64)1<<(sizeof(ulong)*8))-1);
407+
touchEvent->setTimestamp(timestame);
408+
#else
409+
QTouchEvent *touchEvent = new QTouchEvent(eventType, QTouchEvent::TouchScreen, Qt::NoModifier, touchPointStates, touchPoints);
410+
#endif
411+
return touchEvent;
412+
}
413+
375414
} // namespace webdriver

src/webdriver/extension_qt/web_view_executor.cc

Lines changed: 5 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -576,31 +576,8 @@ void QWebViewCmdExecutor::TouchClick(const ElementId& element, Error **error) {
576576

577577
QPoint point = QCommonUtil::ConvertPointToQPoint(location);
578578

579-
QList<QTouchEvent::TouchPoint> points;
580-
QTouchEvent::TouchPoint touchPoint(1);
581-
touchPoint.setPos(point);
582-
touchPoint.setScreenPos(view_->mapToGlobal(point));
583-
touchPoint.setStartScreenPos(view_->mapToGlobal(point));
584-
touchPoint.setState(Qt::TouchPointPressed);
585-
touchPoint.setPressure(1);
586-
points.append(touchPoint);
587-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
588-
QTouchEvent *touchBeginEvent = new QTouchEvent(QEvent::TouchBegin, &touchDevice, Qt::NoModifier, Qt::TouchPointPressed, points);
589-
#else
590-
QTouchEvent *touchBeginEvent = new QTouchEvent(QEvent::TouchBegin, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointPressed, points);
591-
#endif
592-
points.clear();
593-
touchPoint.setPos(point);
594-
touchPoint.setScreenPos(view_->mapToGlobal(point));
595-
touchPoint.setStartScreenPos(view_->mapToGlobal(point));
596-
touchPoint.setState(Qt::TouchPointReleased);
597-
touchPoint.setPressure(1);
598-
points.append(touchPoint);
599-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
600-
QTouchEvent *touchEndEvent = new QTouchEvent(QEvent::TouchEnd, &touchDevice, Qt::NoModifier, Qt::TouchPointReleased, points);
601-
#else
602-
QTouchEvent *touchEndEvent = new QTouchEvent(QEvent::TouchEnd, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointReleased, points);
603-
#endif
579+
QTouchEvent *touchBeginEvent = createSimpleTouchEvent(QEvent::TouchBegin, Qt::TouchPointPressed, QPointF(point));
580+
QTouchEvent *touchEndEvent = createSimpleTouchEvent(QEvent::TouchEnd, Qt::TouchPointReleased, QPointF(point));
604581

605582
QApplication::postEvent(view_, touchBeginEvent);
606583
QApplication::postEvent(view_, touchEndEvent);
@@ -632,18 +609,7 @@ void QWebViewCmdExecutor::TouchDown(const int &x, const int &y, Error **error) {
632609

633610
QPoint point = QCommonUtil::ConvertPointToQPoint(Point(x, y));
634611

635-
QList<QTouchEvent::TouchPoint> points;
636-
QTouchEvent::TouchPoint touchPoint(1);
637-
touchPoint.setPos(point);
638-
touchPoint.setState(Qt::TouchPointPressed);
639-
touchPoint.setPressure(1);
640-
points.append(touchPoint);
641-
642-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
643-
QTouchEvent *touchBeginEvent = new QTouchEvent(QEvent::TouchBegin, &touchDevice, Qt::NoModifier, Qt::TouchPointPressed, points);
644-
#else
645-
QTouchEvent *touchBeginEvent = new QTouchEvent(QEvent::TouchBegin, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointPressed, points);
646-
#endif
612+
QTouchEvent *touchBeginEvent = createSimpleTouchEvent(QEvent::TouchBegin, Qt::TouchPointPressed, point);
647613

648614
QApplication::postEvent(view_, touchBeginEvent);
649615
}
@@ -653,18 +619,7 @@ void QWebViewCmdExecutor::TouchUp(const int &x, const int &y, Error **error) {
653619

654620
QPoint point = QCommonUtil::ConvertPointToQPoint(Point(x, y));
655621

656-
QList<QTouchEvent::TouchPoint> points;
657-
QTouchEvent::TouchPoint touchPoint(1);
658-
touchPoint.setPos(point);
659-
touchPoint.setState(Qt::TouchPointPressed);
660-
touchPoint.setPressure(1);
661-
points.append(touchPoint);
662-
663-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
664-
QTouchEvent *touchEndEvent = new QTouchEvent(QEvent::TouchEnd, &touchDevice, Qt::NoModifier, Qt::TouchPointReleased, points);
665-
#else
666-
QTouchEvent *touchEndEvent = new QTouchEvent(QEvent::TouchEnd, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointReleased, points);
667-
#endif
622+
QTouchEvent *touchEndEvent = createSimpleTouchEvent(QEvent::TouchEnd, Qt::TouchPointReleased, point);
668623

669624
QApplication::postEvent(view_, touchEndEvent);
670625
}
@@ -674,18 +629,7 @@ void QWebViewCmdExecutor::TouchMove(const int &x, const int &y, Error **error) {
674629

675630
QPoint point = QCommonUtil::ConvertPointToQPoint(Point(x, y));
676631

677-
QList<QTouchEvent::TouchPoint> points;
678-
QTouchEvent::TouchPoint touchPoint(1);
679-
touchPoint.setPos(point);
680-
touchPoint.setState(Qt::TouchPointMoved);
681-
touchPoint.setPressure(1);
682-
points.append(touchPoint);
683-
684-
#if (QT_VERSION >= QT_VERSION_CHECK(5, 0, 0))
685-
QTouchEvent *touchMoveEvent = new QTouchEvent(QEvent::TouchUpdate, &touchDevice, Qt::NoModifier, Qt::TouchPointMoved, points);
686-
#else
687-
QTouchEvent *touchMoveEvent = new QTouchEvent(QEvent::TouchUpdate, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointMoved, points);
688-
#endif
632+
QTouchEvent *touchMoveEvent = createSimpleTouchEvent(QEvent::TouchUpdate, Qt::TouchPointMoved, point);
689633

690634
QApplication::postEvent(view_, touchMoveEvent);
691635
}
@@ -700,30 +644,6 @@ void QWebViewCmdExecutor::TouchLongClick(const ElementId& element, Error **error
700644

701645
QPoint point = QCommonUtil::ConvertPointToQPoint(location);
702646

703-
// QList<QTouchEvent::TouchPoint> points;
704-
// QTouchEvent::TouchPoint touchPoint(1);
705-
// touchPoint.setPos(point);
706-
// touchPoint.setScreenPos(view_->mapToGlobal(point));
707-
// touchPoint.setStartScreenPos(view_->mapToGlobal(point));
708-
// touchPoint.setState(Qt::TouchPointPressed);
709-
// touchPoint.setPressure(1);
710-
// points.append(touchPoint);
711-
// QTouchEvent *touchBeginEvent = new QTouchEvent(QEvent::TouchBegin, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointPressed, points);
712-
713-
// points.clear();
714-
// touchPoint.setPos(point);
715-
// touchPoint.setScreenPos(view_->mapToGlobal(point));
716-
// touchPoint.setStartScreenPos(view_->mapToGlobal(point));
717-
// touchPoint.setState(Qt::TouchPointReleased);
718-
// touchPoint.setPressure(1);
719-
// points.append(touchPoint);
720-
// QTouchEvent *touchEndEvent = new QTouchEvent(QEvent::TouchEnd, QTouchEvent::TouchScreen, Qt::NoModifier, Qt::TouchPointReleased, points);
721-
722-
// QTimer::singleShot(1000, &loop, SLOT(quit()));
723-
// QApplication::postEvent(view_, touchBeginEvent);
724-
// loop.exec(QEventLoop::ExcludeUserInputEvents);
725-
// QApplication::postEvent(view_, touchEndEvent);
726-
727647
QContextMenuEvent *contextEvent = new QContextMenuEvent(QContextMenuEvent::Other, point, view_->mapToGlobal(point));
728648
qApp->postEvent(view_, contextEvent);
729649
}

0 commit comments

Comments
 (0)