Add flag in testlib to disable committing the simulated touch
authorLaszlo Agocs <laszlo.p.agocs@nokia.com>
Tue, 24 Apr 2012 07:57:57 +0000 (10:57 +0300)
committerQt by Nokia <qt-info@nokia.com>
Tue, 24 Apr 2012 17:36:55 +0000 (19:36 +0200)
Some declarative tests (e.g. 24319) need more fine-grained control
over processing the simulated touch events.

Change-Id: Ib163cfd29254016ea16e8d739ad97369b6ccdc90
Reviewed-by: Jason McDonald <jason.mcdonald@nokia.com>
src/testlib/qtesttouch.h

index 291a721..6e456f3 100644 (file)
@@ -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);
     }
 
 }