summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-07-29 23:20:41 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-07-29 23:20:41 (GMT)
commit3f2be090858165d291f27a39157f76aab25d1aaa (patch)
tree6fe076c9daf7dd20da31ed0f85e96b1077a90134 /tests
parent91119eaa185934d568d0c83e25129b0028b5a607 (diff)
parentebbab30af417dfbf3df47dec15c0e2f8d6a30fa6 (diff)
downloadQt-3f2be090858165d291f27a39157f76aab25d1aaa.zip
Qt-3f2be090858165d291f27a39157f76aab25d1aaa.tar.gz
Qt-3f2be090858165d291f27a39157f76aab25d1aaa.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Fix the rendering of lines with the X11 paint engine Fix the byte order in QImage::fill for 24bpp formats QScript: remove JSC::JSLock QScript: document/obsolete things that does not work since the move to JSC
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qimage/tst_qimage.cpp64
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp65
2 files changed, 129 insertions, 0 deletions
diff --git a/tests/auto/qimage/tst_qimage.cpp b/tests/auto/qimage/tst_qimage.cpp
index 1330d96..62deb5ae 100644
--- a/tests/auto/qimage/tst_qimage.cpp
+++ b/tests/auto/qimage/tst_qimage.cpp
@@ -103,6 +103,9 @@ private slots:
void copy();
+ void fill_data();
+ void fill();
+
void setPixel_data();
void setPixel();
@@ -1015,6 +1018,67 @@ void tst_QImage::copy()
}
}
+void tst_QImage::fill_data()
+{
+ QTest::addColumn<int>("format");
+ QTest::addColumn<uint>("input");
+ QTest::addColumn<uint>("expectedResult");
+
+ QTest::newRow("ARGB32") << int(QImage::Format_ARGB32) << 0x33557799u << 0x33557799u;
+ QTest::newRow("RGB888") << int(QImage::Format_RGB888) << 0x335577u << 0x335577u;
+ QTest::newRow("RGB16") << int(QImage::Format_RGB16) << 0x3355u << 0x3355u;
+ QTest::newRow("Indexed8") << int(QImage::Format_Indexed8) << 0x55u << 0x55u;
+ QTest::newRow("Mono") << int(QImage::Format_Mono) << 1u << 1u;
+ QTest::newRow("Mono_LSB") << int(QImage::Format_MonoLSB) << 0u << 0u;
+}
+
+void tst_QImage::fill()
+{
+ QFETCH(int, format);
+ QFETCH(uint, input);
+ QFETCH(uint, expectedResult);
+
+ QImage img(13, 15, (QImage::Format)format);
+ img.fill(input);
+
+ const int bpp = img.depth();
+ for (int y = 0; y < img.height(); ++y) {
+ uchar *line = img.scanLine(y);
+ for (int x = 0; x < img.width(); ++x) {
+ uint value;
+ switch (bpp) {
+ case 32:
+ value = *((uint*)line);
+ line += 4;
+ break;
+ case 24:
+ value = ((uint)line[0] << 16) | ((uint)line[1] << 8) | line[2];
+ line += 3;
+ break;
+ case 16:
+ value = *((quint16*)line);
+ line += 2;
+ break;
+ case 8:
+ value = *line;
+ line++;
+ break;
+ case 1:
+ if (format == QImage::Format_Mono)
+ value = (*line >> (7- (x & 7))) & 1;
+ else if (format == QImage::Format_MonoLSB)
+ value = (*line >> (x & 7)) & 1;
+
+ if (x && !(x & 7))
+ ++line;
+ break;
+ }
+
+ QCOMPARE(value, expectedResult);
+ }
+ }
+}
+
void tst_QImage::setPixel_data()
{
QTest::addColumn<int>("format");
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index f358681..2cbb9b2 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -118,10 +118,12 @@ private slots:
void drawLine_task190634();
void drawLine_task229459();
void drawLine_task234891();
+ void drawHorizontalLineF();
void drawRect_data() { fillData(); }
void drawRect();
void drawRect2();
+ void drawRectFHorizontalLine();
void fillRect();
void fillRect2();
@@ -251,6 +253,7 @@ private slots:
void setPenColorOnPixmap();
void QTBUG5939_attachPainterPrivate();
+ void drawHorizontalLine();
private:
void fillData();
@@ -1218,6 +1221,26 @@ void tst_QPainter::drawLine_task234891()
QCOMPARE(expected, img);
}
+void tst_QPainter::drawHorizontalLineF()
+{
+ QPixmap pixmap(100, 3);
+ pixmap.fill();
+
+ {
+ QPainter painter(&pixmap);
+ painter.drawLine(QLineF(1.5f, 1.5f, 98.5f, 1.5f));
+ }
+
+ QImage refImage(100, 3, QImage::Format_ARGB32);
+ refImage.fill(0xFFFFFFFF);
+ {
+ QPainter painter(&refImage);
+ painter.drawLine(QLineF(1.5f, 1.5f, 98.5f, 1.5f));
+ }
+
+ QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage);
+}
+
void tst_QPainter::drawLine_task216948()
{
QImage img(1, 10, QImage::Format_ARGB32_Premultiplied);
@@ -1302,6 +1325,26 @@ void tst_QPainter::drawRect2()
}
}
+void tst_QPainter::drawRectFHorizontalLine()
+{
+ QPixmap pixmap(100, 3);
+ pixmap.fill();
+
+ {
+ QPainter painter(&pixmap);
+ painter.drawRect(QRectF(1.5f, 1.5f, 98.5f, 1.5f));
+ }
+
+ QImage refImage(100, 3, QImage::Format_ARGB32);
+ refImage.fill(0xFFFFFFFF);
+ {
+ QPainter painter(&refImage);
+ painter.drawRect(QRectF(1.5f, 1.5f, 98.5f, 1.5f));
+ }
+
+ QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage);
+}
+
void tst_QPainter::fillRect()
{
QImage image(100, 100, QImage::Format_ARGB32_Premultiplied);
@@ -4522,6 +4565,28 @@ void tst_QPainter::QTBUG5939_attachPainterPrivate()
QCOMPARE(widget->deviceTransform, proxy->deviceTransform);
}
+void tst_QPainter::drawHorizontalLine()
+{
+ QPixmap pixmap(100, 3);
+ pixmap.fill();
+
+ {
+ QPainter painter(&pixmap);
+ painter.translate(0.3, 0.3);
+ painter.drawLine(QLine(1, 1, 99, 1));
+ }
+
+ QImage refImage(100, 3, QImage::Format_ARGB32);
+ refImage.fill(0xFFFFFFFF);
+ {
+ QPainter painter(&refImage);
+ painter.translate(0.3, 0.3);
+ painter.drawLine(QLine(1, 1, 99, 1));
+ }
+
+ QCOMPARE(pixmap.toImage().convertToFormat(QImage::Format_ARGB32), refImage);
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"