1#!/usr/bin/python 2 3############################################################################# 4## 5## Copyright (C) 2017 The Qt Company Ltd. 6## Contact: https://www.qt.io/licensing/ 7## 8## This file is part of the test suite of Qt for Python. 9## 10## $QT_BEGIN_LICENSE:GPL-EXCEPT$ 11## Commercial License Usage 12## Licensees holding valid commercial Qt licenses may use this file in 13## accordance with the commercial license agreement provided with the 14## Software or, alternatively, in accordance with the terms contained in 15## a written agreement between you and The Qt Company. For licensing terms 16## and conditions see https://www.qt.io/terms-conditions. For further 17## information use the contact form at https://www.qt.io/contact-us. 18## 19## GNU General Public License Usage 20## Alternatively, this file may be used under the terms of the GNU 21## General Public License version 3 as published by the Free Software 22## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT 23## included in the packaging of this file. Please review the following 24## information to ensure the GNU General Public License requirements will 25## be met: https://www.gnu.org/licenses/gpl-3.0.html. 26## 27## $QT_END_LICENSE$ 28## 29############################################################################# 30 31'''Test cases for QCharts''' 32 33import os 34import sys 35import unittest 36 37sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 38from init_paths import init_test_paths 39init_test_paths(False) 40 41from helper.usesqapplication import UsesQApplication 42from PySide2.QtCore import QRect, QSize, QTimer 43from PySide2.QtGui import QGuiApplication, QScreen 44from PySide2.QtCharts import QtCharts 45 46class QChartsTestCase(UsesQApplication): 47 '''Tests related to QCharts''' 48 49 def testCharts(self): 50 self.series = QtCharts.QPieSeries() 51 self.series.append("Jane", 1); 52 self.series.append("Joe", 2); 53 self.series.append("Andy", 3); 54 self.series.append("Barbara", 4); 55 self.series.append("Axel", 5); 56 slice = self.series.slices()[1] 57 slice.setExploded(); 58 slice.setLabelVisible(); 59 self.chart = QtCharts.QChart() 60 self.chart.addSeries(self.series); 61 chartView = QtCharts.QChartView(self.chart) 62 screenSize = QGuiApplication.primaryScreen().geometry().size() 63 chartView.resize(screenSize / 2) 64 chartView.show() 65 QTimer.singleShot(500, self.app.quit) 66 self.app.exec_() 67 68if __name__ == '__main__': 69 unittest.main() 70