summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-07-31 10:36:25 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-07-31 10:36:25 (GMT)
commit759fe35812975104f3b73934d7d179159ce9effa (patch)
tree592d320ba88a4c20be0d83cad1932bb90840a5c7 /tests
parente93d11c733bb44208089a7488c6e7a176468d407 (diff)
parent210aa246b6d95dbdb2c1561bf36b80d4c2a2674b (diff)
downloadQt-759fe35812975104f3b73934d7d179159ce9effa.zip
Qt-759fe35812975104f3b73934d7d179159ce9effa.tar.gz
Qt-759fe35812975104f3b73934d7d179159ce9effa.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 tst_QPainter::drawImage_task258776 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.cpp67
2 files changed, 130 insertions, 1 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..7679545 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);
@@ -3599,7 +3642,7 @@ void tst_QPainter::drawImage_task258776()
painter.end();
QImage expected(33, 33, QImage::Format_RGB32);
- expected.fill(0xff0000);
+ expected.fill(0x0000ff);
painter.begin(&expected);
painter.drawImage(QRectF(0, 0, 32, 32), src);
@@ -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"