diff options
Diffstat (limited to 'tests/auto/gui/painting')
-rw-r--r-- | tests/auto/gui/painting/qcolor/tst_qcolor.cpp | 13 | ||||
-rw-r--r-- | tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 50 | ||||
-rw-r--r-- | tests/auto/gui/painting/qpen/tst_qpen.cpp | 53 |
3 files changed, 113 insertions, 3 deletions
diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 1b1f5575b1..2e1d55ced4 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -530,10 +530,19 @@ static const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData); void tst_QColor::setNamedColor() { for (int i = 0; i < rgbTblSize; ++i) { - QColor color; - color.setNamedColor(QLatin1String(rgbTbl[i].name)); QColor expected; expected.setRgba(rgbTbl[i].value); + + QColor color; + color.setNamedColor(QLatin1String(rgbTbl[i].name)); + QCOMPARE(color, expected); + + // name should be case insensitive + color.setNamedColor(QString(rgbTbl[i].name).toUpper()); + QCOMPARE(color, expected); + + // spaces should be ignored + color.setNamedColor(QString(rgbTbl[i].name).insert(1, ' ')); QCOMPARE(color, expected); } } diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index e4340451ce..5af5b1a269 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -282,6 +282,8 @@ private slots: void QTBUG17053_zeroDashPattern(); + void QTBUG38781_NoBrushAndQBitmap(); + void drawTextOutsideGuiThread(); void drawTextWithComplexBrush(); @@ -1134,6 +1136,8 @@ void tst_QPainter::fillRect2_data() QTest::newRow("argb32pm") << QImage::Format_ARGB32_Premultiplied; QTest::newRow("rgba8888") << QImage::Format_RGBA8888; QTest::newRow("rgba8888pm") << QImage::Format_RGBA8888_Premultiplied; + QTest::newRow("a2rgb30pm") << QImage::Format_A2RGB30_Premultiplied; + QTest::newRow("a2bgr30pm") << QImage::Format_A2BGR30_Premultiplied; } void tst_QPainter::fillRect2() @@ -1526,6 +1530,8 @@ void tst_QPainter::qimageFormats_data() QTest::newRow("Qimage::Format_RGB555") << QImage::Format_RGB555; QTest::newRow("Qimage::Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied; QTest::newRow("Qimage::Format_RGB888") << QImage::Format_RGB888; + QTest::newRow("Qimage::Format_A2RGB30_Premultiplied") << QImage::Format_A2RGB30_Premultiplied; + QTest::newRow("Qimage::Format_RGB30") << QImage::Format_RGB30; } /* @@ -2342,6 +2348,26 @@ void tst_QPainter::setOpacity_data() QTest::newRow("RGB32 on RGBx8888") << QImage::Format_RGB32 << QImage::Format_RGBX8888; + + QTest::newRow("A2RGB30P on A2RGB30P") << QImage::Format_A2RGB30_Premultiplied + << QImage::Format_A2RGB30_Premultiplied; + + QTest::newRow("ARGB32P on A2RGB30P") << QImage::Format_ARGB32_Premultiplied + << QImage::Format_A2RGB30_Premultiplied; + + + QTest::newRow("RGB32 on A2BGR30P") << QImage::Format_ARGB32_Premultiplied + << QImage::Format_A2BGR30_Premultiplied; + + QTest::newRow("A2RGB30P on A2BGR30P") << QImage::Format_A2RGB30_Premultiplied + << QImage::Format_A2BGR30_Premultiplied; + + QTest::newRow("ARGB32P on BGR30") << QImage::Format_ARGB32_Premultiplied + << QImage::Format_BGR30; + + QTest::newRow("ARGB32P on RGB30") << QImage::Format_A2RGB30_Premultiplied + << QImage::Format_RGB30; + } void tst_QPainter::setOpacity() @@ -2430,7 +2456,9 @@ void tst_QPainter::drawhelper_blend_untransformed() dest.bytesPerLine(), dest.format()); if (dest.format() == QImage::Format_ARGB8565_Premultiplied || - dest.format() == QImage::Format_ARGB8555_Premultiplied) { + dest.format() == QImage::Format_ARGB8555_Premultiplied || + dest.format() == QImage::Format_A2BGR30_Premultiplied || + dest.format() == QImage::Format_A2RGB30_Premultiplied ) { // Test skipped due to rounding errors... continue; } @@ -4473,6 +4501,26 @@ void tst_QPainter::QTBUG17053_zeroDashPattern() QCOMPARE(image, original); } +void tst_QPainter::QTBUG38781_NoBrushAndQBitmap() +{ + QBitmap bitmap(10, 10); + bitmap.fill(Qt::color0); + QPainter p(&bitmap); + p.setPen(Qt::color1); + p.drawLine(0, 1, 9, 1); // at horizontal line at y=1 + p.setBrush(Qt::NoBrush); + p.drawRect(0, 0, 9, 9); // a rect all around + + QRgb white = qRgb(0xff, 0xff, 0xff); + QRgb black = qRgb(0, 0, 0); + QImage image = bitmap.toImage(); + QCOMPARE(image.pixel(0, 0), black); + QCOMPARE(image.pixel(5, 5), white); + + // Check that the rect didn't overwrite the line + QCOMPARE(image.pixel(5, 1), black); +} + class TextDrawerThread : public QThread { public: diff --git a/tests/auto/gui/painting/qpen/tst_qpen.cpp b/tests/auto/gui/painting/qpen/tst_qpen.cpp index 07c996d026..a373c51710 100644 --- a/tests/auto/gui/painting/qpen/tst_qpen.cpp +++ b/tests/auto/gui/painting/qpen/tst_qpen.cpp @@ -57,6 +57,8 @@ public: private slots: void getSetCheck(); void swap(); + void move(); + void move_assign(); void operator_eq_eq(); void operator_eq_eq_data(); @@ -101,6 +103,57 @@ void tst_QPen::swap() QCOMPARE(p2.color(), QColor(Qt::black)); } +void tst_QPen::move() +{ + QPen p1(Qt::black); + + // check that moving does the right thing: + QPen p2 = qMove(p1); // could be move or copy construction, so don't check p1's state + QCOMPARE(p2.color(), QColor(Qt::black)); + + // this, executed ehre, would crash: + // QVERIFY(p1.style() != Qt::NoPen); + + // check that moved-from QPen p1 can still be safely copied: + const QPen p3 = p1; + + // check that moved-from QPen p1 can still be safely assigned to: + const QPen p4(Qt::yellow); + p1 = p4; + QCOMPARE(p1.color(), QColor(Qt::yellow)); + + // check that moved-from QPens p2, p3 can still be safely destroyed: + QPen p5 = qMove(p2); + + // intentionally no more statements beyond this point +} + +void tst_QPen::move_assign() +{ + QPen p1(Qt::black), p2(Qt::white); + + // check that moving does the right thing: + p2 = qMove(p1); // could be move or copy assignment, so don't check p1's state + QCOMPARE(p2.color(), QColor(Qt::black)); + + // check that move-assigned-from QPen p1 can still be used, albeit + // with undocumented state (it's p2's original state): + QVERIFY(p1.style() != Qt::NoPen); + + // check that moved-from QPen p1 can still be safely copied: + const QPen p3 = p1; + + // check that moved-from QPen p1 can still be safely assigned to: + const QPen p4(Qt::yellow); + p1 = p4; + QCOMPARE(p1.color(), QColor(Qt::yellow)); + + // check that moved-from QPens p2, p3 can still be safely destroyed: + QPen p5; + p5 = qMove(p2); + + // intentionally no more statements beyond this point +} tst_QPen::tst_QPen() |