summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/graphicsview/qgraphicsitem
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/graphicsview/qgraphicsitem')
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp34
1 files changed, 22 insertions, 12 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index f686b5854c..c89b05616d 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the test suite of the Qt Toolkit.
@@ -49,6 +49,7 @@
#include <QAbstractTextDocumentLayout>
#include <QBitmap>
#include <QCursor>
+#include <QScreen>
#include <QLabel>
#include <QDial>
#include <QGraphicsItem>
@@ -141,6 +142,17 @@ static void sendKeyClick(QGraphicsScene *scene, Qt::Key key)
sendKeyRelease(scene, key);
}
+static inline void centerOnScreen(QWidget *w, const QSize &size)
+{
+ const QPoint offset = QPoint(size.width() / 2, size.height() / 2);
+ w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset);
+}
+
+static inline void centerOnScreen(QWidget *w)
+{
+ centerOnScreen(w, w->geometry().size());
+}
+
class EventSpy : public QGraphicsWidget
{
Q_OBJECT
@@ -4213,14 +4225,18 @@ void tst_QGraphicsItem::cursor()
item2->setCursor(Qt::PointingHandCursor);
QWidget topLevel;
+ topLevel.resize(250, 150);
+ centerOnScreen(&topLevel);
QGraphicsView view(&scene,&topLevel);
view.setFixedSize(200, 100);
topLevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&topLevel));
+
QTest::mouseMove(&view, view.rect().center());
QTest::qWait(25);
- QCursor cursor = view.viewport()->cursor();
+ const Qt::CursorShape viewportShape = view.viewport()->cursor().shape();
{
QTest::mouseMove(view.viewport(), QPoint(100, 50));
@@ -4228,9 +4244,7 @@ void tst_QGraphicsItem::cursor()
QApplication::sendEvent(view.viewport(), &event);
}
- QTest::qWait(25);
-
- QCOMPARE(view.viewport()->cursor().shape(), cursor.shape());
+ QTRY_COMPARE(view.viewport()->cursor().shape(), viewportShape);
{
QTest::mouseMove(view.viewport(), view.mapFromScene(item1->sceneBoundingRect().center()));
@@ -4238,7 +4252,7 @@ void tst_QGraphicsItem::cursor()
QApplication::sendEvent(view.viewport(), &event);
}
- QCOMPARE(view.viewport()->cursor().shape(), item1->cursor().shape());
+ QTRY_COMPARE(view.viewport()->cursor().shape(), item1->cursor().shape());
{
QTest::mouseMove(view.viewport(), view.mapFromScene(item2->sceneBoundingRect().center()));
@@ -4246,9 +4260,7 @@ void tst_QGraphicsItem::cursor()
QApplication::sendEvent(view.viewport(), &event);
}
- QTest::qWait(25);
-
- QCOMPARE(view.viewport()->cursor().shape(), item2->cursor().shape());
+ QTRY_COMPARE(view.viewport()->cursor().shape(), item2->cursor().shape());
{
QTest::mouseMove(view.viewport(), view.rect().center());
@@ -4256,9 +4268,7 @@ void tst_QGraphicsItem::cursor()
QApplication::sendEvent(view.viewport(), &event);
}
- QTest::qWait(25);
-
- QCOMPARE(view.viewport()->cursor().shape(), cursor.shape());
+ QTRY_COMPARE(view.viewport()->cursor().shape(), viewportShape);
}
#endif
/*