diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-10-07 10:29:22 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-10-07 10:29:22 (GMT) |
commit | 345ea61326100c70328e4ff0783fd4c3ee8ae441 (patch) | |
tree | c292f4042c40c3014cd1e3f102d93c307f3d9313 /tests | |
parent | 62a2fe9092d3b6038a08f5c5a7faa4a863b84fdc (diff) | |
parent | c9533981e129655e2ca74b13ac1ff107df7db0e7 (diff) | |
download | Qt-345ea61326100c70328e4ff0783fd4c3ee8ae441.zip Qt-345ea61326100c70328e4ff0783fd4c3ee8ae441.tar.gz Qt-345ea61326100c70328e4ff0783fd4c3ee8ae441.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: (22 commits)
ActiveQt: also make the designer plugin for qaxwidget build in the opensource versions
Fix compilation
Code cleaning with the merge request 2286
Fix a pending issue with the merge request 2286
Doc: fix description of the expected behavior for QGraphicsItem::cursor
Fixed the build error in qtconfig
Resolved a little code style issue in qtconfig
Renamed controls in qtconfig's MainWindow
Removed inheritance from UI file in qtconfig's MainWindow
Fixed a bug and resolved some translation issues in qtconfig
Fixed some problems in qtconfig's PreviewWidget
Removed the inheritance from ui file in qtconfig's PaletteEditorAdvanced
Replaced the unnecessary include with declaration
Resolved some code style issues and fixed the broken copyright year
Finally removed the qtconfig dependency from qt3support
Modified previewwidget's ui file in qtconfig
Fixed some code style issues in qtconfig
Refactored the MainWindow in qtconfig
Refactored PaletteEditorAdvanced in qtconfig
Removed more legacy code from qtconfig and fixed codestyle issues
...
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 76 |
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 |