diff options
author | Samuel Rødal <samuel.rodal@digia.com> | 2013-03-21 08:18:12 +0100 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@digia.com> | 2013-03-21 08:49:01 +0100 |
commit | 2ab9b747fcc5aa50e8cca758f7780158e734a222 (patch) | |
tree | 7017007823d54c2d658079e928f7220a1f57a852 /tests/auto/gui/painting | |
parent | f1e681bed21e131864fe1e1c91679f7a56b06823 (diff) | |
parent | 8bfbaa41783dad66976fc83d4ca8c7e2673f5629 (diff) |
Merge remote-tracking branch 'gerrit/release' into stable
Conflicts:
configure
mkspecs/features/qt_module_headers.prf
mkspecs/features/qt_tool.prf
src/angle/angle.pro
src/tools/bootstrap/bootstrap.pro
tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
Change-Id: Ide5759fe419a50f1c944211a48f7c66f662684e0
Diffstat (limited to 'tests/auto/gui/painting')
-rw-r--r-- | tests/auto/gui/painting/qpainter/tst_qpainter.cpp | 58 |
1 files changed, 47 insertions, 11 deletions
diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index 6c37f1fc27..4f1213dff9 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -277,7 +277,9 @@ private slots: void drawTextWithComplexBrush(); void QTBUG26013_squareCapStroke(); void QTBUG25153_drawLine(); - void dashing_systemClip(); + + void cosmeticStrokerClipping_data(); + void cosmeticStrokerClipping(); private: void fillData(); @@ -4459,22 +4461,54 @@ void tst_QPainter::QTBUG25153_drawLine() } } -static void dashing_systemClip_paint(QPainter *p) +enum CosmeticStrokerPaint +{ + Antialiasing, + Dashing +}; + +static void paint_func(QPainter *p, CosmeticStrokerPaint type) +{ + p->save(); + switch (type) { + case Antialiasing: + p->setPen(Qt::black); + p->setRenderHint(QPainter::Antialiasing); + p->drawLine(4, 8, 42, 42); + break; + case Dashing: + p->setPen(QPen(Qt::black, 1, Qt::DashLine, Qt::RoundCap, Qt::MiterJoin)); + p->drawLine(8, 8, 42, 8); + p->drawLine(42, 8, 42, 42); + p->drawLine(42, 42, 8, 42); + p->drawLine(8, 42, 8, 8); + break; + default: + Q_ASSERT(false); + break; + } + p->restore(); +} + +Q_DECLARE_METATYPE(CosmeticStrokerPaint) + +void tst_QPainter::cosmeticStrokerClipping_data() { - p->setPen(QPen(Qt::black, 1, Qt::DashLine, Qt::RoundCap, Qt::MiterJoin)); - p->drawLine(8, 8, 42, 8); - p->drawLine(42, 8, 42, 42); - p->drawLine(42, 42, 8, 42); - p->drawLine(8, 42, 8, 8); + QTest::addColumn<CosmeticStrokerPaint>("paint"); + + QTest::newRow("antialiasing_paint") << Antialiasing; + QTest::newRow("dashing_paint") << Dashing; } -void tst_QPainter::dashing_systemClip() +void tst_QPainter::cosmeticStrokerClipping() { + QFETCH(CosmeticStrokerPaint, paint); + QImage image(50, 50, QImage::Format_RGB32); image.fill(Qt::white); QPainter p(&image); - dashing_systemClip_paint(&p); + paint_func(&p, paint); p.end(); QImage old = image.copy(); @@ -4482,7 +4516,8 @@ void tst_QPainter::dashing_systemClip() image.paintEngine()->setSystemClip(QRect(10, 0, image.width() - 10, image.height())); p.begin(&image); - dashing_systemClip_paint(&p); + p.fillRect(image.rect(), Qt::white); + paint_func(&p, paint); // doing same paint operation again with different system clip should not change the image QCOMPARE(old, image); @@ -4490,7 +4525,8 @@ void tst_QPainter::dashing_systemClip() old = image; p.setClipRect(QRect(20, 20, 30, 30)); - dashing_systemClip_paint(&p); + p.fillRect(image.rect(), Qt::white); + paint_func(&p, paint); // ditto for regular clips QCOMPARE(old, image); |