summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-10-08 00:18:25 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-10-08 00:18:25 (GMT)
commit7c555955e96bc188bfebdea2cd066d871f151b59 (patch)
tree71e8765fa2f82878cbb2b5505857bd5f09595228 /tests/auto
parent7b78eab2c04ed0388a2ffdf43bbe5ca37ccc8167 (diff)
parent558acd8c8ff94c6fd1e96514a2dffb587a66bb2f (diff)
downloadQt-7c555955e96bc188bfebdea2cd066d871f151b59.zip
Qt-7c555955e96bc188bfebdea2cd066d871f151b59.tar.gz
Qt-7c555955e96bc188bfebdea2cd066d871f151b59.tar.bz2
Merge branch 4.7 into qt-master-from-4.7
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp76
1 files changed, 76 insertions, 0 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 25ec040..2901dd5 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -445,6 +445,7 @@ private slots:
void textItem_shortcuts();
void scroll();
void stopClickFocusPropagation();
+ void deviceCoordinateCache_simpleRotations();
// task specific tests below me
void task141694_textItemEnsureVisible();
@@ -10560,6 +10561,81 @@ void tst_QGraphicsItem::stopClickFocusPropagation()
QVERIFY(itemWithFocus->hasFocus());
}
+void tst_QGraphicsItem::deviceCoordinateCache_simpleRotations()
+{
+ // Make sure we don't invalidate the cache when applying simple
+ // (90, 180, 270, 360) rotation transforms to the item.
+ QGraphicsRectItem *item = new QGraphicsRectItem(0, 0, 300, 200);
+ item->setBrush(Qt::red);
+ item->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
+
+ QGraphicsScene scene;
+ scene.setSceneRect(0, 0, 300, 200);
+ scene.addItem(item);
+
+ MyGraphicsView view(&scene);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+ QTRY_VERIFY(view.repaints > 0);
+
+ QGraphicsItemCache *itemCache = QGraphicsItemPrivate::get(item)->extraItemCache();
+ Q_ASSERT(itemCache);
+ QPixmapCache::Key currentKey = itemCache->deviceData.value(view.viewport()).key;
+
+ // Trigger an update and verify that the cache is unchanged.
+ QPixmapCache::Key oldKey = currentKey;
+ view.reset();
+ view.viewport()->update();
+ QTRY_VERIFY(view.repaints > 0);
+ currentKey = itemCache->deviceData.value(view.viewport()).key;
+ QCOMPARE(currentKey, oldKey);
+
+ // Check 90, 180, 270 and 360 degree rotations.
+ for (int angle = 90; angle <= 360; angle += 90) {
+ // Rotate item and verify that the cache was invalidated.
+ oldKey = currentKey;
+ view.reset();
+ QTransform transform;
+ transform.translate(150, 100);
+ transform.rotate(angle);
+ transform.translate(-150, -100);
+ item->setTransform(transform);
+ QTRY_VERIFY(view.repaints > 0);
+ currentKey = itemCache->deviceData.value(view.viewport()).key;
+ QVERIFY(currentKey != oldKey);
+
+ // IMPORTANT PART:
+ // Trigger an update and verify that the cache is unchanged.
+ oldKey = currentKey;
+ view.reset();
+ view.viewport()->update();
+ QTRY_VERIFY(view.repaints > 0);
+ currentKey = itemCache->deviceData.value(view.viewport()).key;
+ QCOMPARE(currentKey, oldKey);
+ }
+
+ // 45 degree rotation.
+ oldKey = currentKey;
+ view.reset();
+ QTransform transform;
+ transform.translate(150, 100);
+ transform.rotate(45);
+ transform.translate(-150, -100);
+ item->setTransform(transform);
+ QTRY_VERIFY(view.repaints > 0);
+ currentKey = itemCache->deviceData.value(view.viewport()).key;
+ QVERIFY(currentKey != oldKey);
+
+ // Trigger an update and verify that the cache was invalidated.
+ // We should always invalidate the cache for non-trivial transforms.
+ oldKey = currentKey;
+ view.reset();
+ view.viewport()->update();
+ QTRY_VERIFY(view.repaints > 0);
+ currentKey = itemCache->deviceData.value(view.viewport()).key;
+ QVERIFY(currentKey != oldKey);
+}
+
void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor()
{
struct Item : public QGraphicsTextItem