summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsview
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qgraphicsview')
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index a043d49..364def4 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -216,6 +216,7 @@ private slots:
void task239047_fitInViewSmallViewport();
void task245469_itemsAtPointWithClip();
void task253415_reconnectUpdateSceneOnSceneChanged();
+ void task255529_transformationAnchorMouseAndViewportMargins();
};
void tst_QGraphicsView::initTestCase()
@@ -2531,7 +2532,7 @@ void tst_QGraphicsView::scrollBarRanges()
QSKIP("No Motif style compiled.", SkipSingle);
#endif
} else {
-#if defined(Q_OS_WINCE)
+#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
view.setStyle(new QWindowsStyle);
#elif !defined(QT_NO_STYLE_PLASTIQUE)
view.setStyle(new QPlastiqueStyle);
@@ -3627,5 +3628,41 @@ void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged()
QVERIFY(wasConnected2);
}
+void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins()
+{
+ QGraphicsScene scene(-100, -100, 200, 200);
+ scene.addRect(QRectF(-50, -50, 100, 100), QPen(Qt::black), QBrush(Qt::blue));
+
+ class VpGraphicsView: public QGraphicsView
+ {
+ public:
+ VpGraphicsView(QGraphicsScene *scene)
+ : QGraphicsView(scene)
+ {
+ setViewportMargins(8, 16, 12, 20);
+ setTransformationAnchor(QGraphicsView::AnchorUnderMouse);
+ setMouseTracking(true);
+ }
+ };
+
+ VpGraphicsView view(&scene);
+ view.show();
+ QPoint mouseViewPos(20, 20);
+ sendMouseMove(view.viewport(), mouseViewPos);
+ QTest::qWait(125);
+
+ QPointF mouseScenePos = view.mapToScene(mouseViewPos);
+ view.setTransform(QTransform().scale(5, 5));
+ QTest::qWait(125);
+ view.setTransform(QTransform().rotate(5, Qt::ZAxis), true);
+ QTest::qWait(125);
+
+ QPointF newMouseScenePos = view.mapToScene(mouseViewPos);
+ qreal slack = 3;
+ QVERIFY(qAbs(newMouseScenePos.x() - mouseScenePos.x()) < slack);
+ QVERIFY(qAbs(newMouseScenePos.y() - mouseScenePos.y()) < slack);
+}
+
+
QTEST_MAIN(tst_QGraphicsView)
#include "tst_qgraphicsview.moc"