summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-06-03 09:26:41 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-06-03 17:29:30 (GMT)
commit0cca7705c01d262c1bb008f969a9705786e1c80e (patch)
tree3f263e6b08a8182eaacc0310f4f19452ec62cba1 /tests
parent437330b3c0c4d848e3dca6c1e41a9c31eb99fd10 (diff)
downloadQt-0cca7705c01d262c1bb008f969a9705786e1c80e.zip
Qt-0cca7705c01d262c1bb008f969a9705786e1c80e.tar.gz
Qt-0cca7705c01d262c1bb008f969a9705786e1c80e.tar.bz2
Moved the QTest::touchEvent() implementation to testlib.
Modified it the same time to remove refcount and static variable.
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gestures/tst_gestures.cpp104
1 files changed, 0 insertions, 104 deletions
diff --git a/tests/auto/gestures/tst_gestures.cpp b/tests/auto/gestures/tst_gestures.cpp
index 9ab252a..9639fb0 100644
--- a/tests/auto/gestures/tst_gestures.cpp
+++ b/tests/auto/gestures/tst_gestures.cpp
@@ -779,110 +779,6 @@ void tst_Gestures::overlappingGraphicsItems()
QVERIFY(item->gesture.last.singleshot.delivered);
}
-namespace QTest
-{
-
- class QTouchEventSequence
- {
- public:
- QTouchEventSequence(QWidget *widget)
- : relativeWindow(widget)
- {
- ++refcount;
- }
- QTouchEventSequence(const QTouchEventSequence &v)
- : relativeWindow(v.relativeWindow)
- {
- ++refcount;
- }
- ~QTouchEventSequence()
- {
- if (!--refcount) {
- commit();
- foreach(QTouchEvent::TouchPoint *pt, points)
- delete pt;
- points.clear();
- }
- }
- QTouchEventSequence& press(int touchId, const QPoint &pt)
- {
- touchPointStates |= Qt::TouchPointPressed;
- QTouchEvent::TouchPoint *p = point(touchId);
- p->setStartPos(pt);
- p->setStartScreenPos(relativeWindow->mapToGlobal(pt));
- p->setLastPos(pt);
- p->setLastScreenPos(relativeWindow->mapToGlobal(pt));
- p->setPos(pt);
- p->setScreenPos(relativeWindow->mapToGlobal(pt));
- p->setState(Qt::TouchPointPressed);
- return *this;
- }
- QTouchEventSequence& move(int touchId, const QPoint &pt)
- {
- touchPointStates |= Qt::TouchPointMoved;
- QTouchEvent::TouchPoint *p = point(touchId);
- p->setLastPos(p->pos());
- p->setLastScreenPos(relativeWindow->mapToGlobal(p->pos().toPoint()));
- p->setPos(pt);
- p->setScreenPos(relativeWindow->mapToGlobal(pt));
- p->setState(Qt::TouchPointMoved);
- return *this;
- }
- QTouchEventSequence& release(int touchId, const QPoint &pt)
- {
- touchPointStates |= Qt::TouchPointReleased;
- QTouchEvent::TouchPoint *p = point(touchId);
- p->setLastPos(p->pos());
- p->setLastScreenPos(relativeWindow->mapToGlobal(p->pos().toPoint()));
- p->setPos(pt);
- p->setScreenPos(relativeWindow->mapToGlobal(pt));
- p->setState(Qt::TouchPointReleased);
- return *this;
- }
- QTouchEventSequence& stationary(int touchId)
- {
- touchPointStates |= Qt::TouchPointStationary;
- QTouchEvent::TouchPoint *p = point(touchId);
- p->setState(Qt::TouchPointStationary);
- return *this;
- }
-
- private:
- QTouchEvent::TouchPoint* point(int touchId)
- {
- QTouchEvent::TouchPoint *pt = points.value(touchId, 0);
- if (!pt) {
- pt = new QTouchEvent::TouchPoint;
- pt->setId(touchId);
- points.insert(touchId, pt);
- }
- return pt;
- }
- void commit()
- {
- if (relativeWindow) {
- QTouchEvent event(QEvent::RawTouch, Qt::NoModifier,
- touchPointStates, points.values());
- ::sendSpontaneousEvent(relativeWindow, &event);
- relativeWindow = 0;
- }
- }
-
- static int refcount;
- QMap<int, QTouchEvent::TouchPoint*> points;
- QWidget *relativeWindow;
- Qt::TouchPointStates touchPointStates;
- friend QTouchEventSequence touchBeginEvent(QWidget*);
- };
- int QTouchEventSequence::refcount = 0;
-
- QTouchEventSequence touchEvent(QWidget *widget)
- {
- return QTouchEventSequence(widget);
- }
-
-}
-
void tst_Gestures::touch()
{
mainWidget->setAttribute(Qt::WA_AcceptTouchEvents);