From 1e4cad1d99d873e0cab831b11829adb175324a5e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 8 May 2018 14:26:45 +0200 Subject: Add more QtCore classes Add QIdentityProxyModel, QLockFile, QMessageAuthenticationCode, OperatingSystemVersion and QSignalBlocker. Task-number: PYSIDE-487 Change-Id: I680c3d175394e9d560152a38195d015fc6abb7fa Reviewed-by: Alexandru Croitor --- sources/pyside2/PySide2/QtCore/CMakeLists.txt | 5 ++ .../PySide2/QtCore/typesystem_core_common.xml | 9 ++++ sources/pyside2/tests/QtCore/CMakeLists.txt | 3 ++ .../pyside2/tests/QtCore/blocking_signals_test.py | 11 ++++- .../tests/QtCore/qabstractitemmodel_test.py | 9 ++++ sources/pyside2/tests/QtCore/qlockfile_test.py | 55 ++++++++++++++++++++++ .../QtCore/qmessageauthenticationcode_test.py | 45 ++++++++++++++++++ .../tests/QtCore/qoperatingsystemversion_test.py | 40 ++++++++++++++++ 8 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 sources/pyside2/tests/QtCore/qlockfile_test.py create mode 100644 sources/pyside2/tests/QtCore/qmessageauthenticationcode_test.py create mode 100644 sources/pyside2/tests/QtCore/qoperatingsystemversion_test.py diff --git a/sources/pyside2/PySide2/QtCore/CMakeLists.txt b/sources/pyside2/PySide2/QtCore/CMakeLists.txt index d29c0dfab..f086a3f3d 100644 --- a/sources/pyside2/PySide2/QtCore/CMakeLists.txt +++ b/sources/pyside2/PySide2/QtCore/CMakeLists.txt @@ -55,6 +55,7 @@ ${QtCore_GEN_DIR}/qfinalstate_wrapper.cpp ${QtCore_GEN_DIR}/qgenericargument_wrapper.cpp ${QtCore_GEN_DIR}/qgenericreturnargument_wrapper.cpp ${QtCore_GEN_DIR}/qhistorystate_wrapper.cpp +${QtCore_GEN_DIR}/qidentityproxymodel_wrapper.cpp ${QtCore_GEN_DIR}/qiodevice_wrapper.cpp ${QtCore_GEN_DIR}/qjsonarray_wrapper.cpp ${QtCore_GEN_DIR}/qjsondocument_wrapper.cpp @@ -67,8 +68,10 @@ ${QtCore_GEN_DIR}/qlibraryinfo_wrapper.cpp ${QtCore_GEN_DIR}/qline_wrapper.cpp ${QtCore_GEN_DIR}/qlinef_wrapper.cpp ${QtCore_GEN_DIR}/qlocale_wrapper.cpp +${QtCore_GEN_DIR}/qlockfile_wrapper.cpp ${QtCore_GEN_DIR}/qmargins_wrapper.cpp ${QtCore_GEN_DIR}/qmarginsf_wrapper.cpp +${QtCore_GEN_DIR}/qmessageauthenticationcode_wrapper.cpp ${QtCore_GEN_DIR}/qmessagelogcontext_wrapper.cpp ${QtCore_GEN_DIR}/qmetaclassinfo_wrapper.cpp ${QtCore_GEN_DIR}/qmetaenum_wrapper.cpp @@ -83,6 +86,7 @@ ${QtCore_GEN_DIR}/qmodelindex_wrapper.cpp ${QtCore_GEN_DIR}/qmutex_wrapper.cpp ${QtCore_GEN_DIR}/qmutexlocker_wrapper.cpp ${QtCore_GEN_DIR}/qobject_wrapper.cpp +${QtCore_GEN_DIR}/qoperatingsystemversion_wrapper.cpp ${QtCore_GEN_DIR}/qparallelanimationgroup_wrapper.cpp ${QtCore_GEN_DIR}/qpauseanimation_wrapper.cpp ${QtCore_GEN_DIR}/qpersistentmodelindex_wrapper.cpp @@ -106,6 +110,7 @@ ${QtCore_GEN_DIR}/qsavefile_wrapper.cpp ${QtCore_GEN_DIR}/qsemaphore_wrapper.cpp ${QtCore_GEN_DIR}/qsequentialanimationgroup_wrapper.cpp ${QtCore_GEN_DIR}/qsettings_wrapper.cpp +${QtCore_GEN_DIR}/qsignalblocker_wrapper.cpp ${QtCore_GEN_DIR}/qsignalmapper_wrapper.cpp ${QtCore_GEN_DIR}/qsignaltransition_wrapper.cpp ${QtCore_GEN_DIR}/qsize_wrapper.cpp diff --git a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml index f8259063d..b0c4da4ee 100644 --- a/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml +++ b/sources/pyside2/PySide2/QtCore/typesystem_core_common.xml @@ -1974,6 +1974,11 @@ + + + + + @@ -2123,6 +2128,7 @@ + @@ -2953,6 +2959,9 @@ + + + diff --git a/sources/pyside2/tests/QtCore/CMakeLists.txt b/sources/pyside2/tests/QtCore/CMakeLists.txt index bc83aec7a..4efee6ebd 100644 --- a/sources/pyside2/tests/QtCore/CMakeLists.txt +++ b/sources/pyside2/tests/QtCore/CMakeLists.txt @@ -66,6 +66,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 +83,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) 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 66c178949..3f321c7d6 100644 --- a/sources/pyside2/tests/QtCore/qabstractitemmodel_test.py +++ b/sources/pyside2/tests/QtCore/qabstractitemmodel_test.py @@ -50,6 +50,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/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() -- cgit v1.2.3