diff options
Diffstat (limited to 'sources/pyside2/tests/QtTest')
-rw-r--r-- | sources/pyside2/tests/QtTest/CMakeLists.txt | 5 | ||||
-rw-r--r-- | sources/pyside2/tests/QtTest/click_test.py | 55 | ||||
-rw-r--r-- | sources/pyside2/tests/QtTest/eventfilter_test.py | 75 | ||||
-rw-r--r-- | sources/pyside2/tests/QtTest/qvalidator_test.py | 133 | ||||
-rw-r--r-- | sources/pyside2/tests/QtTest/touchevent_test.py | 77 |
5 files changed, 0 insertions, 345 deletions
diff --git a/sources/pyside2/tests/QtTest/CMakeLists.txt b/sources/pyside2/tests/QtTest/CMakeLists.txt deleted file mode 100644 index cf72dfa5c..000000000 --- a/sources/pyside2/tests/QtTest/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -PYSIDE_TEST(click_test.py) -PYSIDE_TEST(eventfilter_test.py) -# The test is currently permanently broken, needs to be fixed. -#PYSIDE_TEST(touchevent_test.py) -PYSIDE_TEST(qvalidator_test.py) diff --git a/sources/pyside2/tests/QtTest/click_test.py b/sources/pyside2/tests/QtTest/click_test.py deleted file mode 100644 index c03c42ddd..000000000 --- a/sources/pyside2/tests/QtTest/click_test.py +++ /dev/null @@ -1,55 +0,0 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## GNU General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## included in the packaging of this file. Please review the following -## information to ensure the GNU General Public License requirements will -## be met: https://www.gnu.org/licenses/gpl-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# - -'''QtTest mouse click functionalities''' - -import unittest - -from PySide2.QtCore import Qt, QObject -from PySide2.QtWidgets import QPushButton, QLineEdit -from PySide2.QtTest import QTest - -from helper import UsesQApplication - -class MouseClickTest(UsesQApplication): - - def testBasic(self): - '''QTest.mouseClick with QCheckBox''' - button = QPushButton() - button.setCheckable(True) - button.setChecked(False) - - QTest.mouseClick(button, Qt.LeftButton) - self.assertTrue(button.isChecked()) - - QTest.mouseClick(button, Qt.LeftButton) - self.assertFalse(button.isChecked()) - - -if __name__ == '__main__': - unittest.main() diff --git a/sources/pyside2/tests/QtTest/eventfilter_test.py b/sources/pyside2/tests/QtTest/eventfilter_test.py deleted file mode 100644 index f69f85ac0..000000000 --- a/sources/pyside2/tests/QtTest/eventfilter_test.py +++ /dev/null @@ -1,75 +0,0 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## GNU General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## included in the packaging of this file. Please review the following -## information to ensure the GNU General Public License requirements will -## be met: https://www.gnu.org/licenses/gpl-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# - -'''Tests for QKeyEvent''' - -import unittest - -from PySide2.QtCore import Qt, QObject, QEvent -from PySide2.QtGui import QKeyEvent -from PySide2.QtWidgets import QLineEdit -from PySide2.QtTest import QTest - -from helper import UsesQApplication - - -class KeyEventFilter(QObject): - - def __init__(self, widget, eventType, key): - QObject.__init__(self) - - self.widget = widget - self.eventType = eventType - self.key = key - - self.processed = False - - def eventFilter(self, obj, event): - if self.widget == obj and event.type() == self.eventType and \ - isinstance(event, QKeyEvent) and event.key() == self.key: - self.processed = True - return True - - return False - -class EventFilterTest(UsesQApplication): - - def testKeyEvent(self): - widget = QLineEdit() - key = Qt.Key_A - eventFilter = KeyEventFilter(widget, QEvent.KeyPress, key) - widget.installEventFilter(eventFilter) - - QTest.keyClick(widget, key) - - self.assertTrue(eventFilter.processed) - - - -if __name__ == '__main__': - unittest.main() diff --git a/sources/pyside2/tests/QtTest/qvalidator_test.py b/sources/pyside2/tests/QtTest/qvalidator_test.py deleted file mode 100644 index 408f14f6e..000000000 --- a/sources/pyside2/tests/QtTest/qvalidator_test.py +++ /dev/null @@ -1,133 +0,0 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## GNU General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## included in the packaging of this file. Please review the following -## information to ensure the GNU General Public License requirements will -## be met: https://www.gnu.org/licenses/gpl-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# - -from PySide2.QtCore import * -from PySide2.QtGui import * -from PySide2.QtWidgets import * -from PySide2.QtTest import * - -import unittest -from helper import UsesQApplication - -class MyValidator1(QValidator): - def fixup(self, input): - return "fixed" - - def validate(self, input, pos): - return (QValidator.Acceptable, "fixed", 1) - -class MyValidator2(QValidator): - def fixup(self, input): - return "fixed" - - def validate(self, input, pos): - return (QValidator.Acceptable, "fixed") - -class MyValidator3(QValidator): - def fixup(self, input): - return "fixed" - - def validate(self, input, pos): - return (QValidator.Acceptable,) - -class MyValidator4(QValidator): - def fixup(self, input): - return "fixed" - - def validate(self, input, pos): - return QValidator.Acceptable - -class MyValidator5(QValidator): - def validate(self, input, pos): - if input.islower(): - return (QValidator.Intermediate, input, pos) - else: - return (QValidator.Acceptable, input, pos) - - def fixup(self, input): - return "22" - -class QValidatorTest(UsesQApplication): - def testValidator1(self): - line = QLineEdit() - line.setValidator(MyValidator1()) - line.show() - line.setText("foo") - - QTimer.singleShot(0, line.close) - self.app.exec_() - - self.assertEqual(line.text(), "fixed") - self.assertEqual(line.cursorPosition(), 1) - - def testValidator2(self): - line = QLineEdit() - line.setValidator(MyValidator2()) - line.show() - line.setText("foo") - - QTimer.singleShot(0, line.close) - self.app.exec_() - - self.assertEqual(line.text(), "fixed") - self.assertEqual(line.cursorPosition(), 3) - - def testValidator3(self): - line = QLineEdit() - line.setValidator(MyValidator3()) - line.show() - line.setText("foo") - - QTimer.singleShot(0, line.close) - self.app.exec_() - - self.assertEqual(line.text(), "foo") - self.assertEqual(line.cursorPosition(), 3) - - def testValidator4(self): - line = QLineEdit() - line.setValidator(MyValidator4()) - line.show() - line.setText("foo") - - QTimer.singleShot(0, line.close) - self.app.exec_() - - self.assertEqual(line.text(), "foo") - self.assertEqual(line.cursorPosition(), 3) - - def testValidator5(self): - line = QLineEdit() - line.show() - line.setValidator(MyValidator5()) - line.setText("foo") - QTest.keyClick(line, Qt.Key_Return) - self.assertEqual(line.text(), "22") - -if __name__ == '__main__': - unittest.main() diff --git a/sources/pyside2/tests/QtTest/touchevent_test.py b/sources/pyside2/tests/QtTest/touchevent_test.py deleted file mode 100644 index 1fa8adc60..000000000 --- a/sources/pyside2/tests/QtTest/touchevent_test.py +++ /dev/null @@ -1,77 +0,0 @@ -############################################################################# -## -## Copyright (C) 2016 The Qt Company Ltd. -## Contact: https://www.qt.io/licensing/ -## -## This file is part of the test suite of Qt for Python. -## -## $QT_BEGIN_LICENSE:GPL-EXCEPT$ -## Commercial License Usage -## Licensees holding valid commercial Qt licenses may use this file in -## accordance with the commercial license agreement provided with the -## Software or, alternatively, in accordance with the terms contained in -## a written agreement between you and The Qt Company. For licensing terms -## and conditions see https://www.qt.io/terms-conditions. For further -## information use the contact form at https://www.qt.io/contact-us. -## -## GNU General Public License Usage -## Alternatively, this file may be used under the terms of the GNU -## General Public License version 3 as published by the Free Software -## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -## included in the packaging of this file. Please review the following -## information to ensure the GNU General Public License requirements will -## be met: https://www.gnu.org/licenses/gpl-3.0.html. -## -## $QT_END_LICENSE$ -## -############################################################################# - -from PySide2.QtWidgets import QWidget -from PySide2.QtCore import QPoint, QTimer, Qt, QEvent -from PySide2.QtGui import QTouchDevice -from PySide2.QtTest import QTest - -import unittest - -from helper import UsesQApplication - -class MyWidget(QWidget): - def __init__(self, parent = None): - QWidget.__init__(self, parent) - self._sequence = [] - # Fixme (Qt 5): The device needs to be registered (using - # QWindowSystemInterface::registerTouchDevice()) for the test to work - self._device = QTouchDevice() - 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, self._device) - o.press(0, QPoint(10, 10)) - o.commit() - del o - - QTest.touchEvent(self, self._device).press(0, QPoint(10, 10)) - QTest.touchEvent(self, self._device).stationary(0).press(1, QPoint(40, 10)) - QTest.touchEvent(self, self._device).move(0, QPoint(12, 12)).move(1, QPoint(45, 5)) - QTest.touchEvent(self, self._device).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() |