diff --git a/tests/BasicDataPlotTest.cpp b/tests/BasicDataPlotTest.cpp index ee6bc5a..e757167 100644 --- a/tests/BasicDataPlotTest.cpp +++ b/tests/BasicDataPlotTest.cpp @@ -61,11 +61,10 @@ void BasicDataPlotTest::testPlotWithData() { BasicDataPlot plot; preparePlot(plot); - plot.setAxisVisible(QwtPlot::xBottom, false); const QString expectedPath{ QString::fromLatin1(":/res/BasicDataPlotDefault.png")}; - common::checkPlot(plot, expectedPath); + common::checkPlotCanvas(plot, expectedPath); } void BasicDataPlotTest::testPlotWithoutData() @@ -78,7 +77,7 @@ void BasicDataPlotTest::testPlotWithoutData() const QString expectedPath{ QString::fromLatin1(":/res/BasicDataPlotEmpty.png")}; - common::checkPlot(plot, expectedPath); + common::checkPlotCanvas(plot, expectedPath); } void BasicDataPlotTest::testLegendItemsChecking() @@ -92,5 +91,5 @@ void BasicDataPlotTest::testLegendItemsChecking() const QString expectedPath{ QString::fromLatin1(":/res/BasicDataPlotItemChecked.png")}; - common::checkPlot(plot, expectedPath); + common::checkPlotCanvas(plot, expectedPath); } diff --git a/tests/Common.cpp b/tests/Common.cpp index b37dc19..654c6ed 100644 --- a/tests/Common.cpp +++ b/tests/Common.cpp @@ -84,4 +84,12 @@ void checkPlot(QwtPlot& plot, const QString& expectedPath) expected = expected.convertToFormat(actual.format()); QCOMPARE(actual, expected); } + +void checkPlotCanvas(QwtPlot& plot, const QString& expectedPath) +{ + const QImage actual{plot.canvas()->grab().toImage()}; + QImage expected(expectedPath); + expected = expected.convertToFormat(actual.format()); + QCOMPARE(actual, expected); +} } // namespace common diff --git a/tests/Common.h b/tests/Common.h index 2dfb9f1..a37ed01 100644 --- a/tests/Common.h +++ b/tests/Common.h @@ -20,4 +20,6 @@ QVariant getItemInfo(QwtPlot& plot, const QString& text); QSize getPlotSize(); void checkPlot(QwtPlot& plot, const QString& expectedPath); + +void checkPlotCanvas(QwtPlot& plot, const QString& expectedPath); } // namespace common diff --git a/tests/Tests.cpp b/tests/Tests.cpp index 814c6ba..3f9eb17 100644 --- a/tests/Tests.cpp +++ b/tests/Tests.cpp @@ -48,7 +48,9 @@ void setupFont() const QString family{QFontDatabase::applicationFontFamilies(id).at(0)}; QFont font(family); font.setPixelSize(12); - font.setStyleStrategy(QFont::NoAntialias); + font.setStyleStrategy(static_cast(QFont::NoAntialias | + QFont::PreferBitmap | QFont::NoSubpixelAntialias | + QFont::PreferNoShaping | QFont::NoFontMerging)); QApplication::setFont(font); } } // namespace diff --git a/tests/res/BasicDataPlotDefault.png b/tests/res/BasicDataPlotDefault.png index 4f4dac8..c28bef1 100644 Binary files a/tests/res/BasicDataPlotDefault.png and b/tests/res/BasicDataPlotDefault.png differ diff --git a/tests/res/BasicDataPlotEmpty.png b/tests/res/BasicDataPlotEmpty.png index a4594e0..315d9d0 100644 Binary files a/tests/res/BasicDataPlotEmpty.png and b/tests/res/BasicDataPlotEmpty.png differ diff --git a/tests/res/BasicDataPlotItemChecked.png b/tests/res/BasicDataPlotItemChecked.png index 82391c2..c2089ef 100644 Binary files a/tests/res/BasicDataPlotItemChecked.png and b/tests/res/BasicDataPlotItemChecked.png differ