##// END OF EJS Templates
Fix label angle setting for axis before axis is added to chart....
Fix label angle setting for axis before axis is added to chart. Since slots are obviously not connected before ChartAxis item is created, setting label angle before this is lost unless set in the constructor.

File last commit:

r1922:c54b94e53f20
r2410:47bf654423ee
Show More
tst_qxymodelmapper.cpp
584 lines | 18.4 KiB | text/x-c | CppLexer
Marek Rosa
License added to several files
r1365 /****************************************************************************
**
** 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$
**
****************************************************************************/
Marek Rosa
Added tests for XYModelMapper
r1352 #include <QtCore/QString>
#include <QtTest/QtTest>
#include <qchart.h>
#include <qchartview.h>
#include <qxyseries.h>
#include <qlineseries.h>
#include <qvxymodelmapper.h>
#include <qhxymodelmapper.h>
#include <QStandardItemModel>
QTCOMMERCIALCHART_USE_NAMESPACE
class tst_qxymodelmapper : public QObject
{
Q_OBJECT
Marek Rosa
Added more tests to QXYModelMapper
r1422 public:
Marek Rosa
Added tests for XYModelMapper
r1352 tst_qxymodelmapper();
Marek Rosa
Added more tests to QXYModelMapper
r1422 void createVerticalMapper();
void createHorizontalMapper();
Marek Rosa
Added tests for XYModelMapper
r1352
Marek Rosa
Added more tests to QXYModelMapper
r1422 private Q_SLOTS:
Marek Rosa
Added tests for XYModelMapper
r1352 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();
void seriesUpdated();
Marek Rosa
Added more tests to QXYModelMapper
r1422 void verticalModelInsertRows();
void verticalModelRemoveRows();
void verticalModelInsertColumns();
void verticalModelRemoveColumns();
void horizontalModelInsertRows();
void horizontalModelRemoveRows();
void horizontalModelInsertColumns();
void horizontalModelRemoveColumns();
void modelUpdateCell();
Marek Rosa
Added signals test cases to xymodelmapper plus fix to xymodelmapper
r1922 void verticalMapperSignals();
void horizontalMapperSignals();
Marek Rosa
Added more tests to QXYModelMapper
r1422
private:
Marek Rosa
Added tests for XYModelMapper
r1352 QStandardItemModel *m_model;
int m_modelRowCount;
int m_modelColumnCount;
Marek Rosa
Added more tests to QXYModelMapper
r1422 QHXYModelMapper *m_hMapper;
QVXYModelMapper *m_vMapper;
Marek Rosa
Added tests for XYModelMapper
r1352 QXYSeries *m_series;
QChart *m_chart;
};
tst_qxymodelmapper::tst_qxymodelmapper():
m_model(0),
m_modelRowCount(10),
Marek Rosa
Added more tests to QXYModelMapper
r1422 m_modelColumnCount(8),
m_hMapper(0),
m_vMapper(0),
m_series(0),
m_chart(0)
Marek Rosa
Added tests for XYModelMapper
r1352 {
}
Marek Rosa
Added more tests to QXYModelMapper
r1422 void tst_qxymodelmapper::createVerticalMapper()
{
m_vMapper = new QVXYModelMapper;
QVERIFY(m_vMapper->model() == 0);
m_vMapper->setXColumn(0);
m_vMapper->setYColumn(1);
m_vMapper->setModel(m_model);
m_vMapper->setSeries(m_series);
}
void tst_qxymodelmapper::createHorizontalMapper()
{
m_hMapper = new QHXYModelMapper;
QVERIFY(m_hMapper->model() == 0);
m_hMapper->setXRow(0);
m_hMapper->setYRow(1);
m_hMapper->setModel(m_model);
m_hMapper->setSeries(m_series);
}
Marek Rosa
Added tests for XYModelMapper
r1352 void tst_qxymodelmapper::init()
{
m_series = new QLineSeries;
m_chart->addSeries(m_series);
Marek Rosa
Added more tests to QXYModelMapper
r1422
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 tests for XYModelMapper
r1352 }
void tst_qxymodelmapper::cleanup()
{
m_chart->removeSeries(m_series);
Marek Rosa
Added more tests to QXYModelMapper
r1422 m_series->deleteLater();
Marek Rosa
Added tests for XYModelMapper
r1352 m_series = 0;
Marek Rosa
Added more tests to QXYModelMapper
r1422
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 tests for XYModelMapper
r1352 }
void tst_qxymodelmapper::initTestCase()
{
m_chart = new QChart;
QChartView *chartView = new QChartView(m_chart);
chartView->show();
}
void tst_qxymodelmapper::cleanupTestCase()
{
Marek Rosa
Added more tests to QXYModelMapper
r1422 //
Marek Rosa
Added tests for XYModelMapper
r1352 }
void tst_qxymodelmapper::verticalMapper_data()
{
QTest::addColumn<int>("xColumn");
QTest::addColumn<int>("yColumn");
QTest::addColumn<int>("expectedCount");
QTest::newRow("different x and y columns") << 0 << 1 << m_modelRowCount;
QTest::newRow("same x and y columns") << 1 << 1 << m_modelRowCount;
QTest::newRow("invalid x column and correct y column") << -3 << 1 << 0;
QTest::newRow("x column beyond the size of model and correct y column") << m_modelColumnCount << 1 << 0;
QTest::newRow("x column beyond the size of model and invalid y column") << m_modelColumnCount << -1 << 0;
}
void tst_qxymodelmapper::verticalMapper()
{
QFETCH(int, xColumn);
QFETCH(int, yColumn);
QFETCH(int, expectedCount);
QVXYModelMapper *mapper = new QVXYModelMapper;
Marek Rosa
Added modelUpdated() test to xy model mapper
r1399 QVERIFY(mapper->model() == 0);
Marek Rosa
Added tests for XYModelMapper
r1352 mapper->setXColumn(xColumn);
mapper->setYColumn(yColumn);
mapper->setModel(m_model);
mapper->setSeries(m_series);
QCOMPARE(m_series->count(), expectedCount);
QCOMPARE(mapper->xColumn(), qMax(-1, xColumn));
QCOMPARE(mapper->yColumn(), qMax(-1, yColumn));
delete mapper;
mapper = 0;
}
void tst_qxymodelmapper::verticalMapperCustomMapping_data()
{
QTest::addColumn<int>("first");
QTest::addColumn<int>("countLimit");
QTest::addColumn<int>("expectedCount");
QTest::newRow("first: 0, unlimited count") << 0 << -1 << m_modelRowCount;
QTest::newRow("first: 3, unlimited count") << 3 << -1 << m_modelRowCount - 3;
QTest::newRow("first: 0, count: 5") << 0 << 5 << qMin(5, m_modelRowCount);
QTest::newRow("first: 3, count: 5") << 3 << 5 << 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;
QTest::newRow("first: +1 greater then the number of rows in the model, count: 5") << m_modelRowCount + 1 << 5 << 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 << m_modelRowCount;
QTest::newRow("first: -3(invalid - should default to 0), unlimited count") << -3 << -1 << m_modelRowCount;
QTest::newRow("first: 0, count: -3 (invalid - shlould default to -1)") << 0 << -3 << m_modelRowCount;
QTest::newRow("first: -3(invalid - should default to 0), count: -3 (invalid - shlould default to -1)") << -3 << -3 << m_modelRowCount;
}
void tst_qxymodelmapper::verticalMapperCustomMapping()
{
QFETCH(int, first);
QFETCH(int, countLimit);
QFETCH(int, expectedCount);
QCOMPARE(m_series->count(), 0);
QVXYModelMapper *mapper = new QVXYModelMapper;
mapper->setXColumn(0);
mapper->setYColumn(1);
mapper->setModel(m_model);
mapper->setSeries(m_series);
Marek Rosa
QXYModelMapper removed from the docs
r1507 mapper->setFirstRow(first);
mapper->setRowCount(countLimit);
Marek Rosa
Added tests for XYModelMapper
r1352
QCOMPARE(m_series->count(), expectedCount);
// change values column mapping to invalid
mapper->setXColumn(-1);
mapper->setYColumn(1);
QCOMPARE(m_series->count(), 0);
delete mapper;
mapper = 0;
}
void tst_qxymodelmapper::horizontalMapper_data()
{
QTest::addColumn<int>("xRow");
QTest::addColumn<int>("yRow");
QTest::addColumn<int>("expectedCount");
QTest::newRow("different x and y rows") << 0 << 1 << m_modelColumnCount;
QTest::newRow("same x and y rows") << 1 << 1 << m_modelColumnCount;
QTest::newRow("invalid x row and correct y row") << -3 << 1 << 0;
QTest::newRow("x row beyond the size of model and correct y row") << m_modelRowCount << 1 << 0;
QTest::newRow("x row beyond the size of model and invalid y row") << m_modelRowCount << -1 << 0;
}
void tst_qxymodelmapper::horizontalMapper()
{
QFETCH(int, xRow);
QFETCH(int, yRow);
QFETCH(int, expectedCount);
QHXYModelMapper *mapper = new QHXYModelMapper;
mapper->setXRow(xRow);
mapper->setYRow(yRow);
mapper->setModel(m_model);
mapper->setSeries(m_series);
QCOMPARE(m_series->count(), expectedCount);
QCOMPARE(mapper->xRow(), qMax(-1, xRow));
QCOMPARE(mapper->yRow(), qMax(-1, yRow));
delete mapper;
mapper = 0;
}
void tst_qxymodelmapper::horizontalMapperCustomMapping_data()
{
QTest::addColumn<int>("first");
QTest::addColumn<int>("countLimit");
QTest::addColumn<int>("expectedCount");
QTest::newRow("first: 0, unlimited count") << 0 << -1 << m_modelColumnCount;
QTest::newRow("first: 3, unlimited count") << 3 << -1 << m_modelColumnCount - 3;
QTest::newRow("first: 0, count: 5") << 0 << 5 << qMin(5, m_modelColumnCount);
QTest::newRow("first: 3, count: 5") << 3 << 5 << qMin(5, m_modelColumnCount - 3);
QTest::newRow("first: +1 greater then the number of columns in the model, unlimited count") << m_modelColumnCount + 1 << -1 << 0;
QTest::newRow("first: +1 greater then the number of columns in the model, count: 5") << m_modelColumnCount + 1 << 5 << 0;
QTest::newRow("first: 0, count: +3 greater than the number of columns in the model (should limit to the size of model)") << 0 << m_modelColumnCount + 3 << m_modelColumnCount;
QTest::newRow("first: -3(invalid - should default to 0), unlimited count") << -3 << -1 << m_modelColumnCount;
QTest::newRow("first: 0, count: -3 (invalid - shlould default to -1)") << 0 << -3 << m_modelColumnCount;
QTest::newRow("first: -3(invalid - should default to 0), count: -3 (invalid - shlould default to -1)") << -3 << -3 << m_modelColumnCount;
}
void tst_qxymodelmapper::horizontalMapperCustomMapping()
{
QFETCH(int, first);
QFETCH(int, countLimit);
QFETCH(int, expectedCount);
QCOMPARE(m_series->count(), 0);
QHXYModelMapper *mapper = new QHXYModelMapper;
mapper->setXRow(0);
mapper->setYRow(1);
mapper->setModel(m_model);
mapper->setSeries(m_series);
Marek Rosa
QXYModelMapper removed from the docs
r1507 mapper->setFirstColumn(first);
mapper->setColumnCount(countLimit);
Marek Rosa
Added tests for XYModelMapper
r1352
QCOMPARE(m_series->count(), expectedCount);
// change values row mapping to invalid
mapper->setXRow(-1);
mapper->setYRow(1);
QCOMPARE(m_series->count(), 0);
delete mapper;
mapper = 0;
}
void tst_qxymodelmapper::seriesUpdated()
{
Marek Rosa
Added more tests to QPieModelMapper
r1427 // setup the mapper
createVerticalMapper();
Marek Rosa
Added tests for XYModelMapper
r1352 QCOMPARE(m_series->count(), m_modelRowCount);
Marek Rosa
QXYModelMapper removed from the docs
r1507 QCOMPARE(m_vMapper->rowCount(), -1);
Marek Rosa
Added tests for XYModelMapper
r1352
m_series->append(QPointF(100, 100));
QCOMPARE(m_series->count(), m_modelRowCount + 1);
Marek Rosa
QXYModelMapper removed from the docs
r1507 QCOMPARE(m_vMapper->rowCount(), -1); // the value should not change as it indicates 'all' items there are in the model
Marek Rosa
Added tests for XYModelMapper
r1352
m_series->remove(m_series->points().last());
QCOMPARE(m_series->count(), m_modelRowCount);
Marek Rosa
QXYModelMapper removed from the docs
r1507 QCOMPARE(m_vMapper->rowCount(), -1); // the value should not change as it indicates 'all' items there are in the model
Marek Rosa
Added tests for XYModelMapper
r1352
Marek Rosa
Added more tests to QPieModelMapper
r1427 m_series->replace(m_series->points().first(), QPointF(25.0, 75.0));
QCOMPARE(m_model->data(m_model->index(0, 0)).toReal(), 25.0);
QCOMPARE(m_model->data(m_model->index(0, 1)).toReal(), 75.0);
Marek Rosa
Added more tests to QXYModelMapper
r1422 }
void tst_qxymodelmapper::verticalModelInsertRows()
{
// setup the mapper
createVerticalMapper();
QCOMPARE(m_series->count(), m_modelRowCount);
QVERIFY(m_vMapper->model() != 0);
int insertCount = 4;
m_model->insertRows(3, insertCount);
QCOMPARE(m_series->count(), m_modelRowCount + insertCount);
int first = 3;
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_vMapper->setFirstRow(3);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), m_modelRowCount + insertCount - first);
m_model->insertRows(3, insertCount);
QCOMPARE(m_series->count(), m_modelRowCount + 2 * insertCount - first);
Marek Rosa
Added modelUpdated() test to xy model mapper
r1399
Marek Rosa
Added more tests to QXYModelMapper
r1422 int countLimit = 6;
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_vMapper->setRowCount(countLimit);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 2 * insertCount - first));
m_model->insertRows(3, insertCount);
QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount - first));
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_vMapper->setFirstRow(0);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount + 3 * insertCount));
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_vMapper->setRowCount(-1);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), m_modelRowCount + 3 * insertCount);
Marek Rosa
Added modelUpdated() test to xy model mapper
r1399 }
Marek Rosa
Added more tests to QXYModelMapper
r1422 void tst_qxymodelmapper::verticalModelRemoveRows()
Marek Rosa
Added modelUpdated() test to xy model mapper
r1399 {
Marek Rosa
Added more tests to QXYModelMapper
r1422 // setup the mapper
createVerticalMapper();
QCOMPARE(m_series->count(), m_modelRowCount);
QVERIFY(m_vMapper->model() != 0);
Marek Rosa
Added modelUpdated() test to xy model mapper
r1399
Marek Rosa
Added more tests to QXYModelMapper
r1422 int removeCount = 2;
m_model->removeRows(1, removeCount);
QCOMPARE(m_series->count(), m_modelRowCount - removeCount);
int first = 1;
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_vMapper->setFirstRow(first);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), m_modelRowCount - removeCount - first);
m_model->removeRows(1, removeCount);
QCOMPARE(m_series->count(), m_modelRowCount - 2 * removeCount - first);
int countLimit = 3;
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_vMapper->setRowCount(countLimit);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 2 * removeCount - first));
m_model->removeRows(1, removeCount);
QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount - first));
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_vMapper->setFirstRow(0);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), qMin(countLimit, m_modelRowCount - 3 * removeCount));
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_vMapper->setRowCount(-1);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), m_modelRowCount - 3 * removeCount);
}
void tst_qxymodelmapper::verticalModelInsertColumns()
{
// setup the mapper
createVerticalMapper();
Marek Rosa
Added modelUpdated() test to xy model mapper
r1399 QCOMPARE(m_series->count(), m_modelRowCount);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QVERIFY(m_vMapper->model() != 0);
Marek Rosa
Added modelUpdated() test to xy model mapper
r1399
Marek Rosa
Added more tests to QXYModelMapper
r1422 int insertCount = 4;
m_model->insertColumns(3, insertCount);
QCOMPARE(m_series->count(), m_modelRowCount);
}
Marek Rosa
Added modelUpdated() test to xy model mapper
r1399
Marek Rosa
Added more tests to QXYModelMapper
r1422 void tst_qxymodelmapper::verticalModelRemoveColumns()
{
// setup the mapper
createVerticalMapper();
QCOMPARE(m_series->count(), m_modelRowCount);
QVERIFY(m_vMapper->model() != 0);
Marek Rosa
Added modelUpdated() test to xy model mapper
r1399
Marek Rosa
Added more tests to QXYModelMapper
r1422 int removeCount = m_modelColumnCount - 2;
m_model->removeColumns(0, removeCount);
QCOMPARE(m_series->count(), m_modelRowCount);
Marek Rosa
Added modelUpdated() test to xy model mapper
r1399
Marek Rosa
Added more tests to QXYModelMapper
r1422 // leave only one column
m_model->removeColumns(0, m_modelColumnCount - removeCount - 1);
QCOMPARE(m_series->count(), 0);
}
void tst_qxymodelmapper::horizontalModelInsertRows()
{
// setup the mapper
createHorizontalMapper();
QCOMPARE(m_series->count(), m_modelColumnCount);
QVERIFY(m_hMapper->model() != 0);
int insertCount = 4;
m_model->insertRows(3, insertCount);
QCOMPARE(m_series->count(), m_modelColumnCount);
}
void tst_qxymodelmapper::horizontalModelRemoveRows()
{
// setup the mapper
createHorizontalMapper();
QCOMPARE(m_series->count(), m_modelColumnCount);
QVERIFY(m_hMapper->model() != 0);
int removeCount = m_modelRowCount - 2;
m_model->removeRows(0, removeCount);
QCOMPARE(m_series->count(), m_modelColumnCount);
// leave only one column
m_model->removeRows(0, m_modelRowCount - removeCount - 1);
QCOMPARE(m_series->count(), 0);
}
void tst_qxymodelmapper::horizontalModelInsertColumns()
{
// setup the mapper
createHorizontalMapper();
QCOMPARE(m_series->count(), m_modelColumnCount);
QVERIFY(m_hMapper->model() != 0);
int insertCount = 4;
m_model->insertColumns(3, insertCount);
QCOMPARE(m_series->count(), m_modelColumnCount + insertCount);
int first = 3;
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_hMapper->setFirstColumn(3);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), m_modelColumnCount + insertCount - first);
m_model->insertColumns(3, insertCount);
QCOMPARE(m_series->count(), m_modelColumnCount + 2 * insertCount - first);
int countLimit = 6;
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_hMapper->setColumnCount(countLimit);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 2 * insertCount - first));
m_model->insertColumns(3, insertCount);
QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount - first));
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_hMapper->setFirstColumn(0);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount + 3 * insertCount));
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_hMapper->setColumnCount(-1);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), m_modelColumnCount + 3 * insertCount);
}
void tst_qxymodelmapper::horizontalModelRemoveColumns()
{
// setup the mapper
createHorizontalMapper();
QCOMPARE(m_series->count(), m_modelColumnCount);
QVERIFY(m_hMapper->model() != 0);
int removeCount = 2;
m_model->removeColumns(1, removeCount);
QCOMPARE(m_series->count(), m_modelColumnCount - removeCount);
int first = 1;
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_hMapper->setFirstColumn(first);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), m_modelColumnCount - removeCount - first);
m_model->removeColumns(1, removeCount);
QCOMPARE(m_series->count(), m_modelColumnCount - 2 * removeCount - first);
int countLimit = 3;
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_hMapper->setColumnCount(countLimit);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 2 * removeCount - first));
m_model->removeColumns(1, removeCount);
QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount - first));
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_hMapper->setFirstColumn(0);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), qMin(countLimit, m_modelColumnCount - 3 * removeCount));
Marek Rosa
QXYModelMapper removed from the docs
r1507 m_hMapper->setColumnCount(-1);
Marek Rosa
Added more tests to QXYModelMapper
r1422 QCOMPARE(m_series->count(), m_modelColumnCount - 3 * removeCount);
}
void tst_qxymodelmapper::modelUpdateCell()
{
// setup the mapper
createVerticalMapper();
Marek Rosa
Added modelUpdated() test to xy model mapper
r1399
Marek Rosa
Added more tests to QXYModelMapper
r1422 QVERIFY(m_model->setData(m_model->index(1, 0), 44));
QCOMPARE(m_series->points().at(1).x(), 44.0);
QCOMPARE(m_model->data(m_model->index(1, 0)).toReal(), 44.0);
Marek Rosa
Added tests for XYModelMapper
r1352 }
Marek Rosa
Added signals test cases to xymodelmapper plus fix to xymodelmapper
r1922 void tst_qxymodelmapper::verticalMapperSignals()
{
QVXYModelMapper *mapper = new QVXYModelMapper;
QSignalSpy spy0(mapper, SIGNAL(firstRowChanged()));
QSignalSpy spy1(mapper, SIGNAL(rowCountChanged()));
QSignalSpy spy2(mapper, SIGNAL(xColumnChanged()));
QSignalSpy spy3(mapper, SIGNAL(yColumnChanged()));
QSignalSpy spy4(mapper, SIGNAL(modelReplaced()));
QSignalSpy spy5(mapper, SIGNAL(seriesReplaced()));
mapper->setXColumn(0);
mapper->setYColumn(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);
}
void tst_qxymodelmapper::horizontalMapperSignals()
{
QHXYModelMapper *mapper = new QHXYModelMapper;
QSignalSpy spy0(mapper, SIGNAL(firstColumnChanged()));
QSignalSpy spy1(mapper, SIGNAL(columnCountChanged()));
QSignalSpy spy2(mapper, SIGNAL(xRowChanged()));
QSignalSpy spy3(mapper, SIGNAL(yRowChanged()));
QSignalSpy spy4(mapper, SIGNAL(modelReplaced()));
QSignalSpy spy5(mapper, SIGNAL(seriesReplaced()));
mapper->setXRow(0);
mapper->setYRow(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);
}
Marek Rosa
Added tests for XYModelMapper
r1352 QTEST_MAIN(tst_qxymodelmapper)
#include "tst_qxymodelmapper.moc"