diff options
author | Michal Guminiak <michal.guminiak@teleca.com> | 2010-08-03 10:13:57 +0200 |
---|---|---|
committer | Dominik Kapusta <dominik.kapusta@teleca.com> | 2010-08-04 09:56:54 +0200 |
commit | 2be1d166f79e292d4c6d9634bc6d95b42d13acc1 (patch) | |
tree | ac9f4f0bb00405ad5242f07cbc3a80d5974e444f | |
parent | b7fe07c4ebc78ec32497a9f274982546ed58c614 (diff) |
New: A redefined swipe recognizer, which allows one-finger swipes.
RevBy: Dominik, Michael Hasselmann
Details: The swipe gesture recognizer available in Qt's sources was
not really working in our environment, because for example
it recognizes only "three-finger swipe" gesture. This implementation
is based on the Qt's sources and the "flick" gesture ideas from input
method project.
-rw-r--r-- | src/corelib/core/mcomponentdata.cpp | 4 | ||||
-rw-r--r-- | src/corelib/events/events.pri | 6 | ||||
-rw-r--r-- | src/corelib/events/mswipegesture.cpp | 33 | ||||
-rw-r--r-- | src/corelib/events/mswipegesture_p.h | 82 | ||||
-rw-r--r-- | src/corelib/events/mswiperecognizer.cpp | 153 | ||||
-rw-r--r-- | src/corelib/events/mswiperecognizer.h | 83 | ||||
-rw-r--r-- | src/corelib/events/mswiperecognizer_p.h | 46 | ||||
-rw-r--r-- | tests/tests.pro | 1 | ||||
-rw-r--r-- | tests/ut_mswiperecognizer/.gitignore | 1 | ||||
-rw-r--r-- | tests/ut_mswiperecognizer/ut_mswiperecognizer.cpp | 147 | ||||
-rw-r--r-- | tests/ut_mswiperecognizer/ut_mswiperecognizer.h | 46 | ||||
-rw-r--r-- | tests/ut_mswiperecognizer/ut_mswiperecognizer.pro | 16 |
12 files changed, 618 insertions, 0 deletions
diff --git a/src/corelib/core/mcomponentdata.cpp b/src/corelib/core/mcomponentdata.cpp index f23e81dd..1fe6c8b8 100644 --- a/src/corelib/core/mcomponentdata.cpp +++ b/src/corelib/core/mcomponentdata.cpp @@ -44,6 +44,7 @@ #include "mapplicationwindow.h" #include "mtapandholdrecognizer.h" #include "mpanrecognizer.h" +#include "mswiperecognizer.h" #include <MDebug> #ifdef TESTABLE @@ -443,6 +444,9 @@ void MComponentDataPrivate::init(int &argc, char **argv, const QString &appIdent QGestureRecognizer::unregisterRecognizer(Qt::PanGesture); QGestureRecognizer::registerRecognizer(new MPanRecognizer()); + QGestureRecognizer::unregisterRecognizer(Qt::SwipeGesture); + QGestureRecognizer::registerRecognizer(new MSwipeRecognizer()); + q->setShowCursor(showCursor); } diff --git a/src/corelib/events/events.pri b/src/corelib/events/events.pri index feaae74f..f78f8c9f 100644 --- a/src/corelib/events/events.pri +++ b/src/corelib/events/events.pri @@ -12,6 +12,7 @@ PUBLIC_HEADERS += \ $$EVENTS_SRC_DIR/morientationchangeevent.h \ $$EVENTS_SRC_DIR/morientationtracker.h \ $$EVENTS_SRC_DIR/mtapandholdrecognizer.h \ + $$EVENTS_SRC_DIR/mswiperecognizer.h \ $$EVENTS_SRC_DIR/mkeyboardstatetracker.h \ PRIVATE_HEADERS += \ @@ -24,6 +25,9 @@ PRIVATE_HEADERS += \ $$EVENTS_SRC_DIR/mpangesture_p.h \ $$EVENTS_SRC_DIR/mpanrecognizer_p.h \ $$EVENTS_SRC_DIR/mpanrecognizer.h \ + $$EVENTS_SRC_DIR/mswipegesture_p.h \ + $$EVENTS_SRC_DIR/mswiperecognizer_p.h \ + $$EVENTS_SRC_DIR/mswiperecognizer.h \ SOURCES += \ $$EVENTS_SRC_DIR/morientationtracker.cpp \ @@ -38,3 +42,5 @@ SOURCES += \ $$EVENTS_SRC_DIR/mkeyboardstatetracker.cpp \ $$EVENTS_SRC_DIR/mpanrecognizer.cpp \ $$EVENTS_SRC_DIR/mpangesture.cpp \ + $$EVENTS_SRC_DIR/mswiperecognizer.cpp \ + $$EVENTS_SRC_DIR/mswipegesture.cpp \ diff --git a/src/corelib/events/mswipegesture.cpp b/src/corelib/events/mswipegesture.cpp new file mode 100644 index 00000000..b9d0711e --- /dev/null +++ b/src/corelib/events/mswipegesture.cpp @@ -0,0 +1,33 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libmeegotouch. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#include "mswipegesture_p.h" + +MSwipeGesture::MSwipeGesture(QObject* parent) : + QSwipeGesture(parent), + recognizedAngle(0), + prevDistance(0), + startPosition(QPointF()), + time(QTime()) +{ +} + +MSwipeGesture::~MSwipeGesture() +{ +} diff --git a/src/corelib/events/mswipegesture_p.h b/src/corelib/events/mswipegesture_p.h new file mode 100644 index 00000000..2d1d8a68 --- /dev/null +++ b/src/corelib/events/mswipegesture_p.h @@ -0,0 +1,82 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libmeegotouch. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#ifndef MSWIPEGESTURE_P_H +#define MSWIPEGESTURE_P_H + +#include <QSwipeGesture> + +//! \internal + +/*! + This is a private class that provides Swipe gesture state. + It's objects are delivered to registered handlers when a gesture is initiated. + */ +class MSwipeGesture : public QSwipeGesture +{ + Q_OBJECT + +public: + + /*! + Default constructor. + */ + explicit MSwipeGesture(QObject *parent = 0); + + /*! + Default destructor. + */ + virtual ~MSwipeGesture(); + +private: + + /*! + Recognized direction of the swipe gesture. The change of them beyond angle threshold + indicates that the user "zigzagged" on the screen and it is not a swipe gesture. + */ + qreal recognizedAngle; + + /*! + The previously calculated distance traveled by the pointer. Used to check + if the user changed the direction in which he was swiping. + */ + qreal prevDistance; + + /*! + Initial mouse press position in scene space coordinates. + */ + QPointF startPosition; + + /*! + Time of the initial mousepress used to check if the swipe gesture is fast enough. + */ + QTime time; + + friend class MSwipeRecognizer; + +#ifdef UNIT_TEST + friend class Ut_MSwipeRecognizer; +#endif + + Q_DISABLE_COPY(MSwipeGesture) +}; + +//! \internal_end + +#endif diff --git a/src/corelib/events/mswiperecognizer.cpp b/src/corelib/events/mswiperecognizer.cpp new file mode 100644 index 00000000..0450d6f1 --- /dev/null +++ b/src/corelib/events/mswiperecognizer.cpp @@ -0,0 +1,153 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libmeegotouch. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#include "mswiperecognizer.h" +#include "mswiperecognizer_p.h" + +#include "mswipegesture_p.h" + +#include <QEvent> +#include <QBasicTimer> +#include <QGraphicsSceneMouseEvent> +#include <QLineF> + +/* Recognizer default settings */ +static const int MSwipeTimeout = 300; /* miliseconds */ +static const int MSwipeMovementThreshold = 50; /* pixels */ +static const qreal MSwipeAngleThreshold = 15; /* degrees */ + +MSwipeRecognizerPrivate::MSwipeRecognizerPrivate() + : q_ptr( 0 ) +{ +} + +MSwipeRecognizerPrivate::~MSwipeRecognizerPrivate() +{ +} + +MSwipeRecognizer::MSwipeRecognizer() : + d_ptr(new MSwipeRecognizerPrivate()) +{ + d_ptr->q_ptr = this; +} + +MSwipeRecognizer::~MSwipeRecognizer() +{ + delete d_ptr; +} + +QGesture* MSwipeRecognizer::create(QObject* target) +{ + Q_UNUSED(target); + + return new MSwipeGesture(); +} + +QGestureRecognizer::Result MSwipeRecognizer::recognize(QGesture *state, QObject */*watched*/, QEvent *event) +{ + + MSwipeGesture *swipeGesture = static_cast<MSwipeGesture *>(state); + const QGraphicsSceneMouseEvent *mouseEvent = static_cast<const QGraphicsSceneMouseEvent*>(event); + QGestureRecognizer::Result result; + + switch (event->type()) { + + case QEvent::GraphicsSceneMousePress: + swipeGesture->time = QTime::currentTime(); + swipeGesture->startPosition = mouseEvent->scenePos(); + swipeGesture->setHotSpot(mouseEvent->screenPos()); + + result = QGestureRecognizer::MayBeGesture; + break; + + case QEvent::GraphicsSceneMouseMove: { + int xDistance = qAbs(mouseEvent->scenePos().x() - swipeGesture->startPosition.x()); + int yDistance = qAbs(mouseEvent->scenePos().y() - swipeGesture->startPosition.y()); + + swipeGesture->setSwipeAngle(QLineF(swipeGesture->startPosition, mouseEvent->scenePos()).angle()); + int elapsedTime = swipeGesture->time.msecsTo(QTime::currentTime()); + + if (swipeGesture->state() == Qt::NoGesture && elapsedTime > MSwipeTimeout) { + + //Timeout! This movement is too slow to be a swipe; + result = QGestureRecognizer::CancelGesture; + + } else if (swipeGesture->state() == Qt::NoGesture && + (xDistance > MSwipeMovementThreshold || yDistance > MSwipeMovementThreshold)) { + + //The gesture has just been recognized, store the current angle to validate with further events. + swipeGesture->recognizedAngle = QLineF(swipeGesture->startPosition, mouseEvent->scenePos()).angle(); + QPointF gestureVector = mouseEvent->scenePos() - swipeGesture->startPosition; + swipeGesture->prevDistance = 0.7 *(gestureVector.x()*gestureVector.x() + gestureVector.y()*gestureVector.y()); + result = QGestureRecognizer::TriggerGesture; + + } else if (swipeGesture->state() != Qt::NoGesture) { + + //The gesture was already recognized, check if the user didn't zigzagged. + qreal angleDelta = swipeGesture->recognizedAngle - swipeGesture->swipeAngle(); + if (angleDelta < 0) + angleDelta += 360; + + QPointF gestureVector = mouseEvent->scenePos() - swipeGesture->startPosition; + qreal currentDistance = 0.7 *(gestureVector.x()*gestureVector.x() + gestureVector.y()*gestureVector.y()); + + if ( (angleDelta < MSwipeAngleThreshold || (360 - angleDelta ) < MSwipeAngleThreshold) && + currentDistance > swipeGesture->prevDistance ) + result = QGestureRecognizer::TriggerGesture; + else + result = QGestureRecognizer::CancelGesture; + + swipeGesture->prevDistance = currentDistance; + + + } else { + //The gesture was not yet recognized, keep checking. + result = QGestureRecognizer::MayBeGesture; + } + + break; + } + + case QEvent::GraphicsSceneMouseRelease: { + if (swipeGesture->state() != Qt::NoGesture) { + result = QGestureRecognizer::FinishGesture; + } else { + result = QGestureRecognizer::CancelGesture; + } + break; + } + default: + result = QGestureRecognizer::Ignore; + break; + } + return result; +} + +void MSwipeRecognizer::reset(QGesture* state) +{ + MSwipeGesture *swipeGesture = static_cast<MSwipeGesture *>(state); + + swipeGesture->setSwipeAngle(0); + swipeGesture->recognizedAngle = 0; + swipeGesture->prevDistance = 0; + swipeGesture->startPosition = QPointF(); + swipeGesture->time = QTime(); + + QGestureRecognizer::reset(swipeGesture); +} diff --git a/src/corelib/events/mswiperecognizer.h b/src/corelib/events/mswiperecognizer.h new file mode 100644 index 00000000..e6031c39 --- /dev/null +++ b/src/corelib/events/mswiperecognizer.h @@ -0,0 +1,83 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libmeegotouch. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#ifndef MSWIPERECOGNIZER_H +#define MSWIPERECOGNIZER_H + +#include <QGestureRecognizer> + +class MSwipeRecognizerPrivate; + +//! \internal + +/*! + This is a private class that provides Swipe gesture recognition functionality. + It provides event based handling of the gestures. + + */ +class MSwipeRecognizer : public QGestureRecognizer +{ +public: + + /*! + Default constructor. + */ + MSwipeRecognizer(); + + /*! + Default destructor. + */ + virtual ~MSwipeRecognizer(); + + /*! + Method used internally by Qt recognition manager to create a gesture state. + \sa MSwipeGesture + */ + QGesture* create(QObject* target); + + /*! + Event filtering routine, responsible for changing state of the state machine and + triggering recognition events. + */ + QGestureRecognizer::Result recognize(QGesture* gesture, QObject* watched, QEvent* event); + + /*! + Method for resetting the gesture recognition state machine. + */ + void reset(QGesture* gesture); + +protected: + /*! + Private object attribute. + */ + MSwipeRecognizerPrivate * const d_ptr; + +private: + + Q_DECLARE_PRIVATE(MSwipeRecognizer) + Q_DISABLE_COPY(MSwipeRecognizer) + +#ifdef UNIT_TEST + friend class Ut_MSwipeRecognizer; +#endif +}; + +//! \internal_end + +#endif diff --git a/src/corelib/events/mswiperecognizer_p.h b/src/corelib/events/mswiperecognizer_p.h new file mode 100644 index 00000000..7303813b --- /dev/null +++ b/src/corelib/events/mswiperecognizer_p.h @@ -0,0 +1,46 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libmeegotouch. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#ifndef MSWIPERECOGNIZER_P_H +#define MSWIPERECOGNIZER_P_H + +#include "mswiperecognizer.h" + +/*! + Private class used by MSwipeRecognizer objects to + store variables during gesture recognition. + */ +class MSwipeRecognizerPrivate +{ +public: + + Q_DECLARE_PUBLIC(MSwipeRecognizer) + MSwipeRecognizerPrivate(); + virtual ~MSwipeRecognizerPrivate(); + +protected: + + MSwipeRecognizer* q_ptr; + +#ifdef UNIT_TEST + friend class Ut_MSwipeRecognizer; +#endif +}; + +#endif diff --git a/tests/tests.pro b/tests/tests.pro index edd58631..82d4063a 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -166,6 +166,7 @@ SUBDIRS = \ ut_mlocationdatabase \ ut_mlocalthemedaemon \ ut_mremotethemedaemon \ + ut_mswiperecognizer \ # enable only when we have icu available diff --git a/tests/ut_mswiperecognizer/.gitignore b/tests/ut_mswiperecognizer/.gitignore new file mode 100644 index 00000000..d7b3a22c --- /dev/null +++ b/tests/ut_mswiperecognizer/.gitignore @@ -0,0 +1 @@ +ut_mswiperecognizer diff --git a/tests/ut_mswiperecognizer/ut_mswiperecognizer.cpp b/tests/ut_mswiperecognizer/ut_mswiperecognizer.cpp new file mode 100644 index 00000000..139fa15b --- /dev/null +++ b/tests/ut_mswiperecognizer/ut_mswiperecognizer.cpp @@ -0,0 +1,147 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libmeegotouch. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#include "ut_mswiperecognizer.h" +#include "mswiperecognizer.h" +#include "mswiperecognizer_p.h" + +#include "mswipegesture_p.h" + +#include <QGraphicsSceneMouseEvent> +#include <QtTest/QtTest> + + +Qt::GestureState currentGestureState = Qt::NoGesture; +Qt::GestureState QGesture::state() const +{ + return currentGestureState; +} + +void Ut_MSwipeRecognizer::init() +{ + recognizer = new MSwipeRecognizer(); +} + +void Ut_MSwipeRecognizer::cleanup() +{ + delete recognizer; +} + +void Ut_MSwipeRecognizer::testCreateGesture() +{ + swipeGesture = static_cast<MSwipeGesture*>(recognizer->create(this)); +} + +void Ut_MSwipeRecognizer::testRecognize() +{ + QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); + pressEvent.setPos(QPointF(0,0)); + pressEvent.setScenePos(QPointF(0,0)); + pressEvent.setScreenPos(QPoint(0,0)); + + QGraphicsSceneMouseEvent moveEvent(QEvent::GraphicsSceneMouseMove); + moveEvent.setPos(QPointF(55,0)); + moveEvent.setScenePos(QPointF(55,0)); + moveEvent.setScreenPos(QPoint(55,0)); + + QGestureRecognizer::Result currentState; + currentState = recognizer->recognize(swipeGesture, 0, &pressEvent); + QCOMPARE( currentState, QGestureRecognizer::MayBeGesture); + + currentState = recognizer->recognize(swipeGesture, 0, &moveEvent); + QCOMPARE( currentState, QGestureRecognizer::TriggerGesture); + +} + +void Ut_MSwipeRecognizer::testFastTap() +{ + + QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); + pressEvent.setPos(QPointF(0,0)); + pressEvent.setScenePos(QPointF(0,0)); + pressEvent.setScreenPos(QPoint(0,0)); + + QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); + releaseEvent.setPos(QPointF(0,0)); + releaseEvent.setScenePos(QPointF(0,0)); + releaseEvent.setScreenPos(QPoint(0,0)); + + QGestureRecognizer::Result currentState; + currentState = recognizer->recognize(swipeGesture, 0, &pressEvent); + QCOMPARE( currentState, QGestureRecognizer::MayBeGesture); + + currentState = recognizer->recognize(swipeGesture, 0, &releaseEvent); + QCOMPARE( currentState, QGestureRecognizer::CancelGesture); +} + +void Ut_MSwipeRecognizer::testTimedout() +{ + QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); + pressEvent.setPos(QPointF(0,0)); + pressEvent.setScenePos(QPointF(0,0)); + pressEvent.setScreenPos(QPoint(0,0)); + + QGraphicsSceneMouseEvent moveEvent(QEvent::GraphicsSceneMouseMove); + moveEvent.setPos(QPointF(30,0)); + moveEvent.setScenePos(QPointF(30,0)); + moveEvent.setScreenPos(QPoint(30,0)); + + QGestureRecognizer::Result currentState; + currentState = recognizer->recognize(swipeGesture, 0, &pressEvent); + QCOMPARE( currentState, QGestureRecognizer::MayBeGesture); + + swipeGesture->time = QTime().currentTime().addSecs(-3); + + currentState = recognizer->recognize(swipeGesture, 0, &moveEvent); + QCOMPARE( currentState, QGestureRecognizer::CancelGesture); + +} + +void Ut_MSwipeRecognizer::testZigzagged() +{ + QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); + pressEvent.setPos(QPointF(0,0)); + pressEvent.setScenePos(QPointF(0,0)); + pressEvent.setScreenPos(QPoint(0,0)); + + QGraphicsSceneMouseEvent moveEvent(QEvent::GraphicsSceneMouseMove); + moveEvent.setPos(QPointF(55,0)); + moveEvent.setScenePos(QPointF(55,0)); + moveEvent.setScreenPos(QPoint(55,0)); + + QGestureRecognizer::Result currentState; + currentState = recognizer->recognize(swipeGesture, 0, &pressEvent); + QCOMPARE( currentState, QGestureRecognizer::MayBeGesture); + + currentState = recognizer->recognize(swipeGesture, 0, &moveEvent); + QCOMPARE( currentState, QGestureRecognizer::TriggerGesture); + + moveEvent.setPos(QPointF(-100,0)); + moveEvent.setScenePos(QPointF(-100,0)); + moveEvent.setScreenPos(QPoint(-100,0)); + + currentGestureState = Qt::GestureStarted; + + currentState = recognizer->recognize(swipeGesture, 0, &moveEvent); + QCOMPARE( currentState, QGestureRecognizer::CancelGesture); + +} + +QTEST_APPLESS_MAIN(Ut_MSwipeRecognizer) + diff --git a/tests/ut_mswiperecognizer/ut_mswiperecognizer.h b/tests/ut_mswiperecognizer/ut_mswiperecognizer.h new file mode 100644 index 00000000..cd72b1f7 --- /dev/null +++ b/tests/ut_mswiperecognizer/ut_mswiperecognizer.h @@ -0,0 +1,46 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libmeegotouch. +** +** If you have questions regarding the use of this file, please contact +** Nokia at directui@nokia.com. +** +** This library is free software; you can redistribute it and/or +** modify it under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation +** and appearing in the file LICENSE.LGPL included in the packaging +** of this file. +** +****************************************************************************/ + +#ifndef UT_MSWIPERECOGNIZER_H +#define UT_MSWIPERECOGNIZER_H + +#include <QObject> + +class MSwipeRecognizer; +class MSwipeGesture; + +class Ut_MSwipeRecognizer : public QObject +{ + Q_OBJECT + +private: + MSwipeRecognizer* recognizer; + MSwipeGesture* swipeGesture; +private slots: + void init(); + void cleanup(); + + void testCreateGesture(); + void testRecognize(); + void testFastTap(); + void testTimedout(); + void testZigzagged(); +}; + +#endif // UT_MSWIPERECOGNIZER_H diff --git a/tests/ut_mswiperecognizer/ut_mswiperecognizer.pro b/tests/ut_mswiperecognizer/ut_mswiperecognizer.pro new file mode 100644 index 00000000..bcc331a5 --- /dev/null +++ b/tests/ut_mswiperecognizer/ut_mswiperecognizer.pro @@ -0,0 +1,16 @@ +include(../common_top.pri) +INCLUDEPATH += $$MSRCDIR/corelib/events +TARGET = ut_mswiperecognizer + +# unit test and unit classes +SOURCES += \ + ut_mswiperecognizer.cpp \ + $$MSRCDIR/corelib/events/mswiperecognizer.cpp \ + $$MSRCDIR/corelib/events/mswipegesture.cpp \ + +# unit test and unit classes +HEADERS += \ + ut_mswiperecognizer.h \ + $$MSRCDIR/corelib/events/mswipegesture_p.h \ + +include(../common_bot.pri) |