aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/QtCharts
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/tests/QtCharts')
-rw-r--r--sources/pyside6/tests/QtCharts/CMakeLists.txt2
-rw-r--r--sources/pyside6/tests/QtCharts/QtCharts.pyproject3
-rw-r--r--sources/pyside6/tests/QtCharts/qcharts_numpy_test.py49
-rw-r--r--sources/pyside6/tests/QtCharts/qcharts_test.py46
4 files changed, 100 insertions, 0 deletions
diff --git a/sources/pyside6/tests/QtCharts/CMakeLists.txt b/sources/pyside6/tests/QtCharts/CMakeLists.txt
new file mode 100644
index 000000000..4d031937a
--- /dev/null
+++ b/sources/pyside6/tests/QtCharts/CMakeLists.txt
@@ -0,0 +1,2 @@
+PYSIDE_TEST(qcharts_test.py)
+PYSIDE_TEST(qcharts_numpy_test.py)
diff --git a/sources/pyside6/tests/QtCharts/QtCharts.pyproject b/sources/pyside6/tests/QtCharts/QtCharts.pyproject
new file mode 100644
index 000000000..6f2bd66f2
--- /dev/null
+++ b/sources/pyside6/tests/QtCharts/QtCharts.pyproject
@@ -0,0 +1,3 @@
+{
+ "files": ["qcharts_test.py"]
+}
diff --git a/sources/pyside6/tests/QtCharts/qcharts_numpy_test.py b/sources/pyside6/tests/QtCharts/qcharts_numpy_test.py
new file mode 100644
index 000000000..8154020c0
--- /dev/null
+++ b/sources/pyside6/tests/QtCharts/qcharts_numpy_test.py
@@ -0,0 +1,49 @@
+#!/usr/bin/python
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+'''Test cases for QCharts/numpy'''
+
+import os
+import sys
+import unittest
+try:
+ import numpy as np
+ HAVE_NUMPY = True
+except ModuleNotFoundError:
+ HAVE_NUMPY = False
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from helper.usesqapplication import UsesQApplication
+from PySide6.QtCore import QCoreApplication
+from PySide6.QtCharts import QLineSeries
+
+
+class QChartsNumpyTestCase(UsesQApplication):
+ '''Tests related to QCharts/numpy'''
+
+ @unittest.skipUnless(HAVE_NUMPY, "requires numpy")
+ def test(self):
+ """PYSIDE-2313: Verify various types."""
+ line_series = QLineSeries()
+ data_types = [np.short, np.ushort, np.int32, np.uint32,
+ np.int64, np.uint64, np.float32, np.float64]
+ for dt in data_types:
+ print("Testing ", dt)
+ old_size = line_series.count()
+ x_arr = np.array([2], dtype=dt)
+ y_arr = np.array([3], dtype=dt)
+ line_series.appendNp(x_arr, y_arr)
+ size = line_series.count()
+ self.assertEqual(size, old_size + 1)
+ point = line_series.points()[size - 1]
+ self.assertEqual(point.x(), 2)
+ self.assertEqual(point.y(), 3)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/sources/pyside6/tests/QtCharts/qcharts_test.py b/sources/pyside6/tests/QtCharts/qcharts_test.py
new file mode 100644
index 000000000..8d57c07eb
--- /dev/null
+++ b/sources/pyside6/tests/QtCharts/qcharts_test.py
@@ -0,0 +1,46 @@
+#!/usr/bin/python
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+
+'''Test cases for QCharts'''
+
+import os
+import sys
+import unittest
+
+from pathlib import Path
+sys.path.append(os.fspath(Path(__file__).resolve().parents[1]))
+from init_paths import init_test_paths
+init_test_paths(False)
+
+from helper.usesqapplication import UsesQApplication
+from PySide6.QtCore import QRect, QSize, QTimer
+from PySide6.QtGui import QGuiApplication, QScreen
+from PySide6.QtCharts import QChart, QChartView, QPieSeries
+
+
+class QChartsTestCase(UsesQApplication):
+ '''Tests related to QCharts'''
+
+ def testCharts(self):
+ self.series = QPieSeries()
+ self.series.append("Jane", 1)
+ self.series.append("Joe", 2)
+ self.series.append("Andy", 3)
+ self.series.append("Barbara", 4)
+ self.series.append("Axel", 5)
+ slice = self.series.slices()[1]
+ slice.setExploded()
+ slice.setLabelVisible()
+ self.chart = QChart()
+ self.chart.addSeries(self.series)
+ chartView = QChartView(self.chart)
+ screenSize = QGuiApplication.primaryScreen().geometry().size()
+ chartView.resize(screenSize / 2)
+ chartView.show()
+ QTimer.singleShot(500, self.app.quit)
+ self.app.exec()
+
+
+if __name__ == '__main__':
+ unittest.main()