From 4023ab3862eee7ca3084dd83ca76fba11b5db46b Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Tue, 27 Mar 2018 15:16:03 +0200 Subject: Add default return value to pythonTypeIsValueType When a class inherits from two base classes, Shiboken sets the converter of the newly created SbkObject to 0 (SbkObjectTypeTpNew), and handle the multiple inheritance in a different way. When any SbkObject try to release its ownership, it first verify if the ownership is already on the C++ side by checking the attribute hasOwership and also if the converter is a ValueType. The later fails if the converter is null, so a default value (false) was added. A test case using deleteLater() was included, which uses the releaseOwnership method internally. Task-number: PYSIDE-11 Change-Id: I34fba0d3e5d28b99b49a183ed08e977a311da632 Reviewed-by: Friedemann Kleint --- .../pyside2/tests/QtCore/qobject_inherits_test.py | 37 +++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) (limited to 'sources/pyside2/tests') diff --git a/sources/pyside2/tests/QtCore/qobject_inherits_test.py b/sources/pyside2/tests/QtCore/qobject_inherits_test.py index 8c4c797a4..1d089776b 100644 --- a/sources/pyside2/tests/QtCore/qobject_inherits_test.py +++ b/sources/pyside2/tests/QtCore/qobject_inherits_test.py @@ -29,8 +29,12 @@ '''Test cases for QObject methods''' import unittest +import sys -from PySide2.QtCore import QObject +from PySide2.QtCore import QObject, QTimer +from PySide2.QtWidgets import QApplication, QLabel, QVBoxLayout + +is_alive = None class InheritsCase(unittest.TestCase): '''Test case for QObject.inherits''' @@ -87,5 +91,36 @@ class InheritsCase(unittest.TestCase): self.assertRaises(TypeError, declareClass) + # PYSIDE-11: + # The takeOwnership() method was relying that the SbkObject + # had a converter, which it's not the case when multiple + # inheritance is used. + # The deleteLater() method uses the takeOwnership() to give + # control of the object to C++, so it can be remove once + # the destructor is called. + # The solution was to add a default case when the object + # is null under the pythonTypeIsValueType() method in shiboken. + def testDeleteMultipleInheritance(self): + app = QApplication(sys.argv) + class DerivedLabel(QLabel, QObject): + def __del__(self): + global is_alive + is_alive = False + + global is_alive + child = DerivedLabel('Hello') + is_alive = True + parent = QVBoxLayout() + parent.addWidget(child) + parent.removeWidget(child) + child.deleteLater() + self.assertTrue(is_alive) + del child + self.assertTrue(is_alive) + QTimer.singleShot(100, app.quit) + app.exec_() + self.assertFalse(is_alive) + + if __name__ == '__main__': unittest.main() -- cgit v1.2.3 From a89690409972501741c846ac8ad4a499f2982809 Mon Sep 17 00:00:00 2001 From: Christian Tismer Date: Fri, 23 Mar 2018 19:54:42 +0100 Subject: fix more qApp crashes When building PySide with a debug Python, a lot more problems become visible. They were triggered by some malicious ordering of the shutdown code, which must come *after* the refcounts of the variables are adjusted. The initial issue PYSIDE-585 was caused because the shutdown code is not only used for every created Q*Application, but also for the module shutdown, which deletes qApp_contents too often. Instead of special-casing that or adding some refcount, it was much more intuitive in that context to set qApp_content's refcount to the same value as Py_None, which also is not supposed to be garbage collected. Btw., the reason for the error message is that Py_None has it, too. When we set qApp_content's type to Py_None's type, it inherits the protection code that prevents someone from garbage collecting Py_None. Task-number: PYSIDE-585 Change-Id: I4af9de1192730f06054a5aca099a32e2392e367d Reviewed-by: Friedemann Kleint --- sources/pyside2/tests/QtWidgets/CMakeLists.txt | 1 + sources/pyside2/tests/QtWidgets/qapp_issue_585.py | 68 +++++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 sources/pyside2/tests/QtWidgets/qapp_issue_585.py (limited to 'sources/pyside2/tests') diff --git a/sources/pyside2/tests/QtWidgets/CMakeLists.txt b/sources/pyside2/tests/QtWidgets/CMakeLists.txt index fa64d1c3b..c22981251 100644 --- a/sources/pyside2/tests/QtWidgets/CMakeLists.txt +++ b/sources/pyside2/tests/QtWidgets/CMakeLists.txt @@ -82,6 +82,7 @@ PYSIDE_TEST(parent_method_test.py) PYSIDE_TEST(python_properties_test.py) PYSIDE_TEST(qabstracttextdocumentlayout_test.py) PYSIDE_TEST(qaction_test.py) +PYSIDE_TEST(qapp_issue_585.py) PYSIDE_TEST(qapp_test.py) PYSIDE_TEST(qapplication_exit_segfault_test.py) PYSIDE_TEST(qapplication_singleton_test.py) diff --git a/sources/pyside2/tests/QtWidgets/qapp_issue_585.py b/sources/pyside2/tests/QtWidgets/qapp_issue_585.py new file mode 100644 index 000000000..9dd2014c0 --- /dev/null +++ b/sources/pyside2/tests/QtWidgets/qapp_issue_585.py @@ -0,0 +1,68 @@ +############################################################################# +## +## Copyright (C) 2018 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $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$ +## +############################################################################# + +""" +The bug was caused by this commit: +"Support the qApp macro correctly, final version incl. debug" +e30e0c161b2b4d50484314bf006e9e5e8ff6b380 +2017-10-27 + +The bug was first solved by this commit: +"Fix qApp macro refcount" +b811c874dedd14fd8b072bc73761d39255216073 +2018-03-21 + +This test triggers the refcounting bug of qApp, issue PYSIDE-585. +Finally, the real patch included more changes, because another error +was in the ordering of shutdown calls. It was found using the following +Python configuration: + + In Python 3.6 create a directory 'debug' and cd into it. + + ../configure --with-pydebug --prefix=$HOME/pydebug/ --enable-shared + +Then a lot more refcounting errors show up, which are due to a bug in +the code position of the shutdown procedure. +The reason for the initial refcount bug was that the shutdown code is once +more often called than the creation of the qApp wrapper. +Finally, it was easiest and more intuitive to simply make the refcount of +qApp_content equal to that of Py_None, which is also not supposed to be +garbage-collected. + +For some reason, the test does not work as a unittest because it creates +no crash. We leave it this way. +""" + +from PySide2.QtCore import QTimer +from PySide2 import QtWidgets + +app_instance = QtWidgets.QApplication([]) +# If the following line is commented, application doesn't crash on exit anymore. +app_instance2 = app_instance +QTimer.singleShot(0, qApp.quit) +app_instance.exec_() -- cgit v1.2.3 From f93da21b3286db1bf693c26df47a538e581ff908 Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Thu, 29 Mar 2018 11:13:57 +0200 Subject: Transfer ownership of new Widget to QTreeWidget When new widgets were added to a QTreeWidget the ownership was not being transferred. This problem happened when the Widget was being build inside the method call. When trying to show owner-less Widgets inside the Tree, a segfault happened. A test case was added. Task-number: PYSIDE-73 Change-Id: I0f1c3c065ae8ed0a336c8e39b1766f3e8870b54d Reviewed-by: Friedemann Kleint --- sources/pyside2/tests/QtWidgets/CMakeLists.txt | 1 + .../pyside2/tests/QtWidgets/qtreewidget_test.py | 64 ++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 sources/pyside2/tests/QtWidgets/qtreewidget_test.py (limited to 'sources/pyside2/tests') diff --git a/sources/pyside2/tests/QtWidgets/CMakeLists.txt b/sources/pyside2/tests/QtWidgets/CMakeLists.txt index c22981251..0384e0a8d 100644 --- a/sources/pyside2/tests/QtWidgets/CMakeLists.txt +++ b/sources/pyside2/tests/QtWidgets/CMakeLists.txt @@ -122,6 +122,7 @@ PYSIDE_TEST(qtabwidgetclear_test.py) PYSIDE_TEST(qtextedit_test.py) PYSIDE_TEST(qtextedit_signal_test.py) PYSIDE_TEST(qtreeview_test.py) +PYSIDE_TEST(qtreewidget_test.py) PYSIDE_TEST(qtoolbar_test.py) PYSIDE_TEST(qtoolbox_test.py) PYSIDE_TEST(qvariant_test.py) diff --git a/sources/pyside2/tests/QtWidgets/qtreewidget_test.py b/sources/pyside2/tests/QtWidgets/qtreewidget_test.py new file mode 100644 index 000000000..11fa83c5a --- /dev/null +++ b/sources/pyside2/tests/QtWidgets/qtreewidget_test.py @@ -0,0 +1,64 @@ +############################################################################# +## +## Copyright (C) 2018 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $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.QtWidgets import QTreeWidget, QTreeWidgetItem, QPushButton +from helper import UsesQApplication + +class QTreeWidgetTest(UsesQApplication): + + # PYSIDE-73: + # There was a problem when adding items to a QTreeWidget + # when the Widget was being build on the method call instead + # of as a separate variable. + # The problem was there was not ownership transfer, so the + # QTreeWidget did not own the QWidget element + def testSetItemWidget(self): + + treeWidget = QTreeWidget() + treeWidget.setColumnCount(2) + + item = QTreeWidgetItem(['text of column 0', '']) + treeWidget.insertTopLevelItem(0, item) + # Adding QPushButton inside the method + treeWidget.setItemWidget(item, 1, + QPushButton('Push button on column 1')) + + # Getting the widget back + w = treeWidget.itemWidget(treeWidget.itemAt(0,1), 1) + self.assertIsInstance(w, QPushButton) + + p = QPushButton('New independent button') + # Adding QPushButton object from variable + treeWidget.setItemWidget(item, 0, p) + w = treeWidget.itemWidget(treeWidget.itemAt(0,0), 0) + self.assertIsInstance(w, QPushButton) + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3 From b5debb687463f77053344f1e4cd7754275e487b2 Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Fri, 6 Apr 2018 16:28:22 +0200 Subject: Transfer ownership of the header to the QTreeView When using setHeader on a QTreeView, the view needs to take ownership of the header object. Task-number: PYSIDE-227 Change-Id: Ib37c00c098be422c7f0df4a32a6795c267642a41 Reviewed-by: Friedemann Kleint --- sources/pyside2/tests/QtWidgets/qtreeview_test.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'sources/pyside2/tests') diff --git a/sources/pyside2/tests/QtWidgets/qtreeview_test.py b/sources/pyside2/tests/QtWidgets/qtreeview_test.py index a731ddafa..703131ec3 100644 --- a/sources/pyside2/tests/QtWidgets/qtreeview_test.py +++ b/sources/pyside2/tests/QtWidgets/qtreeview_test.py @@ -29,7 +29,9 @@ import unittest from PySide2.QtGui import QStandardItemModel -from PySide2.QtWidgets import QWidget, QTreeView, QVBoxLayout, QStyledItemDelegate +from PySide2.QtWidgets import (QWidget, QTreeView, QVBoxLayout, + QStyledItemDelegate, QHeaderView) +from PySide2.QtCore import Qt from helper import UsesQApplication class Widget(QWidget): @@ -85,5 +87,10 @@ class QWidgetTest(UsesQApplication): t.setItemDelegate(QStyledItemDelegate()) self.assertIsInstance(t.itemDelegate(), QStyledItemDelegate) + def testHeader(self): + tree = QTreeView() + tree.setHeader(QHeaderView(Qt.Horizontal)) + self.assertIsNotNone(tree.header()) + if __name__ == '__main__': unittest.main() -- cgit v1.2.3 From 67d6c85a9dc17fe68ab399e14da73d10a1f9a351 Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Thu, 29 Mar 2018 14:35:28 +0200 Subject: Check default superclass when getting baseClasses Reimplementing a class must respect the closest base class instead of falling back to QObject. By adding a default-superclass argument one can verify that field first when shiboken is getting the base classes. This problem was found by reimplementing QGraphicsObject including methods from one of its parent classes, QGraphicsItem. With this change, the generated wrapper will list all the base classes in `Sbk_QGraphicsObject_Type_bases` leaving QObject at the end, because if not, it will match inmediately. A test case was included. This change doesn't affect other existing tests. Task-number: PYSIDE-86 Change-Id: I6b9a220497b12c8085302a502f8581cc2d3fb11b Reviewed-by: Friedemann Kleint --- sources/pyside2/tests/QtWidgets/CMakeLists.txt | 1 + .../tests/QtWidgets/qgraphicsobjectreimpl_test.py | 76 ++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 sources/pyside2/tests/QtWidgets/qgraphicsobjectreimpl_test.py (limited to 'sources/pyside2/tests') diff --git a/sources/pyside2/tests/QtWidgets/CMakeLists.txt b/sources/pyside2/tests/QtWidgets/CMakeLists.txt index 0384e0a8d..9caf7e365 100644 --- a/sources/pyside2/tests/QtWidgets/CMakeLists.txt +++ b/sources/pyside2/tests/QtWidgets/CMakeLists.txt @@ -93,6 +93,7 @@ PYSIDE_TEST(qdynamic_signal.py) PYSIDE_TEST(qformlayout_test.py) PYSIDE_TEST(qgraphicsitem_test.py) PYSIDE_TEST(qgraphicsitem_isblocked_test.py) +PYSIDE_TEST(qgraphicsobjectreimpl_test.py) PYSIDE_TEST(qgraphicsproxywidget_test.py) PYSIDE_TEST(qgraphicsscene_test.py) PYSIDE_TEST(qimage_test.py) diff --git a/sources/pyside2/tests/QtWidgets/qgraphicsobjectreimpl_test.py b/sources/pyside2/tests/QtWidgets/qgraphicsobjectreimpl_test.py new file mode 100644 index 000000000..fd79ce3aa --- /dev/null +++ b/sources/pyside2/tests/QtWidgets/qgraphicsobjectreimpl_test.py @@ -0,0 +1,76 @@ +############################################################################# +## +## Copyright (C) 2018 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $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 related to QGraphicsItem and subclasses''' + +import unittest + +from PySide2.QtWidgets import QGraphicsObject, QGraphicsWidget +from PySide2.QtCore import QRectF + +from helper import UsesQApplication + +class GObjA(QGraphicsObject): + def paint(self, *args): + pass + + def boundingRect(self): + return QRectF() + + def itemChange(self, *args): + return QGraphicsObject.itemChange(self, *args) + +class GObjB(QGraphicsObject): + def paint(self, *args): + pass + + def boundingRect(self): + return QRectF() + +class QGraphicsObjectReimpl(UsesQApplication): + '''Test case for reimplementing QGraphicsObject''' + + def testReimplementationTypes(self): + w = QGraphicsWidget() + + # PYSIDE-86: + # This case failed because GObjA was reimplementing + # the method itemChange() from QGraphicsItem, + # and then the QVariant was not associated with + # a QGraphicsItem but a QObjectItem because the base + # class was a QObject. + gobjA = GObjA() + gobjA.setParentItem(w) + self.assertIs(type(w), type(gobjA.parentItem())) + + gobjB = GObjB() + gobjB.setParentItem(w) + self.assertIs(type(w), type(gobjB.parentItem())) + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3 From 516682fc232db273511440d3c7107ab15f08b5ea Mon Sep 17 00:00:00 2001 From: David Rosca Date: Sun, 18 Mar 2018 11:00:27 +0100 Subject: Add QtWebEngineCore module Change-Id: I8e1127e082abe5978a94aa8a080dfb1d8bbd5952 Reviewed-by: Friedemann Kleint --- .../pyside2/tests/QtWebEngineCore/CMakeLists.txt | 29 ++++++++++ .../QtWebEngineCore/web_engine_custom_scheme.py | 64 ++++++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 sources/pyside2/tests/QtWebEngineCore/CMakeLists.txt create mode 100644 sources/pyside2/tests/QtWebEngineCore/web_engine_custom_scheme.py (limited to 'sources/pyside2/tests') diff --git a/sources/pyside2/tests/QtWebEngineCore/CMakeLists.txt b/sources/pyside2/tests/QtWebEngineCore/CMakeLists.txt new file mode 100644 index 000000000..2e361383c --- /dev/null +++ b/sources/pyside2/tests/QtWebEngineCore/CMakeLists.txt @@ -0,0 +1,29 @@ +############################################################################# +## +## Copyright (C) 2018 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $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$ +## +############################################################################# + +PYSIDE_TEST(web_engine_custom_scheme.py) diff --git a/sources/pyside2/tests/QtWebEngineCore/web_engine_custom_scheme.py b/sources/pyside2/tests/QtWebEngineCore/web_engine_custom_scheme.py new file mode 100644 index 000000000..b7c57d8e6 --- /dev/null +++ b/sources/pyside2/tests/QtWebEngineCore/web_engine_custom_scheme.py @@ -0,0 +1,64 @@ +############################################################################# +## +## Copyright (C) 2018 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $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 __future__ import print_function + +import unittest + +from PySide2.QtCore import QBuffer, QTimer +from PySide2.QtWidgets import QApplication +from PySide2.QtWebEngineWidgets import QWebEngineView, QWebEngineProfile +from PySide2.QtWebEngineCore import QWebEngineUrlSchemeHandler + +class TestSchemeHandler(QWebEngineUrlSchemeHandler): + def requestStarted(self, request): + if request.requestUrl() == "testpy:hello": + request.redirect("testpy:goodbye") + return + + self.buffer = QBuffer() + self.buffer.setData("Really nice goodbye text.") + self.buffer.aboutToClose.connect(self.buffer.deleteLater) + request.reply("text/plain;charset=utf-8", self.buffer) + +class MainTest(unittest.TestCase): + def test_SchemeHandlerRedirect(self): + app = QApplication([]) + handler = TestSchemeHandler() + profile = QWebEngineProfile.defaultProfile() + profile.installUrlSchemeHandler("testpy", handler) + view = QWebEngineView() + view.loadFinished.connect(app.quit) + QTimer.singleShot(5000, app.quit) + view.show() + view.load("testpy:hello") + app.exec_() + self.assertEqual(view.url(), "testpy:goodbye") + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3 From 186b40b958aa1ebe7317ccf5de7109a327b5c65d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 20 Apr 2018 08:39:24 +0200 Subject: Add QtSensors Task-number: PYSIDE-487 Change-Id: Id60f3f6e70b4fbb8e4316b994cdd557ff9be7b3b Reviewed-by: Alexandru Croitor --- sources/pyside2/tests/QtSensors/CMakeLists.txt | 1 + sources/pyside2/tests/QtSensors/sensors.py | 55 ++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 sources/pyside2/tests/QtSensors/CMakeLists.txt create mode 100644 sources/pyside2/tests/QtSensors/sensors.py (limited to 'sources/pyside2/tests') diff --git a/sources/pyside2/tests/QtSensors/CMakeLists.txt b/sources/pyside2/tests/QtSensors/CMakeLists.txt new file mode 100644 index 000000000..87e548f87 --- /dev/null +++ b/sources/pyside2/tests/QtSensors/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(sensors.py) diff --git a/sources/pyside2/tests/QtSensors/sensors.py b/sources/pyside2/tests/QtSensors/sensors.py new file mode 100644 index 000000000..5b41ac63d --- /dev/null +++ b/sources/pyside2/tests/QtSensors/sensors.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 PySide2. +## +## $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 QSensor''' + +from PySide2.QtSensors import QSensor, QSensorReading +import unittest + +class QSensorTest(unittest.TestCase): + def test(self): + for sensorType in QSensor.sensorTypes(): + identifiers = QSensor.sensorsForType(sensorType) + values = [] + usedIdentifier = None + for identifier in identifiers: + sensor = QSensor(sensorType, None); + sensor.setIdentifier(identifier) + if sensor.connectToBackend(): + usedIdentifier = identifier + reading = sensor.reading() + for i in range(0, reading.valueCount()): + values.append(reading.value(i)) + break + if usedIdentifier: + print('Sensor ', sensorType, usedIdentifier, values) + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3 From 55d871a8abfd9c29b96ecf7c011c3b3b9fd05d31 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 20 Apr 2018 16:01:25 +0200 Subject: shiboken: Strip parameters of invalid type with a default value expression For example for: void QWebEnginePage::findText(const QString &subString, FindFlags options = FindFlags(), const QWebEngineCallback &resultCallback = QWebEngineCallback()) the resultCallback will be removed and a binding for void QWebEnginePage::findText(const QString &subString, FindFlags options) generated. Task-number: PYSIDE-487 Change-Id: I6299d1735ad6c00e257daecb64d8f2f235140a98 Reviewed-by: Cristian Maureira-Fredes Reviewed-by: Christian Tismer --- .../pyside2/tests/QtWebEngineWidgets/pyside-474-qtwebengineview.py | 4 ---- 1 file changed, 4 deletions(-) (limited to 'sources/pyside2/tests') diff --git a/sources/pyside2/tests/QtWebEngineWidgets/pyside-474-qtwebengineview.py b/sources/pyside2/tests/QtWebEngineWidgets/pyside-474-qtwebengineview.py index 6ea3aa95a..b4aef26d1 100644 --- a/sources/pyside2/tests/QtWebEngineWidgets/pyside-474-qtwebengineview.py +++ b/sources/pyside2/tests/QtWebEngineWidgets/pyside-474-qtwebengineview.py @@ -39,11 +39,7 @@ class MainTest(unittest.TestCase): qApp = (QtWidgets.QApplication.instance() or QtWidgets.QApplication([])) view = QtWebEngineWidgets.QWebEngineView() - with self.assertRaises(TypeError): - view.findText(123) view.findText("nothing") - # we are testing only the existence of the function, - # after it suddenly showed up. if __name__ == '__main__': unittest.main() -- cgit v1.2.3 From 4cedac360986b3cdc21519b102d605671e9e7610 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 18 Apr 2018 14:22:01 +0200 Subject: Add QtPositioning and QtLocation Task-number: PYSIDE-487 Change-Id: Ie44d8472beb3f1a5ab75caafd1f58b512b53ccb1 Reviewed-by: Alexandru Croitor --- sources/pyside2/tests/QtLocation/CMakeLists.txt | 1 + sources/pyside2/tests/QtLocation/location.py | 41 +++++++++++++++++++++ sources/pyside2/tests/QtPositioning/CMakeLists.txt | 1 + sources/pyside2/tests/QtPositioning/positioning.py | 43 ++++++++++++++++++++++ 4 files changed, 86 insertions(+) create mode 100644 sources/pyside2/tests/QtLocation/CMakeLists.txt create mode 100644 sources/pyside2/tests/QtLocation/location.py create mode 100644 sources/pyside2/tests/QtPositioning/CMakeLists.txt create mode 100644 sources/pyside2/tests/QtPositioning/positioning.py (limited to 'sources/pyside2/tests') diff --git a/sources/pyside2/tests/QtLocation/CMakeLists.txt b/sources/pyside2/tests/QtLocation/CMakeLists.txt new file mode 100644 index 000000000..b97ac1098 --- /dev/null +++ b/sources/pyside2/tests/QtLocation/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(location.py) diff --git a/sources/pyside2/tests/QtLocation/location.py b/sources/pyside2/tests/QtLocation/location.py new file mode 100644 index 000000000..ca964c46c --- /dev/null +++ b/sources/pyside2/tests/QtLocation/location.py @@ -0,0 +1,41 @@ +############################################################################# +## +## Copyright (C) 2018 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $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 Location''' + +from PySide2.QtLocation import QGeoServiceProvider +import unittest + +class QLocationTestCase(unittest.TestCase): + def test(self): + geoServiceProvider = QGeoServiceProvider("none") + self.assertEqual(geoServiceProvider.errorString(), + 'The geoservices provider none is not supported.') + +if __name__ == "__main__": + unittest.main() diff --git a/sources/pyside2/tests/QtPositioning/CMakeLists.txt b/sources/pyside2/tests/QtPositioning/CMakeLists.txt new file mode 100644 index 000000000..b9f7631b1 --- /dev/null +++ b/sources/pyside2/tests/QtPositioning/CMakeLists.txt @@ -0,0 +1 @@ +PYSIDE_TEST(positioning.py) diff --git a/sources/pyside2/tests/QtPositioning/positioning.py b/sources/pyside2/tests/QtPositioning/positioning.py new file mode 100644 index 000000000..9f61fe1ef --- /dev/null +++ b/sources/pyside2/tests/QtPositioning/positioning.py @@ -0,0 +1,43 @@ +############################################################################# +## +## Copyright (C) 2018 The Qt Company Ltd. +## Contact: https://www.qt.io/licensing/ +## +## This file is part of the test suite of PySide2. +## +## $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 Positioning''' + +from PySide2.QtPositioning import QGeoPositionInfoSource +import unittest + +class QPositioningTestCase(unittest.TestCase): + def test(self): + source = QGeoPositionInfoSource.createDefaultSource(None) + self.assertTrue(source is not None) + name = source.sourceName() + print('QtPositioning source: {}'.format(name)) + self.assertTrue(name) + +if __name__ == "__main__": + unittest.main() -- cgit v1.2.3