From 6fba3c1904aa7601722a70099d88126191cf60cf Mon Sep 17 00:00:00 2001
From: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Date: Mon, 1 Jun 2015 09:58:59 +0200
Subject: [PATCH] Stabilize tst_qtouchevent.

- Use QTRY_COMPARE() in touchBeginWithGraphicsWidget.
- Change raw event translation tests to wait for the
  window to become active to avoid WM positioning issues.
- Blacklist the raw event translation tests on Linux.

Task-number: QTBUG-46266
Change-Id: I73aae375ee279a518a2a083d0ce8919cce474cb3
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
---
 tests/auto/gui/kernel/qtouchevent/BLACKLIST           | 6 ++++++
 tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp | 8 ++++----
 2 files changed, 10 insertions(+), 4 deletions(-)
 create mode 100644 tests/auto/gui/kernel/qtouchevent/BLACKLIST

diff --git a/tests/auto/gui/kernel/qtouchevent/BLACKLIST b/tests/auto/gui/kernel/qtouchevent/BLACKLIST
new file mode 100644
index 00000000000..8e78d7e41f5
--- /dev/null
+++ b/tests/auto/gui/kernel/qtouchevent/BLACKLIST
@@ -0,0 +1,6 @@
+[basicRawEventTranslation]
+linux
+[multiPointRawEventTranslationOnTouchScreen]
+linux
+[multiPointRawEventTranslationOnTouchPad]
+linux
diff --git a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
index dc35058f66b..aa1f573aa94 100644
--- a/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
+++ b/tests/auto/gui/kernel/qtouchevent/tst_qtouchevent.cpp
@@ -601,7 +601,7 @@ void tst_QTouchEvent::basicRawEventTranslation()
     touchWidget.setAttribute(Qt::WA_AcceptTouchEvents);
     touchWidget.setGeometry(100, 100, 400, 300);
     touchWidget.show();
-    QVERIFY(QTest::qWaitForWindowExposed(&touchWidget));
+    QVERIFY(QTest::qWaitForWindowActive(&touchWidget));
 
     QPointF pos = touchWidget.rect().center();
     QPointF screenPos = touchWidget.mapToGlobal(pos.toPoint());
@@ -738,7 +738,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchScreen()
     rightWidget.setGeometry(300, 100, 100, 100);
 
     touchWidget.show();
-    QVERIFY(QTest::qWaitForWindowExposed(&touchWidget));
+    QVERIFY(QTest::qWaitForWindowActive(&touchWidget));
 
     QPointF leftPos = leftWidget.rect().center();
     QPointF rightPos = rightWidget.rect().center();
@@ -968,7 +968,7 @@ void tst_QTouchEvent::multiPointRawEventTranslationOnTouchPad()
     rightWidget.setGeometry(300, 100, 100, 100);
 
     touchWidget.show();
-    QVERIFY(QTest::qWaitForWindowExposed(&touchWidget));
+    QVERIFY(QTest::qWaitForWindowActive(&touchWidget));
 
     QPointF leftPos = leftWidget.rect().center();
     QPointF rightPos = rightWidget.rect().center();
@@ -1468,7 +1468,7 @@ void tst_QTouchEvent::touchBeginWithGraphicsWidget()
             .release(0, view.mapFromScene(root->mapToScene(3,3)), view.viewport())
             .release(1, view.mapFromScene(root->mapToScene(6,6)), view.viewport());
 
-    QCOMPARE(root->touchBeginCounter, 1);
+    QTRY_COMPARE(root->touchBeginCounter, 1);
     QCOMPARE(root->touchUpdateCounter, 1);
     QCOMPARE(root->touchEndCounter, 1);
     QCOMPARE(root->touchUpdatePoints.size(), 2);
-- 
GitLab