From b2453e3ca6792e61bef118406604f65fe3b9f379 2012-05-29 14:22:38 From: sauimone Date: 2012-05-29 14:22:38 Subject: [PATCH] barseries autotest update --- diff --git a/src/barchart/barchartitem.cpp b/src/barchart/barchartitem.cpp index 09bab8e..2a0544f 100644 --- a/src/barchart/barchartitem.cpp +++ b/src/barchart/barchartitem.cpp @@ -113,7 +113,7 @@ QVector BarChartItem::calculateLayout() qreal scaleY = (height / rangeY); qreal scaleX = (width / rangeX); qreal categoryWidth = width / categoryCount; - qreal barWidth = categoryWidth / setCount - categoryWidth * m_series->d_func()->barMargin(); + qreal barWidth = categoryWidth - categoryWidth * m_series->d_func()->barMargin(); int itemIndex(0); for (int category = 0; category < categoryCount; category++) { diff --git a/tests/auto/qbarseries/tst_qbarseries.cpp b/tests/auto/qbarseries/tst_qbarseries.cpp index 0474fcd..92ed62a 100644 --- a/tests/auto/qbarseries/tst_qbarseries.cpp +++ b/tests/auto/qbarseries/tst_qbarseries.cpp @@ -442,8 +442,6 @@ void tst_QBarSeries::mouseclicked() *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); series->append(set2); - QSignalSpy setSpy1(set1, SIGNAL(clicked(QString))); - QSignalSpy setSpy2(set2, SIGNAL(clicked(QString))); QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString))); QChartView view(new QChart()); @@ -454,109 +452,75 @@ void tst_QBarSeries::mouseclicked() //==================================================================================== // barset 1, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(105,180)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,142)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); QCOMPARE(seriesSpy.count(), 1); - QList setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); QList seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); //==================================================================================== // barset 1, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(200,180)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,142)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); //==================================================================================== // barset 1, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(295,180)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(291,142)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); //==================================================================================== // barset 2, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(145,180)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(134,142)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); //==================================================================================== // barset 2, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(240,180)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(227,142)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); //==================================================================================== // barset 2, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(335,180)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(319,142)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); - -//==================================================================================== -// no event cases - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1,1)); // Outside of both sets - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(1,1)); // Right mouse button outside and inside sets - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(105,180)); // barset 1, category test1 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(200,180)); // barset 1, category test2 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(295,180)); // barset 1, category test3 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(145,180)); // barset 2, category test1 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(240,180)); // barset 2, category test2 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(335,180)); // barset 2, category test3 - - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 0); - QCOMPARE(seriesSpy.count(), 0); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); } void tst_QBarSeries::mousehovered_data() @@ -579,8 +543,6 @@ void tst_QBarSeries::mousehovered() *set2 << QPointF(0.3,10) << QPointF(1.3,10) << QPointF(2.3,10); series->append(set2); - QSignalSpy setSpy1(set1, SIGNAL(hovered(bool))); - QSignalSpy setSpy2(set2, SIGNAL(hovered(bool))); QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool))); QChartView view(new QChart()); @@ -589,48 +551,33 @@ void tst_QBarSeries::mousehovered() view.show(); QTest::qWaitForWindowShown(&view); + //this is hack since view does not get events otherwise + view.setMouseTracking(true); + //======================================================================= // move mouse to left border - QTest::mouseMove(view.viewport(), QPoint(0, 180)); + QTest::mouseMove(view.viewport(), QPoint(0, 142)); - QVERIFY(setSpy1.count() == 0); - QVERIFY(setSpy2.count() == 0); QVERIFY(seriesSpy.count() == 0); //======================================================================= // move mouse on top of set1 - QTest::mouseMove(view.viewport(), QPoint(105,180)); + QTest::mouseMove(view.viewport(), QPoint(106,142)); - QVERIFY(setSpy1.count() == 1); - QVERIFY(setSpy2.count() == 0); QVERIFY(seriesSpy.count() == 1); - QList setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == true); - QList seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); + QVERIFY(seriesSpyArg.at(1).toBool() == true); //======================================================================= // move mouse from top of set1 to top of set2 - QTest::mouseMove(view.viewport(), QPoint(145,180)); + QTest::mouseMove(view.viewport(), QPoint(134,142)); - QVERIFY(setSpy1.count() == 1); - QVERIFY(setSpy2.count() == 1); QVERIFY(seriesSpy.count() == 2); // should leave set1 - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == false); - - // should enter set2 - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == true); - - // should leave set1 seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); @@ -644,29 +591,16 @@ void tst_QBarSeries::mousehovered() //======================================================================= // move mouse from top of set2 to background - QTest::mouseMove(view.viewport(), QPoint(175,180)); - - QVERIFY(setSpy1.count() == 0); - QVERIFY(setSpy2.count() == 1); + QTest::mouseMove(view.viewport(), QPoint(134,0)); QVERIFY(seriesSpy.count() == 1); - // should leave set2 (event via set) - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == false); - - // should leave set2 (event via series) + // should leave set2 seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); QVERIFY(seriesSpyArg.at(1).toBool() == false); } -/* -bool setModel(QAbstractItemModel *model); -void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); -void setModelMappingRange(int first, int count = -1); -*/ QTEST_MAIN(tst_QBarSeries) #include "tst_qbarseries.moc" diff --git a/tests/auto/qgroupedbarseries/tst_qgroupedbarseries.cpp b/tests/auto/qgroupedbarseries/tst_qgroupedbarseries.cpp index 2278c13..224d7a7 100644 --- a/tests/auto/qgroupedbarseries/tst_qgroupedbarseries.cpp +++ b/tests/auto/qgroupedbarseries/tst_qgroupedbarseries.cpp @@ -114,8 +114,6 @@ void tst_QGroupedBarSeries::mouseclicked() *set2 << 10 << 10 << 10; series->append(set2); - QSignalSpy setSpy1(set1, SIGNAL(clicked(QString))); - QSignalSpy setSpy2(set2, SIGNAL(clicked(QString))); QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString))); QChartView view(new QChart()); @@ -126,109 +124,75 @@ void tst_QGroupedBarSeries::mouseclicked() //==================================================================================== // barset 1, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(90,180)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(95,143)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); QCOMPARE(seriesSpy.count(), 1); - QList setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); QList seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); //==================================================================================== // barset 1, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(185,180)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(187,143)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); //==================================================================================== // barset 1, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(280,180)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(280,143)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); //==================================================================================== // barset 2, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(135,180)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(118,143)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); //==================================================================================== // barset 2, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(230,180)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(210,143)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); //==================================================================================== // barset 2, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(320,180)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(303,143)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); - -//==================================================================================== -// no event cases - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1,1)); // Outside of both sets - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(1,1)); // Right mouse button outside and inside sets - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(900,180)); // barset 1, category test1 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(185,180)); // barset 1, category test2 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(280,180)); // barset 1, category test3 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(135,180)); // barset 2, category test1 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(230,180)); // barset 2, category test2 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(320,180)); // barset 2, category test3 - - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 0); - QCOMPARE(seriesSpy.count(), 0); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::String); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); } void tst_QGroupedBarSeries::mousehovered_data() @@ -251,8 +215,6 @@ void tst_QGroupedBarSeries::mousehovered() *set2 << 10 << 10 << 10; series->append(set2); - QSignalSpy setSpy1(set1, SIGNAL(hovered(bool))); - QSignalSpy setSpy2(set2, SIGNAL(hovered(bool))); QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool))); QChartView view(new QChart()); @@ -260,7 +222,6 @@ void tst_QGroupedBarSeries::mousehovered() view.chart()->addSeries(series); view.show(); QTest::qWaitForWindowShown(&view); -// QTest::qWait(1000*20); //this is hack since view does not get events otherwise view.setMouseTracking(true); @@ -268,51 +229,33 @@ void tst_QGroupedBarSeries::mousehovered() //======================================================================= // move mouse to left border qDebug() << "move mouse to left border"; - QTest::mouseMove(view.viewport(), QPoint(0, 180)); + QTest::mouseMove(view.viewport(), QPoint(0, 143)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QVERIFY(setSpy1.count() == 0); - QVERIFY(setSpy2.count() == 0); QVERIFY(seriesSpy.count() == 0); //======================================================================= // move mouse on top of set1 qDebug() << "move mouse on top of set1"; - QTest::mouseMove(view.viewport(), QPoint(90,180)); + QTest::mouseMove(view.viewport(), QPoint(95,143)); QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); - QVERIFY(setSpy1.count() == 1); - QVERIFY(setSpy2.count() == 0); QVERIFY(seriesSpy.count() == 1); - QList setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == true); - QList seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); + QVERIFY(seriesSpyArg.at(1).toBool() == true); //======================================================================= // move mouse from top of set1 to top of set2 qDebug() << "move mouse from top of set1 to top of set2"; - QTest::mouseMove(view.viewport(), QPoint(135,180)); + QTest::mouseMove(view.viewport(), QPoint(118,143)); QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); - QVERIFY(setSpy1.count() == 1); - QVERIFY(setSpy2.count() == 1); QVERIFY(seriesSpy.count() == 2); // should leave set1 - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == false); - - // should enter set2 - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == true); - - // should leave set1 seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); @@ -328,19 +271,12 @@ void tst_QGroupedBarSeries::mousehovered() // move mouse from top of set2 to background qDebug() << "move mouse from top of set2 to background"; - QTest::mouseMove(view.viewport(), QPoint(135,0)); + QTest::mouseMove(view.viewport(), QPoint(118,0)); QCoreApplication::processEvents(QEventLoop::AllEvents, 10000); - QVERIFY(setSpy1.count() == 0); - QVERIFY(setSpy2.count() == 1); QVERIFY(seriesSpy.count() == 1); - // should leave set2 (event via set) - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == false); - - // should leave set2 (event via series) + // should leave set2 seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); diff --git a/tests/auto/qpercentbarseries/tst_qpercentbarseries.cpp b/tests/auto/qpercentbarseries/tst_qpercentbarseries.cpp index 7aaf09b..41d5b9b 100644 --- a/tests/auto/qpercentbarseries/tst_qpercentbarseries.cpp +++ b/tests/auto/qpercentbarseries/tst_qpercentbarseries.cpp @@ -112,8 +112,6 @@ void tst_QPercentBarSeries::mouseclicked() *set2 << 10 << 10 << 10; series->append(set2); - QSignalSpy setSpy1(set1, SIGNAL(clicked(QString))); - QSignalSpy setSpy2(set2, SIGNAL(clicked(QString))); QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString))); QChartView view(new QChart()); @@ -124,109 +122,69 @@ void tst_QPercentBarSeries::mouseclicked() //==================================================================================== // barset 1, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(115,230)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,190)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); QCOMPARE(seriesSpy.count(), 1); - QList setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); QList seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); //==================================================================================== // barset 1, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(205,230)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,190)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); //==================================================================================== // barset 1, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(300,230)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,190)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); //==================================================================================== // barset 2, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(115,140)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,95)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); //==================================================================================== // barset 2, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(205,140)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,95)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); //==================================================================================== // barset 2, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(300,140)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,95)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); - -//==================================================================================== -// no event cases - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1,1)); // Outside of both sets - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(1,1)); // Right mouse button outside and inside sets - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,230)); // barset 1, category test1 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,230)); // barset 1, category test2 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,230)); // barset 1, category test3 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,140)); // barset 2, category test1 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,140)); // barset 2, category test2 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,140)); // barset 2, category test3 - - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 0); - QCOMPARE(seriesSpy.count(), 0); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); } void tst_QPercentBarSeries::mousehovered_data() @@ -249,8 +207,6 @@ void tst_QPercentBarSeries::mousehovered() *set2 << 10 << 10 << 10; series->append(set2); - QSignalSpy setSpy1(set1, SIGNAL(hovered(bool))); - QSignalSpy setSpy2(set2, SIGNAL(hovered(bool))); QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool))); QChartView view(new QChart()); @@ -259,49 +215,33 @@ void tst_QPercentBarSeries::mousehovered() view.show(); QTest::qWaitForWindowShown(&view); + //this is hack since view does not get events otherwise + view.setMouseTracking(true); + //======================================================================= // move mouse to left border - QTest::mouseMove(view.viewport(), QPoint(0, 230)); - + QTest::mouseMove(view.viewport(), QPoint(0, 190)); - QVERIFY(setSpy1.count() == 0); - QVERIFY(setSpy2.count() == 0); QVERIFY(seriesSpy.count() == 0); //======================================================================= // move mouse on top of set1 - QTest::mouseMove(view.viewport(), QPoint(115,230)); + QTest::mouseMove(view.viewport(), QPoint(106,190)); - QVERIFY(setSpy1.count() == 1); - QVERIFY(setSpy2.count() == 0); QVERIFY(seriesSpy.count() == 1); - QList setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == true); - QList seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); + QVERIFY(seriesSpyArg.at(1).toBool() == true); //======================================================================= // move mouse from top of set1 to top of set2 - QTest::mouseMove(view.viewport(), QPoint(115,140)); + QTest::mouseMove(view.viewport(), QPoint(106,95)); - QVERIFY(setSpy1.count() == 1); - QVERIFY(setSpy2.count() == 1); QVERIFY(seriesSpy.count() == 2); // should leave set1 - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == false); - - // should enter set2 - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == true); - - // should leave set1 seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); @@ -315,29 +255,17 @@ void tst_QPercentBarSeries::mousehovered() //======================================================================= // move mouse from top of set2 to background - QTest::mouseMove(view.viewport(), QPoint(0,140)); + QTest::mouseMove(view.viewport(), QPoint(106,0)); - QVERIFY(setSpy1.count() == 0); - QVERIFY(setSpy2.count() == 1); QVERIFY(seriesSpy.count() == 1); - // should leave set2 (event via set) - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == false); - - // should leave set2 (event via series) + // should leave set2 seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); QVERIFY(seriesSpyArg.at(1).toBool() == false); } -/* -bool setModel(QAbstractItemModel *model); -void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); -void setModelMappingRange(int first, int count = -1); -*/ QTEST_MAIN(tst_QPercentBarSeries) #include "tst_qpercentbarseries.moc" diff --git a/tests/auto/qstackedbarseries/tst_qstackedbarseries.cpp b/tests/auto/qstackedbarseries/tst_qstackedbarseries.cpp index 5c411c9..58ab5f7 100644 --- a/tests/auto/qstackedbarseries/tst_qstackedbarseries.cpp +++ b/tests/auto/qstackedbarseries/tst_qstackedbarseries.cpp @@ -112,8 +112,6 @@ void tst_QStackedBarSeries::mouseclicked() *set2 << 10 << 10 << 10; series->append(set2); - QSignalSpy setSpy1(set1, SIGNAL(clicked(QString))); - QSignalSpy setSpy2(set2, SIGNAL(clicked(QString))); QSignalSpy seriesSpy(series,SIGNAL(clicked(QBarSet*,QString))); QChartView view(new QChart()); @@ -124,109 +122,69 @@ void tst_QStackedBarSeries::mouseclicked() //==================================================================================== // barset 1, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(115,230)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,190)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); QCOMPARE(seriesSpy.count(), 1); - QList setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); QList seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); //==================================================================================== // barset 1, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(205,230)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,190)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); //==================================================================================== // barset 1, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(300,230)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,190)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 1); - QCOMPARE(setSpy2.count(), 0); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); //==================================================================================== // barset 2, category test1 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(115,140)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(106,95)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test1")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test1")) == 0); //==================================================================================== // barset 2, category test2 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(205,140)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(199,95)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test2")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test2")) == 0); //==================================================================================== // barset 2, category test3 - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(300,140)); + QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(292,95)); QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 1); QCOMPARE(seriesSpy.count(), 1); - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::String); - QVERIFY(setSpyArg.at(0).toString().compare(QString("test3")) == 0); seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); - -//==================================================================================== -// no event cases - QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, QPoint(1,1)); // Outside of both sets - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(1,1)); // Right mouse button outside and inside sets - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,230)); // barset 1, category test1 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,230)); // barset 1, category test2 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,230)); // barset 1, category test3 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(115,140)); // barset 2, category test1 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(205,140)); // barset 2, category test2 - QTest::mouseClick(view.viewport(), Qt::RightButton, 0, QPoint(300,140)); // barset 2, category test3 - - QCoreApplication::processEvents(QEventLoop::AllEvents, 1000); - QCOMPARE(setSpy1.count(), 0); - QCOMPARE(setSpy2.count(), 0); - QCOMPARE(seriesSpy.count(), 0); + QVERIFY(seriesSpyArg.at(1).toString().compare(QString("test3")) == 0); } void tst_QStackedBarSeries::mousehovered_data() @@ -249,8 +207,6 @@ void tst_QStackedBarSeries::mousehovered() *set2 << 10 << 10 << 10; series->append(set2); - QSignalSpy setSpy1(set1, SIGNAL(hovered(bool))); - QSignalSpy setSpy2(set2, SIGNAL(hovered(bool))); QSignalSpy seriesSpy(series,SIGNAL(hovered(QBarSet*,bool))); QChartView view(new QChart()); @@ -259,48 +215,33 @@ void tst_QStackedBarSeries::mousehovered() view.show(); QTest::qWaitForWindowShown(&view); + //this is hack since view does not get events otherwise + view.setMouseTracking(true); + //======================================================================= // move mouse to left border - QTest::mouseMove(view.viewport(), QPoint(0, 230)); + QTest::mouseMove(view.viewport(), QPoint(0, 190)); - QVERIFY(setSpy1.count() == 0); - QVERIFY(setSpy2.count() == 0); QVERIFY(seriesSpy.count() == 0); //======================================================================= // move mouse on top of set1 - QTest::mouseMove(view.viewport(), QPoint(115,230)); + QTest::mouseMove(view.viewport(), QPoint(106,190)); - QVERIFY(setSpy1.count() == 1); - QVERIFY(setSpy2.count() == 0); QVERIFY(seriesSpy.count() == 1); - QList setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == true); - QList seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); + QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); + QVERIFY(seriesSpyArg.at(1).toBool() == true); //======================================================================= // move mouse from top of set1 to top of set2 - QTest::mouseMove(view.viewport(), QPoint(115,140)); + QTest::mouseMove(view.viewport(), QPoint(106,95)); - QVERIFY(setSpy1.count() == 1); - QVERIFY(setSpy2.count() == 1); QVERIFY(seriesSpy.count() == 2); // should leave set1 - setSpyArg = setSpy1.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == false); - - // should enter set2 - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == true); - - // should leave set1 seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set1); QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); @@ -314,30 +255,17 @@ void tst_QStackedBarSeries::mousehovered() //======================================================================= // move mouse from top of set2 to background - QTest::mouseMove(view.viewport(), QPoint(0,140)); + QTest::mouseMove(view.viewport(), QPoint(106,0)); - QVERIFY(setSpy1.count() == 0); - QVERIFY(setSpy2.count() == 1); QVERIFY(seriesSpy.count() == 1); - // should leave set2 (event via set) - setSpyArg = setSpy2.takeFirst(); - QVERIFY(setSpyArg.at(0).type() == QVariant::Bool); - QVERIFY(setSpyArg.at(0).toBool() == false); - - // should leave set2 (event via series) + // should leave set2 seriesSpyArg = seriesSpy.takeFirst(); QCOMPARE(qvariant_cast(seriesSpyArg.at(0)), set2); QVERIFY(seriesSpyArg.at(1).type() == QVariant::Bool); QVERIFY(seriesSpyArg.at(1).toBool() == false); } - -/* -bool setModel(QAbstractItemModel *model); -void setModelMapping(int categories, int bottomBoundary, int topBoundary, Qt::Orientation orientation = Qt::Vertical); -void setModelMappingRange(int first, int count = -1); -*/ QTEST_MAIN(tst_QStackedBarSeries) #include "tst_qstackedbarseries.moc"