diff options
Diffstat (limited to 'tests/auto/gui/painting')
-rw-r--r-- | tests/auto/gui/painting/qbrush/tst_qbrush.cpp | 21 | ||||
-rw-r--r-- | tests/auto/gui/painting/qcolor/tst_qcolor.cpp | 20 | ||||
-rw-r--r-- | tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 14 |
3 files changed, 43 insertions, 12 deletions
diff --git a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp index 9098bb0f6e..cd3eaa1478 100644 --- a/tests/auto/gui/painting/qbrush/tst_qbrush.cpp +++ b/tests/auto/gui/painting/qbrush/tst_qbrush.cpp @@ -58,6 +58,7 @@ private slots: void testQGradientCopyConstructor(); void gradientStops(); + void gradientPresets(); void textures(); @@ -326,6 +327,26 @@ void tst_QBrush::gradientStops() QCOMPARE(gradient.stops().at(0).second, QColor()); } +void tst_QBrush::gradientPresets() +{ + QGradient gradient(QGradient::WarmFlame); + QCOMPARE(gradient.type(), QGradient::LinearGradient); + QCOMPARE(gradient.coordinateMode(), QGradient::ObjectMode); + + QLinearGradient *lg = static_cast<QLinearGradient *>(&gradient); + QCOMPARE(lg->start(), QPointF(0, 1)); + QCOMPARE(lg->finalStop(), QPointF(1, 0)); + + QCOMPARE(lg->stops().size(), 3); + QCOMPARE(lg->stops().at(0), QGradientStop(0, QColor(QLatin1Literal("#ff9a9e")))); + QCOMPARE(lg->stops().at(1), QGradientStop(0.99, QColor(QLatin1Literal("#fad0c4")))); + QCOMPARE(lg->stops().at(2), QGradientStop(1, QColor(QLatin1Literal("#fad0c4")))); + + + QGradient invalidPreset(QGradient::Preset(-1)); + QCOMPARE(invalidPreset.type(), QGradient::NoGradient); +} + void fill(QPaintDevice *pd) { QPainter p(pd); diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 67d30d7c9a..ece7a30830 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -1492,10 +1492,28 @@ void tst_QColor::unpremultiply_sse4() // Tests that qUnpremultiply_sse4 returns the same as qUnpremultiply. #if QT_COMPILER_SUPPORTS_HERE(SSE4_1) if (qCpuHasFeature(SSE4_1)) { + int minorDifferences = 0; + for (uint a = 0; a < 256; a++) { + for (uint c = 0; c <= a; c++) { + const QRgb p = qRgba(c, a-c, c/2, a); + const uint u = qUnpremultiply(p); + const uint usse4 = qUnpremultiply_sse4(p); + if (u != usse4) { + QCOMPARE(qAlpha(u), qAlpha(usse4)); + QVERIFY(qAbs(qRed(u) - qRed(usse4)) <= 1); + QVERIFY(qAbs(qGreen(u) - qGreen(usse4)) <= 1); + QVERIFY(qAbs(qBlue(u) - qBlue(usse4)) <= 1); + ++minorDifferences; + } + } + } + // Allow a few rounding differences as long as it still obeys + // the qPremultiply(qUnpremultiply(x)) == x invariant + QVERIFY(minorDifferences <= 16 * 255); for (uint a = 0; a < 256; a++) { for (uint c = 0; c <= a; c++) { QRgb p = qRgba(c, a-c, c, a); - QCOMPARE(qUnpremultiply(p), qUnpremultiply_sse4(p)); + QCOMPARE(p, qPremultiply(qUnpremultiply_sse4(p))); } } return; diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 181c609c6e..58ac025f0c 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -31,9 +31,9 @@ #include <qpainter.h> #ifndef QT_NO_WIDGETS #include <qdrawutil.h> -#include <qapplication.h> #include <qwidget.h> #endif +#include <qguiapplication.h> #include <qfontmetrics.h> #include <qbitmap.h> #include <qimage.h> @@ -41,26 +41,18 @@ #include <limits.h> #include <math.h> #include <qpaintengine.h> -#ifndef QT_NO_WIDGETS -#include <qdesktopwidget.h> -#endif #include <qpixmap.h> #include <qrandom.h> #include <private/qdrawhelper_p.h> #include <qpainter.h> - -#ifndef QT_NO_WIDGETS -#include <qlabel.h> -#endif - #include <qqueue.h> +#include <qscreen.h> #ifndef QT_NO_WIDGETS #include <qgraphicsview.h> #include <qgraphicsscene.h> #include <qgraphicsproxywidget.h> -#include <qlayout.h> #endif #include <qfontdatabase.h> @@ -404,7 +396,7 @@ void tst_QPainter::cleanupTestCase() #ifndef QT_NO_WIDGETS void tst_QPainter::drawPixmap_comp_data() { - if (qApp->desktop()->depth() < 24) + if (QGuiApplication::primaryScreen()->depth() < 24) QSKIP("Test only works on 32 bit displays"); QTest::addColumn<uint>("dest"); |