diff options
Diffstat (limited to 'tests/auto/cpptest/q3dbars/tst_bars.cpp')
-rw-r--r-- | tests/auto/cpptest/q3dbars/tst_bars.cpp | 95 |
1 files changed, 40 insertions, 55 deletions
diff --git a/tests/auto/cpptest/q3dbars/tst_bars.cpp b/tests/auto/cpptest/q3dbars/tst_bars.cpp index 0d128c36..96219cb0 100644 --- a/tests/auto/cpptest/q3dbars/tst_bars.cpp +++ b/tests/auto/cpptest/q3dbars/tst_bars.cpp @@ -1,31 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the Qt Data Visualization module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL$ -** 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 or (at your option) any later version -** approved by the KDE Free Qt Foundation. The licenses are as published by -** the Free Software Foundation and appearing in the file LICENSE.GPL3 -** 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$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtTest/QtTest> @@ -36,8 +10,6 @@ #include "cpptestutil.h" -using namespace QtDataVisualization; - class tst_bars: public QObject { Q_OBJECT @@ -59,6 +31,7 @@ private slots: void selectSeries(); void removeSeries(); void removeMultipleSeries(); + void hasSeries(); // The following tests are not required for scatter or surface, as they are handled identically void addInputHandler(); @@ -123,8 +96,9 @@ void tst_bars::initialProperties() QCOMPARE(m_graph->isMultiSeriesUniform(), false); QCOMPARE(m_graph->barThickness(), 1.0); QCOMPARE(m_graph->barSpacing(), QSizeF(1.0f, 1.0f)); + QCOMPARE(m_graph->barSeriesMargin(), QSizeF(0.0f, 0.0f)); QCOMPARE(m_graph->isBarSpacingRelative(), true); - QCOMPARE(m_graph->seriesList().length(), 0); + QCOMPARE(m_graph->seriesList().size(), 0); QVERIFY(!m_graph->selectedSeries()); QVERIFY(!m_graph->primarySeries()); QCOMPARE(m_graph->floorLevel(), 0.0); @@ -159,12 +133,14 @@ void tst_bars::initializeProperties() m_graph->setMultiSeriesUniform(true); m_graph->setBarThickness(0.2f); m_graph->setBarSpacing(QSizeF(0.1f, 0.1f)); + m_graph->setBarSeriesMargin(QSizeF(0.3f, 0.3f)); m_graph->setBarSpacingRelative(false); m_graph->setFloorLevel(1.0f); QCOMPARE(m_graph->isMultiSeriesUniform(), true); QCOMPARE(m_graph->barThickness(), 0.2f); QCOMPARE(m_graph->barSpacing(), QSizeF(0.1f, 0.1f)); + QCOMPARE(m_graph->barSeriesMargin(), QSizeF(0.3f, 0.3f)); QCOMPARE(m_graph->isBarSpacingRelative(), false); QCOMPARE(m_graph->floorLevel(), 1.0f); @@ -210,9 +186,9 @@ void tst_bars::invalidProperties() m_graph->setLocale(QLocale("XX")); QCOMPARE(m_graph->selectionMode(), QAbstract3DGraph::SelectionItem); - QCOMPARE(m_graph->aspectRatio(), -1.0/*2.0*/); // TODO: Fix once QTRD-3367 is done - QCOMPARE(m_graph->horizontalAspectRatio(), -1.0/*0.0*/); // TODO: Fix once QTRD-3367 is done - QCOMPARE(m_graph->reflectivity(), -1.0/*0.5*/); // TODO: Fix once QTRD-3367 is done + QCOMPARE(m_graph->aspectRatio(), 2.0); + QCOMPARE(m_graph->horizontalAspectRatio(), 0.0); + QCOMPARE(m_graph->reflectivity(), 0.5); QCOMPARE(m_graph->locale(), QLocale("C")); } @@ -222,7 +198,7 @@ void tst_bars::addSeries() m_graph->addSeries(series); - QCOMPARE(m_graph->seriesList().length(), 1); + QCOMPARE(m_graph->seriesList().size(), 1); QVERIFY(!m_graph->selectedSeries()); QCOMPARE(m_graph->primarySeries(), series); } @@ -237,7 +213,7 @@ void tst_bars::addMultipleSeries() m_graph->addSeries(series2); m_graph->addSeries(series3); - QCOMPARE(m_graph->seriesList().length(), 3); + QCOMPARE(m_graph->seriesList().size(), 3); QCOMPARE(m_graph->primarySeries(), series); m_graph->setPrimarySeries(series2); @@ -252,7 +228,7 @@ void tst_bars::selectSeries() m_graph->addSeries(series); m_graph->primarySeries()->setSelectedBar(QPoint(0, 0)); - QCOMPARE(m_graph->seriesList().length(), 1); + QCOMPARE(m_graph->seriesList().size(), 1); QCOMPARE(m_graph->selectedSeries(), series); m_graph->clearSelection(); @@ -265,7 +241,7 @@ void tst_bars::removeSeries() m_graph->addSeries(series); m_graph->removeSeries(series); - QCOMPARE(m_graph->seriesList().length(), 0); + QCOMPARE(m_graph->seriesList().size(), 0); delete series; } @@ -283,22 +259,31 @@ void tst_bars::removeMultipleSeries() QCOMPARE(m_graph->selectedSeries(), series); m_graph->removeSeries(series); - QCOMPARE(m_graph->seriesList().length(), 2); + QCOMPARE(m_graph->seriesList().size(), 2); QCOMPARE(m_graph->primarySeries(), series2); QVERIFY(!m_graph->selectedSeries()); m_graph->removeSeries(series2); - QCOMPARE(m_graph->seriesList().length(), 1); + QCOMPARE(m_graph->seriesList().size(), 1); QCOMPARE(m_graph->primarySeries(), series3); m_graph->removeSeries(series3); - QCOMPARE(m_graph->seriesList().length(), 0); + QCOMPARE(m_graph->seriesList().size(), 0); delete series; delete series2; delete series3; } +void tst_bars::hasSeries() +{ + QBar3DSeries *series1 = newSeries(); + m_graph->addSeries(series1); + QCOMPARE(m_graph->hasSeries(series1), true); + QBar3DSeries *series2 = newSeries(); + QCOMPARE(m_graph->hasSeries(series2), false); +} + // The following tests are not required for scatter or surface, as they are handled identically void tst_bars::addInputHandler() { @@ -309,14 +294,14 @@ void tst_bars::addInputHandler() m_graph->addInputHandler(handler); m_graph->addInputHandler(handler2); - QCOMPARE(m_graph->inputHandlers().length(), 3); // Default, as it is still active, plus added ones + QCOMPARE(m_graph->inputHandlers().size(), 3); // Default, as it is still active, plus added ones QCOMPARE(m_graph->activeInputHandler(), initialHandler); m_graph->setActiveInputHandler(handler2); QCOMPARE(m_graph->activeInputHandler(), handler2); m_graph->setActiveInputHandler(NULL); QVERIFY(!m_graph->activeInputHandler()); - QCOMPARE(m_graph->inputHandlers().length(), 2); + QCOMPARE(m_graph->inputHandlers().size(), 2); } void tst_bars::removeInputHandler() @@ -328,12 +313,12 @@ void tst_bars::removeInputHandler() m_graph->addInputHandler(handler2); m_graph->setActiveInputHandler(handler2); - QCOMPARE(m_graph->inputHandlers().length(), 2); // Default handler removed by previous call + QCOMPARE(m_graph->inputHandlers().size(), 2); // Default handler removed by previous call QCOMPARE(m_graph->activeInputHandler(), handler2); m_graph->releaseInputHandler(handler2); - QCOMPARE(m_graph->inputHandlers().length(), 1); + QCOMPARE(m_graph->inputHandlers().size(), 1); m_graph->releaseInputHandler(handler); - QCOMPARE(m_graph->inputHandlers().length(), 0); + QCOMPARE(m_graph->inputHandlers().size(), 0); delete handler2; delete handler; @@ -347,7 +332,7 @@ void tst_bars::addTheme() m_graph->addTheme(theme); m_graph->addTheme(theme2); - QCOMPARE(m_graph->themes().length(), 3); // Default, plus added ones + QCOMPARE(m_graph->themes().size(), 3); // Default, plus added ones QCOMPARE(m_graph->activeTheme(), initialTheme); m_graph->setActiveTheme(theme2); QCOMPARE(m_graph->activeTheme(), theme2); @@ -363,9 +348,9 @@ void tst_bars::removeTheme() m_graph->setActiveTheme(theme2); QCOMPARE(m_graph->activeTheme(), theme2); m_graph->releaseTheme(theme2); - QCOMPARE(m_graph->themes().length(), 2); + QCOMPARE(m_graph->themes().size(), 2); m_graph->releaseTheme(theme); - QCOMPARE(m_graph->themes().length(), 1); // Default theme remains + QCOMPARE(m_graph->themes().size(), 1); // Default theme remains delete theme2; delete theme; @@ -377,9 +362,9 @@ void tst_bars::addCustomItem() QCustom3DItem *item2 = new QCustom3DItem(); m_graph->addCustomItem(item); - QCOMPARE(m_graph->customItems().length(), 1); + QCOMPARE(m_graph->customItems().size(), 1); m_graph->addCustomItem(item2); - QCOMPARE(m_graph->customItems().length(), 2); + QCOMPARE(m_graph->customItems().size(), 2); } void tst_bars::removeCustomItem() @@ -394,14 +379,14 @@ void tst_bars::removeCustomItem() m_graph->addCustomItem(item3); m_graph->releaseCustomItem(item); - QCOMPARE(m_graph->customItems().length(), 2); + QCOMPARE(m_graph->customItems().size(), 2); m_graph->removeCustomItem(item2); - QCOMPARE(m_graph->customItems().length(), 1); + QCOMPARE(m_graph->customItems().size(), 1); m_graph->addCustomItem(item); m_graph->removeCustomItemAt(QVector3D(1, 1, 1)); - QCOMPARE(m_graph->customItems().length(), 1); + QCOMPARE(m_graph->customItems().size(), 1); m_graph->removeCustomItems(); - QCOMPARE(m_graph->customItems().length(), 0); + QCOMPARE(m_graph->customItems().size(), 0); } void tst_bars::renderToImage() |