summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-11-26 09:26:27 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-11-26 09:31:23 (GMT)
commitc8494e085cd5abc3b30229409c7dacac676c81b9 (patch)
tree078c20210cbc1a6e530e4447bf067be03c740ea5 /tests
parent0f06d08a3c5eb4d0397406ed559cfaba6e137492 (diff)
downloadQt-c8494e085cd5abc3b30229409c7dacac676c81b9.zip
Qt-c8494e085cd5abc3b30229409c7dacac676c81b9.tar.gz
Qt-c8494e085cd5abc3b30229409c7dacac676c81b9.tar.bz2
QGraphicsTextItem::setDefaultTextColor check change before calling update()
Some applications call setDefaultTextColor in the paint event. Task-number: QTBUG-6242 Reviewed-by: Gabriel
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index db80db6..565a3e7 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -9759,16 +9759,16 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor()
{
struct Item : public QGraphicsTextItem
{
- bool painted;
+ int painted;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *opt, QWidget *wid)
{
- painted = true;
+ painted++;
QGraphicsTextItem::paint(painter, opt, wid);
}
};
Item *i = new Item;
- i->painted = false;
+ i->painted = 0;
i->setPlainText("I AM A TROLL");
QGraphicsScene scene;
@@ -9780,11 +9780,11 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor()
QTRY_VERIFY(i->painted);
QApplication::processEvents();
- i->painted = false;
+ i->painted = 0;
QColor col(Qt::red);
i->setDefaultTextColor(col);
QApplication::processEvents();
- QTRY_VERIFY(i->painted); //check that changing the color force an update
+ QTRY_COMPARE(i->painted, 1); //check that changing the color force an update
i->painted = false;
QImage image(400, 200, QImage::Format_RGB32);
@@ -9792,7 +9792,7 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor()
QPainter painter(&image);
scene.render(&painter);
painter.end();
- QVERIFY(i->painted);
+ QCOMPARE(i->painted, 1);
int numRedPixel = 0;
QRgb rgb = col.rgb();
@@ -9810,6 +9810,11 @@ void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor()
}
}
QCOMPARE(numRedPixel, -1); //color not found, FAIL!
+
+ i->painted = 0;
+ i->setDefaultTextColor(col);
+ QApplication::processEvents();
+ QCOMPARE(i->painted, 0); //same color as before should not trigger an update (QTBUG-6242)
}
QTEST_MAIN(tst_QGraphicsItem)