##// END OF EJS Templates
Plugged some memory leaks....
Plugged some memory leaks. Autotests were also made Valgrind friendly by adding a final one millisecond wait to the end of the test to allow pending deleteLaters to run. Also some minor cosmetic cleanup done to autotests. Change-Id: Ic3719167a22949f243eaf54614e174a681dbe34a Reviewed-by: Titta Heikkala <titta.heikkala@theqtcompany.com>

File last commit:

r2733:c6ed50e68438
r2733:c6ed50e68438
Show More
tst_qbarmodelmapper.cpp
680 lines | 25.6 KiB | text/x-c | CppLexer
Marek Rosa
License added to several files
r1365 /****************************************************************************
**
Titta Heikkala
Update copyright year...
r2688 ** Copyright (C) 2014 Digia Plc
Marek Rosa
License added to several files
r1365 ** All rights reserved.
** For any questions to Digia, please use contact form at http://qt.digia.com
**
Miikka Heikkinen
Qt Commercial -> Qt Enterprise...
r2574 ** This file is part of the Qt Enterprise Charts Add-on.
Marek Rosa
License added to several files
r1365 **
** $QT_BEGIN_LICENSE$
Miikka Heikkinen
Qt Commercial -> Qt Enterprise...
r2574 ** Licensees holding valid Qt Enterprise licenses may use this file in
** accordance with the Qt Enterprise License Agreement provided with the
Marek Rosa
License added to several files
r1365 ** 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$
**
****************************************************************************/
Marek Rosa
Added some tests for BarModelMapper
r1364 #include <QtCore/QString>
#include <QtTest/QtTest>
Titta Heikkala
Fix include syntax...
r2714 #include <QtCharts/QChart>
#include <QtCharts/QChartView>
#include <QtCharts/QBarSeries>
#include <QtCharts/QBarSet>
#include <QtCharts/QVBarModelMapper>
#include <QtCharts/QHBarModelMapper>
#include <QtGui/QStandardItemModel>
Marek Rosa
Added some tests for BarModelMapper
r1364
Titta Heikkala
Qt Charts project file structure change...
r2712 QT_CHARTS_USE_NAMESPACE
Marek Rosa
Added some tests for BarModelMapper
r1364
class tst_qbarmodelmapper : public QObject
{
Q_OBJECT
public:
tst_qbarmodelmapper();
Marek Rosa
Added more test for QBarModelMapper
r1428 void createVerticalMapper();
void createHorizontalMapper();
Marek Rosa
Added some tests for BarModelMapper
r1364
private Q_SLOTS:
void initTestCase();
void cleanupTestCase();
void init();
void cleanup();
void verticalMapper_data();
void verticalMapper();
void verticalMapperCustomMapping_data();
void verticalMapperCustomMapping();
void horizontalMapper_data();
void horizontalMapper();
void horizontalMapperCustomMapping_data();
void horizontalMapperCustomMapping();
Marek Rosa
New test added to BarModelMapper
r1436 void seriesUpdated();
Marek Rosa
Added more test for QBarModelMapper
r1428 void verticalModelInsertRows();
void verticalModelRemoveRows();
void verticalModelInsertColumns();
void verticalModelRemoveColumns();
void horizontalModelInsertRows();
void horizontalModelRemoveRows();
void horizontalModelInsertColumns();
void horizontalModelRemoveColumns();
void modelUpdateCell();
Marek Rosa
Added signals tests to pie and bar model mappers
r1924 void verticalMapperSignals();
void horizontalMapperSignals();
Marek Rosa
Added more test for QBarModelMapper
r1428
Marek Rosa
Added some tests for BarModelMapper
r1364 private:
QStandardItemModel *m_model;
int m_modelRowCount;
int m_modelColumnCount;
Marek Rosa
Added more test for QBarModelMapper
r1428 QVBarModelMapper *m_vMapper;
QHBarModelMapper *m_hMapper;
sauimone
GroupedBarSeries to BarSeries
r1594 QBarSeries *m_series;
Marek Rosa
Added some tests for BarModelMapper
r1364 QChart *m_chart;
Miikka Heikkinen
Plugged some memory leaks....
r2733 QChartView *m_chartView;
Marek Rosa
Added some tests for BarModelMapper
r1364 };
tst_qbarmodelmapper::tst_qbarmodelmapper():
m_model(0),
m_modelRowCount(10),
Marek Rosa
Added more test for QBarModelMapper
r1428 m_modelColumnCount(8),
m_vMapper(0),
m_hMapper(0),
m_series(0),
Miikka Heikkinen
Plugged some memory leaks....
r2733 m_chart(0),
m_chartView(0)
Marek Rosa
Added more test for QBarModelMapper
r1428 {
}
void tst_qbarmodelmapper::createVerticalMapper()
{
m_vMapper = new QVBarModelMapper;
QVERIFY(m_vMapper->model() == 0);
m_vMapper->setFirstBarSetColumn(0);
m_vMapper->setLastBarSetColumn(4);
m_vMapper->setModel(m_model);
m_vMapper->setSeries(m_series);
}
void tst_qbarmodelmapper::createHorizontalMapper()
Marek Rosa
Added some tests for BarModelMapper
r1364 {
Marek Rosa
Added more test for QBarModelMapper
r1428 m_hMapper = new QHBarModelMapper;
QVERIFY(m_hMapper->model() == 0);
m_hMapper->setFirstBarSetRow(0);
m_hMapper->setLastBarSetRow(4);
m_hMapper->setModel(m_model);
m_hMapper->setSeries(m_series);
Marek Rosa
Added some tests for BarModelMapper
r1364 }
void tst_qbarmodelmapper::init()
{
sauimone
GroupedBarSeries to BarSeries
r1594 m_series = new QBarSeries;
Marek Rosa
Added more test for QBarModelMapper
r1428 m_chart->addSeries(m_series);
m_model = new QStandardItemModel(m_modelRowCount, m_modelColumnCount, this);
for (int row = 0; row < m_modelRowCount; ++row) {
for (int column = 0; column < m_modelColumnCount; column++) {
m_model->setData(m_model->index(row, column), row * column);
}
}
Marek Rosa
Added some tests for BarModelMapper
r1364 }
void tst_qbarmodelmapper::cleanup()
{
m_chart->removeSeries(m_series);
delete m_series;
m_series = 0;
Marek Rosa
Added more test for QBarModelMapper
r1428
m_model->clear();
m_model->deleteLater();
m_model = 0;
if (m_vMapper) {
m_vMapper->deleteLater();
m_vMapper = 0;
}
if (m_hMapper) {
m_hMapper->deleteLater();
m_hMapper = 0;
}
Marek Rosa
Added some tests for BarModelMapper
r1364 }
void tst_qbarmodelmapper::initTestCase()
{
m_chart = new QChart;
Miikka Heikkinen
Plugged some memory leaks....
r2733 m_chartView = new QChartView(m_chart);
m_chartView->show();
Marek Rosa
Added some tests for BarModelMapper
r1364 }
void tst_qbarmodelmapper::cleanupTestCase()
{
Miikka Heikkinen
Plugged some memory leaks....
r2733 delete m_chartView;
QTest::qWait(1); // Allow final deleteLaters to run
Marek Rosa
Added some tests for BarModelMapper
r1364 }
void tst_qbarmodelmapper::verticalMapper_data()
{
QTest::addColumn<int>("firstBarSetColumn");
QTest::addColumn<int>("lastBarSetColumn");
QTest::addColumn<int>("expectedBarSetCount");
QTest::newRow("lastBarSetColumn greater than firstBarSetColumn") << 0 << 1 << 2;
QTest::newRow("lastBarSetColumn equal to firstBarSetColumn") << 1 << 1 << 1;
QTest::newRow("lastBarSetColumn lesser than firstBarSetColumn") << 1 << 0 << 0;
QTest::newRow("invalid firstBarSetColumn and correct lastBarSetColumn") << -3 << 1 << 0;
QTest::newRow("firstBarSetColumn beyond the size of model and correct lastBarSetColumn") << m_modelColumnCount << 1 << 0;
QTest::newRow("firstBarSetColumn beyond the size of model and invalid lastBarSetColumn") << m_modelColumnCount << -1 << 0;
}
void tst_qbarmodelmapper::verticalMapper()
{
QFETCH(int, firstBarSetColumn);
QFETCH(int, lastBarSetColumn);
QFETCH(int, expectedBarSetCount);
Miikka Heikkinen
Plugged some memory leaks....
r2733 QBarSeries *series = new QBarSeries;
Marek Rosa
Added some tests for BarModelMapper
r1364
QVBarModelMapper *mapper = new QVBarModelMapper;
mapper->setFirstBarSetColumn(firstBarSetColumn);
mapper->setLastBarSetColumn(lastBarSetColumn);
mapper->setModel(m_model);
Miikka Heikkinen
Plugged some memory leaks....
r2733 mapper->setSeries(series);
Marek Rosa
Added some tests for BarModelMapper
r1364
Miikka Heikkinen
Plugged some memory leaks....
r2733 m_chart->addSeries(series);
Marek Rosa
Added some tests for BarModelMapper
r1364
Miikka Heikkinen
Plugged some memory leaks....
r2733 QCOMPARE(series->count(), expectedBarSetCount);
Marek Rosa
Added some tests for BarModelMapper
r1364 QCOMPARE(mapper->firstBarSetColumn(), qMax(-1, firstBarSetColumn));
QCOMPARE(mapper->lastBarSetColumn(), qMax(-1, lastBarSetColumn));
delete mapper;
Miikka Heikkinen
Plugged some memory leaks....
r2733 m_chart->removeSeries(series);
delete series;
Marek Rosa
Added some tests for BarModelMapper
r1364 }
void tst_qbarmodelmapper::verticalMapperCustomMapping_data()
{
QTest::addColumn<int>("first");
QTest::addColumn<int>("countLimit");
QTest::addColumn<int>("expectedBarSetCount");
QTest::addColumn<int>("expectedCount");
QTest::newRow("first: 0, unlimited count") << 0 << -1 << 2 << m_modelRowCount;
QTest::newRow("first: 3, unlimited count") << 3 << -1 << 2 << m_modelRowCount - 3;
QTest::newRow("first: 0, count: 5") << 0 << 5 << 2 << qMin(5, m_modelRowCount);
QTest::newRow("first: 3, count: 5") << 3 << 5 << 2 << qMin(5, m_modelRowCount - 3);
QTest::newRow("first: +1 greater then the number of rows in the model, unlimited count") << m_modelRowCount + 1 << -1 << 0 << 0;
QTest::newRow("first: +1 greater then the number of rows in the model, count: 5") << m_modelRowCount + 1 << 5 << 0 << 0;
QTest::newRow("first: 0, count: +3 greater than the number of rows in the model (should limit to the size of model)") << 0 << m_modelRowCount + 3 << 2 << m_modelRowCount;
QTest::newRow("first: -3(invalid - should default to 0), unlimited count") << -3 << -1 << 2 << m_modelRowCount;
QTest::newRow("first: 0, count: -3 (invalid - shlould default to -1)") << 0 << -3 << 2 << m_modelRowCount;
QTest::newRow("first: -3(invalid - should default to 0), count: -3 (invalid - shlould default to -1)") << -3 << -3 << 2 << m_modelRowCount;
}
void tst_qbarmodelmapper::verticalMapperCustomMapping()
{
QFETCH(int, first);
QFETCH(int, countLimit);
QFETCH(int, expectedBarSetCount);
QFETCH(int, expectedCount);
Miikka Heikkinen
Plugged some memory leaks....
r2733 QBarSeries *series = new QBarSeries;
Marek Rosa
Added some tests for BarModelMapper
r1364
Miikka Heikkinen
Plugged some memory leaks....
r2733 QCOMPARE(series->count(), 0);
Marek Rosa
Added some tests for BarModelMapper
r1364
QVBarModelMapper *mapper = new QVBarModelMapper;
mapper->setFirstBarSetColumn(0);
mapper->setLastBarSetColumn(1);
mapper->setModel(m_model);
Miikka Heikkinen
Plugged some memory leaks....
r2733 mapper->setSeries(series);
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 mapper->setFirstRow(first);
mapper->setRowCount(countLimit);
Miikka Heikkinen
Plugged some memory leaks....
r2733 m_chart->addSeries(series);
Marek Rosa
Added some tests for BarModelMapper
r1364
Miikka Heikkinen
Plugged some memory leaks....
r2733 QCOMPARE(series->count(), expectedBarSetCount);
Marek Rosa
Added some tests for BarModelMapper
r1364
if (expectedBarSetCount > 0)
Miikka Heikkinen
Plugged some memory leaks....
r2733 QCOMPARE(series->barSets().first()->count(), expectedCount);
Marek Rosa
Added some tests for BarModelMapper
r1364
// change values column mapping to invalid
mapper->setFirstBarSetColumn(-1);
mapper->setLastBarSetColumn(1);
Miikka Heikkinen
Plugged some memory leaks....
r2733 QCOMPARE(series->count(), 0);
Marek Rosa
Added some tests for BarModelMapper
r1364
delete mapper;
Miikka Heikkinen
Plugged some memory leaks....
r2733 m_chart->removeSeries(series);
delete series;
Marek Rosa
Added some tests for BarModelMapper
r1364 }
void tst_qbarmodelmapper::horizontalMapper_data()
{
QTest::addColumn<int>("firstBarSetRow");
QTest::addColumn<int>("lastBarSetRow");
QTest::addColumn<int>("expectedBarSetCount");
QTest::newRow("lastBarSetRow greater than firstBarSetRow") << 0 << 1 << 2;
QTest::newRow("lastBarSetRow equal to firstBarSetRow") << 1 << 1 << 1;
QTest::newRow("lastBarSetRow lesser than firstBarSetRow") << 1 << 0 << 0;
QTest::newRow("invalid firstBarSetRow and correct lastBarSetRow") << -3 << 1 << 0;
QTest::newRow("firstBarSetRow beyond the size of model and correct lastBarSetRow") << m_modelRowCount << 1 << 0;
QTest::newRow("firstBarSetRow beyond the size of model and invalid lastBarSetRow") << m_modelRowCount << -1 << 0;
}
void tst_qbarmodelmapper::horizontalMapper()
{
QFETCH(int, firstBarSetRow);
QFETCH(int, lastBarSetRow);
QFETCH(int, expectedBarSetCount);
Miikka Heikkinen
Plugged some memory leaks....
r2733 QBarSeries *series = new QBarSeries;
Marek Rosa
Added some tests for BarModelMapper
r1364
QHBarModelMapper *mapper = new QHBarModelMapper;
mapper->setFirstBarSetRow(firstBarSetRow);
mapper->setLastBarSetRow(lastBarSetRow);
mapper->setModel(m_model);
Miikka Heikkinen
Plugged some memory leaks....
r2733 mapper->setSeries(series);
Marek Rosa
Added some tests for BarModelMapper
r1364
Miikka Heikkinen
Plugged some memory leaks....
r2733 m_chart->addSeries(series);
Marek Rosa
Added some tests for BarModelMapper
r1364
Miikka Heikkinen
Plugged some memory leaks....
r2733 QCOMPARE(series->count(), expectedBarSetCount);
Marek Rosa
Added some tests for BarModelMapper
r1364 QCOMPARE(mapper->firstBarSetRow(), qMax(-1, firstBarSetRow));
QCOMPARE(mapper->lastBarSetRow(), qMax(-1, lastBarSetRow));
delete mapper;
Miikka Heikkinen
Plugged some memory leaks....
r2733 m_chart->removeSeries(series);
delete series;
Marek Rosa
Added some tests for BarModelMapper
r1364 }
void tst_qbarmodelmapper::horizontalMapperCustomMapping_data()
{
QTest::addColumn<int>("first");
QTest::addColumn<int>("countLimit");
QTest::addColumn<int>("expectedBarSetCount");
QTest::addColumn<int>("expectedCount");
QTest::newRow("first: 0, unlimited count") << 0 << -1 << 2 << m_modelColumnCount;
QTest::newRow("first: 3, unlimited count") << 3 << -1 << 2 << m_modelColumnCount - 3;
QTest::newRow("first: 0, count: 5") << 0 << 5 << 2 << qMin(5, m_modelColumnCount);
QTest::newRow("first: 3, count: 5") << 3 << 5 << 2 << qMin(5, m_modelColumnCount - 3);
QTest::newRow("first: +1 greater then the number of rows in the model, unlimited count") << m_modelColumnCount + 1 << -1 << 0 << 0;
QTest::newRow("first: +1 greater then the number of rows in the model, count: 5") << m_modelColumnCount + 1 << 5 << 0 << 0;
QTest::newRow("first: 0, count: +3 greater than the number of rows in the model (should limit to the size of model)") << 0 << m_modelColumnCount + 3 << 2 << m_modelColumnCount;
QTest::newRow("first: -3(invalid - should default to 0), unlimited count") << -3 << -1 << 2 << m_modelColumnCount;
QTest::newRow("first: 0, count: -3 (invalid - shlould default to -1)") << 0 << -3 << 2 << m_modelColumnCount;
QTest::newRow("first: -3(invalid - should default to 0), count: -3 (invalid - shlould default to -1)") << -3 << -3 << 2 << m_modelColumnCount;
}
void tst_qbarmodelmapper::horizontalMapperCustomMapping()
{
QFETCH(int, first);
QFETCH(int, countLimit);
QFETCH(int, expectedBarSetCount);
QFETCH(int, expectedCount);
Miikka Heikkinen
Plugged some memory leaks....
r2733 QBarSeries *series = new QBarSeries;
Marek Rosa
Added some tests for BarModelMapper
r1364
Miikka Heikkinen
Plugged some memory leaks....
r2733 QCOMPARE(series->count(), 0);
Marek Rosa
Added some tests for BarModelMapper
r1364
QHBarModelMapper *mapper = new QHBarModelMapper;
mapper->setFirstBarSetRow(0);
mapper->setLastBarSetRow(1);
mapper->setModel(m_model);
Miikka Heikkinen
Plugged some memory leaks....
r2733 mapper->setSeries(series);
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 mapper->setFirstColumn(first);
mapper->setColumnCount(countLimit);
Miikka Heikkinen
Plugged some memory leaks....
r2733 m_chart->addSeries(series);
Marek Rosa
Added some tests for BarModelMapper
r1364
Miikka Heikkinen
Plugged some memory leaks....
r2733 QCOMPARE(series->count(), expectedBarSetCount);
Marek Rosa
Added some tests for BarModelMapper
r1364
if (expectedBarSetCount > 0)
Miikka Heikkinen
Plugged some memory leaks....
r2733 QCOMPARE(series->barSets().first()->count(), expectedCount);
Marek Rosa
Added some tests for BarModelMapper
r1364
// change values column mapping to invalid
mapper->setFirstBarSetRow(-1);
mapper->setLastBarSetRow(1);
Miikka Heikkinen
Plugged some memory leaks....
r2733 QCOMPARE(series->count(), 0);
Marek Rosa
Added some tests for BarModelMapper
r1364
delete mapper;
Miikka Heikkinen
Plugged some memory leaks....
r2733 m_chart->removeSeries(series);
delete series;
Marek Rosa
Added some tests for BarModelMapper
r1364 }
Marek Rosa
New test added to BarModelMapper
r1436 void tst_qbarmodelmapper::seriesUpdated()
{
// setup the mapper
createVerticalMapper();
QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 QCOMPARE(m_vMapper->rowCount(), -1);
Marek Rosa
New test added to BarModelMapper
r1436
m_series->barSets().first()->append(123);
QCOMPARE(m_model->rowCount(), m_modelRowCount + 1);
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 QCOMPARE(m_vMapper->rowCount(), -1); // the value should not change as it indicates 'all' items there are in the model
Marek Rosa
New test added to BarModelMapper
r1436
m_series->barSets().last()->remove(0, m_modelRowCount);
QCOMPARE(m_model->rowCount(), 1);
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 QCOMPARE(m_vMapper->rowCount(), -1); // the value should not change as it indicates 'all' items there are in the model
Marek Rosa
New test added to BarModelMapper
r1436
m_series->barSets().first()->replace(0, 444.0);
QCOMPARE(m_model->data(m_model->index(0, 0)).toReal(), 444.0);
m_series->barSets().first()->setLabel("Hello");
QCOMPARE(m_model->headerData(0, Qt::Horizontal).toString(), QString("Hello"));
QList<qreal> newValues;
newValues << 15 << 27 << 35 << 49;
m_series->barSets().first()->append(newValues);
QCOMPARE(m_model->rowCount(), 1 + newValues.count());
QList<QBarSet* > newBarSets;
QBarSet* newBarSet_1 = new QBarSet("New_1");
newBarSet_1->append(101);
newBarSet_1->append(102);
newBarSet_1->append(103);
newBarSets.append(newBarSet_1);
Marek Rosa
minor fix
r1602 QBarSet* newBarSet_2 = new QBarSet("New_2");
Marek Rosa
New test added to BarModelMapper
r1436 newBarSet_2->append(201);
newBarSet_2->append(202);
newBarSet_2->append(203);
newBarSets.append(newBarSet_2);
m_series->append(newBarSets);
QCOMPARE(m_model->columnCount(), m_modelColumnCount + newBarSets.count());
}
Marek Rosa
Added more test for QBarModelMapper
r1428 void tst_qbarmodelmapper::verticalModelInsertRows()
{
// setup the mapper
createVerticalMapper();
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
QVERIFY(m_vMapper->model() != 0);
int insertCount = 4;
m_model->insertRows(3, insertCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + insertCount);
int first = 3;
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_vMapper->setFirstRow(3);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + insertCount - first);
m_model->insertRows(3, insertCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + 2 * insertCount - first);
int countLimit = 6;
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_vMapper->setRowCount(countLimit);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount + 2 * insertCount - first));
m_model->insertRows(3, insertCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount - first));
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_vMapper->setFirstRow(0);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount));
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_vMapper->setRowCount(-1);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount + 3 * insertCount);
}
void tst_qbarmodelmapper::verticalModelRemoveRows()
{
// setup the mapper
createVerticalMapper();
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
QVERIFY(m_vMapper->model() != 0);
int removeCount = 2;
m_model->removeRows(1, removeCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - removeCount);
int first = 1;
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_vMapper->setFirstRow(first);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - removeCount - first);
m_model->removeRows(1, removeCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - 2 * removeCount - first);
int countLimit = 3;
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_vMapper->setRowCount(countLimit);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount - 2 * removeCount - first));
m_model->removeRows(1, removeCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount - first));
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_vMapper->setFirstRow(0);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount));
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_vMapper->setRowCount(-1);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount - 3 * removeCount);
}
void tst_qbarmodelmapper::verticalModelInsertColumns()
{
// setup the mapper
createVerticalMapper();
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
QVERIFY(m_vMapper->model() != 0);
int insertCount = 4;
m_model->insertColumns(3, insertCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
}
void tst_qbarmodelmapper::verticalModelRemoveColumns()
{
// setup the mapper
createVerticalMapper();
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), qMin(m_model->columnCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1));
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
QVERIFY(m_vMapper->model() != 0);
int removeCount = m_modelColumnCount - 2;
m_model->removeColumns(0, removeCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), qMin(m_model->columnCount(), m_vMapper->lastBarSetColumn() - m_vMapper->firstBarSetColumn() + 1));
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelRowCount);
// leave all the columns
m_model->removeColumns(0, m_modelColumnCount - removeCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), 0);
Marek Rosa
Added more test for QBarModelMapper
r1428 }
void tst_qbarmodelmapper::horizontalModelInsertRows()
{
// setup the mapper
createHorizontalMapper();
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
QVERIFY(m_hMapper->model() != 0);
int insertCount = 4;
m_model->insertRows(3, insertCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
}
void tst_qbarmodelmapper::horizontalModelRemoveRows()
{
// setup the mapper
createHorizontalMapper();
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), qMin(m_model->rowCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1));
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
QVERIFY(m_hMapper->model() != 0);
int removeCount = m_modelRowCount - 2;
m_model->removeRows(0, removeCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), qMin(m_model->rowCount(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1));
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
// leave all the columns
m_model->removeRows(0, m_modelRowCount - removeCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), 0);
Marek Rosa
Added more test for QBarModelMapper
r1428 }
void tst_qbarmodelmapper::horizontalModelInsertColumns()
{
// setup the mapper
createHorizontalMapper();
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
QVERIFY(m_hMapper->model() != 0);
int insertCount = 4;
m_model->insertColumns(3, insertCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + insertCount);
int first = 3;
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_hMapper->setFirstColumn(3);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + insertCount - first);
m_model->insertColumns(3, insertCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + 2 * insertCount - first);
int countLimit = 6;
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_hMapper->setColumnCount(countLimit);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount + 2 * insertCount - first));
m_model->insertColumns(3, insertCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount - first));
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_hMapper->setFirstColumn(0);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount));
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_hMapper->setColumnCount(-1);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount + 3 * insertCount);
}
void tst_qbarmodelmapper::horizontalModelRemoveColumns()
{
// setup the mapper
createHorizontalMapper();
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount);
QVERIFY(m_hMapper->model() != 0);
int removeCount = 2;
m_model->removeColumns(1, removeCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - removeCount);
int first = 1;
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_hMapper->setFirstColumn(first);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - removeCount - first);
m_model->removeColumns(1, removeCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - 2 * removeCount - first);
int countLimit = 3;
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_hMapper->setColumnCount(countLimit);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount - 2 * removeCount - first));
m_model->removeColumns(1, removeCount);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount - first));
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_hMapper->setFirstColumn(0);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount));
Marek Rosa
BarModel mapper properties first, count moved to Vertical and Horizontal mappers with more descriptive names
r1495 m_hMapper->setColumnCount(-1);
sauimone
barsetCount -> count in tests and examples too
r1463 QCOMPARE(m_series->count(), m_hMapper->lastBarSetRow() - m_hMapper->firstBarSetRow() + 1);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_series->barSets().first()->count(), m_modelColumnCount - 3 * removeCount);
}
void tst_qbarmodelmapper::modelUpdateCell()
{
// setup the mapper
createVerticalMapper();
QVERIFY(m_model->setData(m_model->index(1, 0), 44));
sauimone
Removed QPointF from QBarSet
r1580 QCOMPARE(m_series->barSets().at(0)->at(1), 44.0);
Marek Rosa
Added more test for QBarModelMapper
r1428 QCOMPARE(m_model->data(m_model->index(1, 0)).toReal(), 44.0);
}
Marek Rosa
Added signals tests to pie and bar model mappers
r1924 void tst_qbarmodelmapper::verticalMapperSignals()
{
QVBarModelMapper *mapper = new QVBarModelMapper;
QSignalSpy spy0(mapper, SIGNAL(firstRowChanged()));
QSignalSpy spy1(mapper, SIGNAL(rowCountChanged()));
QSignalSpy spy2(mapper, SIGNAL(firstBarSetColumnChanged()));
QSignalSpy spy3(mapper, SIGNAL(lastBarSetColumnChanged()));
QSignalSpy spy4(mapper, SIGNAL(modelReplaced()));
QSignalSpy spy5(mapper, SIGNAL(seriesReplaced()));
mapper->setFirstBarSetColumn(0);
mapper->setLastBarSetColumn(1);
mapper->setModel(m_model);
mapper->setSeries(m_series);
mapper->setFirstRow(1);
mapper->setRowCount(5);
QCOMPARE(spy0.count(), 1);
QCOMPARE(spy1.count(), 1);
QCOMPARE(spy2.count(), 1);
QCOMPARE(spy3.count(), 1);
QCOMPARE(spy4.count(), 1);
QCOMPARE(spy5.count(), 1);
Miikka Heikkinen
Plugged some memory leaks....
r2733 delete mapper;
Marek Rosa
Added signals tests to pie and bar model mappers
r1924 }
void tst_qbarmodelmapper::horizontalMapperSignals()
{
QHBarModelMapper *mapper = new QHBarModelMapper;
QSignalSpy spy0(mapper, SIGNAL(firstColumnChanged()));
QSignalSpy spy1(mapper, SIGNAL(columnCountChanged()));
QSignalSpy spy2(mapper, SIGNAL(firstBarSetRowChanged()));
QSignalSpy spy3(mapper, SIGNAL(lastBarSetRowChanged()));
QSignalSpy spy4(mapper, SIGNAL(modelReplaced()));
QSignalSpy spy5(mapper, SIGNAL(seriesReplaced()));
mapper->setFirstBarSetRow(0);
mapper->setLastBarSetRow(1);
mapper->setModel(m_model);
mapper->setSeries(m_series);
mapper->setFirstColumn(1);
mapper->setColumnCount(5);
QCOMPARE(spy0.count(), 1);
QCOMPARE(spy1.count(), 1);
QCOMPARE(spy2.count(), 1);
QCOMPARE(spy3.count(), 1);
QCOMPARE(spy4.count(), 1);
QCOMPARE(spy5.count(), 1);
Miikka Heikkinen
Plugged some memory leaks....
r2733
delete mapper;
Marek Rosa
Added signals tests to pie and bar model mappers
r1924 }
Marek Rosa
Added some tests for BarModelMapper
r1364 QTEST_MAIN(tst_qbarmodelmapper)
#include "tst_qbarmodelmapper.moc"