summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsitem
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-06-08 12:49:44 (GMT)
committerAndreas Aardal Hanssen <andreas.aardal.hanssen@nokia.com>2009-06-09 07:43:37 (GMT)
commit9ba5a561b017ec028d675627df2eda5b13e3a6fc (patch)
tree0b336556a4926f0fad6fc3e7a9beffb7e23d9e49 /tests/auto/qgraphicsitem
parent56f23d4ccfc27f737d30e92ae5b3ecde6e8b0bbf (diff)
downloadQt-9ba5a561b017ec028d675627df2eda5b13e3a6fc.zip
Qt-9ba5a561b017ec028d675627df2eda5b13e3a6fc.tar.gz
Qt-9ba5a561b017ec028d675627df2eda5b13e3a6fc.tar.bz2
Fix two regressions in Plasma. The painter state proctection was not
properly pass to drawItemHelper. The second is a double conversion to deviceTransform in createStyleOption of QGraphicsItem. Since the recursive drawing already give a transform in device mode we don't need to convert it two times. Reviewed-by:andreas
Diffstat (limited to 'tests/auto/qgraphicsitem')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 82c173b..7a789c5 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -44,6 +44,7 @@
#include <private/qtextcontrol_p.h>
#include <private/qgraphicsitem_p.h>
+#include <QStyleOptionGraphicsItem>
#include <QAbstractTextDocumentLayout>
#include <QBitmap>
#include <QCursor>
@@ -222,6 +223,7 @@ private slots:
void update();
void setTransformProperties_data();
void setTransformProperties();
+ void itemUsesExtendedStyleOption();
// task specific tests below me
void task141694_textItemEnsureVisible();
@@ -6449,6 +6451,7 @@ void tst_QGraphicsItem::update()
{
QGraphicsScene scene;
MyGraphicsView view(&scene);
+
view.show();
#ifdef Q_WS_X11
qt_x11_wait_for_window_manager(&view);
@@ -6683,5 +6686,55 @@ void tst_QGraphicsItem::setTransformProperties()
}
}
+class MyStyleOptionTester : public QGraphicsRectItem
+{
+public:
+ MyStyleOptionTester(const QRectF &rect)
+ : QGraphicsRectItem(rect), startTrack(false)
+ {}
+
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0)
+ {
+ if (startTrack) {
+ //Doesn't use the extended style option so the exposed rect is the boundingRect
+ if (!(flags() & QGraphicsItem::ItemUsesExtendedStyleOption)) {
+ QCOMPARE(option->exposedRect, boundingRect());
+ } else {
+ QVERIFY(option->exposedRect != QRect());
+ QVERIFY(option->exposedRect != boundingRect());
+ }
+ }
+ QGraphicsRectItem::paint(painter, option, widget);
+ }
+ bool startTrack;
+};
+
+void tst_QGraphicsItem::itemUsesExtendedStyleOption()
+{
+ QGraphicsScene scene(0, 0, 300, 300);
+ QGraphicsPixmapItem item;
+ item.setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true);
+ QCOMPARE(item.flags(), QGraphicsItem::GraphicsItemFlags(QGraphicsItem::ItemUsesExtendedStyleOption));
+ item.setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, false);
+ QCOMPARE(item.flags(), 0);
+
+ //We now test the content of the style option
+ MyStyleOptionTester *rect = new MyStyleOptionTester(QRect(0, 0, 100, 100));
+ scene.addItem(rect);
+ rect->setPos(200, 200);
+ QGraphicsView view(&scene);
+ QTest::qWait(500);
+ rect->startTrack = true;
+ rect->update(10, 10, 10, 10);
+ QTest::qWait(125);
+ rect->startTrack = false;
+ rect->setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true);
+ QVERIFY((rect->flags() & QGraphicsItem::ItemUsesExtendedStyleOption));
+ QTest::qWait(125);
+ rect->startTrack = true;
+ rect->update(10, 10, 10, 10);
+ QTest::qWait(125);
+}
+
QTEST_MAIN(tst_QGraphicsItem)
#include "tst_qgraphicsitem.moc"