summaryrefslogtreecommitdiffstats
path: root/src/testlib/qtestcase.cpp
diff options
context:
space:
mode:
authorJan Arve Sæther <jan-arve.saether@qt.io>2020-02-04 11:32:00 +0100
committerJan Arve Sæther <jan-arve.saether@qt.io>2020-02-06 09:31:47 +0100
commit8c6c4df3e83776d821f357582a717dbfbeb1c3ff (patch)
treeaaeb78842920fcffd3dcb6ec2d62643c0557ce64 /src/testlib/qtestcase.cpp
parent6d6ca70538851e8334eb01550a93b60ceba75d34 (diff)
Maintain at least 500ms timestamp distance between each test function
If we had one test function that just did tst_Mouse::f1() { QTest::mouseMove(w, QPoint(0,0)); } and another test function that did tst_Mouse::f2() { QTest::mouseMove(w, QPoint(500,500)); } their corresponding event timestamps were only 1 apart from each other. This meant that any code that tried to estimate the velocity of a mouse cursor would get a really high velocity estimate inside f2(). This would come as a surprise to most people. So to avoid this, we add a 500 ms timestamp delay between each test function call. In theory this could also prevent generating a mouseDoubleClickEvent when a pair of test functions containing a press-release sequence was run, but there is a separate pre-existing mechanism to handle that case. Change-Id: Icd4fc35853c09f080466d22411208c7b5c4174b5 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r--src/testlib/qtestcase.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
index 6be623d7fc..6805d17b6e 100644
--- a/src/testlib/qtestcase.cpp
+++ b/src/testlib/qtestcase.cpp
@@ -296,6 +296,8 @@ namespace QTestPrivate
namespace QTest
{
+extern Q_TESTLIB_EXPORT int lastMouseTimestamp;
+
class WatchDog;
static QObject *currentTestObject = nullptr;
@@ -1173,6 +1175,7 @@ bool TestMethods::invokeTest(int index, const char *data, WatchDog *watchDog) co
QTestPrivate::qtestMouseButtons = Qt::NoButton;
if (watchDog)
watchDog->beginTest();
+ QTest::lastMouseTimestamp += 500; // Maintain at least 500ms mouse event timestamps between each test function call
invokeTestOnData(index);
if (watchDog)
watchDog->testFinished();