From 63051701b473e6560e315cf9bec255a9e3a0a118 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Tue, 24 Apr 2012 10:57:57 +0300 Subject: Add flag in testlib to disable committing the simulated touch Some declarative tests (e.g. 24319) need more fine-grained control over processing the simulated touch events. Change-Id: Ib163cfd29254016ea16e8d739ad97369b6ccdc90 Reviewed-by: Jason McDonald --- src/testlib/qtesttouch.h | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src/testlib/qtesttouch.h') diff --git a/src/testlib/qtesttouch.h b/src/testlib/qtesttouch.h index 291a7219b3..6e456f375c 100644 --- a/src/testlib/qtesttouch.h +++ b/src/testlib/qtesttouch.h @@ -71,7 +71,8 @@ namespace QTest public: ~QTouchEventSequence() { - commit(); + if (commitWhenDestroyed) + commit(); } QTouchEventSequence& press(int touchId, const QPoint &pt, QWindow *window = 0) { @@ -125,7 +126,7 @@ namespace QTest } #endif - void commit() + void commit(bool processEvents = true) { if (!points.isEmpty()) { if (targetWindow) @@ -139,7 +140,8 @@ namespace QTest } #endif } - QCoreApplication::processEvents(); + if (processEvents) + QCoreApplication::processEvents(); previousPoints = points; points.clear(); } @@ -170,17 +172,17 @@ namespace QTest private: #ifdef QT_WIDGETS_LIB - QTouchEventSequence(QWidget *widget, QTouchDevice *aDevice) - : targetWidget(widget), targetWindow(0), device(aDevice) + QTouchEventSequence(QWidget *widget, QTouchDevice *aDevice, bool autoCommit) + : targetWidget(widget), targetWindow(0), device(aDevice), commitWhenDestroyed(autoCommit) { } #endif - QTouchEventSequence(QWindow *window, QTouchDevice *aDevice) + QTouchEventSequence(QWindow *window, QTouchDevice *aDevice, bool autoCommit) : #ifdef QT_WIDGETS_LIB targetWidget(0), #endif - targetWindow(window), device(aDevice) + targetWindow(window), device(aDevice), commitWhenDestroyed(autoCommit) { } @@ -224,25 +226,28 @@ namespace QTest #endif QWindow *targetWindow; QTouchDevice *device; + bool commitWhenDestroyed; #ifdef QT_WIDGETS_LIB - friend QTouchEventSequence touchEvent(QWidget *, QTouchDevice*); + friend QTouchEventSequence touchEvent(QWidget *, QTouchDevice*, bool); #endif - friend QTouchEventSequence touchEvent(QWindow *, QTouchDevice*); + friend QTouchEventSequence touchEvent(QWindow *, QTouchDevice*, bool); }; #ifdef QT_WIDGETS_LIB inline QTouchEventSequence touchEvent(QWidget *widget, - QTouchDevice *device) + QTouchDevice *device, + bool autoCommit = true) { - return QTouchEventSequence(widget, device); + return QTouchEventSequence(widget, device, autoCommit); } #endif inline QTouchEventSequence touchEvent(QWindow *window, - QTouchDevice *device) + QTouchDevice *device, + bool autoCommit = true) { - return QTouchEventSequence(window, device); + return QTouchEventSequence(window, device, autoCommit); } } -- cgit v1.2.3