##// END OF EJS Templates
Updated QML Oscilloscope documentation...
Updated QML Oscilloscope documentation Updated explanation about environment variable usage so that it reflects the one used with Qt5. Change-Id: I5cedcf3db73ebc0b8e02181e00d5c8cc56b10e8b Task-number: QTRD-3509 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>

File last commit:

r2815:4c1d3bc34edb
r2819:3a89e3fee61a
Show More
tst_qlineseries.cpp
228 lines | 6.9 KiB | text/x-c | CppLexer
Michal Klocek
Update of tst_qlineseries.cpp
r1064 /****************************************************************************
**
Titta Heikkala
Copyright header changes...
r2776 ** Copyright (C) 2015 The Qt Company Ltd
Michal Klocek
Update of tst_qlineseries.cpp
r1064 ** All rights reserved.
Titta Heikkala
Copyright header changes...
r2776 ** For any questions to The Qt Company, please use contact form at http://qt.io
Michal Klocek
Update of tst_qlineseries.cpp
r1064 **
Titta Heikkala
Updated license headers...
r2740 ** This file is part of the Qt Charts module.
Michal Klocek
Update of tst_qlineseries.cpp
r1064 **
Titta Heikkala
Updated license headers...
r2740 ** Licensees holding valid commercial license for Qt may use this file in
** accordance with the Qt License Agreement provided with the Software
** or, alternatively, in accordance with the terms contained in a written
Titta Heikkala
Copyright header changes...
r2776 ** agreement between you and The Qt Company.
Michal Klocek
Update of tst_qlineseries.cpp
r1064 **
** If you have questions regarding the use of this file, please use
Titta Heikkala
Updated license headers...
r2740 ** contact form at http://qt.io
Michal Klocek
Update of tst_qlineseries.cpp
r1064 **
****************************************************************************/
Michal Klocek
Adds spline scatter unit tests
r1266 #include "../qxyseries/tst_qxyseries.h"
Titta Heikkala
Fix include syntax...
r2714 #include <QtCharts/QLineSeries>
Michal Klocek
Update of tst_qlineseries.cpp
r1064
Michal Klocek
Add tst_qlineseries stub
r1058
Michal Klocek
Adds spline scatter unit tests
r1266 Q_DECLARE_METATYPE(QList<QPointF>)
Michal Klocek
Add tst_qlineseries stub
r1058
Michal Klocek
Adds spline scatter unit tests
r1266 class tst_QLineSeries : public tst_QXYSeries
Michal Klocek
Add tst_qlineseries stub
r1058 {
Q_OBJECT
Michal Klocek
Adds spline scatter unit tests
r1266 public slots:
Michal Klocek
Add tst_qlineseries stub
r1058 void initTestCase();
void cleanupTestCase();
void init();
void cleanup();
Michal Klocek
Adds spline scatter unit tests
r1266 private slots:
Michal Klocek
Update of tst_qlineseries.cpp
r1064 void qlineseries_data();
void qlineseries();
Titta Heikkala
Add pressed, released and doubleClicked signals...
r2739 void pressedSignal();
void releasedSignal();
void doubleClickedSignal();
Friedemann Kleint
QXYSeries::insert(): Handle out-of-range indexes gracefully....
r2772 void insert();
Michal Klocek
Adds spline scatter unit tests
r1266 protected:
Michal Klocek
Adds default 0,1 domain for emmpty series, update tst_qlineseries
r1070 void pointsVisible_data();
Michal Klocek
Add tst_qlineseries stub
r1058 };
void tst_QLineSeries::initTestCase()
{
}
void tst_QLineSeries::cleanupTestCase()
{
Miikka Heikkinen
Plugged some memory leaks....
r2733 QTest::qWait(1); // Allow final deleteLaters to run
Michal Klocek
Add tst_qlineseries stub
r1058 }
void tst_QLineSeries::init()
{
Michal Klocek
Adds spline scatter unit tests
r1266 tst_QXYSeries::init();
Marek Rosa
Spline series now recalcutes control points on adding/removing data to/from model
r1072 m_series = new QLineSeries();
Michal Klocek
Add tst_qlineseries stub
r1058 }
void tst_QLineSeries::cleanup()
{
Michal Klocek
Adds default 0,1 domain for emmpty series, update tst_qlineseries
r1070 delete m_series;
Michal Klocek
Adds tst_qvaluesaxis stub implementation
r1699 m_series=0;
Michal Klocek
Adds spline scatter unit tests
r1266 tst_QXYSeries::cleanup();
Michal Klocek
Add tst_qlineseries stub
r1058 }
Michal Klocek
Update of tst_qlineseries.cpp
r1064 void tst_QLineSeries::qlineseries_data()
Michal Klocek
Add tst_qlineseries stub
r1058 {
Michal Klocek
Adds default 0,1 domain for emmpty series, update tst_qlineseries
r1070
Michal Klocek
Add tst_qlineseries stub
r1058 }
Michal Klocek
Update of tst_qlineseries.cpp
r1064 void tst_QLineSeries::qlineseries()
Michal Klocek
Add tst_qlineseries stub
r1058 {
Marek Rosa
Fixed some of the tests after Model mapping refactoring
r1178 QLineSeries series;
Michal Klocek
Update of tst_qlineseries.cpp
r1064
Marek Rosa
Fixed some of the tests after Model mapping refactoring
r1178 QCOMPARE(series.count(),0);
QCOMPARE(series.brush(), QBrush());
QCOMPARE(series.points(), QList<QPointF>());
QCOMPARE(series.pen(), QPen());
QCOMPARE(series.pointsVisible(), false);
Titta Heikkala
Added possibility to show series value...
r2689 QCOMPARE(series.pointLabelsVisible(), false);
QCOMPARE(series.pointLabelsFormat(), QLatin1String("@xPoint, @yPoint"));
Titta Heikkala
Added option to set labels clipping...
r2815 QCOMPARE(series.pointLabelsClipping(), true);
Michal Klocek
Update of tst_qlineseries.cpp
r1064
Marek Rosa
Fixed some of the tests after Model mapping refactoring
r1178 series.append(QList<QPointF>());
series.append(0.0,0.0);
series.append(QPointF());
Michal Klocek
Update of tst_qlineseries.cpp
r1064
Marek Rosa
Fixed some of the tests after Model mapping refactoring
r1178 series.remove(0.0,0.0);
series.remove(QPointF());
Jani Honkonen
xyseries: removeAll() was duplicate of clear()
r1374 series.clear();
Michal Klocek
Update of tst_qlineseries.cpp
r1064
Marek Rosa
Fixed some of the tests after Model mapping refactoring
r1178 series.replace(QPointF(),QPointF());
series.replace(0,0,0,0);
series.setBrush(QBrush());
Michal Klocek
Update of tst_qlineseries.cpp
r1064
Marek Rosa
Fixed some of the tests after Model mapping refactoring
r1178 series.setPen(QPen());
series.setPointsVisible(false);
Michal Klocek
Adds default 0,1 domain for emmpty series, update tst_qlineseries
r1070
Titta Heikkala
Added possibility to show series value...
r2689 series.setPointLabelsVisible(false);
series.setPointLabelsFormat(QString());
Marek Rosa
Fixed some of the tests after Model mapping refactoring
r1178 m_chart->addSeries(&series);
m_view->show();
QTest::qWaitForWindowShown(m_view);
Michal Klocek
Add tst_qlineseries stub
r1058 }
Titta Heikkala
Add pressed, released and doubleClicked signals...
r2739 void tst_QLineSeries::pressedSignal()
{
SKIP_IF_CANNOT_TEST_MOUSE_EVENTS();
QPointF linePoint(4, 12);
QLineSeries *lineSeries = new QLineSeries();
lineSeries->append(QPointF(2, 1));
lineSeries->append(linePoint);
lineSeries->append(QPointF(6, 12));
QChartView view;
view.chart()->legend()->setVisible(false);
view.chart()->addSeries(lineSeries);
view.show();
QTest::qWaitForWindowShown(&view);
QSignalSpy seriesSpy(lineSeries, SIGNAL(pressed(QPointF)));
QPointF checkPoint = view.chart()->mapToPosition(linePoint);
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, checkPoint.toPoint());
QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
QCOMPARE(seriesSpy.count(), 1);
QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
// checkPoint is QPointF and for the mouseClick it it's changed to QPoint
// this causes small distinction in decimals so we round it before comparing
QPointF signalPoint = qvariant_cast<QPointF>(seriesSpyArg.at(0));
QCOMPARE(qRound(signalPoint.x()), qRound(linePoint.x()));
QCOMPARE(qRound(signalPoint.y()), qRound(linePoint.y()));
}
void tst_QLineSeries::releasedSignal()
{
SKIP_IF_CANNOT_TEST_MOUSE_EVENTS();
QPointF linePoint(4, 12);
QLineSeries *lineSeries = new QLineSeries();
lineSeries->append(QPointF(2, 20));
lineSeries->append(linePoint);
lineSeries->append(QPointF(6, 12));
QChartView view;
view.chart()->legend()->setVisible(false);
view.chart()->addSeries(lineSeries);
view.show();
QTest::qWaitForWindowShown(&view);
QSignalSpy seriesSpy(lineSeries, SIGNAL(released(QPointF)));
QPointF checkPoint = view.chart()->mapToPosition(linePoint);
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, checkPoint.toPoint());
QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
QCOMPARE(seriesSpy.count(), 1);
QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
// checkPoint is QPointF and for the mouseClick it it's changed to QPoint
// this causes small distinction in decimals so we round it before comparing
QPointF signalPoint = qvariant_cast<QPointF>(seriesSpyArg.at(0));
QCOMPARE(qRound(signalPoint.x()), qRound(linePoint.x()));
QCOMPARE(qRound(signalPoint.y()), qRound(linePoint.y()));
}
Friedemann Kleint
QXYSeries::insert(): Handle out-of-range indexes gracefully....
r2772 void tst_QLineSeries::insert()
{
QLineSeries lineSeries;
QSignalSpy insertSpy(&lineSeries, &QXYSeries::pointAdded);
lineSeries.insert(0, QPoint(3, 3));
QCOMPARE(insertSpy.count(), 1);
QVariantList arguments = insertSpy.takeFirst();
QCOMPARE(arguments.first().toInt(), 0);
lineSeries.insert(0, QPoint(1, 1));
arguments = insertSpy.takeFirst();
QCOMPARE(arguments.first().toInt(), 0);
lineSeries.insert(1, QPoint(2, 2));
arguments = insertSpy.takeFirst();
QCOMPARE(arguments.first().toInt(), 1);
lineSeries.insert(42, QPoint(0, 0));
arguments = insertSpy.takeFirst();
QCOMPARE(arguments.first().toInt(), 3);
lineSeries.insert(-42, QPoint(0, 0));
arguments = insertSpy.takeFirst();
QCOMPARE(arguments.first().toInt(), 0);
}
Titta Heikkala
Add pressed, released and doubleClicked signals...
r2739 void tst_QLineSeries::doubleClickedSignal()
{
SKIP_IF_CANNOT_TEST_MOUSE_EVENTS();
QPointF linePoint(4, 12);
QLineSeries *lineSeries = new QLineSeries();
lineSeries->append(QPointF(2, 20));
lineSeries->append(linePoint);
lineSeries->append(QPointF(6, 12));
QChartView view;
view.chart()->legend()->setVisible(false);
view.chart()->addSeries(lineSeries);
view.show();
QTest::qWaitForWindowShown(&view);
QSignalSpy seriesSpy(lineSeries, SIGNAL(doubleClicked(QPointF)));
QPointF checkPoint = view.chart()->mapToPosition(linePoint);
Titta Heikkala
Fix clicked, released and doubleClicked signal points...
r2746 // mouseClick needed first to save the position
QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, checkPoint.toPoint());
Titta Heikkala
Add pressed, released and doubleClicked signals...
r2739 QTest::mouseDClick(view.viewport(), Qt::LeftButton, 0, checkPoint.toPoint());
QCoreApplication::processEvents(QEventLoop::AllEvents, 1000);
QCOMPARE(seriesSpy.count(), 1);
QList<QVariant> seriesSpyArg = seriesSpy.takeFirst();
// checkPoint is QPointF and for the mouseClick it it's changed to QPoint
// this causes small distinction in decimals so we round it before comparing
QPointF signalPoint = qvariant_cast<QPointF>(seriesSpyArg.at(0));
QCOMPARE(qRound(signalPoint.x()), qRound(linePoint.x()));
QCOMPARE(qRound(signalPoint.y()), qRound(linePoint.y()));
}
Michal Klocek
Add tst_qlineseries stub
r1058 QTEST_MAIN(tst_QLineSeries)
#include "tst_qlineseries.moc"