##// END OF EJS Templates
label angle initialization fix
label angle initialization fix

File last commit:

r2110:a93a773ef512
r2406:d3d25f8317f5
Show More
tst_qbarseries.cpp
707 lines | 21.1 KiB | text/x-c | CppLexer
sauimone
barseries unit testing
r1100 /****************************************************************************
**
** Copyright (C) 2012 Digia Plc
** 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 <QtTest/QtTest>
sauimone
GroupedBarSeries to BarSeries
r1594 #include <qbarseries.h>
sauimone
include header fix
r1106 #include <qbarset.h>
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 #include <qchartview.h>
#include <qchart.h>
Jani Honkonen
autotests: try to fix bar hover failures in bamboo
r1466 #include "tst_definitions.h"
sauimone
barseries unit testing
r1100
QTCOMMERCIALCHART_USE_NAMESPACE
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 Q_DECLARE_METATYPE(QBarSet*)
sauimone
Implemented QBarSeries::take(), updated tests
r1802 Q_DECLARE_METATYPE(QList<QBarSet*>)
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
sauimone
barseries unit testing
r1100 class tst_QBarSeries : public QObject
{
Q_OBJECT
public slots:
void initTestCase();
void cleanupTestCase();
void init();
void cleanup();
private slots:
void qbarseries_data();
void qbarseries();
void type_data();
void type();
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 void append_data();
void append();
void remove_data();
void remove();
sauimone
Implemented QBarSeries::take(), updated tests
r1802 void take_data();
void take();
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 void appendList_data();
void appendList();
sauimone
barsetCount -> count in tests and examples too
r1463 void count_data();
void count();
sauimone
updated barseries unit test. fixed found errors.
r1101 void barSets_data();
void barSets();
void setLabelsVisible_data();
void setLabelsVisible();
Tero Ahola
Added opacity property to QAbstractSeries
r2067 void opacity();
sauimone
mouse hover test cases for barcharts
r1146 void mouseclicked_data();
void mouseclicked();
void mousehovered_data();
void mousehovered();
Marek Rosa
Added new test case to BarSeries tests: clear() with animations enabled
r1375 void clearWithAnimations();
Jani Honkonen
Adding series destruction tests for bar & pie...
r1768 void destruction();
sauimone
barseries unit testing
r1100
private:
sauimone
GroupedBarSeries to BarSeries
r1594 QBarSeries* m_barseries;
QBarSeries* m_barseries_with_sets;
sauimone
updated barseries unit test. fixed found errors.
r1101
QList<QBarSet*> m_testSets;
sauimone
barseries unit testing
r1100 };
void tst_QBarSeries::initTestCase()
{
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 qRegisterMetaType<QBarSet*>("QBarSet*");
Michal Klocek
minor. compilation fix in tst_qbarseries
r1803 qRegisterMetaType<QList<QBarSet*> >("QList<QBarSet*>");
sauimone
barseries unit testing
r1100 }
void tst_QBarSeries::cleanupTestCase()
{
}
void tst_QBarSeries::init()
{
sauimone
GroupedBarSeries to BarSeries
r1594 m_barseries = new QBarSeries();
m_barseries_with_sets = new QBarSeries();
sauimone
updated barseries unit test. fixed found errors.
r1101
for (int i=0; i<5; i++) {
m_testSets.append(new QBarSet("testset"));
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 m_barseries_with_sets->append(m_testSets.at(i));
sauimone
updated barseries unit test. fixed found errors.
r1101 }
sauimone
barseries unit testing
r1100 }
void tst_QBarSeries::cleanup()
{
Jani Honkonen
coding style: foreach whitespace fix
r2100 foreach (QBarSet* s, m_testSets) {
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 m_barseries_with_sets->remove(s);
sauimone
updated barseries unit test. fixed found errors.
r1101 }
m_testSets.clear();
sauimone
barseries unit testing
r1100 delete m_barseries;
m_barseries = 0;
sauimone
updated barseries unit test. fixed found errors.
r1101 delete m_barseries_with_sets;
m_barseries_with_sets = 0;
sauimone
barseries unit testing
r1100 }
void tst_QBarSeries::qbarseries_data()
{
}
void tst_QBarSeries::qbarseries()
{
sauimone
GroupedBarSeries to BarSeries
r1594 QBarSeries *barseries = new QBarSeries();
sauimone
barseries unit testing
r1100 QVERIFY(barseries != 0);
}
void tst_QBarSeries::type_data()
{
}
void tst_QBarSeries::type()
{
QVERIFY(m_barseries->type() == QAbstractSeries::SeriesTypeBar);
}
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 void tst_QBarSeries::append_data()
sauimone
barseries unit testing
r1100 {
}
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 void tst_QBarSeries::append()
sauimone
barseries unit testing
r1100 {
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries->count() == 0);
sauimone
barseries unit testing
r1100
sauimone
improved set/remove barset test cases. fixed errors
r1122 bool ret = false;
// Try adding barset
sauimone
barseries unit testing
r1100 QBarSet *barset = new QBarSet("testset");
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 ret = m_barseries->append(barset);
sauimone
barseries unit testing
r1100
sauimone
improved set/remove barset test cases. fixed errors
r1122 QVERIFY(ret == true);
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries->count() == 1);
sauimone
updated barseries unit test. fixed found errors.
r1101
sauimone
improved set/remove barset test cases. fixed errors
r1122 // Try adding another set
sauimone
updated barseries unit test. fixed found errors.
r1101 QBarSet *barset2 = new QBarSet("testset2");
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 ret = m_barseries->append(barset2);
sauimone
improved set/remove barset test cases. fixed errors
r1122
QVERIFY(ret == true);
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries->count() == 2);
sauimone
updated barseries unit test. fixed found errors.
r1101
sauimone
improved set/remove barset test cases. fixed errors
r1122 // Try adding same set again
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 ret = m_barseries->append(barset2);
sauimone
improved set/remove barset test cases. fixed errors
r1122 QVERIFY(ret == false);
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries->count() == 2);
sauimone
improved set/remove barset test cases. fixed errors
r1122
// Try adding null set
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 ret = m_barseries->append(0);
sauimone
improved set/remove barset test cases. fixed errors
r1122 QVERIFY(ret == false);
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries->count() == 2);
sauimone
improved set/remove barset test cases. fixed errors
r1122
sauimone
updated barseries unit test. fixed found errors.
r1101 }
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 void tst_QBarSeries::remove_data()
sauimone
updated barseries unit test. fixed found errors.
r1101 {
}
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 void tst_QBarSeries::remove()
sauimone
updated barseries unit test. fixed found errors.
r1101 {
int count = m_testSets.count();
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries_with_sets->count() == count);
sauimone
updated barseries unit test. fixed found errors.
r1101
sauimone
improved set/remove barset test cases. fixed errors
r1122 // Try to remove null pointer (should not remove, should not crash)
bool ret = false;
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 ret = m_barseries_with_sets->remove(0);
sauimone
improved set/remove barset test cases. fixed errors
r1122 QVERIFY(ret == false);
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries_with_sets->count() == count);
sauimone
improved set/remove barset test cases. fixed errors
r1122
// Try to remove invalid pointer (should not remove, should not crash)
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 ret = m_barseries_with_sets->remove((QBarSet*) (m_testSets.at(0) + 1) );
sauimone
improved set/remove barset test cases. fixed errors
r1122 QVERIFY(ret == false);
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries_with_sets->count() == count);
sauimone
improved set/remove barset test cases. fixed errors
r1122
sauimone
updated barseries unit test. fixed found errors.
r1101 // remove some sets
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 ret = m_barseries_with_sets->remove(m_testSets.at(2));
sauimone
improved set/remove barset test cases. fixed errors
r1122 QVERIFY(ret == true);
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 ret = m_barseries_with_sets->remove(m_testSets.at(3));
sauimone
improved set/remove barset test cases. fixed errors
r1122 QVERIFY(ret == true);
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 ret = m_barseries_with_sets->remove(m_testSets.at(4));
sauimone
improved set/remove barset test cases. fixed errors
r1122 QVERIFY(ret == true);
sauimone
updated barseries unit test. fixed found errors.
r1101
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries_with_sets->count() == 2);
sauimone
updated barseries unit test. fixed found errors.
r1101
QList<QBarSet*> verifysets = m_barseries_with_sets->barSets();
QVERIFY(verifysets.at(0) == m_testSets.at(0));
QVERIFY(verifysets.at(1) == m_testSets.at(1));
sauimone
improved set/remove barset test cases. fixed errors
r1122 // Try removing all sets again (should be ok, even if some sets have already been removed)
ret = false;
sauimone
updated barseries unit test. fixed found errors.
r1101 for (int i=0; i<count; i++) {
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 ret |= m_barseries_with_sets->remove(m_testSets.at(i));
sauimone
updated barseries unit test. fixed found errors.
r1101 }
sauimone
improved set/remove barset test cases. fixed errors
r1122 QVERIFY(ret == true);
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries_with_sets->count() == 0);
sauimone
updated barseries unit test. fixed found errors.
r1101 }
sauimone
Implemented QBarSeries::take(), updated tests
r1802 void tst_QBarSeries::take_data()
{
}
void tst_QBarSeries::take()
{
int count = m_testSets.count();
QVERIFY(m_barseries_with_sets->count() == count);
QSignalSpy countSpy(m_barseries_with_sets,SIGNAL(countChanged()));
Jani Honkonen
normalize signal/slot signatures
r2110 QSignalSpy removedSpy(m_barseries_with_sets,SIGNAL(barsetsRemoved(QList<QBarSet*>)));
sauimone
Implemented QBarSeries::take(), updated tests
r1802
for (int i=0; i<m_testSets.count(); i++) {
QBarSet* set = m_testSets.at(i);
bool success = m_barseries_with_sets->take(set);
QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
QVERIFY(success);
TRY_COMPARE(countSpy.count(),1);
TRY_COMPARE(removedSpy.count(),1);
QList<QVariant> removedSpyArg = removedSpy.takeFirst();
Michal Klocek
minor. compilation fix in tst_qbarseries
r1803 QList<QBarSet*> removedSets = qvariant_cast<QList<QBarSet*> > (removedSpyArg.at(0));
sauimone
Implemented QBarSeries::take(), updated tests
r1802 QCOMPARE(removedSets.at(0), m_testSets.at(i));
countSpy.takeFirst();
}
}
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 void tst_QBarSeries::appendList_data()
sauimone
updated barseries unit test. fixed found errors.
r1101 {
}
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 void tst_QBarSeries::appendList()
sauimone
updated barseries unit test. fixed found errors.
r1101 {
int count = 5;
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries->count() == 0);
sauimone
updated barseries unit test. fixed found errors.
r1101
QList<QBarSet*> sets;
for (int i=0; i<count; i++) {
sets.append(new QBarSet("testset"));
}
sauimone
improved set/remove barset test cases. fixed errors
r1122 // Append new sets (should succeed, count should match the count of sets)
bool ret = false;
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 ret = m_barseries->append(sets);
sauimone
improved set/remove barset test cases. fixed errors
r1122 QVERIFY(ret == true);
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries->count() == count);
sauimone
improved set/remove barset test cases. fixed errors
r1122
// Append same sets again (should fail, count should remain same)
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 ret = m_barseries->append(sets);
sauimone
improved set/remove barset test cases. fixed errors
r1122 QVERIFY(ret == false);
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries->count() == count);
sauimone
improved set/remove barset test cases. fixed errors
r1122
// Try append empty list (should succeed, but count should remain same)
QList<QBarSet*> invalidList;
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 ret = m_barseries->append(invalidList);
sauimone
improved set/remove barset test cases. fixed errors
r1122 QVERIFY(ret == true);
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries->count() == count);
sauimone
improved set/remove barset test cases. fixed errors
r1122
// Try append list with one new and one existing set (should fail, count remains same)
invalidList.append(new QBarSet("ok set"));
invalidList.append(sets.at(0));
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 ret = m_barseries->append(invalidList);
sauimone
improved set/remove barset test cases. fixed errors
r1122 QVERIFY(ret == false);
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries->count() == count);
sauimone
improved set/remove barset test cases. fixed errors
r1122
// Try append list with null pointers (should fail, count remains same)
QList<QBarSet*> invalidList2;
invalidList2.append(0);
invalidList2.append(0);
invalidList2.append(0);
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 ret = m_barseries->append(invalidList2);
sauimone
improved set/remove barset test cases. fixed errors
r1122 QVERIFY(ret == false);
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries->count() == count);
sauimone
updated barseries unit test. fixed found errors.
r1101 }
sauimone
barsetCount -> count in tests and examples too
r1463 void tst_QBarSeries::count_data()
sauimone
updated barseries unit test. fixed found errors.
r1101 {
}
sauimone
barsetCount -> count in tests and examples too
r1463 void tst_QBarSeries::count()
sauimone
updated barseries unit test. fixed found errors.
r1101 {
sauimone
barsetCount -> count in tests and examples too
r1463 QVERIFY(m_barseries->count() == 0);
QVERIFY(m_barseries_with_sets->count() == m_testSets.count());
sauimone
updated barseries unit test. fixed found errors.
r1101 }
void tst_QBarSeries::barSets_data()
{
}
void tst_QBarSeries::barSets()
{
QVERIFY(m_barseries->barSets().count() == 0);
QList<QBarSet*> sets = m_barseries_with_sets->barSets();
QVERIFY(sets.count() == m_testSets.count());
for (int i=0; i<m_testSets.count(); i++) {
QVERIFY(sets.at(i) == m_testSets.at(i));
}
}
void tst_QBarSeries::setLabelsVisible_data()
{
}
void tst_QBarSeries::setLabelsVisible()
{
sauimone
label test tweak
r1123 // labels should be invisible by default
sauimone
removed barlabel. label visibility control is now per series instead of per set
r1246 QVERIFY(m_barseries->isLabelsVisible() == false);
QVERIFY(m_barseries_with_sets->isLabelsVisible() == false);
sauimone
updated barseries unit test. fixed found errors.
r1101
sauimone
label test tweak
r1123 // turn labels to visible
sauimone
updated barseries unit test. fixed found errors.
r1101 m_barseries_with_sets->setLabelsVisible(true);
sauimone
removed barlabel. label visibility control is now per series instead of per set
r1246 // TODO: test the signal
QVERIFY(m_barseries_with_sets->isLabelsVisible() == true);
sauimone
updated barseries unit test. fixed found errors.
r1101
sauimone
label test tweak
r1123 // turn labels to invisible
sauimone
updated barseries unit test. fixed found errors.
r1101 m_barseries_with_sets->setLabelsVisible(false);
sauimone
removed barlabel. label visibility control is now per series instead of per set
r1246 // TODO: test the signal
QVERIFY(m_barseries_with_sets->isLabelsVisible() == false);
sauimone
label test tweak
r1123
// without parameter, should turn labels to visible
m_barseries_with_sets->setLabelsVisible();
sauimone
removed barlabel. label visibility control is now per series instead of per set
r1246 // TODO: test the signal
QVERIFY(m_barseries_with_sets->isLabelsVisible() == true);
sauimone
barseries unit testing
r1100 }
Tero Ahola
Added opacity property to QAbstractSeries
r2067 void tst_QBarSeries::opacity()
{
QSignalSpy opacitySpy(m_barseries, SIGNAL(opacityChanged()));
QCOMPARE(m_barseries->opacity(), 1.0);
m_barseries->setOpacity(0.5);
QCOMPARE(m_barseries->opacity(), 0.5);
QCOMPARE(opacitySpy.count(), 1);
m_barseries->setOpacity(0.0);
QCOMPARE(m_barseries->opacity(), 0.0);
QCOMPARE(opacitySpy.count(), 2);
m_barseries->setOpacity(1.0);
QCOMPARE(m_barseries->opacity(), 1.0);
QCOMPARE(opacitySpy.count(), 3);
}
sauimone
mouse hover test cases for barcharts
r1146 void tst_QBarSeries::mouseclicked_data()
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 {
}
sauimone
mouse hover test cases for barcharts
r1146 void tst_QBarSeries::mouseclicked()
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 {
sauimone
added SKIP_IF_CANNOT_TEST_MOUSE_EVENTS macro to barseries tests
r2066 SKIP_IF_CANNOT_TEST_MOUSE_EVENTS();
sauimone
GroupedBarSeries to BarSeries
r1594 QBarSeries* series = new QBarSeries();
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
QBarSet* set1 = new QBarSet(QString("set 1"));
sauimone
Removed QPointF from QBarSet
r1580 *set1 << 10 << 10 << 10;
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 series->append(set1);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
QBarSet* set2 = new QBarSet(QString("set 2"));
sauimone
Removed QPointF from QBarSet
r1580 *set2 << 10 << 10 << 10;
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 series->append(set2);
sauimone
bar test update. Tests now calculate expected layout from charts plot area and use that instead of precalculated QPointF magic numbers
r2073 QList<QBarSet*> barSets = series->barSets();
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
sauimone
removed double signal emitting from barseries/set
r1563 QSignalSpy seriesSpy(series,SIGNAL(clicked(int,QBarSet*)));
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 QSignalSpy setSpy1(set1, SIGNAL(clicked(int)));
QSignalSpy setSpy2(set2, SIGNAL(clicked(int)));
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
QChartView view(new QChart());
view.resize(400,300);
view.chart()->addSeries(series);
view.show();
QTest::qWaitForWindowShown(&view);
sauimone
bar test update. Tests now calculate expected layout from charts plot area and use that instead of precalculated QPointF magic numbers
r2073 // Calculate expected layout for bars
QRectF plotArea = view.chart()->plotArea();
qreal width = plotArea.width();
qreal height = plotArea.height();
qreal rangeY = 10; // From 0 to 10 because of maximum value in set is 10
qreal rangeX = 3; // 3 values per set
qreal scaleY = (height / rangeY);
qreal scaleX = (width / rangeX);
qreal setCount = series->count();
qreal domainMinY = 0; // These come from internal domain used by barseries.
qreal domainMinX = -0.5; // No access to domain from outside, so use hard coded values.
qreal rectWidth = (scaleX / setCount) * series->barWidth();
QVector<QRectF> layout;
// 3 = count of values in set
// Note that rects in this vector will be interleaved (set1 bar0, set2 bar0, set1 bar1, set2 bar1, etc.)
for (int i = 0; i < 3; i++) {
qreal yPos = height + scaleY * domainMinY + plotArea.top();
for (int set = 0; set < setCount; set++) {
qreal xPos = (i - domainMinX) * scaleX + plotArea.left();
xPos -= series->count()*rectWidth/2;
xPos += set*rectWidth;
qreal rectHeight = barSets.at(set)->at(i) * scaleY;
QRectF rect(xPos, yPos - rectHeight, rectWidth, rectHeight);
layout.append(rect);
}
}
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 //====================================================================================
sauimone
enable axis layout changes again
r1386 // barset 1, bar 0
sauimone
bar test update. Tests now calculate expected layout from charts plot area and use that instead of precalculated QPointF magic numbers
r2073 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, layout.at(0).center().toPoint());
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
QCOMPARE(seriesSpy.count(), 1);
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 QCOMPARE(setSpy1.count(), 1);
QCOMPARE(setSpy2.count(), 0);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
sauimone
removed double signal emitting from barseries/set
r1563 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1);
QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int);
QVERIFY(seriesSpyArg.at(0).toInt() == 0);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 QList<QVariant> setSpyArg = setSpy1.takeFirst();
QVERIFY(setSpyArg.at(0).type() == QVariant::Int);
QVERIFY(setSpyArg.at(0).toInt() == 0);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 //====================================================================================
sauimone
enable axis layout changes again
r1386 // barset 1, bar 1
sauimone
bar test update. Tests now calculate expected layout from charts plot area and use that instead of precalculated QPointF magic numbers
r2073 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, layout.at(2).center().toPoint());
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
QCOMPARE(seriesSpy.count(), 1);
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 QCOMPARE(setSpy1.count(), 1);
QCOMPARE(setSpy2.count(), 0);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
seriesSpyArg = seriesSpy.takeFirst();
sauimone
removed double signal emitting from barseries/set
r1563 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1);
QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int);
QVERIFY(seriesSpyArg.at(0).toInt() == 1);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 setSpyArg = setSpy1.takeFirst();
QVERIFY(setSpyArg.at(0).type() == QVariant::Int);
QVERIFY(setSpyArg.at(0).toInt() == 1);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 //====================================================================================
sauimone
enable axis layout changes again
r1386 // barset 1, bar 2
sauimone
bar test update. Tests now calculate expected layout from charts plot area and use that instead of precalculated QPointF magic numbers
r2073 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, layout.at(4).center().toPoint());
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
QCOMPARE(seriesSpy.count(), 1);
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 QCOMPARE(setSpy1.count(), 1);
QCOMPARE(setSpy2.count(), 0);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
seriesSpyArg = seriesSpy.takeFirst();
sauimone
removed double signal emitting from barseries/set
r1563 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1);
QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int);
QVERIFY(seriesSpyArg.at(0).toInt() == 2);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 setSpyArg = setSpy1.takeFirst();
QVERIFY(setSpyArg.at(0).type() == QVariant::Int);
QVERIFY(setSpyArg.at(0).toInt() == 2);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 //====================================================================================
sauimone
enable axis layout changes again
r1386 // barset 2, bar 0
sauimone
bar test update. Tests now calculate expected layout from charts plot area and use that instead of precalculated QPointF magic numbers
r2073 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, layout.at(1).center().toPoint());
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
QCOMPARE(seriesSpy.count(), 1);
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 QCOMPARE(setSpy1.count(), 0);
QCOMPARE(setSpy2.count(), 1);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
seriesSpyArg = seriesSpy.takeFirst();
sauimone
removed double signal emitting from barseries/set
r1563 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2);
QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int);
QVERIFY(seriesSpyArg.at(0).toInt() == 0);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 setSpyArg = setSpy2.takeFirst();
QVERIFY(setSpyArg.at(0).type() == QVariant::Int);
QVERIFY(setSpyArg.at(0).toInt() == 0);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 //====================================================================================
sauimone
enable axis layout changes again
r1386 // barset 2, bar 1
sauimone
bar test update. Tests now calculate expected layout from charts plot area and use that instead of precalculated QPointF magic numbers
r2073 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, layout.at(3).center().toPoint());
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
QCOMPARE(seriesSpy.count(), 1);
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 QCOMPARE(setSpy1.count(), 0);
QCOMPARE(setSpy2.count(), 1);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
seriesSpyArg = seriesSpy.takeFirst();
sauimone
removed double signal emitting from barseries/set
r1563 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2);
QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int);
QVERIFY(seriesSpyArg.at(0).toInt() == 1);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 setSpyArg = setSpy2.takeFirst();
QVERIFY(setSpyArg.at(0).type() == QVariant::Int);
QVERIFY(setSpyArg.at(0).toInt() == 1);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 //====================================================================================
sauimone
enable axis layout changes again
r1386 // barset 2, bar 2
sauimone
bar test update. Tests now calculate expected layout from charts plot area and use that instead of precalculated QPointF magic numbers
r2073 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, layout.at(5).center().toPoint());
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
QCOMPARE(seriesSpy.count(), 1);
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 QCOMPARE(setSpy1.count(), 0);
QCOMPARE(setSpy2.count(), 1);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145
seriesSpyArg = seriesSpy.takeFirst();
sauimone
removed double signal emitting from barseries/set
r1563 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2);
QVERIFY(seriesSpyArg.at(0).type() == QVariant::Int);
QVERIFY(seriesSpyArg.at(0).toInt() == 2);
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490
setSpyArg = setSpy2.takeFirst();
QVERIFY(setSpyArg.at(0).type() == QVariant::Int);
QVERIFY(setSpyArg.at(0).toInt() == 2);
sauimone
mouse click test cases for barcharts. Fixed found error
r1145 }
sauimone
mouse hover test cases for barcharts
r1146 void tst_QBarSeries::mousehovered_data()
{
}
void tst_QBarSeries::mousehovered()
{
sauimone
added SKIP_IF_CANNOT_TEST_MOUSE_EVENTS macro to barseries tests
r2066 SKIP_IF_CANNOT_TEST_MOUSE_EVENTS();
sauimone
GroupedBarSeries to BarSeries
r1594 QBarSeries* series = new QBarSeries();
sauimone
mouse hover test cases for barcharts
r1146
QBarSet* set1 = new QBarSet(QString("set 1"));
sauimone
Removed QPointF from QBarSet
r1580 *set1 << 10 << 10 << 10;
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 series->append(set1);
sauimone
mouse hover test cases for barcharts
r1146
QBarSet* set2 = new QBarSet(QString("set 2"));
sauimone
Removed QPointF from QBarSet
r1580 *set2 << 10 << 10 << 10;
sauimone
Renamed appendBarSet to append, removeBarSet to remove
r1194 series->append(set2);
sauimone
bar test update. Tests now calculate expected layout from charts plot area and use that instead of precalculated QPointF magic numbers
r2073 QList<QBarSet*> barSets = series->barSets();
sauimone
mouse hover test cases for barcharts
r1146
sauimone
removed double signal emitting from barseries/set
r1563 QSignalSpy seriesSpy(series,SIGNAL(hovered(bool,QBarSet*)));
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 QSignalSpy setSpy1(set1, SIGNAL(hovered(bool)));
QSignalSpy setSpy2(set2, SIGNAL(hovered(bool)));
sauimone
mouse hover test cases for barcharts
r1146
QChartView view(new QChart());
view.resize(400,300);
view.chart()->addSeries(series);
view.show();
QTest::qWaitForWindowShown(&view);
sauimone
barseries autotest update
r1287 //this is hack since view does not get events otherwise
view.setMouseTracking(true);
sauimone
bar test update. Tests now calculate expected layout from charts plot area and use that instead of precalculated QPointF magic numbers
r2073 // Calculate expected layout for bars
QRectF plotArea = view.chart()->plotArea();
qreal width = plotArea.width();
qreal height = plotArea.height();
qreal rangeY = 10; // From 0 to 10 because of maximum value in set is 10
qreal rangeX = 3; // 3 values per set
qreal scaleY = (height / rangeY);
qreal scaleX = (width / rangeX);
qreal setCount = series->count();
qreal domainMinY = 0; // These come from internal domain used by barseries.
qreal domainMinX = -0.5; // No access to domain from outside, so use hard coded values.
qreal rectWidth = (scaleX / setCount) * series->barWidth();
QVector<QRectF> layout;
// 3 = count of values in set
// Note that rects in this vector will be interleaved (set1 bar0, set2 bar0, set1 bar1, set2 bar1, etc.)
for (int i = 0; i < 3; i++) {
qreal yPos = height + scaleY * domainMinY + plotArea.top();
for (int set = 0; set < setCount; set++) {
qreal xPos = (i - domainMinX) * scaleX + plotArea.left();
xPos -= series->count()*rectWidth/2;
xPos += set*rectWidth;
qreal rectHeight = barSets.at(set)->at(i) * scaleY;
QRectF rect(xPos, yPos - rectHeight, rectWidth, rectHeight);
layout.append(rect);
}
}
sauimone
mouse hover test cases for barcharts
r1146 //=======================================================================
// move mouse to left border
sauimone
bar test update. Tests now calculate expected layout from charts plot area and use that instead of precalculated QPointF magic numbers
r2073 QTest::mouseMove(view.viewport(), QPoint(0, layout.at(0).center().y()));
Jani Honkonen
autotests: try to fix bar hover failures in bamboo
r1466 QCoreApplication::processEvents(QEventLoop::AllEvents, 10000);
TRY_COMPARE(seriesSpy.count(), 0);
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 TRY_COMPARE(setSpy1.count(), 0);
TRY_COMPARE(setSpy2.count(), 0);
sauimone
mouse hover test cases for barcharts
r1146
//=======================================================================
// move mouse on top of set1
sauimone
bar test update. Tests now calculate expected layout from charts plot area and use that instead of precalculated QPointF magic numbers
r2073 QTest::mouseMove(view.viewport(), layout.at(0).center().toPoint());
Jani Honkonen
autotests: try to fix bar hover failures in bamboo
r1466 TRY_COMPARE(seriesSpy.count(), 1);
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 TRY_COMPARE(setSpy1.count(), 1);
TRY_COMPARE(setSpy2.count(), 0);
sauimone
mouse hover test cases for barcharts
r1146
QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
sauimone
removed double signal emitting from barseries/set
r1563 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1);
QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool);
QVERIFY(seriesSpyArg.at(0).toBool() == true);
sauimone
mouse hover test cases for barcharts
r1146
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 QList<QVariant> setSpyArg = setSpy1.takeFirst();
QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
QVERIFY(setSpyArg.at(0).toBool() == true);
sauimone
mouse hover test cases for barcharts
r1146 //=======================================================================
// move mouse from top of set1 to top of set2
sauimone
bar test update. Tests now calculate expected layout from charts plot area and use that instead of precalculated QPointF magic numbers
r2073 QTest::mouseMove(view.viewport(), layout.at(1).center().toPoint());
Jani Honkonen
autotests: try to fix bar hover failures in bamboo
r1466 TRY_COMPARE(seriesSpy.count(), 2);
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 TRY_COMPARE(setSpy1.count(), 1);
TRY_COMPARE(setSpy2.count(), 1);
sauimone
mouse hover test cases for barcharts
r1146
// should leave set1
seriesSpyArg = seriesSpy.takeFirst();
sauimone
removed double signal emitting from barseries/set
r1563 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set1);
QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool);
QVERIFY(seriesSpyArg.at(0).toBool() == false);
sauimone
mouse hover test cases for barcharts
r1146
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 setSpyArg = setSpy1.takeFirst();
QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
QVERIFY(setSpyArg.at(0).toBool() == false);
sauimone
mouse hover test cases for barcharts
r1146 // should enter set2
seriesSpyArg = seriesSpy.takeFirst();
sauimone
removed double signal emitting from barseries/set
r1563 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2);
QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool);
QVERIFY(seriesSpyArg.at(0).toBool() == true);
sauimone
mouse hover test cases for barcharts
r1146
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 setSpyArg = setSpy2.takeFirst();
QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
QVERIFY(setSpyArg.at(0).toBool() == true);
sauimone
mouse hover test cases for barcharts
r1146 //=======================================================================
// move mouse from top of set2 to background
sauimone
bar test update. Tests now calculate expected layout from charts plot area and use that instead of precalculated QPointF magic numbers
r2073 QTest::mouseMove(view.viewport(), QPoint(layout.at(1).center().x(), 0));
Jani Honkonen
autotests: try to fix bar hover failures in bamboo
r1466 TRY_COMPARE(seriesSpy.count(), 1);
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490 TRY_COMPARE(setSpy1.count(), 0);
TRY_COMPARE(setSpy2.count(), 1);
sauimone
mouse hover test cases for barcharts
r1146
sauimone
barseries autotest update
r1287 // should leave set2
sauimone
mouse hover test cases for barcharts
r1146 seriesSpyArg = seriesSpy.takeFirst();
sauimone
removed double signal emitting from barseries/set
r1563 QCOMPARE(qvariant_cast<QBarSet*>(seriesSpyArg.at(1)), set2);
QVERIFY(seriesSpyArg.at(0).type() == QVariant::Bool);
QVERIFY(seriesSpyArg.at(0).toBool() == false);
sauimone
reintroducing clicked and hovered signals to barset. Makes some things easier on QML api
r1490
setSpyArg = setSpy2.takeFirst();
QVERIFY(setSpyArg.at(0).type() == QVariant::Bool);
QVERIFY(setSpyArg.at(0).toBool() == false);
sauimone
mouse hover test cases for barcharts
r1146 }
Marek Rosa
Added new test case to BarSeries tests: clear() with animations enabled
r1375 void tst_QBarSeries::clearWithAnimations()
{
sauimone
GroupedBarSeries to BarSeries
r1594 QBarSeries* series = new QBarSeries();
Marek Rosa
Added new test case to BarSeries tests: clear() with animations enabled
r1375
QBarSet* set1 = new QBarSet(QString("set 1"));
sauimone
Removed QPointF from QBarSet
r1580 *set1 << 10 << 10 << 10;
Marek Rosa
Added new test case to BarSeries tests: clear() with animations enabled
r1375 series->append(set1);
QBarSet* set2 = new QBarSet(QString("set 2"));
sauimone
Removed QPointF from QBarSet
r1580 *set2 << 10 << 10 << 10;
Marek Rosa
Added new test case to BarSeries tests: clear() with animations enabled
r1375 series->append(set2);
QChartView view(new QChart());
view.resize(400,300);
view.chart()->setAnimationOptions(QChart::SeriesAnimations);
view.chart()->addSeries(series);
view.show();
series->clear();
}
Jani Honkonen
Adding series destruction tests for bar & pie...
r1768 void tst_QBarSeries::destruction()
{
// add a barset
QBarSeries *series = new QBarSeries();
QBarSet *set = new QBarSet("testset");
QSignalSpy spy1(set, SIGNAL(destroyed()));
series->append(set);
// delete the series
delete series;
// check that series deletes the set
QCOMPARE(spy1.count(), 1);
}
sauimone
barseries unit testing
r1100 QTEST_MAIN(tst_QBarSeries)
#include "tst_qbarseries.moc"