diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-05-18 16:45:35 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2018-05-18 16:45:35 +0200 |
commit | 3f8c8702ea295f39357e7c66f46e5138f56bcc9f (patch) | |
tree | 9ca65a7f94d544ba4b36f239c4a48852ad8a7b09 /sources/pyside2/tests/QtCore | |
parent | 5fce76074c01e52a22151133a1e3a2cf71cfe535 (diff) | |
parent | df1a619d65d8e5db91f3c8db46b00872b461e334 (diff) |
Merge remote-tracking branch 'origin/5.9' into 5.11
Change-Id: I20cf741f5b07426ad5113eb8c52f144102c331ce
Diffstat (limited to 'sources/pyside2/tests/QtCore')
8 files changed, 263 insertions, 1 deletions
diff --git a/sources/pyside2/tests/QtCore/CMakeLists.txt b/sources/pyside2/tests/QtCore/CMakeLists.txt index 3a08cb45b..dc7aa3ddd 100644 --- a/sources/pyside2/tests/QtCore/CMakeLists.txt +++ b/sources/pyside2/tests/QtCore/CMakeLists.txt @@ -53,6 +53,7 @@ PYSIDE_TEST(qbytearray_test.py) PYSIDE_TEST(qcollator_test.py) PYSIDE_TEST(qcommandlineparser_test.py) PYSIDE_TEST(qcoreapplication_instance_test.py) +PYSIDE_TEST(qcoreapplication_test.py) PYSIDE_TEST(qdatastream_test.py) PYSIDE_TEST(qdatetime_test.py) PYSIDE_TEST(qdate_test.py) @@ -66,6 +67,8 @@ PYSIDE_TEST(qflags_test.py) PYSIDE_TEST(qinstallmsghandler_test.py) PYSIDE_TEST(qlinef_test.py) PYSIDE_TEST(qlocale_test.py) +PYSIDE_TEST(qlockfile_test.py) +PYSIDE_TEST(qmessageauthenticationcode_test.py) PYSIDE_TEST(qmetaobject_test.py) PYSIDE_TEST(qmimedatabase_test.py) PYSIDE_TEST(qmodelindex_internalpointer_test.py) @@ -81,6 +84,7 @@ PYSIDE_TEST(qobject_protected_methods_test.py) PYSIDE_TEST(qobject_test.py) PYSIDE_TEST(qobject_timer_event_test.py) PYSIDE_TEST(qobject_tr_as_instance_test.py) +PYSIDE_TEST(qoperatingsystemversion_test.py) PYSIDE_TEST(qpoint_test.py) PYSIDE_TEST(qprocess_test.py) PYSIDE_TEST(qproperty_decorator.py) @@ -90,6 +94,7 @@ PYSIDE_TEST(qregularexpression_test.py) PYSIDE_TEST(qresource_test.py) PYSIDE_TEST(qsize_test.py) PYSIDE_TEST(qslot_object_test.py) +PYSIDE_TEST(qsocketnotifier_test.py) PYSIDE_TEST(qsrand_test.py) PYSIDE_TEST(qstandardpaths_test.py) PYSIDE_TEST(qstatemachine_test.py) diff --git a/sources/pyside2/tests/QtCore/blocking_signals_test.py b/sources/pyside2/tests/QtCore/blocking_signals_test.py index 769820355..2f8b95b27 100644 --- a/sources/pyside2/tests/QtCore/blocking_signals_test.py +++ b/sources/pyside2/tests/QtCore/blocking_signals_test.py @@ -32,7 +32,7 @@ import unittest import os from tempfile import mkstemp -from PySide2.QtCore import QObject, SIGNAL, QFile +from PySide2.QtCore import QObject, SIGNAL, QFile, QSignalBlocker class TestSignalsBlockedBasic(unittest.TestCase): '''Basic test case for signalsBlocked''' @@ -46,6 +46,15 @@ class TestSignalsBlockedBasic(unittest.TestCase): self.assertTrue(not obj.blockSignals(True)) self.assertTrue(obj.signalsBlocked()) self.assertTrue(obj.blockSignals(False)) + blocker = QSignalBlocker(obj) + self.assertTrue(obj.signalsBlocked()) + blocker.unblock() + self.assertTrue(not obj.signalsBlocked()) + blocker.reblock() + self.assertTrue(obj.signalsBlocked()) + del blocker + self.assertTrue(not obj.signalsBlocked()) + class TestSignalsBlocked(unittest.TestCase): '''Test case to check if the signals are really blocked''' diff --git a/sources/pyside2/tests/QtCore/qabstractitemmodel_test.py b/sources/pyside2/tests/QtCore/qabstractitemmodel_test.py index 34c15665e..70b610c34 100644 --- a/sources/pyside2/tests/QtCore/qabstractitemmodel_test.py +++ b/sources/pyside2/tests/QtCore/qabstractitemmodel_test.py @@ -54,6 +54,15 @@ class TestQModelIndexInternalPointer(unittest.TestCase): idx = QPersistentModelIndex() m.span(idx) + def testQIdentityProxyModel(self): + sourceModel = QStringListModel(['item1', 'item2']) + sourceIndex = sourceModel.index(0, 0) + sourceData = str(sourceModel.data(sourceIndex, Qt.DisplayRole)) + proxyModel = QIdentityProxyModel() + proxyModel.setSourceModel(sourceModel) + proxyIndex = proxyModel.mapFromSource(sourceIndex) + proxyData = str(proxyModel.data(proxyIndex, Qt.DisplayRole)) + self.assertEqual(sourceData, proxyData) if __name__ == '__main__': unittest.main() diff --git a/sources/pyside2/tests/QtCore/qcoreapplication_test.py b/sources/pyside2/tests/QtCore/qcoreapplication_test.py new file mode 100644 index 000000000..15a905846 --- /dev/null +++ b/sources/pyside2/tests/QtCore/qcoreapplication_test.py @@ -0,0 +1,40 @@ +############################################################################# +## +## 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 unittest + +from PySide2.QtCore import QCoreApplication + +class TestQCoreApplication(unittest.TestCase): + def testNoArguments(self): + app = QCoreApplication() + self.assertIsInstance(app, QCoreApplication) + + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside2/tests/QtCore/qlockfile_test.py b/sources/pyside2/tests/QtCore/qlockfile_test.py new file mode 100644 index 000000000..e943af2b7 --- /dev/null +++ b/sources/pyside2/tests/QtCore/qlockfile_test.py @@ -0,0 +1,55 @@ +#!/usr/bin/python + +############################################################################# +## +## 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$ +## +############################################################################# + +'''Test cases for QLockFile''' + +import os, unittest + +from PySide2.QtCore import QDir, QLockFile, QCoreApplication + +class TestQMessageAuthenticationCode (unittest.TestCase): + + def setUp(self): + pid = QCoreApplication.applicationPid() + self._fileName = "{}/pqlockfiletest{}.tmp".format(QDir.tempPath(), pid) + + def tearDown(self): + if (os.path.exists(self._fileName)): + os.remove(self._fileName) + + def test(self): + # Merely exercise the API, no locking against another processes. + lockFile = QLockFile(self._fileName) + self.assertTrue(lockFile.lock()) + self.assertTrue(lockFile.isLocked()) + lockFile.unlock() + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside2/tests/QtCore/qmessageauthenticationcode_test.py b/sources/pyside2/tests/QtCore/qmessageauthenticationcode_test.py new file mode 100644 index 000000000..392e6f052 --- /dev/null +++ b/sources/pyside2/tests/QtCore/qmessageauthenticationcode_test.py @@ -0,0 +1,45 @@ +#!/usr/bin/python + +############################################################################# +## +## 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$ +## +############################################################################# + +'''Test cases for QMessageAuthenticationCode''' + +import unittest + +from PySide2.QtCore import QCryptographicHash, QMessageAuthenticationCode + +class TestQMessageAuthenticationCode (unittest.TestCase): + def test(self): + code = QMessageAuthenticationCode(QCryptographicHash.Sha1, 'bla') + result = code.result() + self.assertTrue(result.size() > 0) + print(result.toHex()) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside2/tests/QtCore/qoperatingsystemversion_test.py b/sources/pyside2/tests/QtCore/qoperatingsystemversion_test.py new file mode 100644 index 000000000..82c571d18 --- /dev/null +++ b/sources/pyside2/tests/QtCore/qoperatingsystemversion_test.py @@ -0,0 +1,40 @@ +############################################################################# +## +## 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 unittest +from PySide2.QtCore import QOperatingSystemVersion + +class TestQOperatingSystemVersion(unittest.TestCase): + def test(self): + ov = QOperatingSystemVersion.current() + name = "{} v{}.{}.{}".format(ov.name(), ov.majorVersion(), + ov.minorVersion(), ov.microVersion()) + print(name) + +if __name__ == '__main__': + unittest.main() diff --git a/sources/pyside2/tests/QtCore/qsocketnotifier_test.py b/sources/pyside2/tests/QtCore/qsocketnotifier_test.py new file mode 100644 index 000000000..0a9b78af3 --- /dev/null +++ b/sources/pyside2/tests/QtCore/qsocketnotifier_test.py @@ -0,0 +1,59 @@ +#!/usr/bin/python + +############################################################################# +## +## 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$ +## +############################################################################# + +'''Unit tests for QUuid''' + +import unittest + +from PySide2.QtWidgets import QApplication +from PySide2.QtCore import QSocketNotifier +import socket +import sys +import os + +class QSocketNotifierTest(unittest.TestCase): + def testClass(self): + app = QApplication([]) + # socketpair is not available on Windows + if os.name != "nt": + w_sock, r_sock = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM) + + self.assertIsInstance(r_sock.fileno(), int) + + notifier = QSocketNotifier(r_sock.fileno(), QSocketNotifier.Read) + + self.assertIsNotNone(notifier) + + w_sock.close() + r_sock.close() + + +if __name__ == '__main__': + unittest.main() |