summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/image/qimage/tst_qimage.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-08-01 08:51:18 +0200
committerLiang Qi <liang.qi@qt.io>2016-08-01 10:03:21 +0200
commit3cb7302480390e5149a9cf6f49ac1ca94ef63f97 (patch)
tree831134f1053214ab0d5ba4d406cf7b860ed7c578 /tests/auto/gui/image/qimage/tst_qimage.cpp
parent2ff1557937c398a7fb5cc7ba120e7ca3b5eacd36 (diff)
parentf24cc53cc27d8ed4be4c1d0d2df059dd6a6909a9 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: src/widgets/itemviews/qabstractitemview.cpp src/widgets/itemviews/qabstractitemview_p.h Change-Id: I54589b1365103cb1749186af92aab03a49c94b64
Diffstat (limited to 'tests/auto/gui/image/qimage/tst_qimage.cpp')
-rw-r--r--tests/auto/gui/image/qimage/tst_qimage.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 9e4a1abbb1..85d258de5b 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -94,6 +94,8 @@ private slots:
void setPixel_data();
void setPixel();
+ void defaultColorTable_data();
+ void defaultColorTable();
void setColorCount();
void setColor();
@@ -1450,6 +1452,38 @@ void tst_QImage::convertToFormatPreserveText()
QCOMPARE(imgResult2.textKeys(), listResult);
}
+void tst_QImage::defaultColorTable_data()
+{
+ QTest::addColumn<QImage::Format>("format");
+ QTest::addColumn<int>("createdDataCount");
+ QTest::addColumn<int>("externalDataCount");
+
+ // For historical reasons, internally created mono images get a default colormap.
+ // Externally created and Indexed8 images do not.
+ QTest::newRow("Mono") << QImage::Format_Mono << 2 << 0;
+ QTest::newRow("MonoLSB") << QImage::Format_MonoLSB << 2 << 0;
+ QTest::newRow("Indexed8") << QImage::Format_Indexed8 << 0 << 0;
+ QTest::newRow("ARGB32_PM") << QImage::Format_A2BGR30_Premultiplied << 0 << 0;
+}
+
+void tst_QImage::defaultColorTable()
+{
+ QFETCH(QImage::Format, format);
+ QFETCH(int, createdDataCount);
+ QFETCH(int, externalDataCount);
+
+ QImage img1(1, 1, format);
+ QCOMPARE(img1.colorCount(), createdDataCount);
+ QCOMPARE(img1.colorTable().size(), createdDataCount);
+
+ quint32 buf;
+ QImage img2(reinterpret_cast<uchar *>(&buf), 1, 1, format);
+ QCOMPARE(img2.colorCount(), externalDataCount);
+
+ QImage nullImg(0, 0, format);
+ QCOMPARE(nullImg.colorCount(), 0);
+}
+
void tst_QImage::setColorCount()
{
QImage img(0, 0, QImage::Format_Indexed8);
@@ -3182,8 +3216,8 @@ void tst_QImage::pixel()
QImage monolsb(&a, 1, 1, QImage::Format_MonoLSB);
QImage indexed(&a, 1, 1, QImage::Format_Indexed8);
- QCOMPARE(QColor(mono.pixel(0, 0)), QColor(Qt::black));
- QCOMPARE(QColor(monolsb.pixel(0, 0)), QColor(Qt::black));
+ mono.pixel(0, 0); // Don't crash
+ monolsb.pixel(0, 0); // Don't crash
indexed.pixel(0, 0); // Don't crash
}
}