summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp')
-rw-r--r--tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp55
1 files changed, 26 insertions, 29 deletions
diff --git a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
index d5174e0942..f703111384 100644
--- a/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
+++ b/tests/auto/gui/kernel/qmouseevent/tst_qmouseevent.cpp
@@ -1,30 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2020 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:GPL-EXCEPT$
-** 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 General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** 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-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -32,6 +7,8 @@
#include <qwindow.h>
#include <QtGui/private/qpointingdevice_p.h>
+#include <QtCore/qpointer.h>
+
Q_LOGGING_CATEGORY(lcTests, "qt.gui.tests")
class MouseEventWidget : public QWindow
@@ -122,6 +99,7 @@ private slots:
void grabbers_data();
void grabbers();
void velocity();
+ void clone();
private:
MouseEventWidget* testMouseWidget;
@@ -288,14 +266,14 @@ void tst_QMouseEvent::grabbers()
auto firstEPD = devPriv->pointById(0);
QCOMPARE(firstEPD->eventPoint.pressTimestamp(), testMouseWidget->pressTimestamp);
QCOMPARE(firstEPD->exclusiveGrabber, grabExclusive ? testMouseWidget : nullptr);
- QCOMPARE(firstEPD->passiveGrabbers.count(), grabPassive ? 1 : 0);
+ QCOMPARE(firstEPD->passiveGrabbers.size(), grabPassive ? 1 : 0);
if (grabPassive)
QCOMPARE(firstEPD->passiveGrabbers.first(), testMouseWidget);
// Ensure that grabbers are forgotten after release delivery
QTest::mouseRelease(testMouseWidget, Qt::LeftButton, Qt::KeyboardModifiers(), {10, 10});
QTRY_COMPARE(firstEPD->exclusiveGrabber, nullptr);
- QCOMPARE(firstEPD->passiveGrabbers.count(), 0);
+ QCOMPARE(firstEPD->passiveGrabbers.size(), 0);
}
void tst_QMouseEvent::velocity()
@@ -334,5 +312,24 @@ void tst_QMouseEvent::velocity()
QVERIFY(testMouseWidget->velocity.y() > 0);
}
+void tst_QMouseEvent::clone()
+{
+ const QPointF pos(10.0f, 10.0f);
+
+ QMouseEvent originalMe(QEvent::MouseButtonPress, pos, pos, pos, Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
+ QVERIFY(!originalMe.allPointsAccepted());
+ QVERIFY(!originalMe.points().first().isAccepted());
+
+ // create a clone of the original
+ std::unique_ptr<QMouseEvent> clonedMe(originalMe.clone());
+ QVERIFY(!clonedMe->allPointsAccepted());
+ QVERIFY(!clonedMe->points().first().isAccepted());
+
+ // now we alter originalMe, which should *not* change clonedMe
+ originalMe.setAccepted(true);
+ QVERIFY(!clonedMe->allPointsAccepted());
+ QVERIFY(!clonedMe->points().first().isAccepted());
+}
+
QTEST_MAIN(tst_QMouseEvent)
#include "tst_qmouseevent.moc"