1 /**
2  * Copyright (C) 2001-2015 Klaralvdalens Datakonsult AB.  All rights reserved.
3  *
4  * This file is part of the KD Chart library.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
18  */
19 
20 #include <QtTest/QtTest>
21 #include <KChartChart>
22 #include <KChartGlobal>
23 #include <KChartPolarDiagram>
24 #include <KChartPolarCoordinatePlane>
25 
26 #include <TableModel.h>
27 
28 using namespace KChart;
29 
30 class TestPolarDiagrams: public QObject {
31     Q_OBJECT
32 private Q_SLOTS:
33 
initTestCase()34     void initTestCase()
35     {
36         m_chart = new Chart(nullptr);
37         PolarCoordinatePlane* polarPlane = new PolarCoordinatePlane( m_chart );
38         m_chart->replaceCoordinatePlane( polarPlane );
39         m_model = new TableModel( this );
40         m_model->loadFromCSV( ":/data" );
41         m_polar = new PolarDiagram();
42         m_polar->setModel( m_model );
43         m_chart->coordinatePlane()->replaceDiagram( m_polar );
44     }
45 
testPolarDiagramsSettings()46     void testPolarDiagramsSettings()
47     {
48         QVERIFY( m_polar->rotateCircularLabels() == false );
49         QVERIFY( m_polar->showDelimitersAtPosition( Position::NorthWest ) == false );
50         QVERIFY( m_polar->showDelimitersAtPosition( Position::North ) == false );
51         QVERIFY( m_polar->showDelimitersAtPosition( Position::NorthEast ) == false );
52         QVERIFY( m_polar->showDelimitersAtPosition( Position::West ) == false );
53         QVERIFY( m_polar->showDelimitersAtPosition( Position::East ) == false );
54         QVERIFY( m_polar->showDelimitersAtPosition( Position::SouthWest ) == false );
55         QVERIFY( m_polar->showDelimitersAtPosition( Position::South ) == false );
56         QVERIFY( m_polar->showDelimitersAtPosition( Position::SouthEast ) == false );
57         QVERIFY( m_polar->showLabelsAtPosition( Position::NorthWest ) == false );
58         QVERIFY( m_polar->showLabelsAtPosition( Position::North ) == false );
59         QVERIFY( m_polar->showLabelsAtPosition( Position::NorthEast ) == false );
60         QVERIFY( m_polar->showLabelsAtPosition( Position::West ) == false );
61         QVERIFY( m_polar->showLabelsAtPosition( Position::East ) == false );
62         QVERIFY( m_polar->showLabelsAtPosition( Position::SouthWest ) == false );
63         QVERIFY( m_polar->showLabelsAtPosition( Position::South ) == false );
64         QVERIFY( m_polar->showLabelsAtPosition( Position::SouthEast ) == false );
65         qDebug() << "void PolarDiagram::init() is never called.....(?)";
66         m_polar->setRotateCircularLabels(  true );
67         m_polar->setShowDelimitersAtPosition( Position::North, true );
68         m_polar->setShowDelimitersAtPosition( Position::South, true );
69         m_polar->setShowLabelsAtPosition( Position::North, true );
70         m_polar->setShowLabelsAtPosition( Position::South, true );
71         QVERIFY( m_polar->rotateCircularLabels() == true );
72         QVERIFY( m_polar->showDelimitersAtPosition( Position::North ) == true );
73         QVERIFY( m_polar->showDelimitersAtPosition( Position::South ) == true );
74         QVERIFY( m_polar->showLabelsAtPosition( Position::North ) == true );
75         QVERIFY( m_polar->showLabelsAtPosition( Position::South ) == true );
76     }
77 
78 
cleanupTestCase()79     void cleanupTestCase()
80     {
81     }
82 
83 private:
84     Chart *m_chart;
85     PolarDiagram *m_polar;
86     TableModel *m_model;
87 
88 };
89 
90 QTEST_MAIN(TestPolarDiagrams)
91 
92 #include "main.moc"
93