From a847c2cb61dc58e35e6dbcce7067aa1ae10291fc Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 10 Jul 2015 15:06:42 +0200 Subject: Stabilize tst_QTouchEvent::touchBeginWithGraphicsWidget(). The test sends touch events to the root item at the top left corner which fails if the views starts to scroll. Make the view sufficiently large to prevent scrolling and align at top left. FAIL! : tst_QTouchEvent::touchBeginWithGraphicsWidget() Compared values are not the same Actual (((root->touchBeginCounter))): 0 Expected (1) : 1 Loc: [/work/build/qt/qtbase/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp(1471)] Change-Id: I357322ccc809ddb5cb587febf3c75cbe497e59d8 Reviewed-by: Simon Hausmann --- tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'tests/auto/gui') diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp index aa1f573aa9..fd3cfd55ff 100644 --- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp @@ -170,7 +170,10 @@ public: } QRectF boundingRect() const Q_DECL_OVERRIDE { return QRectF(0, 0, 10, 10); } - void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) Q_DECL_OVERRIDE { } + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) Q_DECL_OVERRIDE + { + painter->fillRect(QRectF(QPointF(0, 0), boundingRect().size()), Qt::yellow); + } bool sceneEvent(QEvent *event) Q_DECL_OVERRIDE { @@ -1446,6 +1449,7 @@ void tst_QTouchEvent::touchBeginWithGraphicsWidget() { QGraphicsScene scene; QGraphicsView view(&scene); + view.setWindowTitle(QTest::currentTestFunction()); QScopedPointer root(new tst_QTouchEventGraphicsItem); root->setAcceptTouchEvents(true); scene.addItem(root.data()); @@ -1454,10 +1458,13 @@ void tst_QTouchEvent::touchBeginWithGraphicsWidget() glassWidget->setMinimumSize(100, 100); scene.addItem(glassWidget.data()); - view.resize(200, 200); + view.setAlignment(Qt::AlignLeft | Qt::AlignTop); + const QRect availableGeometry = QGuiApplication::primaryScreen()->availableGeometry(); + view.resize(availableGeometry.size() - QSize(100, 100)); + view.move(availableGeometry.topLeft() + QPoint(50, 50)); + view.fitInView(scene.sceneRect()); view.show(); QVERIFY(QTest::qWaitForWindowExposed(&view)); - view.fitInView(scene.sceneRect()); QTest::touchEvent(&view, touchScreenDevice) .press(0, view.mapFromScene(root->mapToScene(3,3)), view.viewport()); -- cgit v1.2.3