aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest/quicktestevent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qmltest/quicktestevent.cpp')
-rw-r--r--src/qmltest/quicktestevent.cpp66
1 files changed, 18 insertions, 48 deletions
diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp
index a1a707d2d6..9bd2a9887c 100644
--- a/src/qmltest/quicktestevent.cpp
+++ b/src/qmltest/quicktestevent.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "quicktestevent_p.h"
#include <QtTest/qtestkeyboard.h>
@@ -93,7 +57,7 @@ bool QuickTestEvent::keyClick(int key, int modifiers, int delay)
bool QuickTestEvent::keyPressChar(const QString &character, int modifiers, int delay)
{
- QTEST_ASSERT(character.length() == 1);
+ QTEST_ASSERT(character.size() == 1);
QWindow *window = activeWindow();
if (!window)
return false;
@@ -103,7 +67,7 @@ bool QuickTestEvent::keyPressChar(const QString &character, int modifiers, int d
bool QuickTestEvent::keyReleaseChar(const QString &character, int modifiers, int delay)
{
- QTEST_ASSERT(character.length() == 1);
+ QTEST_ASSERT(character.size() == 1);
QWindow *window = activeWindow();
if (!window)
return false;
@@ -113,7 +77,7 @@ bool QuickTestEvent::keyReleaseChar(const QString &character, int modifiers, int
bool QuickTestEvent::keyClickChar(const QString &character, int modifiers, int delay)
{
- QTEST_ASSERT(character.length() == 1);
+ QTEST_ASSERT(character.size() == 1);
QWindow *window = activeWindow();
if (!window)
return false;
@@ -225,9 +189,10 @@ namespace QtQuickTest
QSpontaneKeyEvent::setSpontaneous(&me);
if (!qApp->notify(window, &me)) {
static const char *mouseActionNames[] =
- { "MousePress", "MouseRelease", "MouseClick", "MouseDoubleClick", "MouseMove", "MouseDoubleClickSequence" };
- QString warning = QString::fromLatin1("Mouse event \"%1\" not accepted by receiving window");
- QWARN(warning.arg(QString::fromLatin1(mouseActionNames[static_cast<int>(action)])).toLatin1().data());
+ { "MousePress", "MouseRelease", "MouseClick", "MouseDoubleClick", "MouseMove",
+ "MouseDoubleClickSequence" };
+ qWarning("Mouse event \"%s\" not accepted by receiving window",
+ mouseActionNames[static_cast<int>(action)]);
}
}
@@ -240,8 +205,10 @@ namespace QtQuickTest
QTEST_ASSERT(item);
if (delay == -1 || delay < QTest::defaultMouseDelay())
delay = QTest::defaultMouseDelay();
- if (delay > 0)
+ if (delay > 0) {
QTest::qWait(delay);
+ lastMouseTimestamp += delay;
+ }
QPoint pos;
QQuickItem *sgitem = qobject_cast<QQuickItem *>(item);
@@ -254,10 +221,11 @@ namespace QtQuickTest
stateKey &= static_cast<unsigned int>(Qt::KeyboardModifierMask);
QWheelEvent we(pos, window->mapToGlobal(pos), QPoint(0, 0), QPoint(xDelta, yDelta), buttons,
stateKey, Qt::NoScrollPhase, false);
+ we.setTimestamp(++lastMouseTimestamp);
QSpontaneKeyEvent::setSpontaneous(&we); // hmmmm
if (!qApp->notify(window, &we))
- QTest::qWarn("Wheel event not accepted by receiving window");
+ qWarning("Wheel event not accepted by receiving window");
}
#endif
};
@@ -350,14 +318,14 @@ bool QuickTestEvent::mouseDoubleClickSequence
}
bool QuickTestEvent::mouseMove
- (QObject *item, qreal x, qreal y, int delay, int buttons)
+ (QObject *item, qreal x, qreal y, int delay, int buttons, int modifiers)
{
QWindow *view = eventWindow(item);
if (!view)
return false;
const Qt::MouseButtons effectiveButtons = buttons ? Qt::MouseButtons(buttons) : m_pressedButtons;
QtQuickTest::mouseEvent(QtQuickTest::MouseMove, view, item,
- Qt::MouseButton(int(effectiveButtons)), Qt::NoModifier,
+ Qt::MouseButton(int(effectiveButtons)), Qt::KeyboardModifiers(modifiers),
QPointF(x, y), delay);
return true;
}
@@ -479,3 +447,5 @@ QQuickTouchEventSequence *QuickTestEvent::touchEvent(QObject *item)
}
QT_END_NAMESPACE
+
+#include "moc_quicktestevent_p.cpp"