aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/tests
diff options
context:
space:
mode:
authorMaximilian Goldstein <max.goldstein@qt.io>2020-08-20 13:17:33 +0200
committerMaximilian Goldstein <max.goldstein@qt.io>2020-08-26 07:40:54 +0000
commit387624b29c88f06d1cab8c566bc82fdf40c8f804 (patch)
tree9aff565382349f7d49e129f876987a508e7fc9a4 /sources/pyside2/tests
parentd8e24b439d4b801f97363cf61ced4834970fe96f (diff)
QtQml: Move uncreatable type test into separate file
Change-Id: I01b052ffa85543d5779a87a331c78f77a6529e95 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside2/tests')
-rw-r--r--sources/pyside2/tests/QtQml/CMakeLists.txt1
-rw-r--r--sources/pyside2/tests/QtQml/registertype.py34
-rw-r--r--sources/pyside2/tests/QtQml/registeruncreatable.qml5
-rw-r--r--sources/pyside2/tests/QtQml/registeruncreatabletype.py80
4 files changed, 84 insertions, 36 deletions
diff --git a/sources/pyside2/tests/QtQml/CMakeLists.txt b/sources/pyside2/tests/QtQml/CMakeLists.txt
index aaedc437f..76f9fec49 100644
--- a/sources/pyside2/tests/QtQml/CMakeLists.txt
+++ b/sources/pyside2/tests/QtQml/CMakeLists.txt
@@ -15,6 +15,7 @@ PYSIDE_TEST(qqmlnetwork_test.py)
PYSIDE_TEST(qquickview_test.py)
PYSIDE_TEST(connect_python_qml.py)
PYSIDE_TEST(registertype.py)
+PYSIDE_TEST(registeruncreatabletype.py)
PYSIDE_TEST(registersingletontype.py)
PYSIDE_TEST(javascript_exceptions.py)
PYSIDE_TEST(qqmlincubator_incubateWhile.py)
diff --git a/sources/pyside2/tests/QtQml/registertype.py b/sources/pyside2/tests/QtQml/registertype.py
index 526af178c..e4dcd36f9 100644
--- a/sources/pyside2/tests/QtQml/registertype.py
+++ b/sources/pyside2/tests/QtQml/registertype.py
@@ -38,24 +38,9 @@ from helper.helper import adjust_filename
from PySide2.QtCore import Property, QObject, QTimer, QUrl
from PySide2.QtGui import QGuiApplication, QPen, QColor, QPainter
-from PySide2.QtQml import qmlRegisterType, qmlRegisterUncreatableType, ListProperty
+from PySide2.QtQml import qmlRegisterType, ListProperty
from PySide2.QtQuick import QQuickView, QQuickItem, QQuickPaintedItem
-noCreationReason = 'Cannot create an item of type: Uncreatable (expected)';
-
-class Uncreatable(QObject):
- def __init__(self, parent = None):
- QObject.__init__(self, parent)
- self._name = 'uncreatable'
-
- def getName(self):
- return self._name
-
- def setName(self, value):
- self._name = value
-
- name = Property(str, getName, setName)
-
class PieSlice (QQuickPaintedItem):
def __init__(self, parent = None):
QQuickPaintedItem.__init__(self, parent)
@@ -123,10 +108,8 @@ class TestQmlSupport(unittest.TestCase):
def testIt(self):
app = QGuiApplication([])
- qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart')
- self.assertTrue(qmlRegisterType(PieSlice, "Charts", 1, 0, "PieSlice") > 0);
- self.assertTrue(qmlRegisterUncreatableType(Uncreatable, 'Charts', 1, 0,
- 'Uncreatable', noCreationReason) > 0);
+ self.assertTrue(qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart') != -1)
+ self.assertTrue(qmlRegisterType(PieSlice, "Charts", 1, 0, "PieSlice") != -1)
view = QQuickView()
view.setSource(QUrl.fromLocalFile(adjust_filename('registertype.qml', __file__)))
@@ -136,16 +119,5 @@ class TestQmlSupport(unittest.TestCase):
self.assertTrue(appendCalled)
self.assertTrue(paintCalled)
- # Check that the uncreatable item produces the correct error
- view.setSource(QUrl.fromLocalFile(adjust_filename('registeruncreatable.qml', __file__)))
- self.assertEqual(view.status(), QQuickView.Error)
- errorFound = False
- for e in view.errors():
- if noCreationReason in e.toString():
- errorFound = True
- break
- self.assertTrue(errorFound)
-
-
if __name__ == '__main__':
unittest.main()
diff --git a/sources/pyside2/tests/QtQml/registeruncreatable.qml b/sources/pyside2/tests/QtQml/registeruncreatable.qml
index 347a8117a..bebf68d82 100644
--- a/sources/pyside2/tests/QtQml/registeruncreatable.qml
+++ b/sources/pyside2/tests/QtQml/registeruncreatable.qml
@@ -35,9 +35,4 @@ Item {
Uncreatable {
name : 'uncreatable'
}
-
- PieChart {
- anchors.centerIn: parent
- width: 100; height: 100
- }
}
diff --git a/sources/pyside2/tests/QtQml/registeruncreatabletype.py b/sources/pyside2/tests/QtQml/registeruncreatabletype.py
new file mode 100644
index 000000000..820dc6cc1
--- /dev/null
+++ b/sources/pyside2/tests/QtQml/registeruncreatabletype.py
@@ -0,0 +1,80 @@
+#############################################################################
+##
+## Copyright (C) 2020 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.helper import adjust_filename
+
+from PySide2.QtCore import Property, QObject, QUrl
+from PySide2.QtGui import QGuiApplication
+from PySide2.QtQml import qmlRegisterUncreatableType, QQmlEngine, QQmlComponent
+
+noCreationReason = 'Cannot create an item of type: Uncreatable (expected)';
+
+class Uncreatable(QObject):
+ def __init__(self, parent = None):
+ QObject.__init__(self, parent)
+ self._name = 'uncreatable'
+
+ def getName(self):
+ return self._name
+
+ def setName(self, value):
+ self._name = value
+
+ name = Property(str, getName, setName)
+
+class TestQmlSupport(unittest.TestCase):
+
+ def testIt(self):
+ app = QGuiApplication([])
+
+ self.assertTrue(qmlRegisterUncreatableType(Uncreatable, 'Charts', 1, 0,
+ 'Uncreatable', noCreationReason) != -1);
+
+ engine = QQmlEngine()
+ component = QQmlComponent(engine, QUrl.fromLocalFile(adjust_filename('registeruncreatable.qml', __file__)))
+
+ # Check that the uncreatable item produces the correct error
+ self.assertEqual(component.status(), QQmlComponent.Error)
+ errorFound = False
+ for e in component.errors():
+ if noCreationReason in e.toString():
+ errorFound = True
+ break
+ self.assertTrue(errorFound)
+
+
+if __name__ == '__main__':
+ unittest.main()