tst_qbarcategoryaxis.cpp
709 lines
| 19.1 KiB
| text/x-c
|
CppLexer
|
r1725 | /**************************************************************************** | ||
** | ||||
|
r2433 | ** Copyright (C) 2013 Digia Plc | ||
|
r1725 | ** All rights reserved. | ||
** For any questions to Digia, please use contact form at http://qt.digia.com | ||||
** | ||||
** This file is part of the Qt Commercial Charts Add-on. | ||||
** | ||||
** $QT_BEGIN_LICENSE$ | ||||
** Licensees holding valid Qt Commercial licenses may use this file in | ||||
** accordance with the Qt Commercial License Agreement provided with the | ||||
** Software or, alternatively, in accordance with the terms contained in | ||||
** a written agreement between you and Digia. | ||||
** | ||||
** If you have questions regarding the use of this file, please use | ||||
** contact form at http://qt.digia.com | ||||
** $QT_END_LICENSE$ | ||||
** | ||||
****************************************************************************/ | ||||
#include "../qabstractaxis/tst_qabstractaxis.h" | ||||
#include <qbarseries.h> | ||||
#include <qbarset.h> | ||||
|
r1810 | #include <qbarcategoryaxis.h> | ||
|
r1725 | |||
class tst_QBarCategoriesAxis: public tst_QAbstractAxis | ||||
{ | ||||
Q_OBJECT | ||||
public slots: | ||||
void initTestCase(); | ||||
void cleanupTestCase(); | ||||
void init(); | ||||
void cleanup(); | ||||
private slots: | ||||
|
r1810 | void qbarcategoryaxis_data(); | ||
void qbarcategoryaxis(); | ||||
|
r1725 | |||
|
r2120 | void append2_data(); | ||
void append2(); | ||||
|
r1725 | void append_data(); | ||
void append(); | ||||
void at_data(); | ||||
void at(); | ||||
void categories_data(); | ||||
void categories(); | ||||
void clear_data(); | ||||
void clear(); | ||||
void count_data(); | ||||
void count(); | ||||
void insert_data(); | ||||
void insert(); | ||||
|
r1732 | void remove_data(); | ||
void remove(); | ||||
void max_raw_data(); | ||||
void max_raw(); | ||||
|
r1725 | void max_data(); | ||
void max(); | ||||
|
r1732 | void max_animation_data(); | ||
void max_animation(); | ||||
void min_raw_data(); | ||||
void min_raw(); | ||||
|
r1725 | void min_data(); | ||
void min(); | ||||
|
r1732 | void min_animation_data(); | ||
void min_animation(); | ||||
void range_raw_data(); | ||||
void range_raw(); | ||||
void range_data(); | ||||
void range(); | ||||
void range_animation_data(); | ||||
void range_animation(); | ||||
|
r1764 | void noautoscale_data(); | ||
void noautoscale(); | ||||
void autoscale_data(); | ||||
void autoscale(); | ||||
|
r1732 | |||
|
r1725 | private: | ||
|
r1808 | QBarCategoryAxis* m_baraxis; | ||
|
r1725 | QBarSeries* m_series; | ||
}; | ||||
void tst_QBarCategoriesAxis::initTestCase() | ||||
{ | ||||
} | ||||
void tst_QBarCategoriesAxis::cleanupTestCase() | ||||
{ | ||||
} | ||||
void tst_QBarCategoriesAxis::init() | ||||
{ | ||||
|
r1808 | m_baraxis = new QBarCategoryAxis(); | ||
|
r1725 | m_series = new QBarSeries(); | ||
QBarSet *set0 = new QBarSet("Jane"); | ||||
QBarSet *set1 = new QBarSet("John"); | ||||
QBarSet *set2 = new QBarSet("Axel"); | ||||
QBarSet *set3 = new QBarSet("Mary"); | ||||
QBarSet *set4 = new QBarSet("Samantha"); | ||||
*set0 << 1 << 2 << 3 << 4 << 5 << 6; | ||||
*set1 << 5 << 0 << 0 << 4 << 0 << 7; | ||||
*set2 << 3 << 5 << 8 << 13 << 8 << 5; | ||||
*set3 << 5 << 6 << 7 << 3 << 4 << 5; | ||||
*set4 << 9 << 7 << 5 << 3 << 1 << 2; | ||||
m_series->append(set0); | ||||
m_series->append(set1); | ||||
m_series->append(set2); | ||||
m_series->append(set3); | ||||
m_series->append(set4); | ||||
QStringList categories; | ||||
categories << "Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | ||||
|
r2120 | foreach(QString category, categories) | ||
m_baraxis->append(category); | ||||
|
r1725 | |||
tst_QAbstractAxis::init(m_baraxis, m_series); | ||||
m_chart->addSeries(m_series); | ||||
m_chart->createDefaultAxes(); | ||||
} | ||||
void tst_QBarCategoriesAxis::cleanup() | ||||
{ | ||||
delete m_series; | ||||
delete m_baraxis; | ||||
m_series = 0; | ||||
m_baraxis = 0; | ||||
tst_QAbstractAxis::cleanup(); | ||||
} | ||||
|
r1810 | void tst_QBarCategoriesAxis::qbarcategoryaxis_data() | ||
|
r1725 | { | ||
} | ||||
|
r1810 | void tst_QBarCategoriesAxis::qbarcategoryaxis() | ||
|
r1725 | { | ||
qabstractaxis(); | ||||
|
r1808 | QBarCategoryAxis axis; | ||
|
r1725 | axis.append(QStringList()); | ||
axis.append(QString()); | ||||
|
r2121 | QCOMPARE(axis.count(), 0); | ||
|
r1725 | QStringList test; | ||
QCOMPARE(axis.categories(),test); | ||||
axis.clear(); | ||||
QCOMPARE(axis.count(), 0); | ||||
axis.insert(-1, QString()); | ||||
QCOMPARE(axis.max(), QString()); | ||||
QCOMPARE(axis.min(), QString()); | ||||
axis.remove(QString()); | ||||
axis.setCategories(QStringList()); | ||||
axis.setMax(QString()); | ||||
axis.setMin(QString()); | ||||
axis.setRange(QString(), QString()); | ||||
|
r1818 | QCOMPARE(axis.type(), QAbstractAxis::AxisTypeBarCategory); | ||
|
r1725 | } | ||
void tst_QBarCategoriesAxis::append_data() | ||||
{ | ||||
QTest::addColumn<QStringList>("categories"); | ||||
|
r1732 | QTest::newRow("Jan Feb Mar Apr") << (QStringList() << "Jan" << "Feb" << "Mar" << "Apr"); | ||
QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep"); | ||||
|
r1725 | } | ||
void tst_QBarCategoriesAxis::append() | ||||
{ | ||||
QFETCH(QStringList, categories); | ||||
|
r1808 | QBarCategoryAxis axis; | ||
|
r1725 | |||
QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | ||||
|
r2110 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | ||
QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | ||||
QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | ||||
|
r2249 | QSignalSpy spy4(&axis, SIGNAL(countChanged())); | ||
|
r1725 | |||
axis.append(categories); | ||||
|
r1732 | QCOMPARE(spy0.count(), 1); | ||
QCOMPARE(spy1.count(), 1); | ||||
QCOMPARE(spy2.count(), 1); | ||||
QCOMPARE(spy3.count(), 1); | ||||
m_chart->setAxisX(&axis, m_series); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
QCOMPARE(axis.categories(), categories); | ||||
QCOMPARE(spy0.count(), 1); | ||||
QCOMPARE(spy1.count(), 1); | ||||
QCOMPARE(spy2.count(), 1); | ||||
QCOMPARE(spy3.count(), 1); | ||||
|
r2249 | QCOMPARE(spy4.count(), 1); | ||
|
r1725 | } | ||
|
r2120 | void tst_QBarCategoriesAxis::append2_data() | ||
{ | ||||
QTest::addColumn<QStringList>("categories"); | ||||
QTest::newRow("Jan Feb Mar Apr") << (QStringList() << "Jan" << "Feb" << "Mar" << "Apr"); | ||||
QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep"); | ||||
} | ||||
void tst_QBarCategoriesAxis::append2() | ||||
{ | ||||
QFETCH(QStringList, categories); | ||||
QBarCategoryAxis axis; | ||||
QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | ||||
QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | ||||
QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | ||||
QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | ||||
|
r2249 | QSignalSpy spy4(&axis, SIGNAL(countChanged())); | ||
|
r2120 | |||
foreach(QString category, categories) | ||||
axis.append(category); | ||||
QCOMPARE(spy0.count(), categories.count()); | ||||
QCOMPARE(spy1.count(), categories.count()); | ||||
QCOMPARE(spy2.count(), 1); | ||||
QCOMPARE(spy3.count(), categories.count()); | ||||
m_chart->setAxisX(&axis, m_series); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
QCOMPARE(axis.categories(), categories); | ||||
QCOMPARE(spy0.count(), categories.count()); | ||||
QCOMPARE(spy1.count(), categories.count()); | ||||
QCOMPARE(spy2.count(), 1); | ||||
QCOMPARE(spy3.count(), categories.count()); | ||||
|
r2249 | QCOMPARE(spy4.count(), categories.count()); | ||
|
r2120 | } | ||
|
r1725 | void tst_QBarCategoriesAxis::at_data() | ||
{ | ||||
|
r1732 | QTest::addColumn<QStringList>("categories"); | ||
|
r1725 | QTest::addColumn<int>("index"); | ||
|
r1732 | QTest::addColumn<QString>("string"); | ||
QTest::newRow("Jul Aug Sep 0 Jul") << (QStringList() << "Jul" << "Aug" << "Sep") << 0 << "Jul"; | ||||
QTest::newRow("Jul Aug Sep 2 Sep") << (QStringList() << "Jul" << "Aug" << "Sep") << 2 << "Sep"; | ||||
QTest::newRow("Jul Aug Sep 1 Aug") << (QStringList() << "Jul" << "Aug" << "Sep") << 1 << "Aug"; | ||||
|
r1725 | } | ||
void tst_QBarCategoriesAxis::at() | ||||
{ | ||||
QFETCH(int, index); | ||||
|
r1732 | QFETCH(QString, string); | ||
QFETCH(QStringList, categories); | ||||
|
r1725 | |||
|
r1808 | QBarCategoryAxis axis; | ||
|
r1732 | axis.append(categories); | ||
|
r1725 | |||
QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | ||||
|
r2110 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | ||
QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | ||||
QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | ||||
|
r2249 | QSignalSpy spy4(&axis, SIGNAL(countChanged())); | ||
|
r1725 | |||
|
r1732 | QCOMPARE(axis.at(index), string); | ||
QCOMPARE(spy0.count(), 0); | ||||
QCOMPARE(spy1.count(), 0); | ||||
QCOMPARE(spy2.count(), 0); | ||||
QCOMPARE(spy3.count(), 0); | ||||
m_chart->setAxisX(&axis, m_series); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
QCOMPARE(axis.at(index), string); | ||||
|
r1725 | |||
QCOMPARE(spy0.count(), 0); | ||||
QCOMPARE(spy1.count(), 0); | ||||
QCOMPARE(spy2.count(), 0); | ||||
QCOMPARE(spy3.count(), 0); | ||||
|
r2249 | QCOMPARE(spy4.count(), 0); | ||
|
r1725 | } | ||
void tst_QBarCategoriesAxis::categories_data() | ||||
{ | ||||
QTest::addColumn<QStringList>("categories"); | ||||
|
r1732 | QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep"); | ||
|
r1725 | } | ||
void tst_QBarCategoriesAxis::categories() | ||||
{ | ||||
QFETCH(QStringList, categories); | ||||
|
r1808 | QBarCategoryAxis axis; | ||
|
r1725 | |||
QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | ||||
|
r2110 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | ||
QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | ||||
QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | ||||
|
r2249 | QSignalSpy spy4(&axis, SIGNAL(countChanged())); | ||
|
r1725 | |||
|
r1732 | axis.setCategories(categories); | ||
|
r1725 | QCOMPARE(axis.categories(), categories); | ||
|
r1732 | QCOMPARE(spy0.count(), 1); | ||
QCOMPARE(spy1.count(), 1); | ||||
QCOMPARE(spy2.count(), 1); | ||||
QCOMPARE(spy3.count(), 1); | ||||
m_chart->setAxisX(&axis, m_series); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
QCOMPARE(axis.categories(), categories); | ||||
QCOMPARE(spy0.count(), 1); | ||||
QCOMPARE(spy1.count(), 1); | ||||
QCOMPARE(spy2.count(), 1); | ||||
QCOMPARE(spy3.count(), 1); | ||||
|
r2249 | QCOMPARE(spy4.count(), 1); | ||
|
r1725 | } | ||
void tst_QBarCategoriesAxis::clear_data() | ||||
{ | ||||
|
r1732 | QTest::addColumn<QStringList>("categories"); | ||
QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep"); | ||||
|
r1725 | } | ||
void tst_QBarCategoriesAxis::clear() | ||||
{ | ||||
|
r1732 | QFETCH(QStringList, categories); | ||
|
r1808 | QBarCategoryAxis axis; | ||
|
r1725 | |||
|
r1732 | axis.setCategories(categories); | ||
QCOMPARE(axis.categories(), categories); | ||||
|
r1725 | |||
QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | ||||
|
r2110 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | ||
QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | ||||
QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | ||||
|
r2249 | QSignalSpy spy4(&axis, SIGNAL(countChanged())); | ||
|
r1725 | |||
axis.clear(); | ||||
|
r1732 | QCOMPARE(axis.categories(), QStringList()); | ||
|
r1725 | |||
|
r1732 | QCOMPARE(spy0.count(), 1); | ||
QCOMPARE(spy1.count(), 1); | ||||
QCOMPARE(spy2.count(), 1); | ||||
QCOMPARE(spy3.count(), 1); | ||||
m_chart->setAxisX(&axis, m_series); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
QCOMPARE(spy0.count(), 2); | ||||
QCOMPARE(spy1.count(), 2); | ||||
QCOMPARE(spy2.count(), 2); | ||||
QCOMPARE(spy3.count(), 2); | ||||
axis.clear(); | ||||
QCOMPARE(axis.categories().count(),0); | ||||
QCOMPARE(spy0.count(), 3); | ||||
QCOMPARE(spy1.count(), 3); | ||||
QCOMPARE(spy2.count(), 3); | ||||
QCOMPARE(spy3.count(), 3); | ||||
|
r2249 | QCOMPARE(spy4.count(), 3); | ||
|
r1725 | } | ||
void tst_QBarCategoriesAxis::count_data() | ||||
{ | ||||
|
r1732 | QTest::addColumn<QStringList>("categories"); | ||
|
r1725 | QTest::addColumn<int>("count"); | ||
|
r1732 | QTest::newRow("Jul Aug Sep") << (QStringList() << "Jul" << "Aug" << "Sep") << 3; | ||
QTest::newRow("Jul Aug ") << (QStringList() << "Jul" << "Aug") << 2; | ||||
|
r1725 | } | ||
void tst_QBarCategoriesAxis::count() | ||||
{ | ||||
|
r1732 | QFETCH(QStringList, categories); | ||
|
r1725 | QFETCH(int, count); | ||
|
r1808 | QBarCategoryAxis axis; | ||
|
r1732 | axis.setCategories(categories); | ||
|
r1725 | |||
QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | ||||
|
r2110 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | ||
QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | ||||
QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | ||||
|
r2249 | QSignalSpy spy4(&axis, SIGNAL(countChanged())); | ||
|
r1725 | |||
QCOMPARE(axis.count(), count); | ||||
QCOMPARE(spy0.count(), 0); | ||||
QCOMPARE(spy1.count(), 0); | ||||
QCOMPARE(spy2.count(), 0); | ||||
QCOMPARE(spy3.count(), 0); | ||||
|
r2249 | QCOMPARE(spy4.count(), 0); | ||
|
r1732 | |||
m_chart->setAxisX(&axis, m_series); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
QCOMPARE(axis.count(), count); | ||||
|
r1725 | } | ||
void tst_QBarCategoriesAxis::insert_data() | ||||
{ | ||||
|
r1732 | QTest::addColumn<QStringList>("categories"); | ||
|
r1725 | QTest::addColumn<int>("index"); | ||
QTest::addColumn<QString>("category"); | ||||
|
r2121 | QTest::newRow("Jul Aug Sep 0 Jun") << (QStringList() << "Jul" << "Aug" << "Sep") << 1 << "Jun"; | ||
|
r1732 | QTest::newRow("Jul Aug Sep 2 Summer") << (QStringList() << "Jul" << "Aug" << "Sep") << 2 << "Summer"; | ||
|
r1725 | } | ||
void tst_QBarCategoriesAxis::insert() | ||||
{ | ||||
|
r1732 | QFETCH(QStringList, categories); | ||
|
r1725 | QFETCH(int, index); | ||
QFETCH(QString, category); | ||||
|
r1808 | QBarCategoryAxis axis; | ||
|
r1732 | axis.append(categories); | ||
|
r1725 | |||
QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | ||||
|
r2110 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | ||
QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | ||||
QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | ||||
|
r2249 | QSignalSpy spy4(&axis, SIGNAL(countChanged())); | ||
|
r1725 | |||
axis.insert(index, category); | ||||
|
r1732 | QCOMPARE(axis.at(index),category); | ||
|
r1725 | |||
|
r1732 | QCOMPARE(spy0.count(), 1); | ||
|
r1725 | QCOMPARE(spy1.count(), 0); | ||
QCOMPARE(spy2.count(), 0); | ||||
QCOMPARE(spy3.count(), 0); | ||||
|
r2249 | QCOMPARE(spy4.count(), 1); | ||
|
r1725 | |||
|
r1732 | m_chart->setAxisX(&axis, m_series); | ||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
|
r1725 | } | ||
void tst_QBarCategoriesAxis::remove_data() | ||||
{ | ||||
|
r1732 | QTest::addColumn<QStringList>("categories"); | ||
|
r1725 | QTest::addColumn<QString>("category"); | ||
|
r1732 | QTest::addColumn<QStringList>("result"); | ||
QTest::newRow("Jul Aug Sep 0") << (QStringList() << "Jul" << "Aug" << "Sep") << "Jul" << (QStringList() << "Aug" << "Sep"); | ||||
QTest::newRow("Jul Aug Sep 1") << (QStringList() << "Jul" << "Aug" << "Sep") << "Aug"<< (QStringList() << "Jul" << "Sep"); | ||||
|
r1725 | } | ||
void tst_QBarCategoriesAxis::remove() | ||||
{ | ||||
|
r1732 | QFETCH(QStringList, categories); | ||
|
r1725 | QFETCH(QString, category); | ||
|
r1732 | QFETCH(QStringList, result); | ||
|
r1808 | QBarCategoryAxis axis; | ||
|
r1732 | axis.append(categories); | ||
|
r1725 | |||
|
r1732 | int maxCount = axis.max() == category; | ||
int minCount = axis.min() == category; | ||||
int rangeCount = maxCount + minCount; | ||||
|
r1725 | |||
QSignalSpy spy0(&axis, SIGNAL(categoriesChanged())); | ||||
|
r2110 | QSignalSpy spy1(&axis, SIGNAL(maxChanged(QString))); | ||
QSignalSpy spy2(&axis, SIGNAL(minChanged(QString))); | ||||
QSignalSpy spy3(&axis, SIGNAL(rangeChanged(QString,QString))); | ||||
|
r2249 | QSignalSpy spy4(&axis, SIGNAL(countChanged())); | ||
|
r1725 | |||
axis.remove(category); | ||||
|
r1732 | QCOMPARE(axis.categories(),result); | ||
|
r1725 | |||
|
r1732 | QCOMPARE(spy0.count(), 1); | ||
QCOMPARE(spy1.count(), maxCount); | ||||
QCOMPARE(spy2.count(), minCount); | ||||
QCOMPARE(spy3.count(), rangeCount); | ||||
|
r2249 | QCOMPARE(spy4.count(), 1); | ||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::max_raw_data() | ||
|
r1725 | { | ||
|
r1732 | //"Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | ||
QTest::addColumn<QString>("max"); | ||||
QTest::newRow("Feb") << "Feb"; | ||||
QTest::newRow("Apr") << "Apr"; | ||||
QTest::newRow("May") << "May"; | ||||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::max_raw() | ||
|
r1725 | { | ||
|
r1732 | QFETCH(QString, max); | ||
|
r1725 | |||
|
r1732 | QSignalSpy spy0(m_baraxis, SIGNAL(categoriesChanged())); | ||
|
r2110 | QSignalSpy spy1(m_baraxis, SIGNAL(maxChanged(QString))); | ||
QSignalSpy spy2(m_baraxis, SIGNAL(minChanged(QString))); | ||||
QSignalSpy spy3(m_baraxis, SIGNAL(rangeChanged(QString,QString))); | ||||
|
r2249 | QSignalSpy spy4(m_baraxis, SIGNAL(countChanged())); | ||
|
r1725 | |||
|
r1732 | m_baraxis->setMax(max); | ||
QCOMPARE(m_baraxis->max(), max); | ||||
|
r1725 | |||
QCOMPARE(spy0.count(), 0); | ||||
|
r1732 | QCOMPARE(spy1.count(), 1); | ||
|
r1725 | QCOMPARE(spy2.count(), 0); | ||
|
r1732 | QCOMPARE(spy3.count(), 1); | ||
|
r2249 | QCOMPARE(spy4.count(), 0); | ||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::max_data() | ||
|
r1725 | { | ||
|
r1732 | max_raw_data(); | ||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::max() | ||
|
r1725 | { | ||
|
r1732 | m_chart->setAxisX(m_baraxis, m_series); | ||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
max_raw(); | ||||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::max_animation_data() | ||
|
r1725 | { | ||
|
r1732 | max_data(); | ||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::max_animation() | ||
|
r1725 | { | ||
|
r1732 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); | ||
max(); | ||||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::min_raw_data() | ||
|
r1725 | { | ||
|
r1732 | //"Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | ||
QTest::addColumn<QString>("min"); | ||||
QTest::newRow("Feb") << "Feb"; | ||||
QTest::newRow("Apr") << "Apr"; | ||||
QTest::newRow("May") << "May"; | ||||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::min_raw() | ||
|
r1725 | { | ||
|
r1732 | QFETCH(QString, min); | ||
|
r1725 | |||
|
r1732 | QSignalSpy spy0(m_baraxis, SIGNAL(categoriesChanged())); | ||
|
r2110 | QSignalSpy spy1(m_baraxis, SIGNAL(maxChanged(QString))); | ||
QSignalSpy spy2(m_baraxis, SIGNAL(minChanged(QString))); | ||||
QSignalSpy spy3(m_baraxis, SIGNAL(rangeChanged(QString,QString))); | ||||
|
r2249 | QSignalSpy spy4(m_baraxis, SIGNAL(countChanged())); | ||
|
r1725 | |||
|
r1732 | m_baraxis->setMin(min); | ||
QCOMPARE(m_baraxis->min(), min); | ||||
|
r1725 | |||
QCOMPARE(spy0.count(), 0); | ||||
QCOMPARE(spy1.count(), 0); | ||||
|
r1732 | QCOMPARE(spy2.count(), 1); | ||
QCOMPARE(spy3.count(), 1); | ||||
|
r2249 | QCOMPARE(spy4.count(), 0); | ||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::min_data() | ||
|
r1725 | { | ||
|
r1732 | min_raw_data(); | ||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::min() | ||
|
r1725 | { | ||
|
r2120 | min_raw(); | ||
|
r1732 | m_chart->setAxisX(m_baraxis, m_series); | ||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
|
r2120 | |||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::min_animation_data() | ||
|
r1725 | { | ||
|
r1732 | min_data(); | ||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::min_animation() | ||
|
r1725 | { | ||
|
r1732 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); | ||
min(); | ||||
|
r1725 | } | ||
|
r1732 | |||
void tst_QBarCategoriesAxis::range_raw_data() | ||||
|
r1725 | { | ||
|
r1732 | //"Jan" << "Feb" << "Mar" << "Apr" << "May" << "Jun"; | ||
QTest::addColumn<QString>("min"); | ||||
|
r1725 | QTest::addColumn<QString>("max"); | ||
|
r1732 | QTest::newRow("Feb - Apr") << "Feb" << "Apr"; | ||
QTest::newRow("Feb - May") << "Feb" << "May"; | ||||
QTest::newRow("Mar - Apr") << "Mar" << "Apr"; | ||||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::range_raw() | ||
|
r1725 | { | ||
|
r1732 | QFETCH(QString, min); | ||
|
r1725 | QFETCH(QString, max); | ||
|
r1732 | QSignalSpy spy0(m_baraxis, SIGNAL(categoriesChanged())); | ||
|
r2110 | QSignalSpy spy1(m_baraxis, SIGNAL(maxChanged(QString))); | ||
QSignalSpy spy2(m_baraxis, SIGNAL(minChanged(QString))); | ||||
QSignalSpy spy3(m_baraxis, SIGNAL(rangeChanged(QString,QString))); | ||||
|
r2249 | QSignalSpy spy4(m_baraxis, SIGNAL(countChanged())); | ||
|
r1725 | |||
|
r1732 | m_baraxis->setRange(min, max); | ||
QCOMPARE(m_baraxis->min(), min); | ||||
QCOMPARE(m_baraxis->max(), max); | ||||
|
r1725 | |||
QCOMPARE(spy0.count(), 0); | ||||
|
r1732 | QCOMPARE(spy1.count(), 1); | ||
QCOMPARE(spy2.count(), 1); | ||||
QCOMPARE(spy3.count(), 1); | ||||
|
r2249 | QCOMPARE(spy4.count(), 0); | ||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::range_data() | ||
|
r1725 | { | ||
|
r1732 | range_raw_data(); | ||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::range() | ||
|
r1725 | { | ||
|
r2120 | range_raw(); | ||
|
r1732 | m_chart->setAxisX(m_baraxis, m_series); | ||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
|
r2120 | |||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::range_animation_data() | ||
|
r1725 | { | ||
|
r1732 | range_data(); | ||
|
r1725 | } | ||
|
r1732 | void tst_QBarCategoriesAxis::range_animation() | ||
|
r1725 | { | ||
|
r1732 | m_chart->setAnimationOptions(QChart::GridAxisAnimations); | ||
range(); | ||||
|
r1725 | } | ||
|
r1764 | |||
void tst_QBarCategoriesAxis::noautoscale_data() | ||||
{ | ||||
QTest::addColumn<QString>("min"); | ||||
QTest::addColumn<QString>("max"); | ||||
QTest::newRow("Feb - Mar") << "Feb" << "Mar"; | ||||
QTest::newRow("Feb - May") << "Feb" << "May"; | ||||
QTest::newRow("Apr - May") << "Apr" << "May"; | ||||
} | ||||
void tst_QBarCategoriesAxis::noautoscale() | ||||
{ | ||||
QFETCH(QString, min); | ||||
QFETCH(QString, max); | ||||
QSignalSpy spy0(m_baraxis, SIGNAL(maxChanged(QString))); | ||||
QSignalSpy spy1(m_baraxis, SIGNAL(minChanged(QString))); | ||||
|
r2110 | QSignalSpy spy2(m_baraxis, SIGNAL(rangeChanged(QString,QString))); | ||
|
r1764 | |||
m_baraxis->setRange(min, max); | ||||
QCOMPARE(m_baraxis->min(),min); | ||||
QCOMPARE(m_baraxis->max(),max); | ||||
QCOMPARE(spy0.count(), 1); | ||||
QCOMPARE(spy1.count(), 1); | ||||
QCOMPARE(spy2.count(), 1); | ||||
m_chart->setAxisX(m_baraxis, m_series); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
QCOMPARE(m_baraxis->min(),min); | ||||
QCOMPARE(m_baraxis->max(),max); | ||||
} | ||||
void tst_QBarCategoriesAxis::autoscale_data() | ||||
{ | ||||
} | ||||
void tst_QBarCategoriesAxis::autoscale() | ||||
{ | ||||
delete m_baraxis; | ||||
|
r1808 | m_baraxis = new QBarCategoryAxis(); | ||
|
r1764 | |||
QSignalSpy spy0(m_baraxis, SIGNAL(maxChanged(QString))); | ||||
QSignalSpy spy1(m_baraxis, SIGNAL(minChanged(QString))); | ||||
|
r2110 | QSignalSpy spy2(m_baraxis, SIGNAL(rangeChanged(QString,QString))); | ||
|
r1764 | |||
QCOMPARE(m_baraxis->min(),QString()); | ||||
QCOMPARE(m_baraxis->max(),QString()); | ||||
m_chart->setAxisX(m_baraxis, m_series); | ||||
QCOMPARE(spy0.count(), 1); | ||||
QCOMPARE(spy1.count(), 1); | ||||
QCOMPARE(spy2.count(), 1); | ||||
m_view->show(); | ||||
QTest::qWaitForWindowShown(m_view); | ||||
QCOMPARE(m_baraxis->min(),QString("1")); | ||||
QCOMPARE(m_baraxis->max(),QString("6")); | ||||
} | ||||
|
r1725 | QTEST_MAIN(tst_QBarCategoriesAxis) | ||
|
r1810 | #include "tst_qbarcategoryaxis.moc" | ||
|
r1725 | |||