diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-11-02 16:11:52 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2020-11-02 16:12:04 +0000 |
commit | 25180730194bec25f915f32ab846ea583fb1493f (patch) | |
tree | 9a73e0336ecf21e085d99d6a651c5547b9eb99f8 /sources/pyside6/tests/QtGui | |
parent | 6e3e7b9ca0548430aaa5e2555d6e02c64625fa3f (diff) |
Rename PySide2 to PySide6
Adapt CMake files, build scripts, tests and examples.
Task-number: PYSIDE-904
Change-Id: I845f7b006e9ad274fed5444ec4c1f9dbe176ff88
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside6/tests/QtGui')
46 files changed, 3171 insertions, 0 deletions
diff --git a/sources/pyside6/tests/QtGui/CMakeLists.txt b/sources/pyside6/tests/QtGui/CMakeLists.txt new file mode 100644 index 000000000..179e88fd6 --- /dev/null +++ b/sources/pyside6/tests/QtGui/CMakeLists.txt @@ -0,0 +1,46 @@ +#Keep this in alphabetical sort + +PYSIDE_TEST(bug_300_test.py) +PYSIDE_TEST(bug_367.py) +PYSIDE_TEST(bug_480.py) +PYSIDE_TEST(bug_606.py) +PYSIDE_TEST(bug_617.py) +PYSIDE_TEST(bug_652.py) +PYSIDE_TEST(bug_660.py) +PYSIDE_TEST(bug_716.py) +PYSIDE_TEST(bug_740.py) +PYSIDE_TEST(bug_743.py) +PYSIDE_TEST(bug_991.py) +PYSIDE_TEST(bug_1091.py) +PYSIDE_TEST(bug_PYSIDE-41.py) +PYSIDE_TEST(bug_PYSIDE-344.py) +PYSIDE_TEST(deepcopy_test.py) +PYSIDE_TEST(float_to_int_implicit_conversion_test.py) +PYSIDE_TEST(pyside_reload_test.py) +PYSIDE_TEST(qcolor_test.py) +PYSIDE_TEST(qcolor_reduce_test.py) +PYSIDE_TEST(qcursor_test.py) +PYSIDE_TEST(qdatastream_gui_operators_test.py) +PYSIDE_TEST(qdesktopservices_test.py) +PYSIDE_TEST(qfontmetrics_test.py) +PYSIDE_TEST(qguiapplication_test.py) +PYSIDE_TEST(qicon_test.py) +PYSIDE_TEST(qitemselection_test.py) +PYSIDE_TEST(qpainter_test.py) +PYSIDE_TEST(qpdfwriter_test.py) +PYSIDE_TEST(qpixelformat_test.py) +PYSIDE_TEST(qpixmap_test.py) +PYSIDE_TEST(qpixmapcache_test.py) +PYSIDE_TEST(qpolygonf_test.py) +PYSIDE_TEST(qkeysequence_test.py) +PYSIDE_TEST(qradialgradient_test.py) +PYSIDE_TEST(qrasterwindow_test.py) +PYSIDE_TEST(qregion_test.py) +PYSIDE_TEST(qstylehints_test.py) +PYSIDE_TEST(qtextdocument_functions.py) +PYSIDE_TEST(qtextdocument_undoredo_test.py) +PYSIDE_TEST(qtextdocumentwriter_test.py) +PYSIDE_TEST(qtextline_test.py) +PYSIDE_TEST(qtransform_test.py) +PYSIDE_TEST(repr_test.py) +PYSIDE_TEST(timed_app_and_patching_test.py) diff --git a/sources/pyside6/tests/QtGui/bug_1091.py b/sources/pyside6/tests/QtGui/bug_1091.py new file mode 100644 index 000000000..78645589b --- /dev/null +++ b/sources/pyside6/tests/QtGui/bug_1091.py @@ -0,0 +1,47 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +''' unit test for BUG #1091 ''' + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6 import QtGui + +class QPainterTestCase(unittest.TestCase): + def testIt(self): + self.assertTrue("PixmapFragment" in dir(QtGui.QPainter)) + self.assertTrue("drawPixmapFragments" in dir(QtGui.QPainter)) + +if __name__ == "__main__": + unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_300_test.py b/sources/pyside6/tests/QtGui/bug_300_test.py new file mode 100644 index 000000000..8f734780f --- /dev/null +++ b/sources/pyside6/tests/QtGui/bug_300_test.py @@ -0,0 +1,52 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtCore import QModelIndex, QStringListModel + + +class TestQAbstractItemModelSignals(unittest.TestCase): + def sigCallback(self, index, r, c): + self._called = True + + def testSignals(self): + self._called = False + m = QStringListModel() + m.rowsAboutToBeInserted[QModelIndex,int,int].connect(self.sigCallback) + m.insertRows(0, 3) + self.assertTrue(self._called) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_367.py b/sources/pyside6/tests/QtGui/bug_367.py new file mode 100644 index 000000000..07b229d51 --- /dev/null +++ b/sources/pyside6/tests/QtGui/bug_367.py @@ -0,0 +1,56 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +''' Test bug 367: http://bugs.openbossa.org/show_bug.cgi?id=367''' + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from helper.usesqapplication import UsesQApplication +from PySide6 import QtCore,QtGui + +class BugTest(UsesQApplication): + def testCase(self): + model = QtGui.QStandardItemModel() + parentItem = model.invisibleRootItem() + for i in range(10): + item = QtGui.QStandardItem() + rcount = sys.getrefcount(item) + parentItem.appendRow(item) + self.assertEqual(rcount+1, sys.getrefcount(item)) + parentItem = item + + self.assertTrue(True) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_480.py b/sources/pyside6/tests/QtGui/bug_480.py new file mode 100644 index 000000000..bedf1ae07 --- /dev/null +++ b/sources/pyside6/tests/QtGui/bug_480.py @@ -0,0 +1,59 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6 import QtWidgets + +class BuggyWidget(QtWidgets.QWidget): + def setup(self): + self.verticalLayout = QtWidgets.QVBoxLayout(self) + self.gridLayout = QtWidgets.QGridLayout() + self.lbl = QtWidgets.QLabel(self) + self.gridLayout.addWidget(self.lbl, 0, 1, 1, 1) + + # this cause a segfault during the ownership transfer + self.verticalLayout.addLayout(self.gridLayout) + +class LayoutTransferOwnerShip(unittest.TestCase): + def testBug(self): + app = QtWidgets.QApplication([]) + w = BuggyWidget() + w.setup() + w.show() + self.assertTrue(True) + +if __name__ == '__main__': + unittest.main() + diff --git a/sources/pyside6/tests/QtGui/bug_606.py b/sources/pyside6/tests/QtGui/bug_606.py new file mode 100644 index 000000000..332798a14 --- /dev/null +++ b/sources/pyside6/tests/QtGui/bug_606.py @@ -0,0 +1,60 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +import PySide6 +from PySide6.QtGui import QVector2D, QVector3D, QVector4D +from PySide6.QtGui import QColor + +class testCases(unittest.TestCase): + def testQVector2DToTuple(self): + vec = QVector2D(1, 2) + self.assertEqual((1, 2), vec.toTuple()) + + def testQVector3DToTuple(self): + vec = QVector3D(1, 2, 3) + self.assertEqual((1, 2, 3), vec.toTuple()) + + def testQVector4DToTuple(self): + vec = QVector4D(1, 2, 3, 4) + self.assertEqual((1, 2, 3, 4), vec.toTuple()) + + def testQColorToTuple(self): + c = QColor(0, 0, 255) + c.setRgb(1, 2, 3) + self.assertEqual((1, 2, 3, 255), c.toTuple()) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_617.py b/sources/pyside6/tests/QtGui/bug_617.py new file mode 100644 index 000000000..3c8786cea --- /dev/null +++ b/sources/pyside6/tests/QtGui/bug_617.py @@ -0,0 +1,57 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtCore import QEvent +from PySide6.QtGui import QColor + + +class MyEvent(QEvent): + def __init__(self): + QEvent.__init__(self, QEvent.Type(999)) + + +class Bug617(unittest.TestCase): + def testRepr(self): + c = QColor.fromRgb(1, 2, 3, 4) + s = c.spec() + self.assertEqual(repr(s), repr(QColor.Rgb)) + + def testOutOfBounds(self): + e = MyEvent() + self.assertEqual(repr(e.type()), 'PySide6.QtCore.QEvent.Type(999)') + +if __name__ == "__main__": + unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_652.py b/sources/pyside6/tests/QtGui/bug_652.py new file mode 100644 index 000000000..c70055b3b --- /dev/null +++ b/sources/pyside6/tests/QtGui/bug_652.py @@ -0,0 +1,65 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import * + +class MyData(QTextBlockUserData): + def __init__(self, data): + QTextBlockUserData.__init__(self) + self.data = data + + def getMyNiceData(self): + return self.data + +class TestBug652(unittest.TestCase): + """Segfault when using QTextBlock::setUserData due to missing ownership transfer""" + def testIt(self): + td = QTextDocument() + tc = QTextCursor(td) + tc.insertText("Hello world") + heyHo = "hey ho!" + tc.block().setUserData(MyData(heyHo)) + self.assertEqual(type(tc.block().userData()), MyData) + self.assertEqual(tc.block().userData().getMyNiceData(), heyHo) + + del tc + tc = QTextCursor(td) + blk = tc.block() + self.assertEqual(type(blk.userData()), MyData) + self.assertEqual(blk.userData().getMyNiceData(), heyHo) + +if __name__ == "__main__": + unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_660.py b/sources/pyside6/tests/QtGui/bug_660.py new file mode 100644 index 000000000..e625f2981 --- /dev/null +++ b/sources/pyside6/tests/QtGui/bug_660.py @@ -0,0 +1,61 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import QStandardItemModel, QStandardItem + +class MyItemModel(QStandardItemModel): + def __init__(self,parent=None): + super(MyItemModel,self).__init__(parent) + self.appendRow([QStandardItem('Item 1'),]) + + def mimeTypes(self): + mtypes = super(MyItemModel,self).mimeTypes() + mtypes.append('application/my-form') + return mtypes + + def mimeData(self,indexes): + self.__mimedata = super(MyItemModel,self).mimeData(indexes) + self.__mimedata.setData('application/my-form',bytes('hi', "UTF-8")) + return self.__mimedata + +class TestBug660(unittest.TestCase): + '''QMimeData type deleted prematurely when overriding mime-type in QStandardItemModel drag and drop''' + def testIt(self): + model = MyItemModel() + model.mimeData([model.index(0, 0)]) # if it doesn't raise an exception it's all right! + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_716.py b/sources/pyside6/tests/QtGui/bug_716.py new file mode 100644 index 000000000..f49b909fa --- /dev/null +++ b/sources/pyside6/tests/QtGui/bug_716.py @@ -0,0 +1,44 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys + +sys.path.append(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "util")) +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths() + +from PySide6.QtCore import Qt, QPersistentModelIndex, QStringListModel + +if __name__ == '__main__': + stringListModel = QStringListModel(['one', 'two']) + idx = stringListModel.index(1, 0) + persistentModelIndex = QPersistentModelIndex(idx) + stringListModel.data(persistentModelIndex, Qt.DisplayRole) + diff --git a/sources/pyside6/tests/QtGui/bug_740.py b/sources/pyside6/tests/QtGui/bug_740.py new file mode 100644 index 000000000..1d32fe5bd --- /dev/null +++ b/sources/pyside6/tests/QtGui/bug_740.py @@ -0,0 +1,47 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from helper.usesqapplication import UsesQApplication +from PySide6.QtCore import QSize +from PySide6.QtGui import QBitmap, QImage + +class TestQBitmap(UsesQApplication): + def testFromDataMethod(self): + dataBits = bytes('\x38\x28\x38\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\x10\xfe\xfe\x7c\x7c\x38\x38\x10\x10', "UTF-8") + bim = QBitmap.fromData(QSize(8, 48), dataBits, QImage.Format_Mono) # missing function + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_743.py b/sources/pyside6/tests/QtGui/bug_743.py new file mode 100644 index 000000000..ce2664a6e --- /dev/null +++ b/sources/pyside6/tests/QtGui/bug_743.py @@ -0,0 +1,49 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import QMatrix4x4 + +class TestQMatrix(unittest.TestCase): + def testOperator(self): + m = QMatrix4x4(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) + v = 1 + for x in range(4): + for y in range(4): + self.assertEqual(m[x,y], v) + v += 1 + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_991.py b/sources/pyside6/tests/QtGui/bug_991.py new file mode 100644 index 000000000..63a4a5760 --- /dev/null +++ b/sources/pyside6/tests/QtGui/bug_991.py @@ -0,0 +1,50 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtCore import QObject +from PySide6.QtGui import QPen, QBrush + +class TestBug991 (unittest.TestCase): + def testReprFunction(self): + reprPen = repr(QPen()) + self.assertTrue(reprPen.startswith("<PySide6.QtGui.QPen")) + reprBrush = repr(QBrush()) + self.assertTrue(reprBrush.startswith("<PySide6.QtGui.QBrush")) + reprObject = repr(QObject()) + self.assertTrue(reprObject.startswith("<PySide6.QtCore.QObject")) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_PYSIDE-344.py b/sources/pyside6/tests/QtGui/bug_PYSIDE-344.py new file mode 100644 index 000000000..7b571cfe2 --- /dev/null +++ b/sources/pyside6/tests/QtGui/bug_PYSIDE-344.py @@ -0,0 +1,70 @@ +#!/usr/bin/python + +############################################################################# +## +## 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$ +## +############################################################################# + +'''Test cases for PYSIDE-344, imul/idiv are used instead of mul/div, modifying the argument passed in''' + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtCore import * +from PySide6.QtGui import * + +def testList(): + return [QPoint(10, 10), QPointF(1, 1), QSize(10, 10), QSizeF(1, 1), + QMargins(10, 10, 10, 10), + QTransform(), QMatrix4x4(), + QVector2D(1, 1), QVector3D(1, 1, 1), QVector4D(1, 1, 1, 1), + QQuaternion(1, 1, 1, 1)] + +class TestMulDiv(unittest.TestCase): + + def testMultiplication(self): + fails = '' + for a in testList(): + mul = (a * 2) + if a == mul: + fails += ' ' + type(a).__name__ + self.assertEqual(fails, '') + + def testDivision(self): + fails = '' + for a in testList(): + div = (a * 2) + if a == div: + fails += ' ' + type(a).__name__ + self.assertEqual(fails, '') + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/bug_PYSIDE-41.py b/sources/pyside6/tests/QtGui/bug_PYSIDE-41.py new file mode 100644 index 000000000..46173b171 --- /dev/null +++ b/sources/pyside6/tests/QtGui/bug_PYSIDE-41.py @@ -0,0 +1,78 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +# TODO: +# move this to QtCore -- QStringListModel is part of QtGui and there is no +# simple model class appropriate for this test in QtCore. + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtCore import * +from PySide6.QtGui import * + + +class TestBugPYSIDE41(unittest.TestCase): + + def testIt(self): + + # list of single-character strings + strings = list('abcdefghijklmnopqrstuvwxyz') + + model = QStringListModel(strings) + + # Test hashing of both QModelIndex and QPersistentModelIndex + indexFunctions = [] + indexFunctions.append(model.index) + indexFunctions.append(lambda i: QPersistentModelIndex(model.index(i))) + + for indexFunction in indexFunctions: + + # If two objects compare equal, their hashes MUST also be equal. (The + # reverse is not a requirement.) + for i, _ in enumerate(strings): + index1 = indexFunction(i) + index2 = indexFunction(i) + self.assertEqual(index1, index2) + self.assertEqual(hash(index1), hash(index2)) + + # Adding the full set of indexes to itself is a no-op. + allIndexes1 = set(indexFunction(i) for i, _ in enumerate(strings)) + allIndexes2 = set(indexFunction(i) for i, _ in enumerate(strings)) + allIndexesCombined = allIndexes1 & allIndexes2 + self.assertEqual(allIndexes1, allIndexesCombined) + self.assertEqual(allIndexes2, allIndexesCombined) + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/deepcopy_test.py b/sources/pyside6/tests/QtGui/deepcopy_test.py new file mode 100644 index 000000000..8cffe2b3f --- /dev/null +++ b/sources/pyside6/tests/QtGui/deepcopy_test.py @@ -0,0 +1,151 @@ +############################################################################# +## +## 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 copy import deepcopy +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtCore import QPoint +from PySide6.QtGui import QMatrix2x2, QMatrix2x3, QMatrix2x4 +from PySide6.QtGui import QMatrix3x2, QMatrix3x3, QMatrix3x4 +from PySide6.QtGui import QMatrix4x2, QMatrix4x3, QMatrix4x4 +from PySide6.QtGui import QVector2D, QVector3D, QVector4D +from PySide6.QtGui import QColor, QTransform, QKeySequence, QQuaternion +from PySide6.QtGui import QPolygon + +class DeepCopyHelper: + def testCopy(self): + copy = deepcopy([self.original])[0] + self.assertTrue(copy is not self.original) + self.assertEqual(copy, self.original) + +class DeepCopyColorHelperF: + def testCopy(self): + copy = deepcopy([self.original])[0] + self.assertTrue(copy is not self.original) + self.assertEqual(copy.spec(), self.original.spec()) + # impossible to compare float point + # self.assertEqual(copy, self.original) + + +class QColorDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QColor("red") + +class QColorRGBDeepCopy(DeepCopyColorHelperF, unittest.TestCase): + def setUp(self): + self.original = QColor.fromRgbF(0.2, 0.3, 0.4, 0.5) + +class QColorHSLDeepCopy(DeepCopyColorHelperF, unittest.TestCase): + def setUp(self): + self.original = QColor.fromHslF(0.2, 0.3, 0.4, 0.5) + +class QColorHSVDeepCopy(DeepCopyColorHelperF, unittest.TestCase): + def setUp(self): + self.original = QColor.fromHsvF(0.2, 0.3, 0.4, 0.5) + +class QColorCMYKDeepCopy(DeepCopyColorHelperF, unittest.TestCase): + def setUp(self): + self.original = QColor.fromCmykF(0.2, 0.3, 0.4, 0.5, 0.6) + +class QTransformDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QTransform(1, 2, 3, 4, 5, 6, 7, 8, 9) + +class QKeySequenceDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QKeySequence("Ctrl+P") + +class QQuaternionDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QQuaternion(1, 2, 3, 4) + +class QVector2DDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QVector2D(1, 2) + +class QVector3DDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QVector3D(1, 2, 3) + +class QVector4DDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QVector4D(1, 2, 3, 4) + +class QPolygonDeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QPolygon([QPoint(1, 2), QPoint(3, 4), QPoint(5, 6)]) + + +# Avoid these tests until get gcc fixed +# Related bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43247 +""" +class QMatrix2x2DeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix2x2([1, 2, 3, 4]) + +class QMatrix2x3DeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix2x3([1, 2, 3, 4, 5, 6]) + +class QMatrix2x4DeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix2x4([1, 2, 3, 4, 5, 6, 7, 8]) + +class QMatrix3x2DeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix3x2([1, 2, 3, 4, 5, 6]) + +class QMatrix3x3DeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix3x3([1, 2, 3, 4, 5, 6, 7, 8, 9]) + +class QMatrix3x4DeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix3x4([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) + +class QMatrix4x2DeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix4x2([1, 2, 3, 4, 5, 6, 7, 8]) + +class QMatrix4x3DeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix4x3([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) + +class QMatrix4x4DeepCopy(DeepCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix4x4([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) +""" + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py b/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py new file mode 100644 index 000000000..cc381c20a --- /dev/null +++ b/sources/pyside6/tests/QtGui/float_to_int_implicit_conversion_test.py @@ -0,0 +1,65 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +'''Test cases for QImage''' + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import QImage, qRgb + +from helper.usesqapplication import UsesQApplication + +class SetPixelFloat(UsesQApplication): + '''Test case for calling setPixel with float as argument''' + + def setUp(self): + #Acquire resources + super(SetPixelFloat, self).setUp() + self.color = qRgb(255, 0, 0) + self.image = QImage(200, 200, QImage.Format_RGB32) + + def tearDown(self): + #Release resources + del self.color + del self.image + super(SetPixelFloat, self).tearDown() + + def testFloat(self): + #QImage.setPixel(float, float, color) - Implicit conversion + self.image.setPixel(3.14, 4.2, self.color) + self.assertEqual(self.image.pixel(3.14, 4.2), self.color) + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/pyside_reload_test.py b/sources/pyside6/tests/QtGui/pyside_reload_test.py new file mode 100644 index 000000000..75994f4e4 --- /dev/null +++ b/sources/pyside6/tests/QtGui/pyside_reload_test.py @@ -0,0 +1,84 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import importlib +import importlib.util +import os +import shutil +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + + +orig_path = os.path.join(os.path.dirname(__file__)) +workdir = os.getcwd() +src = os.path.normpath(os.path.join(orig_path, '..', 'QtWidgets', 'test_module_template.py')) +dst = os.path.join(workdir, 'test_module.py') +shutil.copyfile(src, dst) +sys.path.append(workdir) + +def reload_module(moduleName): + importlib.reload(moduleName) + + +def increment_module_value(): + modfile = open(dst, 'a') + modfile.write('Sentinel.value += 1' + os.linesep) + modfile.flush() + modfile.close() + if not sys.dont_write_bytecode: + import importlib.util + cacheFile = importlib.util.cache_from_source(dst) + os.remove(cacheFile) + +class TestModuleReloading(unittest.TestCase): + + def testModuleReloading(self): + '''Test module reloading with on-the-fly modifications.''' + + import test_module + self.assertEqual(test_module.Sentinel.value, 10) + + increment_module_value() + reload_module(sys.modules['test_module']) + self.assertEqual(test_module.Sentinel.value, 11) + + reload_module(sys.modules['test_module']) + self.assertEqual(test_module.Sentinel.value, 11) + + increment_module_value() + reload_module(sys.modules['test_module']) + self.assertEqual(test_module.Sentinel.value, 12) + +if __name__ == "__main__": + unittest.main() + + diff --git a/sources/pyside6/tests/QtGui/qcolor_reduce_test.py b/sources/pyside6/tests/QtGui/qcolor_reduce_test.py new file mode 100644 index 000000000..a508dad50 --- /dev/null +++ b/sources/pyside6/tests/QtGui/qcolor_reduce_test.py @@ -0,0 +1,66 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import pickle +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import QColor + +class TestQColor (unittest.TestCase): + def reduceColor(self, c): + p = pickle.dumps(c) + c2 = pickle.loads(p) + self.assertEqual(c.spec(), c2.spec()) + self.assertEqual(c, c2) + + def testReduceEmpty(self): + self.reduceColor(QColor()) + + def testReduceString(self): + self.reduceColor(QColor('gray')) + + def testReduceRGB(self): + self.reduceColor(QColor.fromRgbF(0.1, 0.2, 0.3, 0.4)) + + def testReduceCMYK(self): + self.reduceColor(QColor.fromCmykF(0.1, 0.2, 0.3, 0.4, 0.5)) + + def testReduceHsl(self): + self.reduceColor(QColor.fromHslF(0.1, 0.2, 0.3, 0.4)) + + def testReduceHsv(self): + self.reduceColor(QColor.fromHsvF(0.1, 0.2, 0.3, 0.4)) + +if __name__ == "__main__": + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qcolor_test.py b/sources/pyside6/tests/QtGui/qcolor_test.py new file mode 100644 index 000000000..aef9c24e0 --- /dev/null +++ b/sources/pyside6/tests/QtGui/qcolor_test.py @@ -0,0 +1,129 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import colorsys +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +import PySide6 +from PySide6.QtCore import Qt +from PySide6.QtGui import QColor, QColorConstants + + +class QColorGetTest(unittest.TestCase): + + def setUp(self): + self.color = QColor(20, 40, 60, 80) + + def testGetRgb(self): + self.assertEqual(self.color.getRgb(), (20, 40, 60, 80)) + + def testGetHslF(self): + hls = colorsys.rgb_to_hls(20.0/255, 40.0/255, 60.0/255) + hsla = hls[0], hls[2], hls[1], self.color.alphaF() + for x, y in zip(self.color.getHslF(), hsla): # Due to rounding problems + self.assertTrue(x - y < 1/100000.0) + + def testGetHsv(self): + hsv = colorsys.rgb_to_hsv(20.0/255, 40.0/255, 60.0/255) + hsva = int(hsv[0]*360.0), int(hsv[1]*255), int(hsv[2]*256), self.color.alpha() + self.assertEqual(self.color.getHsv(), hsva) + + def testGetCmyk(self): # not supported by colorsys + self.assertEqual(self.color.getCmyk(), (170, 85, 0, 195, 80)) + + def testGetCmykF(self): # not supported by colorsys + for x, y in zip(self.color.getCmykF(), (170/255.0, 85/255.0, 0, 195/255.0, 80/255.0)): + self.assertTrue(x - y < 1/10000.0) + + +class QColorQRgbConstructor(unittest.TestCase): + '''QColor(QRgb) constructor''' + # Affected by bug #170 - QColor(QVariant) coming before QColor(uint) + # in overload sorting + + def testBasic(self): + '''QColor(QRgb)''' + color = QColor(255, 0, 0) + #QRgb format #AARRGGBB + rgb = 0x00FF0000 + self.assertEqual(QColor(rgb), color) + + +class QColorEqualGlobalColor(unittest.TestCase): + + def testEqualGlobalColor(self): + '''QColor == Qt::GlobalColor''' + self.assertEqual(QColor(255, 0, 0), Qt.red) + + +class QColorCopy(unittest.TestCase): + + def testDeepCopy(self): + '''QColor deepcopy''' + + from copy import deepcopy + + original = QColor(0, 0, 255) + copy = deepcopy([original])[0] + + self.assertTrue(original is not copy) + self.assertEqual(original, copy) + del original + self.assertEqual(copy, QColor(0, 0, 255)) + + def testEmptyCopy(self): + from copy import deepcopy + + original = QColor() + copy = deepcopy([original])[0] + self.assertTrue(original is not copy) + self.assertEqual(original, copy) + del original + self.assertEqual(copy, QColor()) + + +class QColorRepr(unittest.TestCase): + def testReprFunction(self): + # QColorConstants are disabled for MSVC/5.15, fixme: Check Qt 6 + c = QColorConstants.Yellow if sys.platform != 'win32' else QColor(100, 120, 200) + c2 = eval(c.__repr__()) + self.assertEqual(c, c2) + + def testStrFunction(self): + c = QColor('red') + c2 = eval(c.__str__()) + self.assertEqual(c, c2) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qcursor_test.py b/sources/pyside6/tests/QtGui/qcursor_test.py new file mode 100644 index 000000000..aede84498 --- /dev/null +++ b/sources/pyside6/tests/QtGui/qcursor_test.py @@ -0,0 +1,51 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +'''Test for Bug 630 - Fails to resolve overload for QCursor(QBitmap, QBitmap, int, int) +http://bugs.openbossa.org/show_bug.cgi?id=630 +''' + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import QBitmap, QCursor, QPixmap +from helper.usesqapplication import UsesQApplication + +class TestQCursor(UsesQApplication): + def testQCursorConstructor(self): + bmp = QBitmap(16, 16) + cursor = QCursor(bmp, bmp, 16, 16) + +if __name__ == '__main__': + unittest.main() + diff --git a/sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py b/sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py new file mode 100644 index 000000000..9bcb03753 --- /dev/null +++ b/sources/pyside6/tests/QtGui/qdatastream_gui_operators_test.py @@ -0,0 +1,68 @@ +# -*- coding: utf-8 -*- + +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtCore import QDataStream, QByteArray, QIODevice, Qt +from PySide6.QtGui import QPixmap, QColor + +from helper.usesqapplication import UsesQApplication + +class QPixmapQDatastream(UsesQApplication): + '''QDataStream <<>> QPixmap''' + + def setUp(self): + super(QPixmapQDatastream, self).setUp() + self.source_pixmap = QPixmap(100, 100) + self.source_pixmap.fill(Qt.red) + self.output_pixmap = QPixmap() + self.buffer = QByteArray() + self.read_stream = QDataStream(self.buffer, QIODevice.ReadOnly) + self.write_stream = QDataStream(self.buffer, QIODevice.WriteOnly) + + def testStream(self): + self.write_stream << self.source_pixmap + + self.read_stream >> self.output_pixmap + + image = self.output_pixmap.toImage() + pixel = image.pixel(10,10) + self.assertEqual(pixel, QColor(Qt.red).rgba()) + self.assertEqual(self.source_pixmap.toImage(), self.output_pixmap.toImage()) + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qdesktopservices_test.py b/sources/pyside6/tests/QtGui/qdesktopservices_test.py new file mode 100644 index 000000000..089465c6c --- /dev/null +++ b/sources/pyside6/tests/QtGui/qdesktopservices_test.py @@ -0,0 +1,49 @@ +############################################################################# +## +## Copyright (C) 2017 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$ +## +############################################################################# + +'''Unit tests for QDesktopServices''' + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import QDesktopServices +from PySide6.QtCore import QUrl + +class QDesktopServicesTest(unittest.TestCase): + def testOpenUrl(self): + # At the bare minimum check that they return false for invalid url's + url = QUrl() + self.assertEqual(QDesktopServices.openUrl(url), False) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qfontmetrics_test.py b/sources/pyside6/tests/QtGui/qfontmetrics_test.py new file mode 100644 index 000000000..3a3520003 --- /dev/null +++ b/sources/pyside6/tests/QtGui/qfontmetrics_test.py @@ -0,0 +1,233 @@ +############################################################################# +## +## 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 inject codes and modifications on QFontMetrics + and QFontMetricsF''' + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import QFont, QFontMetrics, QFontMetricsF +from PySide6.QtCore import QRect, QRectF, Qt, QSize, QSizeF +from helper.usesqapplication import UsesQApplication + + +class QFontMetricsTest(UsesQApplication): + '''Base class for QFontMetrics tests''' + + def setUp(self): + super(QFontMetricsTest, self).setUp() + self.font = QFont() + self.metrics = QFontMetrics(self.font) + + def tearDown(self): + del self.metrics + del self.font + super(QFontMetricsTest, self).tearDown() + + +class BoundingRectTest(QFontMetricsTest): + '''Tests for QFontMetrics.boundingRect inject code''' + + def testIntDefault(self): + '''QFontMetrics.boundingRect(int, int, int, int, ...) - default args''' + rect = self.metrics.boundingRect(0, 0, 0, 0, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT') + self.assertTrue(isinstance(rect, QRect)) + + def testIntWithArg(self): + '''QFontMetrics.boundingRect(int, int, int, int, ...) - single arg''' + rect = self.metrics.boundingRect(0, 0, 0, 0, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 2) + self.assertTrue(isinstance(rect, QRect)) + + def testIntWithFull(self): + '''QFontMetrics.boundingRect(int, int, int, int, ...) - all argss''' + rect = self.metrics.boundingRect(0, 0, 0, 0, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, [1, 2, 3, 4, 5]) + self.assertTrue(isinstance(rect, QRect)) + + def testIntTypeError(self): + '''QFontMetrics.boundingRect(int, int, int, int, ...) - type error''' + self.assertRaises(TypeError, self.metrics.boundingRect, 0, 0, 0, 0, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, ['aaaa', 'ase']) + + def testQRectDefault(self): + '''QFontMetrics.boundingRect(QRect, ...) - default args''' + arg = QRect(0, 0, 100, 200) + rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT') + self.assertTrue(isinstance(rect, QRect)) + + def testQRectWithArg(self): + '''QFontMetrics.boundingRect(QRect, ...) - only tabstops''' + arg = QRect(0, 0, 100, 200) + rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 2) + self.assertTrue(isinstance(rect, QRect)) + + def testQRectWithFull(self): + '''QFontMetrics.boundingRect(QRect, ...) - all arguments''' + arg = QRect(0, 0, 100, 200) + rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, + [1, 2, 3, 4, 5]) + self.assertTrue(isinstance(rect, QRect)) + + def testQRectTypeError(self): + '''QFontMetrics.boundingRect(QRect, ...) - type error''' + arg = QRect(0, 0, 100, 200) + self.assertRaises(TypeError, self.metrics.boundingRect, arg, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, ['aaaa', 'ase']) + + +class SizeTest(QFontMetricsTest): + '''Tests for QFontMetrics.size inject code''' + + def testDefault(self): + '''QFontMetrics.size - default arguments''' + size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, + 'PySide by INdT') + self.assertTrue(isinstance(size, QSize)) + + def testWithTabStops(self): + '''QFontMetrics.size - only tabstops''' + size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, + 'PySide by INdT', 2) + self.assertTrue(isinstance(size, QSize)) + + def testFull(self): + '''QFontMetrics.size - all arguments''' + size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, + 'PySide by INdT', 2, [1, 2, 3, 4]) + self.assertTrue(isinstance(size, QSize)) + + def testTypeError(self): + '''QFontMetrics.size - type error''' + self.assertRaises(TypeError, self.metrics.size, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, ['aaaa', 'ase']) + + +class QFontMetricsFTest(UsesQApplication): + '''Base class for QFontMetrics tests''' + + def setUp(self): + super(QFontMetricsFTest, self).setUp() + self.font = QFont() + self.metrics = QFontMetricsF(self.font) + + def tearDown(self): + del self.metrics + del self.font + super(QFontMetricsFTest, self).tearDown() + + +class FBoundingRectTest(QFontMetricsFTest): + '''Tests for QFontMetricsF.boundingRect inject code''' + + def testQRectDefault(self): + '''QFontMetricsF.boundingRect(QRectF, ...) - default args''' + arg = QRectF(0, 0, 100, 200) + rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT') + self.assertTrue(isinstance(rect, QRectF)) + + def testQRectWithArg(self): + '''QFontMetricsF.boundingRect(QRectF, ...) - only tabstops''' + arg = QRectF(0, 0, 100, 200) + rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 2) + self.assertTrue(isinstance(rect, QRectF)) + + def testQRectWithFull(self): + '''QFontMetricsF.boundingRect(QRectF, ...) - all arguments''' + arg = QRectF(0, 0, 100, 200) + rect = self.metrics.boundingRect(arg, Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, + [1, 2, 3, 4, 5]) + self.assertTrue(isinstance(rect, QRectF)) + + def testQRectTypeError(self): + '''QFontMetricsF.boundingRect(QRectF, ...) - type error''' + arg = QRectF(0, 0, 100, 200) + self.assertRaises(TypeError, self.metrics.boundingRect, arg, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, ['aaaa', 'ase']) + + +class FSizeTest(QFontMetricsFTest): + '''Tests for QFontMetricsF.size inject code''' + + def testDefault(self): + '''QFontMetricsF.size - default arguments''' + size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, + 'PySide by INdT') + self.assertTrue(isinstance(size, QSizeF)) + + def testWithTabStops(self): + '''QFontMetricsF.size - only tabstops''' + size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, + 'PySide by INdT', 2) + self.assertTrue(isinstance(size, QSizeF)) + + def testFull(self): + '''QFontMetricsF.size - all arguments''' + size = self.metrics.size(Qt.TextExpandTabs | Qt.TextSingleLine, + 'PySide by INdT', 2, [1, 2, 3, 4]) + self.assertTrue(isinstance(size, QSizeF)) + + def testTypeError(self): + '''QFontMetricsF.size - type error''' + self.assertRaises(TypeError, self.metrics.size, + Qt.TextExpandTabs | Qt.AlignLeft, + 'PySide by INdT', 20, ['aaaa', 'ase']) + + +class QCharTest(QFontMetricsFTest): + + def testBoundingRect(self): + retCh = self.metrics.boundingRectChar('a') + self.assertEqual(type(retCh), QRectF) + + def testWith(self): + retCh = self.metrics.horizontalAdvance('a') + self.assertTrue(retCh > 0) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qguiapplication_test.py b/sources/pyside6/tests/QtGui/qguiapplication_test.py new file mode 100644 index 000000000..68f7b8591 --- /dev/null +++ b/sources/pyside6/tests/QtGui/qguiapplication_test.py @@ -0,0 +1,46 @@ +############################################################################# +## +## Copyright (C) 2018 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import QGuiApplication + +class TestQGuiApplication(unittest.TestCase): + def testNoArguments(self): + app = QGuiApplication() + self.assertIsInstance(app, QGuiApplication) + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qicon_test.py b/sources/pyside6/tests/QtGui/qicon_test.py new file mode 100644 index 000000000..cb95d02db --- /dev/null +++ b/sources/pyside6/tests/QtGui/qicon_test.py @@ -0,0 +1,50 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from helper.timedqapplication import TimedQApplication +from PySide6.QtGui import QIcon + + +class QIconCtorWithNoneTest(TimedQApplication): + '''Test made by seblin, see Bug #944: http://bugs.pyside.org/show_bug.cgi?id=944''' + + def testQIconCtorWithNone(self): + icon = QIcon(None) + pixmap = icon.pixmap(48, 48) + self.app.exec_() + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qitemselection_test.py b/sources/pyside6/tests/QtGui/qitemselection_test.py new file mode 100644 index 000000000..5c913fa08 --- /dev/null +++ b/sources/pyside6/tests/QtGui/qitemselection_test.py @@ -0,0 +1,53 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from helper.usesqapplication import UsesQApplication +from PySide6.QtCore import QItemSelection +from PySide6.QtGui import QStandardItemModel + +class QItemSelectionTest(UsesQApplication): + def testLen(self): + model = QStandardItemModel(2, 2) + model.insertRow(0) + model.insertRow(1) + model.insertColumn(0) + model.insertColumn(1) + selection = QItemSelection(model.index(0,0), model.index(1,1)) + self.assertEqual(len(selection), 1) + +if __name__ == '__main__': + unittest.main() + diff --git a/sources/pyside6/tests/QtGui/qkeysequence_test.py b/sources/pyside6/tests/QtGui/qkeysequence_test.py new file mode 100644 index 000000000..9c8097415 --- /dev/null +++ b/sources/pyside6/tests/QtGui/qkeysequence_test.py @@ -0,0 +1,54 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtCore import Qt +from PySide6.QtGui import QKeySequence + +from helper.usesqapplication import UsesQApplication + +class QKeySequenceTest(UsesQApplication): + + def testGetItemOperator(self): + # bug #774 + ks = QKeySequence(Qt.SHIFT, Qt.CTRL, Qt.Key_P, Qt.Key_R) + self.assertEqual(ks[0], Qt.SHIFT) + self.assertEqual(ks[1], Qt.CTRL) + self.assertEqual(ks[2], Qt.Key_P) + self.assertEqual(ks[3], Qt.Key_R) + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qpainter_test.py b/sources/pyside6/tests/QtGui/qpainter_test.py new file mode 100644 index 000000000..05af83d4f --- /dev/null +++ b/sources/pyside6/tests/QtGui/qpainter_test.py @@ -0,0 +1,117 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import QPainter, QLinearGradient +from PySide6.QtCore import QLine, QLineF, QPoint, QPointF, QRect, QRectF, Qt + +class QPainterDrawText(unittest.TestCase): + + def setUp(self): + self.painter = QPainter() + self.text = 'teste!' + + def tearDown(self): + del self.text + del self.painter + + def testDrawText(self): + # bug #254 + rect = self.painter.drawText(100, 100, 100, 100, + Qt.AlignCenter | Qt.TextWordWrap, + self.text) + self.assertTrue(isinstance(rect, QRect)) + + def testDrawTextWithRect(self): + # bug #225 + rect = QRect(100, 100, 100, 100) + newRect = self.painter.drawText(rect, Qt.AlignCenter | Qt.TextWordWrap, + self.text) + + self.assertTrue(isinstance(newRect, QRect)) + + def testDrawTextWithRectF(self): + '''QPainter.drawText(QRectF, ... ,QRectF*) inject code''' + rect = QRectF(100, 52.3, 100, 100) + newRect = self.painter.drawText(rect, Qt.AlignCenter | Qt.TextWordWrap, + self.text) + + self.assertTrue(isinstance(newRect, QRectF)) + + def testDrawOverloads(self): + '''Calls QPainter.drawLines overloads, if something is + wrong Exception and chaos ensues. Bug #395''' + self.painter.drawLines([QLine(QPoint(0,0), QPoint(1,1))]) + self.painter.drawLines([QPoint(0,0), QPoint(1,1)]) + self.painter.drawLines([QPointF(0,0), QPointF(1,1)]) + self.painter.drawLines([QLineF(QPointF(0,0), QPointF(1,1))]) + self.painter.drawPoints([QPoint(0,0), QPoint(1,1)]) + self.painter.drawPoints([QPointF(0,0), QPointF(1,1)]) + self.painter.drawConvexPolygon([QPointF(10.0, 80.0), + QPointF(20.0, 10.0), + QPointF(80.0, 30.0), + QPointF(90.0, 70.0)]) + self.painter.drawConvexPolygon([QPoint(10.0, 80.0), + QPoint(20.0, 10.0), + QPoint(80.0, 30.0), + QPoint(90.0, 70.0)]) + self.painter.drawPolygon([QPointF(10.0, 80.0), + QPointF(20.0, 10.0), + QPointF(80.0, 30.0), + QPointF(90.0, 70.0)]) + self.painter.drawPolygon([QPoint(10.0, 80.0), + QPoint(20.0, 10.0), + QPoint(80.0, 30.0), + QPoint(90.0, 70.0)]) + self.painter.drawPolyline([QPointF(10.0, 80.0), + QPointF(20.0, 10.0), + QPointF(80.0, 30.0), + QPointF(90.0, 70.0)]) + self.painter.drawPolyline([QPoint(10.0, 80.0), + QPoint(20.0, 10.0), + QPoint(80.0, 30.0), + QPoint(90.0, 70.0)]) + +class SetBrushWithOtherArgs(unittest.TestCase): + '''Using qpainter.setBrush with args other than QBrush''' + + def testSetBrushGradient(self): + painter = QPainter() + gradient = QLinearGradient(0, 0, 0, 0) + painter.setBrush(gradient) + +if __name__ == '__main__': + unittest.main() + diff --git a/sources/pyside6/tests/QtGui/qpdfwriter_test.py b/sources/pyside6/tests/QtGui/qpdfwriter_test.py new file mode 100644 index 000000000..6e567a48e --- /dev/null +++ b/sources/pyside6/tests/QtGui/qpdfwriter_test.py @@ -0,0 +1,54 @@ +############################################################################# +## +## Copyright (C) 2017 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from helper.usesqapplication import UsesQApplication +from PySide6.QtGui import QPageLayout, QPageSize, QPdfWriter, QTextDocument +from PySide6.QtCore import QDir, QMarginsF, QTemporaryFile + +class QPdfWriterTest(UsesQApplication): + + def testWrite(self): + temporaryFile = QTemporaryFile(QDir.tempPath() + "/pdfwriter_test_XXXXXX.pdf") + self.assertTrue(temporaryFile.open()) + pdfWriter = QPdfWriter(temporaryFile) + pdfWriter.setPageLayout(QPageLayout(QPageSize(QPageSize.A4), QPageLayout.Portrait, QMarginsF(10, 10, 10, 10))) + doc = QTextDocument("Some text") + doc.print_(pdfWriter) + temporaryFile.close() + self.assertTrue(temporaryFile.size() > 0) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qpixelformat_test.py b/sources/pyside6/tests/QtGui/qpixelformat_test.py new file mode 100644 index 000000000..d9d98ade3 --- /dev/null +++ b/sources/pyside6/tests/QtGui/qpixelformat_test.py @@ -0,0 +1,56 @@ +############################################################################# +## +## Copyright (C) 2017 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$ +## +############################################################################# + +'''Unit test for QPixelFormat''' + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from helper.usesqapplication import UsesQApplication +from PySide6.QtCore import QSize, Qt +from PySide6.QtGui import QColor, QImage, QPixelFormat + +class QPixelFormatTest(UsesQApplication): + def test(self): + image = QImage(QSize(200, 200), QImage.Format_ARGB32) + image.fill(QColor(Qt.red)) + pixelFormat = image.pixelFormat() + print(pixelFormat.greenSize()) + self.assertEqual(pixelFormat.alphaSize(), 8) + self.assertEqual(pixelFormat.redSize(), 8) + self.assertEqual(pixelFormat.greenSize(), 8) + self.assertEqual(pixelFormat.blueSize(), 8) + self.assertEqual(pixelFormat.bitsPerPixel(), 32) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qpixmap_test.py b/sources/pyside6/tests/QtGui/qpixmap_test.py new file mode 100644 index 000000000..aa8ade833 --- /dev/null +++ b/sources/pyside6/tests/QtGui/qpixmap_test.py @@ -0,0 +1,90 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from helper.usesqapplication import UsesQApplication +from PySide6.QtGui import * +from PySide6.QtCore import * + +class QPixmapTest(UsesQApplication): + def testQVariantConstructor(self): + obj = QObject() + pixmap = QPixmap() + obj.setProperty('foo', pixmap) + self.assertEqual(type(obj.property('foo')), QPixmap) + + def testQSizeConstructor(self): + pixmap = QPixmap(QSize(10,20)) + self.assertTrue(pixmap.size().height(), 20) + + def testQStringConstructor(self): + pixmap = QPixmap("Testing!") + + def testQPixmapLoadFromDataWithQFile(self): + f = QFile(os.path.join(os.path.dirname(__file__), 'sample.png')) + self.assertTrue(f.open(QIODevice.ReadOnly)) + data = f.read(f.size()) + f.close() + pixmap = QPixmap() + self.assertTrue(pixmap.loadFromData(data)) + + def testQPixmapLoadFromDataWithPython(self): + data = open(os.path.join(os.path.dirname(__file__),'sample.png'),'rb').read() + pixmap = QPixmap() + self.assertTrue(pixmap.loadFromData(data)) + + +class QPixmapToImage(UsesQApplication): + + def testFilledImage(self): + '''QPixmap.fill + toImage + image.pixel''' + pixmap = QPixmap(100, 200) + pixmap.fill(Qt.red) # Default Qt.white + + self.assertEqual(pixmap.height(), 200) + self.assertEqual(pixmap.width(), 100) + + image = pixmap.toImage() + + self.assertEqual(image.height(), 200) + self.assertEqual(image.width(), 100) + + pixel = image.pixel(10,10) + self.assertEqual(pixel, QColor(Qt.red).rgba()) + + +if __name__ == '__main__': + unittest.main() + diff --git a/sources/pyside6/tests/QtGui/qpixmapcache_test.py b/sources/pyside6/tests/QtGui/qpixmapcache_test.py new file mode 100644 index 000000000..19b5c99ee --- /dev/null +++ b/sources/pyside6/tests/QtGui/qpixmapcache_test.py @@ -0,0 +1,79 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from helper.usesqapplication import UsesQApplication +from PySide6.QtGui import QPixmapCache, QPixmap + + +class QPixmapCacheTest(UsesQApplication): + + def testWithString(self): + pm1 = QPixmap() + ok = QPixmapCache.find('img', pm1) + self.assertFalse(ok) + + self.assertEqual(QPixmapCache.find('img'), None) + + pm2 = QPixmap() + ok = QPixmapCache.insert('img', pm2) + self.assertTrue(ok) + + pm3 = QPixmap() + ok = QPixmapCache.find('img', pm3) + self.assertTrue(ok) + b1 = QPixmapCache.find('img').toImage().bits() + b2 = pm3.toImage().bits() + self.assertEqual(QPixmapCache.find('img').toImage().bits(), pm3.toImage().bits()) + + def testWithKey(self): + pm1 = QPixmap() + ok = QPixmapCache.find(QPixmapCache.Key(), pm1) + self.assertFalse(ok) + + self.assertEqual(QPixmapCache.find(QPixmapCache.Key()), None) + + pm2 = QPixmap() + key = QPixmapCache.insert(pm2) + + pm3 = QPixmap() + ok = QPixmapCache.find(key, pm3) + self.assertTrue(ok) + + self.assertEqual(QPixmapCache.find(key).toImage().bits(), pm3.toImage().bits()) + +if __name__ == '__main__': + unittest.main() + diff --git a/sources/pyside6/tests/QtGui/qpolygonf_test.py b/sources/pyside6/tests/QtGui/qpolygonf_test.py new file mode 100644 index 000000000..df2586b75 --- /dev/null +++ b/sources/pyside6/tests/QtGui/qpolygonf_test.py @@ -0,0 +1,66 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtCore import QPoint, QPointF +from PySide6.QtGui import QPolygon, QPolygonF + + +class QPolygonFNotIterableTest(unittest.TestCase): + """Test if a QPolygonF is iterable""" + + def testIt(self): + points = [] + for i in range(0, 4): + points.append(QPointF(float(i), float(i))) + + p = QPolygonF(points) + self.assertEqual(len(p), 4) + + i = 0 + for point in p: + self.assertEqual(int(point.x()), i) + self.assertEqual(int(point.y()), i) + i += 1 + + def testPolygonShiftOperators(self): + p = QPolygon() + self.assertEqual(len(p), 0) + p << QPoint(10, 20) << QPoint(20, 30) << [QPoint(20, 30), QPoint(40, 50)] + self.assertEqual(len(p), 4) + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qradialgradient_test.py b/sources/pyside6/tests/QtGui/qradialgradient_test.py new file mode 100644 index 000000000..92ed0e91c --- /dev/null +++ b/sources/pyside6/tests/QtGui/qradialgradient_test.py @@ -0,0 +1,63 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import QRadialGradient +from PySide6.QtCore import QPointF + +class QRadialGradientConstructor(unittest.TestCase): + def _compare(self, qptf, tpl): + self.assertEqual((qptf.x(), qptf.y()), tpl) + + def _assertValues(self, grad): + self._compare(grad.center(), (1.0, 2.0)) + self._compare(grad.focalPoint(), (3.0, 4.0)) + self.assertEqual(grad.radius(), 5.0) + + def testAllInt(self): + grad = QRadialGradient(1, 2, 5, 3, 4) + self._assertValues(grad) + + def testQPointF(self): + grad = QRadialGradient(QPointF(1, 2), 5, QPointF(3, 4)) + self._assertValues(grad) + + def testSetQPointF(self): + grad = QRadialGradient() + grad.setCenter(QPointF(1, 2)) + self._compare(grad.center(), (1.0, 2.0)) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qrasterwindow_test.py b/sources/pyside6/tests/QtGui/qrasterwindow_test.py new file mode 100644 index 000000000..5e3357151 --- /dev/null +++ b/sources/pyside6/tests/QtGui/qrasterwindow_test.py @@ -0,0 +1,92 @@ +############################################################################# +## +## Copyright (C) 2017 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$ +## +############################################################################# + +'''Unit test for QBackingStore, QRasterWindow and QStaticText''' + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from helper.usesqapplication import UsesQApplication +from PySide6.QtCore import QEvent, QPoint, QRect, QSize, QTimer, Qt +from PySide6.QtGui import QColor, QBackingStore, QPaintDevice, QPainter, QWindow, QPaintDeviceWindow, QRasterWindow, QRegion, QStaticText + +# QWindow rendering via QBackingStore +class TestBackingStoreWindow(QWindow): + def __init__(self): + super(TestBackingStoreWindow, self).__init__() + self.backingStore = QBackingStore(self) + self.text = QStaticText("BackingStoreWindow") + + def event(self, event): + if event.type() == QEvent.Resize: + self.backingStore.resize(self.size()) + self.render() + elif event.type() == QEvent.UpdateRequest or event.type() == QEvent.Expose: + self.backingStore.flush(QRegion(QRect(QPoint(0, 0), self.size()))) + + return QWindow.event(self, event) + + def render(self): + clientRect = QRect(QPoint(0, 0), self.size()) + painter = QPainter(self.backingStore.paintDevice()) + painter.fillRect(clientRect, QColor(Qt.green)) + painter.drawStaticText(QPoint(10, 10), self.text) + +# Window using convenience class QRasterWindow +class TestRasterWindow(QRasterWindow): + def __init__(self): + super(TestRasterWindow, self).__init__() + self.text = QStaticText("QRasterWindow") + + def paintEvent(self, event): + clientRect = QRect(QPoint(0, 0), self.size()) + painter = QPainter(self) + painter.fillRect(clientRect, QColor(Qt.red)) + painter.drawStaticText(QPoint(10, 10), self.text) + +class QRasterWindowTest(UsesQApplication): + def test(self): + rasterWindow = TestRasterWindow() + rasterWindow.setFramePosition(QPoint(100, 100)) + rasterWindow.resize(QSize(400, 400)) + rasterWindow.show() + backingStoreWindow = TestBackingStoreWindow() + backingStoreWindow.setFramePosition(QPoint(600, 100)) + backingStoreWindow.resize(QSize(400, 400)) + backingStoreWindow.show() + + QTimer.singleShot(100, self.app.quit) + self.app.exec_() + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qregion_test.py b/sources/pyside6/tests/QtGui/qregion_test.py new file mode 100644 index 000000000..b6614c9c1 --- /dev/null +++ b/sources/pyside6/tests/QtGui/qregion_test.py @@ -0,0 +1,54 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import QRegion +from PySide6.QtCore import QPoint +from helper.usesqapplication import UsesQApplication + +class QRegionTest(UsesQApplication): + + def testFunctionUnit(self): + r = QRegion(0, 0, 10, 10) + r2 = QRegion(5, 5, 10, 10) + + ru = r.united(r2) + self.assertTrue(ru.contains(QPoint(0,0))) + self.assertTrue(ru.contains(QPoint(5,5))) + self.assertTrue(ru.contains(QPoint(10,10))) + self.assertTrue(ru.contains(QPoint(14,14))) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qstylehints_test.py b/sources/pyside6/tests/QtGui/qstylehints_test.py new file mode 100644 index 000000000..f1afc8f3f --- /dev/null +++ b/sources/pyside6/tests/QtGui/qstylehints_test.py @@ -0,0 +1,48 @@ +############################################################################# +## +## Copyright (C) 2017 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$ +## +############################################################################# + +'''Unit test for QStyleHints''' + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from helper.usesqapplication import UsesQApplication +from PySide6.QtGui import QStyleHints + +class QStyleHintsTest(UsesQApplication): + def test(self): + styleHints = self.app.styleHints() + self.assertTrue(styleHints.startDragDistance() > 0) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qtextdocument_functions.py b/sources/pyside6/tests/QtGui/qtextdocument_functions.py new file mode 100644 index 000000000..45e74c3ec --- /dev/null +++ b/sources/pyside6/tests/QtGui/qtextdocument_functions.py @@ -0,0 +1,50 @@ +############################################################################# +## +## Copyright (C) 2019 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import Qt + + +class QTextDocumentFunctions(unittest.TestCase): + + def testFunctions(self): + self.assertFalse(Qt.mightBeRichText('bla')) + self.assertTrue(Qt.mightBeRichText('<html><head/><body><p>bla</p></body></html>')) + html = Qt.convertFromPlainText("A & B", Qt.WhiteSpaceNormal) + self.assertEqual(html, '<p>A & B</p>') + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qtextdocument_undoredo_test.py b/sources/pyside6/tests/QtGui/qtextdocument_undoredo_test.py new file mode 100644 index 000000000..03e0aa3b7 --- /dev/null +++ b/sources/pyside6/tests/QtGui/qtextdocument_undoredo_test.py @@ -0,0 +1,64 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import QTextDocument, QTextCursor + +class QTextDocumentTest(unittest.TestCase): + + def testUndoRedo(self): + text = 'foobar' + doc = QTextDocument(text) + + self.assertFalse(doc.isRedoAvailable()) + self.assertTrue(doc.isUndoAvailable()) + self.assertEqual(doc.toPlainText(), text) + + cursor = QTextCursor(doc) + doc.undo(cursor) + + self.assertTrue(doc.isRedoAvailable()) + self.assertFalse(doc.isUndoAvailable()) + self.assertEqual(doc.toPlainText(), '') + + doc.redo(cursor) + + self.assertFalse(doc.isRedoAvailable()) + self.assertTrue(doc.isUndoAvailable()) + self.assertEqual(doc.toPlainText(), text) + +if __name__ == '__main__': + unittest.main() + diff --git a/sources/pyside6/tests/QtGui/qtextdocumentwriter_test.py b/sources/pyside6/tests/QtGui/qtextdocumentwriter_test.py new file mode 100644 index 000000000..fdf2385aa --- /dev/null +++ b/sources/pyside6/tests/QtGui/qtextdocumentwriter_test.py @@ -0,0 +1,54 @@ +############################################################################# +## +## Copyright (C) 2017 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import QTextDocumentWriter, QTextDocument +from PySide6.QtCore import QBuffer + + +class QTextDocumentWriterTest(unittest.TestCase): + + def testWrite(self): + text = 'foobar' + doc = QTextDocument(text) + b = QBuffer() + b.open(QBuffer.ReadWrite) + writer = QTextDocumentWriter(b, bytes("plaintext", "UTF-8")); + writer.write(doc); + b.close() + self.assertEqual(b.buffer(), text) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/qtextline_test.py b/sources/pyside6/tests/QtGui/qtextline_test.py new file mode 100644 index 000000000..16e3794ce --- /dev/null +++ b/sources/pyside6/tests/QtGui/qtextline_test.py @@ -0,0 +1,56 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtGui import QTextLayout +from helper.usesqapplication import UsesQApplication + +class QTextLineTest(UsesQApplication): + + def testCursorToX(self): + textLayout = QTextLayout() + textLayout.beginLayout() + line = textLayout.createLine() + self.assertTrue(line.isValid()) + x, cursorPos = line.cursorToX(0) + self.assertEqual(type(x), float) + self.assertEqual(type(cursorPos), int) + x, cursorPos = line.cursorToX(1) + self.assertEqual(type(x), float) + self.assertEqual(type(cursorPos), int) + +if __name__ == '__main__': + unittest.main() + diff --git a/sources/pyside6/tests/QtGui/qtransform_test.py b/sources/pyside6/tests/QtGui/qtransform_test.py new file mode 100644 index 000000000..c2d3b9b6c --- /dev/null +++ b/sources/pyside6/tests/QtGui/qtransform_test.py @@ -0,0 +1,108 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from PySide6.QtCore import QPointF +from PySide6.QtGui import QTransform, QPolygonF, QPolygonF + +class QTransformTest(unittest.TestCase): + + def testMap(self): + transform = QTransform() + values = (10.0, 20.0) + tx, ty = transform.map(*values) + self.assertTrue(isinstance(tx, float)) + self.assertTrue(isinstance(ty, float)) + self.assertEqual((tx, ty), values) + + def testquadToQuad(self): + q1 = QPolygonF() + q1.append(QPointF(10.0, 10.0)) + q1.append(QPointF(20.0, 10.0)) + q1.append(QPointF(10.0, -10.0)) + q1.append(QPointF(20.0, -10.0)) + + q2 = QPolygonF() + q2.append(QPointF(20.0, 20.0)) + q2.append(QPointF(30.0, 20.0)) + q2.append(QPointF(20.0, -20.0)) + q2.append(QPointF(30.0, -20.0)) + + t1 = QTransform() + r1 = QTransform.quadToQuad(q1, q2, t1) + r2 = QTransform.quadToQuad(q1, q2) + + self.assertTrue(r1) + self.assertTrue(r2) + + self.assertEqual(t1, r2) + + def testquadToSquare(self): + q1 = QPolygonF() + q1.append(QPointF(10.0, 10.0)) + q1.append(QPointF(20.0, 10.0)) + q1.append(QPointF(10.0, -10.0)) + q1.append(QPointF(20.0, -10.0)) + + t1 = QTransform() + r1 = QTransform.quadToSquare(q1, t1) + r2 = QTransform.quadToSquare(q1) + + self.assertTrue(r1) + self.assertTrue(r2) + + self.assertEqual(t1, r2) + + + def testsquareToQuad(self): + q1 = QPolygonF() + q1.append(QPointF(10.0, 10.0)) + q1.append(QPointF(20.0, 10.0)) + q1.append(QPointF(10.0, -10.0)) + q1.append(QPointF(20.0, -10.0)) + + t1 = QTransform() + r1 = QTransform.squareToQuad(q1, t1) + r2 = QTransform.squareToQuad(q1) + + self.assertTrue(r1) + self.assertTrue(r2) + + self.assertEqual(t1, r2) + + +if __name__ == "__main__": + unittest.main() + diff --git a/sources/pyside6/tests/QtGui/repr_test.py b/sources/pyside6/tests/QtGui/repr_test.py new file mode 100644 index 000000000..d7c4693e5 --- /dev/null +++ b/sources/pyside6/tests/QtGui/repr_test.py @@ -0,0 +1,114 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +import PySide6 +from PySide6.QtCore import QPoint +from PySide6.QtGui import QMatrix2x2, QMatrix2x3, QMatrix2x4 +from PySide6.QtGui import QMatrix3x2, QMatrix3x3, QMatrix3x4 +from PySide6.QtGui import QMatrix4x2, QMatrix4x3, QMatrix4x4 +from PySide6.QtGui import QVector2D, QVector3D, QVector4D +from PySide6.QtGui import QColor, QTransform, QKeySequence, QQuaternion +from PySide6.QtGui import QPolygon + +class ReprCopyHelper: + def testCopy(self): + copy = eval(self.original.__repr__()) + self.assertTrue(copy is not self.original) + self.assertEqual(copy, self.original) + +class QTransformReprCopy(ReprCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QTransform(1, 2, 3, 4, 5, 6, 7, 8, 9) + +class QQuaternionReprCopy(ReprCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QQuaternion(1, 2, 3, 4) + +class QVector2DReprCopy(ReprCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QVector2D(1, 2) + +class QVector3DReprCopy(ReprCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QVector3D(1, 2, 3) + +class QVector4DReprCopy(ReprCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QVector4D(1, 2, 3, 4) + + +# Avoid these tests until get gcc fixed +# Related bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43247 +""" +class QMatrix2x2ReprCopy(ReprCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix2x2([1, 2, 3, 4]) + +class QMatrix2x3ReprCopy(ReprCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix2x3([1, 2, 3, 4, 5, 6]) + +class QMatrix2x4ReprCopy(ReprCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix2x4([1, 2, 3, 4, 5, 6, 7, 8]) + +class QMatrix3x2ReprCopy(ReprCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix3x2([1, 2, 3, 4, 5, 6]) + +class QMatrix3x3ReprCopy(ReprCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix3x3([1, 2, 3, 4, 5, 6, 7, 8, 9]) + +class QMatrix3x4ReprCopy(ReprCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix3x4([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) + +class QMatrix4x2ReprCopy(ReprCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix4x2([1, 2, 3, 4, 5, 6, 7, 8]) + +class QMatrix4x3ReprCopy(ReprCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix4x3([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]) + +class QMatrix4x4ReprCopy(ReprCopyHelper, unittest.TestCase): + def setUp(self): + self.original = QMatrix4x4([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]) +""" + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside6/tests/QtGui/sample.png b/sources/pyside6/tests/QtGui/sample.png Binary files differnew file mode 100644 index 000000000..60450f0dc --- /dev/null +++ b/sources/pyside6/tests/QtGui/sample.png diff --git a/sources/pyside6/tests/QtGui/timed_app_and_patching_test.py b/sources/pyside6/tests/QtGui/timed_app_and_patching_test.py new file mode 100644 index 000000000..8646151b1 --- /dev/null +++ b/sources/pyside6/tests/QtGui/timed_app_and_patching_test.py @@ -0,0 +1,66 @@ +############################################################################# +## +## 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$ +## +############################################################################# + +import os +import sys +import unittest + +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from init_paths import init_test_paths +init_test_paths(False) + +from helper.timedqapplication import TimedQApplication +from PySide6.support import deprecated +from PySide6.support.signature import importhandler +from PySide6 import QtGui + + +class TestTimedApp(TimedQApplication): + '''Simple test case for TimedQApplication''' + + def testFoo(self): + #Simple test of TimedQApplication + self.app.exec_() + + +def fix_for_QtGui(QtGui): + QtGui.something = 42 + +class TestPatchingFramework(unittest.TestCase): + """Simple test that verifies that deprecated.py works""" + + deprecated.fix_for_QtGui = fix_for_QtGui + + def test_patch_works(self): + something = "something" + self.assertFalse(hasattr(QtGui, something)) + importhandler.finish_import(QtGui) + self.assertTrue(hasattr(QtGui, something)) + +if __name__ == '__main__': + unittest.main() |