aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtTest
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-04-29 19:15:49 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:54:17 -0300
commit46986a6d0d5f092f8eef9e81c3af285880d31969 (patch)
treebdc4f0255d74003725a10bb120f2a0de0afc7de8 /tests/QtTest
parent56d3f53bef9ea9131e73f0ac02aac3db727cebe6 (diff)
Created unit test for bug #839.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Hugo Parente Lima <hugo.pl@gmail.com>
Diffstat (limited to 'tests/QtTest')
-rw-r--r--tests/QtTest/CMakeLists.txt1
-rw-r--r--tests/QtTest/touchevent_test.py46
2 files changed, 47 insertions, 0 deletions
diff --git a/tests/QtTest/CMakeLists.txt b/tests/QtTest/CMakeLists.txt
index b1bdac0a6..9d1e9db39 100644
--- a/tests/QtTest/CMakeLists.txt
+++ b/tests/QtTest/CMakeLists.txt
@@ -1,2 +1,3 @@
PYSIDE_TEST(click_test.py)
PYSIDE_TEST(eventfilter_test.py)
+PYSIDE_TEST(touchevent_test.py)
diff --git a/tests/QtTest/touchevent_test.py b/tests/QtTest/touchevent_test.py
new file mode 100644
index 000000000..2db4e8b2f
--- /dev/null
+++ b/tests/QtTest/touchevent_test.py
@@ -0,0 +1,46 @@
+from PySide.QtGui import QWidget
+from PySide.QtCore import QPoint, QTimer, Qt, QEvent
+from PySide.QtTest import QTest
+
+import unittest
+
+from helper import UsesQApplication
+
+class MyWidget(QWidget):
+ def __init__(self, parent = None):
+ QWidget.__init__(self, parent)
+ self._sequence = []
+ self.setAttribute(Qt.WA_AcceptTouchEvents)
+ QTimer.singleShot(200, self.generateEvent)
+
+ def event(self, e):
+ self._sequence.append(e.type())
+ return QWidget.event(self, e)
+
+ def generateEvent(self):
+ o = QTest.touchEvent(self)
+ o.press(0, QPoint(10, 10))
+ o.commit()
+ del o
+
+ QTest.touchEvent(self).press(0, QPoint(10, 10))
+ QTest.touchEvent(self).stationary(0).press(1, QPoint(40, 10))
+ QTest.touchEvent(self).move(0, QPoint(12, 12)).move(1, QPoint(45, 5))
+ QTest.touchEvent(self).release(0, QPoint(12, 12)).release(1, QPoint(45, 5))
+
+ QTimer.singleShot(200, self.deleteLater)
+
+
+class TouchEventTest(UsesQApplication):
+ def testCreateEvent(self):
+ w = MyWidget()
+ w.show()
+ self.app.exec_()
+ # same values as C++
+ self.assertEqual(w._sequence.count(QEvent.Type.TouchBegin), 2)
+ self.assertEqual(w._sequence.count(QEvent.Type.TouchUpdate), 2)
+ self.assertEqual(w._sequence.count(QEvent.Type.TouchEnd), 1)
+
+
+if __name__ == '__main__':
+ unittest.main()