summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2014-02-13 09:35:08 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-02-13 09:35:08 +0100
commit7ac97d7efb1a1e75633ce31fbb03eb43a9b01670 (patch)
tree4284e5eff68c13cc52be1c658d6c2abffee3ece5 /tests/auto/gui
parent5b14bf342f43bd6cb02ad751db8da851850814bb (diff)
parenta9c88c1f39c41215eb9d7288a1fd02aa865e8a04 (diff)
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/painting/qpainter/tst_qpainter.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
index 91c06ab0b2..e4340451ce 100644
--- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
+++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp
@@ -202,6 +202,9 @@ private slots:
void linearGradientSymmetry();
void gradientInterpolation();
+ void gradientPixelFormat_data();
+ void gradientPixelFormat();
+
void fpe_pixmapTransform();
void fpe_zeroLengthLines();
void fpe_divByZero();
@@ -3727,6 +3730,49 @@ void tst_QPainter::linearGradientSymmetry()
QCOMPARE(a, b);
}
+void tst_QPainter::gradientPixelFormat_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+
+ QTest::newRow("argb32") << QImage::Format_ARGB32;
+ QTest::newRow("rgb32") << QImage::Format_RGB32;
+ QTest::newRow("rgb888") << QImage::Format_RGB888;
+ QTest::newRow("rgbx8888") << QImage::Format_RGBX8888;
+ QTest::newRow("rgba8888") << QImage::Format_RGBA8888;
+ QTest::newRow("rgba8888_pm") << QImage::Format_RGBA8888_Premultiplied;
+}
+
+void tst_QPainter::gradientPixelFormat()
+{
+ QFETCH(QImage::Format, format);
+
+ QImage a(8, 64, QImage::Format_ARGB32_Premultiplied);
+ QImage b(8, 64, format);
+
+
+ QGradientStops stops;
+ stops << qMakePair(qreal(0.0), QColor(Qt::blue));
+ stops << qMakePair(qreal(0.3), QColor(Qt::red));
+ stops << qMakePair(qreal(0.6), QColor(Qt::green));
+ stops << qMakePair(qreal(1.0), QColor(Qt::black));
+
+ a.fill(0);
+ b.fill(0);
+
+ QLinearGradient gradient(QRectF(b.rect()).topLeft(), QRectF(b.rect()).bottomLeft());
+ gradient.setStops(stops);
+
+ QPainter pa(&a);
+ pa.fillRect(a.rect(), gradient);
+ pa.end();
+
+ QPainter pb(&b);
+ pb.fillRect(b.rect(), gradient);
+ pb.end();
+
+ QCOMPARE(a, b.convertToFormat(QImage::Format_ARGB32_Premultiplied));
+}
+
void tst_QPainter::gradientInterpolation()
{
QImage image(256, 8, QImage::Format_ARGB32_Premultiplied);