2011-04-27 10:05:43 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** This file is part of the test suite module of the Qt Toolkit.
|
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
|
2012-09-19 12:28:29 +00:00
|
|
|
** 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
|
2015-01-28 08:44:43 +00:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
2016-01-15 12:36:27 +00:00
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2012-09-19 12:28:29 +00:00
|
|
|
**
|
2016-01-15 12:36:27 +00:00
|
|
|
** 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.
|
2011-04-27 10:05:43 +00:00
|
|
|
**
|
|
|
|
** $QT_END_LICENSE$
|
|
|
|
**
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-03-21 14:19:40 +00:00
|
|
|
#include <QApplication>
|
2020-11-26 16:31:50 +00:00
|
|
|
#include <QTest>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#include "ui_form.h"
|
|
|
|
#include "touchwidget.h"
|
|
|
|
|
|
|
|
class MultitouchTestWidget : public QWidget, public Ui::Form
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2020-10-07 11:05:48 +00:00
|
|
|
MultitouchTestWidget(QWidget *parent = nullptr)
|
2011-04-27 10:05:43 +00:00
|
|
|
: QWidget(parent)
|
|
|
|
{
|
|
|
|
setAttribute(Qt::WA_QuitOnClose, false);
|
|
|
|
setupUi(this);
|
2013-03-21 14:19:40 +00:00
|
|
|
setWindowTitle(QT_VERSION_STR);
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void closeEvent(QCloseEvent *event)
|
|
|
|
{
|
|
|
|
event->accept();
|
|
|
|
QTimer::singleShot(1000, qApp, SLOT(quit()));
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class tst_ManualMultitouch : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
tst_ManualMultitouch();
|
|
|
|
~tst_ManualMultitouch();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void ignoringTouchEventsEmulatesMouseEvents();
|
|
|
|
void basicSingleTouchEventHandling();
|
|
|
|
void basicMultiTouchEventHandling();
|
|
|
|
void acceptingTouchBeginStopsPropagation();
|
|
|
|
void ignoringTouchBeginPropagatesToParent();
|
|
|
|
void secondTouchPointOnParentGoesToChild();
|
|
|
|
void secondTouchPointOnChildGoesToParent();
|
|
|
|
void secondTouchPointOnSiblingGoesToSibling();
|
|
|
|
void secondTouchPointOnCousinGoesToCousin();
|
|
|
|
};
|
|
|
|
|
|
|
|
tst_ManualMultitouch::tst_ManualMultitouch()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
tst_ManualMultitouch::~tst_ManualMultitouch()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
void tst_ManualMultitouch::ignoringTouchEventsEmulatesMouseEvents()
|
|
|
|
{
|
|
|
|
// first, make sure that we get mouse events when not enabling touch events
|
|
|
|
MultitouchTestWidget testWidget;
|
|
|
|
testWidget.testNameLabel->setText("Mouse Event Emulation Test");
|
|
|
|
testWidget.testDescriptionLabel->setText("Touch, hold, and release your finger on the green widget.");
|
|
|
|
testWidget.redWidget->hide();
|
|
|
|
testWidget.blueWidget->hide();
|
|
|
|
testWidget.greenWidget->closeWindowOnMouseRelease = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(!testWidget.greenWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchEnd);
|
|
|
|
QVERIFY(testWidget.greenWidget->seenMousePress);
|
|
|
|
// QVERIFY(testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(testWidget.greenWidget->seenMouseRelease);
|
|
|
|
|
|
|
|
// enable touch, but don't accept the events
|
|
|
|
testWidget.greenWidget->reset();
|
|
|
|
testWidget.greenWidget->setAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
testWidget.greenWidget->closeWindowOnMouseRelease = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.greenWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(!testWidget.greenWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchEnd);
|
|
|
|
QVERIFY(testWidget.greenWidget->seenMousePress);
|
|
|
|
// QVERIFY(testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(testWidget.greenWidget->seenMouseRelease);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_ManualMultitouch::basicSingleTouchEventHandling()
|
|
|
|
{
|
|
|
|
// now enable touch and make sure we get the touch events
|
|
|
|
MultitouchTestWidget testWidget;
|
|
|
|
testWidget.testNameLabel->setText("Basic Single-Touch Event Handling Test");
|
|
|
|
testWidget.testDescriptionLabel->setText("Touch, hold, and release your finger on the green widget.");
|
|
|
|
testWidget.redWidget->hide();
|
|
|
|
testWidget.blueWidget->hide();
|
|
|
|
testWidget.greenWidget->setAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
testWidget.greenWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.greenWidget->acceptTouchUpdate = true;
|
|
|
|
testWidget.greenWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.greenWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.greenWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.greenWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.greenWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseRelease);
|
|
|
|
|
|
|
|
// again, ignoring the TouchEnd
|
|
|
|
testWidget.greenWidget->reset();
|
|
|
|
testWidget.greenWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.greenWidget->acceptTouchUpdate = true;
|
|
|
|
// testWidget.greenWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.greenWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.greenWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.greenWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.greenWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseRelease);
|
|
|
|
|
|
|
|
// again, ignoring TouchUpdates
|
|
|
|
testWidget.greenWidget->reset();
|
|
|
|
testWidget.greenWidget->acceptTouchBegin = true;
|
|
|
|
// testWidget.greenWidget->acceptTouchUpdate = true;
|
|
|
|
testWidget.greenWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.greenWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.greenWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.greenWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.greenWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseRelease);
|
|
|
|
|
|
|
|
// last time, ignoring TouchUpdates and TouchEnd
|
|
|
|
testWidget.greenWidget->reset();
|
|
|
|
testWidget.greenWidget->acceptTouchBegin = true;
|
|
|
|
// testWidget.greenWidget->acceptTouchUpdate = true;
|
|
|
|
// testWidget.greenWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.greenWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.greenWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.greenWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.greenWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseRelease);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_ManualMultitouch::basicMultiTouchEventHandling()
|
|
|
|
{
|
|
|
|
// repeat, this time looking for multiple fingers
|
|
|
|
MultitouchTestWidget testWidget;
|
|
|
|
testWidget.testNameLabel->setText("Basic Multi-Touch Event Handling Test");
|
|
|
|
testWidget.testDescriptionLabel->setText("Touch, hold, and release several fingers on the red widget.");
|
|
|
|
testWidget.greenWidget->hide();
|
|
|
|
testWidget.greyWidget->hide();
|
|
|
|
testWidget.redWidget->setAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
testWidget.redWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.redWidget->acceptTouchUpdate = true;
|
|
|
|
testWidget.redWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.redWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchBegin);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchEnd);
|
|
|
|
QVERIFY(testWidget.redWidget->touchPointCount > 1);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseRelease);
|
|
|
|
|
|
|
|
testWidget.redWidget->reset();
|
|
|
|
testWidget.redWidget->acceptTouchBegin = true;
|
|
|
|
// testWidget.redWidget->acceptTouchUpdate = true;
|
|
|
|
testWidget.redWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.redWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchBegin);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchEnd);
|
|
|
|
QVERIFY(testWidget.redWidget->touchPointCount > 1);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseRelease);
|
|
|
|
|
|
|
|
testWidget.redWidget->reset();
|
|
|
|
testWidget.redWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.redWidget->acceptTouchUpdate = true;
|
|
|
|
// testWidget.redWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.redWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchBegin);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchEnd);
|
|
|
|
QVERIFY(testWidget.redWidget->touchPointCount > 1);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseRelease);
|
|
|
|
|
|
|
|
testWidget.redWidget->reset();
|
|
|
|
testWidget.redWidget->acceptTouchBegin = true;
|
|
|
|
// testWidget.redWidget->acceptTouchUpdate = true;
|
|
|
|
// testWidget.redWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.redWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchBegin);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchEnd);
|
|
|
|
QVERIFY(testWidget.redWidget->touchPointCount > 1);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseRelease);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_ManualMultitouch::acceptingTouchBeginStopsPropagation()
|
|
|
|
{
|
|
|
|
// test that accepting the TouchBegin event on the
|
|
|
|
// blueWidget stops propagation to the greenWidget
|
|
|
|
MultitouchTestWidget testWidget;
|
|
|
|
testWidget.testNameLabel->setText("Touch Event Propagation Test: Accepting in Blue Blocks Green");
|
|
|
|
testWidget.testDescriptionLabel->setText("Touch, hold, and release your finger on the blue widget.");
|
|
|
|
testWidget.redWidget->hide();
|
|
|
|
testWidget.blueWidget->setAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
testWidget.greenWidget->setAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
testWidget.blueWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.blueWidget->acceptTouchUpdate = true;
|
|
|
|
testWidget.blueWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.blueWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.blueWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.blueWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.blueWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMouseRelease);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchBegin);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseRelease);
|
|
|
|
|
|
|
|
// ignoring TouchEnd
|
|
|
|
testWidget.blueWidget->reset();
|
|
|
|
testWidget.greenWidget->reset();
|
|
|
|
testWidget.blueWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.blueWidget->acceptTouchUpdate = true;
|
|
|
|
// testWidget.blueWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.blueWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.blueWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.blueWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.blueWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMouseRelease);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchBegin);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseRelease);
|
|
|
|
|
|
|
|
// ignoring TouchUpdate
|
|
|
|
testWidget.blueWidget->reset();
|
|
|
|
testWidget.greenWidget->reset();
|
|
|
|
testWidget.blueWidget->acceptTouchBegin = true;
|
|
|
|
// testWidget.blueWidget->acceptTouchUpdate = true;
|
|
|
|
testWidget.blueWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.blueWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.blueWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.blueWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.blueWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMouseRelease);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchBegin);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseRelease);
|
|
|
|
|
|
|
|
// ignoring TouchUpdate and TouchEnd
|
|
|
|
testWidget.blueWidget->reset();
|
|
|
|
testWidget.greenWidget->reset();
|
|
|
|
testWidget.blueWidget->acceptTouchBegin = true;
|
|
|
|
// testWidget.blueWidget->acceptTouchUpdate = true;
|
|
|
|
// testWidget.blueWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.blueWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.blueWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.blueWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.blueWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMouseRelease);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchBegin);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseRelease);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_ManualMultitouch::ignoringTouchBeginPropagatesToParent()
|
|
|
|
{
|
|
|
|
// repeat the test above, now ignoring touch events in the
|
|
|
|
// greyWidget, they should be propagated to the redWidget
|
|
|
|
MultitouchTestWidget testWidget;
|
|
|
|
testWidget.testNameLabel->setText("Touch Event Propagation Test: Ignoring in Grey Propagates to Red");
|
|
|
|
testWidget.testDescriptionLabel->setText("Touch, hold, and release your finger on the grey widget.");
|
|
|
|
testWidget.greenWidget->hide();
|
|
|
|
testWidget.greyWidget->setAttribute(Qt::WA_AcceptTouchEvents, false);
|
|
|
|
testWidget.redWidget->setAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
testWidget.greyWidget->reset();
|
|
|
|
testWidget.redWidget->reset();
|
|
|
|
testWidget.redWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.redWidget->acceptTouchUpdate = true;
|
|
|
|
testWidget.redWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.redWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenTouchBegin);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMouseRelease);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.redWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMouseRelease);
|
|
|
|
|
|
|
|
// again, but this time greyWidget should see the TouchBegin
|
|
|
|
testWidget.greyWidget->reset();
|
|
|
|
testWidget.redWidget->reset();
|
|
|
|
testWidget.greyWidget->setAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
testWidget.redWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.redWidget->acceptTouchUpdate = true;
|
|
|
|
testWidget.redWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.redWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.greyWidget->seenTouchBegin);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMouseRelease);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.redWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMouseRelease);
|
|
|
|
|
|
|
|
// again, ignoring the TouchEnd
|
|
|
|
testWidget.greyWidget->reset();
|
|
|
|
testWidget.redWidget->reset();
|
|
|
|
testWidget.redWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.redWidget->acceptTouchUpdate = true;
|
|
|
|
// testWidget.redWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.redWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.greyWidget->seenTouchBegin);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMouseRelease);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.redWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMouseRelease);
|
|
|
|
|
|
|
|
// again, ignoring TouchUpdates
|
|
|
|
testWidget.greyWidget->reset();
|
|
|
|
testWidget.redWidget->reset();
|
|
|
|
testWidget.redWidget->acceptTouchBegin = true;
|
|
|
|
// testWidget.redWidget->acceptTouchUpdate = true;
|
|
|
|
testWidget.redWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.redWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.greyWidget->seenTouchBegin);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMouseRelease);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.redWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMouseRelease);
|
|
|
|
|
|
|
|
// last time, ignoring TouchUpdates and TouchEnd
|
|
|
|
testWidget.greyWidget->reset();
|
|
|
|
testWidget.redWidget->reset();
|
|
|
|
testWidget.redWidget->acceptTouchBegin = true;
|
|
|
|
// testWidget.redWidget->acceptTouchUpdate = true;
|
|
|
|
// testWidget.redWidget->acceptTouchEnd = true;
|
|
|
|
testWidget.redWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.greyWidget->seenTouchBegin);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMouseRelease);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.redWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMouseRelease);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_ManualMultitouch::secondTouchPointOnParentGoesToChild()
|
|
|
|
{
|
|
|
|
MultitouchTestWidget testWidget;
|
|
|
|
testWidget.testNameLabel->setText("Additional Touch-Points Outside Child's Rect Go to Child");
|
|
|
|
testWidget.testDescriptionLabel->setText("Press and hold a finger on the blue widget, then on the green one, and release.");
|
|
|
|
testWidget.redWidget->hide();
|
|
|
|
testWidget.greenWidget->setAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
testWidget.blueWidget->setAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
testWidget.blueWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.greenWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.blueWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.blueWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.blueWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.blueWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMouseRelease);
|
|
|
|
QVERIFY(testWidget.blueWidget->touchPointCount > 1);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchBegin);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseRelease);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_ManualMultitouch::secondTouchPointOnChildGoesToParent()
|
|
|
|
{
|
|
|
|
MultitouchTestWidget testWidget;
|
|
|
|
testWidget.testNameLabel->setText("Additional Touch-Points Over Child's Rect Go to Parent");
|
|
|
|
testWidget.testDescriptionLabel->setText("Press and hold a finger on the red widget, then on the grey one, and release.");
|
|
|
|
testWidget.greenWidget->hide();
|
|
|
|
testWidget.redWidget->setAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
testWidget.greyWidget->setAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
testWidget.greyWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.redWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.redWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.redWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMouseRelease);
|
|
|
|
QVERIFY(testWidget.redWidget->touchPointCount > 1);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenTouchBegin);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMouseRelease);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_ManualMultitouch::secondTouchPointOnSiblingGoesToSibling()
|
|
|
|
{
|
|
|
|
MultitouchTestWidget testWidget;
|
|
|
|
testWidget.testNameLabel->setText("Multi-Touch Interaction Test, Unrelated Widgets Get Separate Events");
|
|
|
|
testWidget.testDescriptionLabel->setText("Press and hold a finger on the green widget, then the red one, and release.");
|
|
|
|
testWidget.blueWidget->hide();
|
|
|
|
testWidget.greenWidget->setAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
testWidget.greenWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.greenWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.greyWidget->hide();
|
|
|
|
testWidget.redWidget->setAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
testWidget.redWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.greenWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.greenWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.greenWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greenWidget->seenMouseRelease);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.redWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.redWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.redWidget->seenMouseRelease);
|
|
|
|
QVERIFY(testWidget.greenWidget->touchPointCount == 1);
|
|
|
|
QVERIFY(testWidget.redWidget->touchPointCount == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void tst_ManualMultitouch::secondTouchPointOnCousinGoesToCousin()
|
|
|
|
{
|
|
|
|
MultitouchTestWidget testWidget;
|
|
|
|
testWidget.testNameLabel->setText("Multi-Touch Interaction Test, Unrelated Widgets Get Separate Events");
|
|
|
|
testWidget.testDescriptionLabel->setText("Press and hold a finger on the blue widget, then the grey one, and release.");
|
|
|
|
testWidget.blueWidget->setAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
testWidget.blueWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.blueWidget->closeWindowOnTouchEnd = true;
|
|
|
|
testWidget.greyWidget->setAttribute(Qt::WA_AcceptTouchEvents);
|
|
|
|
testWidget.greyWidget->acceptTouchBegin = true;
|
|
|
|
testWidget.showMaximized();
|
|
|
|
(void) qApp->exec();
|
|
|
|
QVERIFY(testWidget.blueWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.blueWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.blueWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.blueWidget->seenMouseRelease);
|
|
|
|
QVERIFY(testWidget.greyWidget->seenTouchBegin);
|
|
|
|
// QVERIFY(testWidget.greyWidget->seenTouchUpdate);
|
|
|
|
QVERIFY(testWidget.greyWidget->seenTouchEnd);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMousePress);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMouseMove);
|
|
|
|
QVERIFY(!testWidget.greyWidget->seenMouseRelease);
|
|
|
|
QVERIFY(testWidget.blueWidget->touchPointCount == 1);
|
|
|
|
QVERIFY(testWidget.greyWidget->touchPointCount == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
QTEST_MAIN(tst_ManualMultitouch)
|
|
|
|
|
|
|
|
#include "main.moc"
|