diff options
author | Michal Guminiak <michal.guminiak@teleca.com> | 2010-04-12 16:21:12 +0200 |
---|---|---|
committer | Tomas Junnonen <tomas.junnonen@nokia.com> | 2010-04-21 09:56:09 +0300 |
commit | 6e2ee74ae199a0b254562764a8a7b33904152dbe (patch) | |
tree | ed6f5807e5c8dd6060c9c10b03a550264a5d88d5 | |
parent | 42aa81a9d8d9e64f05bcf5378e4c613161e374be (diff) |
Changes: DuiPannableWidget is now going to use pan gestures
RevBy: To be done
Details: Further changes to DuiPannableWidget. The class is now
going to use QPanGesture object to handle panning. This will
also fix issue with DuiPannableWidget inside DuiPannableWidget.
22 files changed, 932 insertions, 693 deletions
diff --git a/src/corelib/core/mcomponentdata.cpp b/src/corelib/core/mcomponentdata.cpp index 69adf8a2..97bfe13e 100644 --- a/src/corelib/core/mcomponentdata.cpp +++ b/src/corelib/core/mcomponentdata.cpp @@ -41,6 +41,7 @@ #include "mapplicationwindow.h" #include "mtapandholdrecognizer.h" #include "mpinchrecognizer.h" +#include "mpanrecognizer.h" #include <MDebug> #ifdef TESTABLE @@ -585,6 +586,9 @@ void MComponentDataPrivate::init(int &argc, char **argv, const QString &appIdent QGestureRecognizer::unregisterRecognizer(Qt::PinchGesture); QGestureRecognizer::registerRecognizer(new MPinchRecognizer()); + QGestureRecognizer::unregisterRecognizer(Qt::PanGesture); + QGestureRecognizer::registerRecognizer(new MPanRecognizer()); + q->setShowCursor(showCursor); } diff --git a/src/corelib/events/events.pri b/src/corelib/events/events.pri index d6f893df..1e3586d9 100644 --- a/src/corelib/events/events.pri +++ b/src/corelib/events/events.pri @@ -22,6 +22,9 @@ PRIVATE_HEADERS += \ $$EVENTS_SRC_DIR/mtapandholdrecognizer_p.h \ $$EVENTS_SRC_DIR/mtapandholdgesture_p.h \ $$EVENTS_SRC_DIR/mkeyboardstatetracker_p.h \ + $$EVENTS_SRC_DIR/mpangesture_p.h \ + $$EVENTS_SRC_DIR/mpanrecognizer_p.h \ + $$EVENTS_SRC_DIR/mpanrecognizer.h \ SOURCES += \ $$EVENTS_SRC_DIR/morientationtracker.cpp \ @@ -35,3 +38,5 @@ SOURCES += \ $$EVENTS_SRC_DIR/mtapandholdrecognizer.cpp \ $$EVENTS_SRC_DIR/mkeyboardstatetracker.cpp \ $$EVENTS_SRC_DIR/mpinchrecognizer.cpp \ + $$EVENTS_SRC_DIR/mpanrecognizer.cpp \ + $$EVENTS_SRC_DIR/mpangesture.cpp \ diff --git a/src/corelib/events/mpangesture.cpp b/src/corelib/events/mpangesture.cpp new file mode 100644 index 00000000..8f6560c0 --- /dev/null +++ b/src/corelib/events/mpangesture.cpp @@ -0,0 +1,31 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** 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 "mpangesture_p.h" + +MPanGesture::MPanGesture(QObject *parent) : + QPanGesture(parent), + startPos(QPointF()), + panDirection(0) +{ +} + +MPanGesture::~MPanGesture() +{ +} diff --git a/src/corelib/events/mpangesture_p.h b/src/corelib/events/mpangesture_p.h new file mode 100644 index 00000000..09b39780 --- /dev/null +++ b/src/corelib/events/mpangesture_p.h @@ -0,0 +1,55 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** 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 MPANGESTURE_P_H +#define MPANGESTURE_P_H + +#include <QPanGesture> + +class MPanRecognizer; + +/*! + This class provides Pan gesture state. + It's objects are delivered to registered handlers when a gesture is initiated. + */ +class MPanGesture : public QPanGesture +{ + Q_OBJECT + +public: + /*! + Default constructor. + */ + MPanGesture(QObject *parent = 0); + + /*! + Default destructor. + */ + virtual ~MPanGesture(); + +private: + + QPointF startPos; + Qt::Orientations panDirection; + + friend class MPanRecognizer; +}; + +#endif diff --git a/src/corelib/events/mpanrecognizer.cpp b/src/corelib/events/mpanrecognizer.cpp new file mode 100644 index 00000000..3ad00332 --- /dev/null +++ b/src/corelib/events/mpanrecognizer.cpp @@ -0,0 +1,150 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** 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 "mpanrecognizer.h" +#include "mpanrecognizer_p.h" + +#include "mpangesture_p.h" + +#include <QGraphicsSceneMouseEvent> + +//Hardcoded movement threshold used to recognize the panning gesture. +static const int defaultPanThreshold = 10; + +MPanRecognizerPrivate::MPanRecognizerPrivate() +{ +} + +MPanRecognizerPrivate::~MPanRecognizerPrivate() +{ +} + +MPanRecognizer::MPanRecognizer() : + d_ptr(new MPanRecognizerPrivate()) +{ + Q_D(MPanRecognizer); + d->movementThreshold = defaultPanThreshold; +} + +MPanRecognizer::~MPanRecognizer() +{ + delete d_ptr; +} + +QGesture* MPanRecognizer::create(QObject* target) +{ + Q_UNUSED(target); + return new MPanGesture; +} + +QGestureRecognizer::Result MPanRecognizer::recognize( QGesture* gesture, + QObject* watched, + QEvent* event) +{ + Q_UNUSED(watched); + Q_D(MPanRecognizer); + + MPanGesture *panGesture = static_cast<MPanGesture*>(gesture); + const QGraphicsSceneMouseEvent *ev = static_cast<const QGraphicsSceneMouseEvent *>(event); + QGestureRecognizer::Result result = QGestureRecognizer::CancelGesture; + qreal distX, distY; + + switch (event->type()) { + case QEvent::GraphicsSceneMousePress: + panGesture->startPos = ev->pos(); + panGesture->setHotSpot(ev->screenPos()); + + if (panGesture->state() != Qt::NoGesture) { + result = QGestureRecognizer::TriggerGesture; + } else { + result = QGestureRecognizer::MayBeGesture; + } + + break; + + case QEvent::GraphicsSceneMouseRelease: + if (panGesture->state() != Qt::NoGesture) { + result = QGestureRecognizer::FinishGesture; + } else { + result = QGestureRecognizer::CancelGesture; + } + + break; + + case QEvent::GraphicsSceneMouseMove: + panGesture->setLastOffset(panGesture->offset()); + panGesture->setOffset(ev->pos() - panGesture->startPos); + + distX = abs(panGesture->offset().x()); + distY = abs(panGesture->offset().y()); + + if (panGesture->state() == Qt::NoGesture) { + + if (distX > d->movementThreshold) { + if (panGesture->panDirection.testFlag(Qt::Vertical)) { + result = QGestureRecognizer::CancelGesture; + } else { + panGesture->panDirection = Qt::Horizontal; + result = QGestureRecognizer::TriggerGesture; + } + } else if (distY > d->movementThreshold) { + if (panGesture->panDirection.testFlag(Qt::Horizontal)) { + result = QGestureRecognizer::CancelGesture; + } else { + panGesture->panDirection = Qt::Vertical; + result = QGestureRecognizer::TriggerGesture; + } + } else { + result = QGestureRecognizer::MayBeGesture; + } + + } else { + result = QGestureRecognizer::TriggerGesture; + } + + if (panGesture->panDirection.testFlag(Qt::Vertical)) { + QPointF zeroedOffset = panGesture->offset(); + zeroedOffset.setX(0); + panGesture->setOffset(zeroedOffset); + } else if (panGesture->panDirection.testFlag(Qt::Horizontal)) { + QPointF zeroedOffset = panGesture->offset(); + zeroedOffset.setY(0); + panGesture->setOffset(zeroedOffset); + } else { + panGesture->setOffset(QPointF()); + } + + break; + default: + result = QGestureRecognizer::Ignore; + break; + } + return result; +} + +void MPanRecognizer::reset(QGesture* gesture) +{ + MPanGesture *panGesture = static_cast<MPanGesture*>(gesture); + panGesture->setOffset(QPointF()); + panGesture->setLastOffset(QPointF()); + panGesture->startPos = QPointF(); + panGesture->panDirection = 0; + + QGestureRecognizer::reset(gesture); +} diff --git a/src/corelib/events/mpanrecognizer.h b/src/corelib/events/mpanrecognizer.h new file mode 100644 index 00000000..161054eb --- /dev/null +++ b/src/corelib/events/mpanrecognizer.h @@ -0,0 +1,74 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** 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 MPANRECOGNIZER_H +#define MPANRECOGNIZER_H + +#include <QGestureRecognizer> + +class QGesture; +class MPanRecognizerPrivate; + +/*! + This class provides Pan gesture recognition functionality. + It provides event based handling of the gestures. + */ +class MPanRecognizer : public QGestureRecognizer +{ +public: + + /*! + Default constructor. + */ + MPanRecognizer(); + + /*! + Default destructor. + */ + virtual ~MPanRecognizer(); + + /*! + Method used internally by Qt recognition manager to create a gesture state. + \sa MPanGesture + */ + 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); + +private: + /*! + Private object attribute. + */ + MPanRecognizerPrivate * const d_ptr; + + Q_DECLARE_PRIVATE(MPanRecognizer) + Q_DISABLE_COPY(MPanRecognizer) + +}; + +#endif // MPANRECOGNIZER_H diff --git a/src/corelib/events/mpanrecognizer_p.h b/src/corelib/events/mpanrecognizer_p.h new file mode 100644 index 00000000..5e9e75db --- /dev/null +++ b/src/corelib/events/mpanrecognizer_p.h @@ -0,0 +1,43 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** 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 MPANRECOGNIZER_P_H +#define MPANRECOGNIZER_P_H + +#include "mpanrecognizer.h" + +/*! + Private class used by MPanRecognizer objects to + store variables during gesture recognition. + */ +class MPanRecognizerPrivate +{ +public: + + Q_DECLARE_PUBLIC(MPanRecognizer) + MPanRecognizerPrivate(); + virtual ~MPanRecognizerPrivate(); + +private: + int movementThreshold; + + MPanRecognizer* q_ptr; +}; + +#endif diff --git a/src/corelib/widgets/mpannablewidget.cpp b/src/corelib/widgets/mpannablewidget.cpp index a53db8b3..e8b6a1ae 100644 --- a/src/corelib/widgets/mpannablewidget.cpp +++ b/src/corelib/widgets/mpannablewidget.cpp @@ -20,6 +20,7 @@ #include <QApplication> #include <QGraphicsSceneMouseEvent> #include <QTapAndHoldGesture> +#include <QPanGesture> #include "mpannablewidget.h" #include "mpannablewidget_p.h" @@ -37,8 +38,9 @@ namespace const int ResentListMaxSize = 10; //! Z-value of the glass const int ZValueGlass = 2; - //! Hardcoded timeout value for tap&hold gesture; - const int TapAndHoldTimeoutValue = 500; + //! Hardcoded timeout value for delivering initial press event; + const int InitialPressDeliveryTimeoutValue = 50; + } /* @@ -108,8 +110,11 @@ public: virtual void mousePressEvent(QGraphicsSceneMouseEvent *event); virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event); virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event); - virtual void ungrabMouseEvent(QEvent *event); - virtual void tapAndHoldGestureEvent(QGestureEvent *event, QTapAndHoldGesture* gesture); + virtual void timerEvent(QTimerEvent* event); + +protected: + virtual void tapAndHoldGestureEvent(QGestureEvent *event, QTapAndHoldGesture* state); + virtual void panGestureEvent(QGestureEvent *event, QPanGesture* state); MPannableWidget *pannableWidget; }; @@ -123,10 +128,15 @@ void MPannableWidgetGlass::tapAndHoldGestureEvent(QGestureEvent *event, QTapAndH event->accept(gesture); } +void MPannableWidgetGlass::panGestureEvent(QGestureEvent *event, QPanGesture* gesture) +{ + pannableWidget->glassPanEvent(event, gesture); +} + MPannableWidgetGlass::MPannableWidgetGlass(QGraphicsItem *parent) : MWidget(parent) { - this->pannableWidget = dynamic_cast<MPannableWidget *>(parent); + pannableWidget = dynamic_cast<MPannableWidget *>(parent); } @@ -158,18 +168,17 @@ void MPannableWidgetGlass::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) pannableWidget->glassMouseReleaseEvent(event); } -void MPannableWidgetGlass::ungrabMouseEvent(QEvent *event) +void MPannableWidgetGlass::timerEvent(QTimerEvent *event) { - pannableWidget->glassUngrabMouseEvent(event); + pannableWidget->glassTimerEvent(event); } MPannableWidgetPrivate::MPannableWidgetPrivate() : - state(MPannableWidgetPrivate::Wait), - itemCount(0), pressEvent(QEvent::GraphicsSceneMousePress), physics(0), mouseGrabber(0), - resentList() + resentList(), + pressDeliveryTimerId(0) { } @@ -186,11 +195,48 @@ void MPannableWidgetPrivate::translateEventToItemCoordinates(const QGraphicsItem event->setPos(destItem->mapFromItem(srcItem, event->pos())); } -void MPannableWidgetPrivate::resetState() +void MPannableWidgetPrivate::deliverPressEvent() +{ + Q_Q(MPannableWidget); + glass->ungrabMouse(); + q->resendEvent(&pressEvent); + mouseGrabber = q->scene()->mouseGrabberItem(); + + MPannableWidgetGlass *otherGlass = dynamic_cast<MPannableWidgetGlass*>(mouseGrabber); + if (otherGlass) { + mouseGrabber = 0; + } else { + glass->grabMouse(); + } +} + +void MPannableWidgetPrivate::initialPressStartTimer() +{ + pressDeliveryTimerId = glass->startTimer(InitialPressDeliveryTimeoutValue); +} + +void MPannableWidgetPrivate::initialPressStopTimer() +{ + if (pressDeliveryTimerId) { + glass->killTimer(pressDeliveryTimerId); + pressDeliveryTimerId = 0; + } +} + +void MPannableWidgetPrivate::resetPhysics() { physics->pointerRelease(); physics->stop(); - state = MPannableWidgetPrivate::Wait; +} + +void MPannableWidgetPrivate::resetMouseGrabber() +{ + Q_Q(MPannableWidget); + + mouseGrabber = 0; + if (glass == q->scene()->mouseGrabberItem()) { + glass->ungrabMouse(); + } } void MPannableWidgetPrivate::deliverMouseEvent(QGraphicsSceneMouseEvent *event) @@ -233,6 +279,7 @@ void MPannableWidget::init() d->glass->setObjectName("glass"); d->glass->grabGesture(Qt::TapAndHoldGesture); + d->glass->grabGesture(Qt::PanGesture); setPosition(QPointF()); setRange(QRectF()); @@ -277,11 +324,7 @@ void MPannableWidget::setEnabled(bool enabled) model()->setEnabled(enabled); if (!enabled) { - d->physics->pointerRelease(); - - d->state = MPannableWidgetPrivate::Wait; - - d->physics->stop(); + d->resetPhysics(); } } @@ -351,13 +394,6 @@ void MPannableWidget::glassMousePressEvent(QGraphicsSceneMouseEvent *event) { Q_D(MPannableWidget); - if (!isEnabled()) { - // Glass: Ignoring, panning disabled - - event->ignore(); - return; - } - if (event->button() != Qt::LeftButton) { // Glass: Ignoring, not a left button @@ -365,13 +401,6 @@ void MPannableWidget::glassMousePressEvent(QGraphicsSceneMouseEvent *event) return; } - if (!(panDirection().testFlag(Qt::Horizontal) || panDirection().testFlag(Qt::Vertical))) { - // Glass: Ignoring, no enabled panning directions - - event->ignore(); - return; - } - if (checkForResent(event)) { // Glass: Ignoring, already seen @@ -379,31 +408,14 @@ void MPannableWidget::glassMousePressEvent(QGraphicsSceneMouseEvent *event) return; } - switch (d->state) { - case MPannableWidgetPrivate::Wait: - // Saves the event so it can be passed forward if the - // press doesn't end to be a panning action - + copyGraphicsSceneMouseEvent(d->pressEvent, *event); + if (!d->physics->inMotion()) { + // sending it now, we will send "cancel" if it will be needed. copyGraphicsSceneMouseEvent(d->pressEvent, *event); + d->initialPressStartTimer(); - if (!d->physics->inMotion()) { - // sending it now, we will send "cancel" if it will be needed. - - d->glass->ungrabMouse(); - this->resendEvent(&d->pressEvent); - d->mouseGrabber = scene()->mouseGrabberItem(); - d->itemCount = scene()->items().size(); - d->glass->grabMouse(); - } - - d->physics->pointerPress(event->pos()); - - d->state = MPannableWidgetPrivate::Evaluate; - break; - - default: - // Evaluate and pan states don't see press events - break; + } else { + d->physics->stop(); } } @@ -411,189 +423,94 @@ void MPannableWidget::glassMouseReleaseEvent(QGraphicsSceneMouseEvent *event) { Q_D(MPannableWidget); - if (!isEnabled()) { - //Widget disabled in the middle of the gesture. We need to deliver - //the events to the underlaying widget if we have it. - d->deliverMouseEvent(event); - d->resetState(); - //All events from this interaction has been delivered or dropped. - //We can now safely become really disabled. - d->mouseGrabber = 0; - d->glass->ungrabMouse(); - return; + if (d->pressDeliveryTimerId) { + d->deliverPressEvent(); + d->initialPressStopTimer(); } - switch (d->state) { - case MPannableWidgetPrivate::Evaluate: { + d->deliverMouseEvent(event); + d->resetMouseGrabber(); +} - d->glass->ungrabMouse(); - //ungrab event handler will ensure that physics is stopped - //and pointer is released. - QPointF velocity = d->physics->velocity(); +void MPannableWidget::glassMouseMoveEvent(QGraphicsSceneMouseEvent *event) +{ + Q_D(MPannableWidget); + d->deliverMouseEvent(event); +} - if (!d->physics->inMotion()) { - // If the scene's item count has changed between mouse press and release, - // there is a possibility that the mousegrabber pointer points to deleted - // object which potentially leads to a crash. - if (d->itemCount != scene()->items().size()) { - resendEvent(&d->pressEvent); // we need to setup implicit mouse grabber - resendEvent(event); - } else { - d->deliverMouseEvent(event); - } - } else if (qAbs(velocity.x()) < model()->panClickThreshold() && - qAbs(velocity.y()) < model()->panClickThreshold()) { - if (d->mouseGrabber) { - resendEvent(&d->pressEvent); // we need to setup implicit mouse grabber - resendEvent(event); - } - } else { - sendCancel(&d->pressEvent); - } +void MPannableWidget::glassLongTapEvent() +{ + Q_D(MPannableWidget); - d->state = MPannableWidgetPrivate::Wait; - break; - } - case MPannableWidgetPrivate::Pan: - d->physics->pointerRelease(); + QGraphicsSceneContextMenuEvent contextEvent(QEvent::GraphicsSceneContextMenu); + contextEvent.setPos(d->pressEvent.pos()); + contextEvent.setScenePos(d->pressEvent.scenePos()); + contextEvent.setScreenPos(d->pressEvent.screenPos()); - d->state = MPannableWidgetPrivate::Wait; - break; + QApplication::sendEvent(scene(), &contextEvent); - default: - // Wait state sees a release event in case of a press / move - // to a passive direction causing a stop of physics because of - // physics being inmotion - break; + if (contextEvent.isAccepted()) { + + sendCancel(&d->pressEvent); + d->resetPhysics(); + + //We will still receive mouse release, but + //we aren't interested in it. + d->resetMouseGrabber(); } } - -void MPannableWidget::glassMouseMoveEvent(QGraphicsSceneMouseEvent *event) +void MPannableWidget::glassPanEvent(QGestureEvent *event, QPanGesture* panGesture) { Q_D(MPannableWidget); - QPointF delta; - qreal distAct, distPass; if (!isEnabled()) { - //Widget disabled in the middle of the gesture. We need to deliver - //the events to the underlaying widget if we have it. - d->deliverMouseEvent(event); - d->resetState(); - //We don't ungrab at this point because we want to deliver - //rest of the events from this interaction to the underlaying widget. + event->ignore(panGesture); return; } - switch (d->state) { - case MPannableWidgetPrivate::Evaluate: - - // Check if the movement is big enough to justify panning - - delta = event->pos() - d->pressEvent.pos(); - - if (panDirection().testFlag(Qt::Horizontal) && !panDirection().testFlag(Qt::Vertical)) { - distAct = abs((int)delta.x()); - distPass = abs((int)delta.y()); - - } else if (!panDirection().testFlag(Qt::Horizontal) && panDirection().testFlag(Qt::Vertical)) { - distAct = abs((int)delta.y()); - distPass = abs((int)delta.x()); - - } else { - // 0.7*(x + y) approximates sqrt(x^2 + y^2) - - distAct = 0.7 * (abs((int)delta.x()) + abs((int)delta.y())); - distPass = 0; + switch (panGesture->state()) + { + case Qt::GestureStarted: + if ((panGesture->offset().x() != 0 && panDirection().testFlag(Qt::Vertical)) || + (panGesture->offset().y() != 0 && panDirection().testFlag(Qt::Horizontal))) + { + // Panning against the pannable direction, we aren't interested in it. + event->ignore(panGesture); + return; } - if (distAct > panThreshold()) { - - // This is panning, cancel the press event. + if (d->pressDeliveryTimerId) { + // The initial MousePress event hasn't been delivered yet. + d->initialPressStopTimer(); + } else { sendCancel(&d->pressEvent); - d->physics->pointerMove(event->pos()); - - d->state = MPannableWidgetPrivate::Pan; - } else if (distPass > panThreshold()) { - d->physics->pointerRelease(); - - if (!d->physics->inMotion()) { - - d->glass->ungrabMouse(); - - resendEvent(&d->pressEvent); // we need to setup implicit mouse grabber - resendEvent(event); - } else { - d->physics->stop(); - } - - d->state = MPannableWidgetPrivate::Wait; + d->mouseGrabber = 0; } + d->physics->pointerPress(d->pressEvent.pos() + panGesture->offset()); break; - - case MPannableWidgetPrivate::Pan: - - d->physics->pointerMove(event->pos()); - - d->state = MPannableWidgetPrivate::Pan; - break; - - default: - // Wait state sees a move event in case of a press / move to a - // passive direction causing a stop of physics because of - // physics being inmotion + case Qt::GestureUpdated: + d->physics->pointerMove(d->pressEvent.pos() + panGesture->offset()); break; - } -} - -void MPannableWidget::glassUngrabMouseEvent(QEvent *event) -{ - Q_UNUSED(event); - Q_D(MPannableWidget); - - //We will reset the state so that pannable widget - //will be ready to receive next mousePress. - switch (d->state) { - case MPannableWidgetPrivate::Evaluate: - case MPannableWidgetPrivate::Pan: - d->resetState(); + case Qt::GestureFinished: + case Qt::GestureCanceled: + d->physics->pointerRelease(); break; default: break; } + + event->accept(panGesture); } -void MPannableWidget::glassLongTapEvent() +void MPannableWidget::glassTimerEvent(QTimerEvent *event) { Q_D(MPannableWidget); - - //We will reset the state so that pannable widget - //will be ready to receive next mousePress. - switch (d->state) { - case MPannableWidgetPrivate::Evaluate: { - QGraphicsSceneContextMenuEvent contextEvent(QEvent::GraphicsSceneContextMenu); - contextEvent.setPos(d->pressEvent.pos()); - contextEvent.setScenePos(d->pressEvent.scenePos()); - contextEvent.setScreenPos(d->pressEvent.screenPos()); - - QApplication::sendEvent(scene(), &contextEvent); - - if (contextEvent.isAccepted()) { - - sendCancel(&d->pressEvent); - d->resetState(); - - //We will still receive mouse release, but - //we aren't interested in it. - d->mouseGrabber = 0; - d->glass->ungrabMouse(); - } - break; - } - default: - break; + if (event->timerId() == d->pressDeliveryTimerId) { + d->deliverPressEvent(); + d->initialPressStopTimer(); } } @@ -624,7 +541,7 @@ void MPannableWidget::resendEvent(QGraphicsSceneMouseEvent *event) break; } - if ((this->scene() == NULL) || (this->scene()->views().size() == 0)) { + if ((scene() == NULL) || (scene()->views().size() == 0)) { // If this widget has been removed from the scene and/or there // is no view, return @@ -632,21 +549,12 @@ void MPannableWidget::resendEvent(QGraphicsSceneMouseEvent *event) } QMouseEvent mouse_event(type, - this->scene()->views()[0]->mapFromScene(event->scenePos()), + scene()->views().at(0)->mapFromScene(event->scenePos()), event->screenPos(), event->button(), event->buttons(), event->modifiers()); - /* - mDebug("MPannableWidget") << "Event: " << type - << " " << this->scene()->views()[0]->mapFromScene(event->scenePos()) - << " " << event->screenPos() - << " " << event->button() - << " " << event->buttons() - << " " << event->modifiers(); - */ - if (type == QEvent::MouseButtonPress) { // Puts the event to exclude list @@ -664,7 +572,7 @@ void MPannableWidget::resendEvent(QGraphicsSceneMouseEvent *event) d->resentList.append(resentItem); } - QApplication::sendEvent(this->scene()->views()[0]->viewport(), &mouse_event); + QApplication::sendEvent(scene()->views().at(0)->viewport(), &mouse_event); } // onDisplayChangeEvent in MWidget handles MPannableWidgets in a @@ -709,7 +617,7 @@ void MPannableWidget::sendCancel(QGraphicsSceneMouseEvent *event) Q_D(MPannableWidget); Q_UNUSED(event); - if ((this->scene() == NULL) || (this->scene()->views().size() == 0)) { + if ((scene() == NULL) || (scene()->views().size() == 0)) { // If this widget has been removed from the scene and/or there // is no view, return @@ -736,13 +644,3 @@ Qt::Orientations MPannableWidget::panDirection() { return model()->panDirection(); } - -void MPannableWidget::setPanThreshold(qreal value) -{ - model()->setPanThreshold(value); -} - -qreal MPannableWidget::panThreshold() -{ - return model()->panThreshold(); -} diff --git a/src/corelib/widgets/mpannablewidget.h b/src/corelib/widgets/mpannablewidget.h index 98ca3a41..941e5ae9 100644 --- a/src/corelib/widgets/mpannablewidget.h +++ b/src/corelib/widgets/mpannablewidget.h @@ -26,6 +26,7 @@ class QTimerEvent; class QGraphicsSceneMouseEvent; +class QPanGesture; class MPannableWidgetPrivate; class MOnDisplayChangeEvent; @@ -54,8 +55,6 @@ class M_EXPORT MPannableWidget : public MWidgetController Q_PROPERTY(QRectF range READ range WRITE setRange) //! \brief Panning position Q_PROPERTY(QPointF position READ position WRITE setPosition NOTIFY positionChanged USER true) - //! \brief Panning threshold - Q_PROPERTY(qreal panThreshold READ panThreshold WRITE setPanThreshold) public: /*! @@ -142,17 +141,6 @@ public: */ Qt::Orientations panDirection(); - /*! - * \brief Sets the panning threshold. This method should be used - * only by the view. For setting this value, use css. - */ - void setPanThreshold(qreal value); - - /*! - * \brief Returns the current panning threshold. - */ - qreal panThreshold(); - public Q_SLOTS: /*! * \brief Virtual slot for receiving position changes from @@ -213,15 +201,19 @@ private: void glassMouseMoveEvent(QGraphicsSceneMouseEvent *event); /*! - * \brief Method for handling situation when some underlying - * widget grabs mouse. + * \brief Method for delivering tap&hold gesture. */ - void glassUngrabMouseEvent(QEvent *event); + void glassLongTapEvent(); /*! - * \brief Method for delivering tap&hold gesture. + * \brief Method for delivering pan gesture. */ - void glassLongTapEvent(); + void glassPanEvent(QGestureEvent* event, QPanGesture* panGesture); + + /*! + * \brief Method for delivering timer events. + */ + void glassTimerEvent(QTimerEvent* event); /*! * \brief Method for checking if the event is on the resent list diff --git a/src/corelib/widgets/mpannablewidget_p.h b/src/corelib/widgets/mpannablewidget_p.h index a7007e78..d99d2029 100644 --- a/src/corelib/widgets/mpannablewidget_p.h +++ b/src/corelib/widgets/mpannablewidget_p.h @@ -28,11 +28,9 @@ class QPoint; class QEvent; -class QTransform; class QGraphicsItem; class QGraphicsSceneMouseEvent; class MPhysics2DPanning; -class MStyle; class MPannableWidgetGlass; class MPannableWidgetPrivate : public MWidgetControllerPrivate @@ -42,10 +40,6 @@ public: explicit MPannableWidgetPrivate(); virtual ~MPannableWidgetPrivate(); - enum states {Wait, Evaluate, Pan}; - int state; - int itemCount; - QGraphicsSceneMouseEvent pressEvent; MPhysics2DPanning *physics; @@ -59,6 +53,8 @@ public: }; QList<struct resentItem> resentList; + + int pressDeliveryTimerId; public: /*! @@ -69,14 +65,36 @@ public: QGraphicsSceneMouseEvent *event); /*! - * \brief Method used for resetting state of the pannable widget. + * \brief Method used for resetting state of the physics engine. */ - void resetState(); + void resetPhysics(); + + /*! + * \brief Method used for resetting glass and mouse grabber. + */ + void resetMouseGrabber(); /*! * \brief Method used for delivering event to interested widget. */ void deliverMouseEvent(QGraphicsSceneMouseEvent *event); + + /*! + * \brief Method used for delivering initial mouse press. It will set + * the mouseGrabber if it is necessary at this point. + */ + void deliverPressEvent(); + + /*! + * \brief Method used to start a timer which will trigger the delivery + * of initial mouse press event. + */ + void initialPressStartTimer(); + + /*! + * \brief Method used for cancelling the mouse press delivery timer. + */ + void initialPressStopTimer(); }; #endif diff --git a/src/corelib/widgets/mwindow.cpp b/src/corelib/widgets/mwindow.cpp index 05dcabf4..efa961e4 100644 --- a/src/corelib/widgets/mwindow.cpp +++ b/src/corelib/widgets/mwindow.cpp @@ -135,6 +135,7 @@ void MWindowPrivate::init() q->viewport()->grabGesture(Qt::PinchGesture); q->setAttribute(Qt::WA_AcceptTouchEvents); + q->viewport()->grabGesture(Qt::PanGesture); } #ifdef Q_WS_X11 diff --git a/tests/stubs/mwidget_stub.h b/tests/stubs/mwidget_stub.h index 2d8842c8..369ac9ee 100644 --- a/tests/stubs/mwidget_stub.h +++ b/tests/stubs/mwidget_stub.h @@ -182,7 +182,7 @@ void MWidgetStub::tapAndHoldGestureEvent(QGestureEvent *event, QTapAndHoldGestur QList<ParameterBase*> params; params.append( new Parameter<QGestureEvent * >(event)); params.append( new Parameter<QTapAndHoldGesture * >(gesture)); - stubMethodEntered("tapAndHoldGesture",params); + stubMethodEntered("tapAndHoldGestureEvent",params); } void MWidgetStub::panGestureEvent(QGestureEvent *event, QPanGesture *gesture) @@ -190,7 +190,7 @@ void MWidgetStub::panGestureEvent(QGestureEvent *event, QPanGesture *gesture) QList<ParameterBase*> params; params.append( new Parameter<QGestureEvent * >(event)); params.append( new Parameter<QPanGesture * >(gesture)); - stubMethodEntered("panGesture",params); + stubMethodEntered("panGestureEvent",params); } void MWidgetStub::pinchGestureEvent(QGestureEvent *event, QPinchGesture *gesture) @@ -198,7 +198,7 @@ void MWidgetStub::pinchGestureEvent(QGestureEvent *event, QPinchGesture *gesture QList<ParameterBase*> params; params.append( new Parameter<QGestureEvent * >(event)); params.append( new Parameter<QPinchGesture * >(gesture)); - stubMethodEntered("pinchGesture",params); + stubMethodEntered("pinchGestureEvent",params); } void MWidgetStub::tapGestureEvent(QGestureEvent *event, QTapGesture *gesture) @@ -206,7 +206,7 @@ void MWidgetStub::tapGestureEvent(QGestureEvent *event, QTapGesture *gesture) QList<ParameterBase*> params; params.append( new Parameter<QGestureEvent * >(event)); params.append( new Parameter<QTapGesture * >(gesture)); - stubMethodEntered("tapGesture",params); + stubMethodEntered("tapGestureEvent",params); } void MWidgetStub::swipeGestureEvent(QGestureEvent *event, QSwipeGesture *gesture) @@ -214,7 +214,7 @@ void MWidgetStub::swipeGestureEvent(QGestureEvent *event, QSwipeGesture *gesture QList<ParameterBase*> params; params.append( new Parameter<QGestureEvent * >(event)); params.append( new Parameter<QSwipeGesture * >(gesture)); - stubMethodEntered("swipeGesture",params); + stubMethodEntered("swipeGestureEvent",params); } // 3. CREATE A STUB INSTANCE diff --git a/tests/tests.pro b/tests/tests.pro index b697c3d0..e8af55f8 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -151,6 +151,7 @@ SUBDIRS = \ ut_mvideowidget \ ut_mservicefwgen \ # ut_mstatusbar \ // Unstable. "Randomly" crashes on clean up, when detroying its MApplication instance. + ut_mpanrecognizer \ # enable only when we have icu available diff --git a/tests/ut_mapplethandle/ut_mapplethandle.cpp b/tests/ut_mapplethandle/ut_mapplethandle.cpp index c3102257..67369028 100644 --- a/tests/ut_mapplethandle/ut_mapplethandle.cpp +++ b/tests/ut_mapplethandle/ut_mapplethandle.cpp @@ -18,7 +18,6 @@ ****************************************************************************/ #include <QtTest/QtTest> -#include <QtGui> #include "ut_mapplethandle.h" #include <mextensionhandle.h> diff --git a/tests/ut_mextensionhandle/ut_mextensionhandle.cpp b/tests/ut_mextensionhandle/ut_mextensionhandle.cpp index 1d7f36bb..3001191a 100644 --- a/tests/ut_mextensionhandle/ut_mextensionhandle.cpp +++ b/tests/ut_mextensionhandle/ut_mextensionhandle.cpp @@ -18,7 +18,6 @@ ****************************************************************************/ #include <QtTest/QtTest> -#include <QtGui> #include <QLocalServer> #include <QPoint> #include <QGraphicsSceneMouseEvent> diff --git a/tests/ut_mpannablewidget/ut_mpannablewidget.cpp b/tests/ut_mpannablewidget/ut_mpannablewidget.cpp index 1f683684..dab19dea 100644 --- a/tests/ut_mpannablewidget/ut_mpannablewidget.cpp +++ b/tests/ut_mpannablewidget/ut_mpannablewidget.cpp @@ -18,478 +18,320 @@ ****************************************************************************/ #include "ut_mpannablewidget.h" -#include "mapplication.h" -#include <mtheme.h> -#include <mpannablewidget.h> -#include "../../src/corelib/widgets/mpannablewidget_p.h" -#include "../../src/corelib/widgets/mphysics2dpanning_p.h" -#include <mapplication.h> - -#include <QMetaType> -#include <QGraphicsSceneMouseEvent> -#include <QGraphicsView> - -/** Events that the test widget emits */ -typedef enum { -// START_TIMER, -// STOP_TIMER, - PHYS_STOP, - PHYS_MOUSE_PRESS, - PHYS_MOUSE_MOVE, - PHYS_MOUSE_RELEASE, - MOUSE_BUTTON_PRESS, - MOUSE_BUTTON_RELEASE, - MOUSE_MOVE, - UNGRAB_MOUSE -} StateTransitionEvent; - -/** Class indicating state of the pannable widget after a state transition. */ -class StateTransitionResult -{ -public: - StateTransitionResult(int targetState = 0) : - _targetState(targetState), _outputEvents(QList<StateTransitionEvent>()) {} - StateTransitionResult(int targetState, QList<StateTransitionEvent> expectedEvents) : - _targetState(targetState), _outputEvents(expectedEvents) {} - - /** Compares this result with another result using QTestLib compare. */ - void compare(const StateTransitionResult &result) const; - - /** State where the pannable widget should be. */ - int _targetState; - /** List of output events from test widget. */ - QList<StateTransitionEvent> _outputEvents; -}; +#include "mpannablewidget.h" +#include "mpannablewidget_p.h" +#include "mcancelevent.h" -void StateTransitionResult::compare(const StateTransitionResult &result) const -{ - // Iterate through the output events and see that they match - QCOMPARE(_outputEvents.size(), result._outputEvents.size()); - QListIterator<StateTransitionEvent> outputEvent(_outputEvents); - QListIterator<StateTransitionEvent> resultEvent(result._outputEvents); - while (outputEvent.hasNext()) { - QCOMPARE(outputEvent.next(), resultEvent.next()); - } -} +#include <QGestureEvent> +#include <QPanGesture> -// Required to insert StateTransitionResult instances to the test data. -Q_DECLARE_METATYPE(StateTransitionResult); +#include <QDebug> -static Ut_MPannableWidget *gTester = 0; - -/* Using the QT timer methods rather than the stubbed ones. - * -// Mock methods of the services required by pannable widget. -void QTimer::start() +class DummyGraphicsItem : public MWidget { - qDebug("QTimer::start() - called."); - gTester->_currentResult->_outputEvents.push_back(START_TIMER); -} - +public: + DummyGraphicsItem() { + mousePressReceived = false; + mouseMoveReceived = false; + mouseReleaseReceived = false; + cancelReceived = false; + } -void QTimer::stop() -{ - qDebug("QTimer::stop() - called."); - gTester->_currentResult->_outputEvents.push_back(STOP_TIMER); -} -*/ + bool mousePressReceived; + bool mouseMoveReceived; + bool mouseReleaseReceived; + bool cancelReceived; +}; +DummyGraphicsItem *dummyItem = 0; -void MPhysics2DPanning::start() -{ - qDebug("Physics2DPanning::start() - called."); -} +struct PhysicsState { -void QTimeLine::start() -{ - qDebug("QTimeLine::start() - called."); -} + PhysicsState() { + pointerPressed = false; + pointerMoved = false; + pointerReleased = false; + } -QWidget::QWidget(QWidget* /*parent*/, Qt::WindowFlags /*f*/) -{ - qDebug("QWidget::QWidget() - called."); -} + bool pointerPressed; + bool pointerMoved; + bool pointerReleased; +}; +PhysicsState *physicsState = 0; -QFrame::QFrame(QWidget* /*parent*/, Qt::WindowFlags /*f*/) -{ - qDebug("QFrame::QFrame() - called."); -} +//Stubs -QAbstractScrollArea::QAbstractScrollArea(QWidget* /*parent*/) +//Physics stubs: +void MPhysics2DPanning::start() { - qDebug("QAbstractScrollArea::QAbstractScrollArea() - called."); } -QGraphicsView::QGraphicsView(QWidget* /*parent*/) +void MPhysics2DPanning::stop() { - qDebug("QGraphicsView::QGraphicsView() - called."); } -QGraphicsScene *QGraphicsItem::scene() const +void MPhysics2DPanning::pointerPress(const QPointF& /*pos*/) { - qDebug("QGraphicsItem::scene() - called."); - return 0; + physicsState->pointerPressed = true; } -QGraphicsItem *QGraphicsScene::mouseGrabberItem() const +void MPhysics2DPanning::pointerMove(const QPointF& /*pos*/) { - qDebug("QGraphicsScene::mouseGrabberItem() - called"); - return 0; + physicsState->pointerMoved = true; } -QList<QGraphicsItem *> QGraphicsScene::items() const +void MPhysics2DPanning::pointerRelease() { - qDebug("QGraphicsScene::items() - called"); - QList<QGraphicsItem *> list; - return list; + physicsState->pointerReleased = true; } -QPointF QGraphicsItem::mapFromItem(const QGraphicsItem */*item*/, const QPointF &/*point*/) const +//QGraphicsObject stubs: +void QGraphicsObject::grabGesture(Qt::GestureType, Qt::GestureFlags) { - qDebug("QGraphicsScene::mapFromItem() - called"); - return QPointF(); } -QList<QGraphicsView *> QGraphicsScene::views() const +//QGraphicsItem stubs: +void QGraphicsItem::grabMouse() { - qDebug("QGraphicsScene::views() - called."); - return QList<QGraphicsView *>(); } -QPoint QGraphicsView::mapFromScene(const QPointF& /*point*/) const +void QGraphicsItem::ungrabMouse() { - qDebug("QGraphicsView::mapFromScene() - called."); - return QPoint(); } -QWidget *QAbstractScrollArea::viewport() const +QGraphicsScene *QGraphicsItem::scene() const { - qDebug("QAbstractScrollArea::viewport() - called."); - return 0; + return (QGraphicsScene*)1; } -bool QGraphicsScene::sendEvent(QGraphicsItem *item, QEvent *event) +//QGraphiscScene stubs: + QGraphicsItem* QGraphicsScene::mouseGrabberItem() const { - Q_UNUSED(item); - Q_UNUSED(event); - qDebug("QGraphicsScene::sendEvent() - called."); - return true; + return dummyItem; } -void QCoreApplication::postEvent(QObject* /*receiver*/, QEvent *event) + QList<QGraphicsItem*> QGraphicsScene::items() const { - qDebug("QCoreApplication::postEvent() - called"); - if (event->type() == QEvent::MouseButtonPress) { - gTester->_currentResult->_outputEvents.push_back(MOUSE_BUTTON_PRESS); - } - if (event->type() == QEvent::MouseButtonRelease) { - gTester->_currentResult->_outputEvents.push_back(MOUSE_BUTTON_RELEASE); - } - if (event->type() == QEvent::MouseMove) { - gTester->_currentResult->_outputEvents.push_back(MOUSE_MOVE); + QList<QGraphicsItem*> itemList; + if (dummyItem) { + itemList.append(dummyItem); } -} - -void MPhysics2DPanning::stop() -{ - gTester->_currentResult->_outputEvents.push_back(PHYS_STOP); -} - -void MPhysics2DPanning::pointerPress(const QPointF& /*pos*/) -{ - gTester->_currentResult->_outputEvents.push_back(PHYS_MOUSE_PRESS); -} - -void MPhysics2DPanning::pointerMove(const QPointF& /*pos*/) -{ - gTester->_currentResult->_outputEvents.push_back(PHYS_MOUSE_MOVE); -} - -void MPhysics2DPanning::pointerRelease() -{ - gTester->_currentResult->_outputEvents.push_back(PHYS_MOUSE_RELEASE); -} - -void MPhysics2DPanningPrivate::_q_integrator(int /*frame*/) -{ -} - -MApplication *app; - -void QGraphicsItem::ungrabMouse() -{ - gTester->_currentResult->_outputEvents.push_back(UNGRAB_MOUSE); -} + return itemList; +} + + QList<QGraphicsView *> QGraphicsScene::views() const + { + QList<QGraphicsView *> viewList; + viewList.append(0); + return viewList; + } + + bool QGraphicsScene::sendEvent(QGraphicsItem *item, QEvent *event) + { + if (item == dummyItem) { + + if (event->type() == MCancelEvent::eventNumber()) { + dummyItem->cancelReceived = true; + } + + switch (event->type()) { + case QEvent::GraphicsSceneMousePress: + dummyItem->mousePressReceived = true; + break; + + case QEvent::GraphicsSceneMouseRelease: + dummyItem->mouseReleaseReceived = true; + break; + + case QEvent::GraphicsSceneMouseMove: + dummyItem->mouseMoveReceived = true; + break; + + default: + break; + } + } + return true; + } + + QPointF QGraphicsItem::mapFromItem(const QGraphicsItem */*item*/, const QPointF &/*point*/) const + { + return QPointF(); + } + + QPoint QGraphicsView::mapFromScene(const QPointF& /*point*/) const + { + return QPoint(); + } + + QWidget *QAbstractScrollArea::viewport() const + { + return 0; + } + + void QCoreApplication::postEvent(QObject* /*receiver*/, QEvent */*event*/) + { + qDebug("QCoreApplication::postEvent() - called"); + } + + Qt::GestureState currentPanState = Qt::NoGesture; + Qt::GestureState QGesture::state() const + { + return currentPanState; + } + + // End of stubs. void Ut_MPannableWidget::initTestCase() { - static int argc = 1; - static char *app_name[1] = { (char *) "./ut_pannablewidget" }; - app = new MApplication(argc, app_name); - Q_UNUSED(app); - - gTester = this; - } void Ut_MPannableWidget::cleanupTestCase() { - gTester = 0; - delete app; } - void Ut_MPannableWidget::init() { - _widget = new MPannableWidget(); - _currentResult = new StateTransitionResult(); + dummyItem = new DummyGraphicsItem; + physicsState = new PhysicsState(); + widget = new MPannableWidget(); } void Ut_MPannableWidget::cleanup() { - delete _currentResult; - delete _widget; - _widget = 0; - _currentResult = 0; + delete widget; + delete physicsState; + delete dummyItem; } -void Ut_MPannableWidget::testWaitState_data() +void Ut_MPannableWidget::mousePressAndReleaseAreDeliveredToGrabber() { - QList<StateTransitionEvent> expectedEvents; + QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); + QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); + QTimerEvent timerEvent(1); - // Create a list of results that the widget should reach to - // when receiving events. - QList<StateTransitionResult> results; + widget->glassMousePressEvent(&pressEvent); - // Result after no events - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Wait))); + QCOMPARE(widget->d_func()->mouseGrabber, (QGraphicsItem*)0); - // Result after mouse press event - expectedEvents.push_back(UNGRAB_MOUSE); - expectedEvents.push_back(PHYS_MOUSE_PRESS); - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Evaluate), expectedEvents)); - expectedEvents.clear(); + widget->d_func()->pressDeliveryTimerId = 1; + widget->glassTimerEvent(&timerEvent); - // Result after mouse release event - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Wait), expectedEvents)); + QCOMPARE(widget->d_func()->mouseGrabber, dummyItem); + QVERIFY2(widget->d_func()->resentList.at(0).type == QEvent::GraphicsSceneMousePress, "Mouse press was not sent"); - // Result after mouse move event - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Wait), expectedEvents)); + widget->glassMouseReleaseEvent(&releaseEvent); - // Result after move over passive threshold event - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Wait), expectedEvents)); - - // Result after move over active threshold event - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Wait), expectedEvents)); - - createTestData(results); -} - -void Ut_MPannableWidget::testWaitState() -{ - // Set the pannable widget into wait state - static_cast<MPannableWidgetPrivate *>(_widget->d_ptr)->state = MPannableWidgetPrivate::Wait; - - testStateTransitions(); + QCOMPARE(widget->d_func()->mouseGrabber, (QGraphicsItem*)0); + QCOMPARE(dummyItem->mouseReleaseReceived, true); } -void Ut_MPannableWidget::testEvaluateState_data() +void Ut_MPannableWidget::mouseMoveIsDelieveredToGrabberIfNoPanningIsRecognized() { - QList<StateTransitionEvent> expectedEvents; - - // Create a list of results that the widget should reach to - // when receiving events. - QList<StateTransitionResult> results; + QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); + QGraphicsSceneMouseEvent moveEvent(QEvent::GraphicsSceneMouseMove); + QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); + QTimerEvent timerEvent(1); - // Result after no events - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Evaluate))); + widget->glassMousePressEvent(&pressEvent); - // Result after mouse press event - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Evaluate))); + QCOMPARE(widget->d_func()->mouseGrabber, (QGraphicsItem*)0); - // Result after mouse release event - expectedEvents.push_back(UNGRAB_MOUSE); - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Wait), expectedEvents)); - expectedEvents.clear(); + widget->d_func()->pressDeliveryTimerId = 1; + widget->glassTimerEvent(&timerEvent); - // Result after mouse move event - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Evaluate))); + QCOMPARE(widget->d_func()->mouseGrabber, dummyItem); + QVERIFY2(widget->d_func()->resentList.at(0).type == QEvent::GraphicsSceneMousePress, "Mouse press was not sent"); - // Result after move over passive threshold event - expectedEvents.push_back(PHYS_MOUSE_RELEASE); - expectedEvents.push_back(UNGRAB_MOUSE); - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Wait), expectedEvents)); - expectedEvents.clear(); + widget->glassMouseMoveEvent(&moveEvent); + QCOMPARE(widget->d_func()->mouseGrabber, dummyItem); + QCOMPARE(dummyItem->mouseMoveReceived, true); + QCOMPARE(dummyItem->mouseReleaseReceived, false); - // Result after move over active threshold event - expectedEvents.push_back(PHYS_MOUSE_MOVE); - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Pan), expectedEvents)); - expectedEvents.clear(); + widget->glassMouseReleaseEvent(&releaseEvent); - createTestData(results); + QCOMPARE(widget->d_func()->mouseGrabber, (QGraphicsItem*)0); + QCOMPARE(dummyItem->mouseReleaseReceived, true); } -void Ut_MPannableWidget::testEvaluateState() +void Ut_MPannableWidget::panGestureMovesPhysicsPointer() { - // Set the pannable widget into evaluate state - static_cast<MPannableWidgetPrivate *>(_widget->d_ptr)->state = MPannableWidgetPrivate::Evaluate; + QPanGesture panGesture; - testStateTransitions(); -} + QList<QGesture*> gestureList; + gestureList.append(&panGesture); + QGestureEvent event(gestureList); -void Ut_MPannableWidget::testPanState_data() -{ - QList<StateTransitionEvent> expectedEvents; + currentPanState = Qt::GestureStarted; + widget->glassPanEvent(&event, &panGesture); + QCOMPARE(physicsState->pointerPressed, true); + QCOMPARE(physicsState->pointerMoved, false); + QCOMPARE(physicsState->pointerReleased, false); + + physicsState->pointerPressed = false; - // Create a list of results that the widget should reach to - // when receiving events. - QList<StateTransitionResult> results; + currentPanState = Qt::GestureUpdated; + widget->glassPanEvent(&event, &panGesture); + QCOMPARE(physicsState->pointerPressed, false); + QCOMPARE(physicsState->pointerMoved, true); + QCOMPARE(physicsState->pointerReleased, false); - // Result after no events - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Pan))); + physicsState->pointerMoved = false; - // Result after mouse press event - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Pan))); + currentPanState = Qt::GestureFinished; + widget->glassPanEvent(&event, &panGesture); + QCOMPARE(physicsState->pointerPressed, false); + QCOMPARE(physicsState->pointerMoved, false); + QCOMPARE(physicsState->pointerReleased, true); - // Result after mouse release event - expectedEvents.push_back(PHYS_MOUSE_RELEASE); - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Wait), expectedEvents)); - expectedEvents.clear(); +} - // Result after mouse move event - expectedEvents.push_back(PHYS_MOUSE_MOVE); - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Pan), expectedEvents)); - expectedEvents.clear(); +void Ut_MPannableWidget::panGestureAgainstPanningDirectionIsIgnored() +{ + QPanGesture panGesture; - // Result after move over passive threshold event - expectedEvents.push_back(PHYS_MOUSE_MOVE); - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Pan), expectedEvents)); - expectedEvents.clear(); + QList<QGesture*> gestureList; + gestureList.append(&panGesture); + QGestureEvent event(gestureList); - // Result after move over active threshold event - expectedEvents.push_back(PHYS_MOUSE_MOVE); - results.push_back(StateTransitionResult(int(MPannableWidgetPrivate::Pan), expectedEvents)); - expectedEvents.clear(); + currentPanState = Qt::GestureStarted; + panGesture.setOffset(QPointF(100,0)); - createTestData(results); + widget->glassPanEvent(&event, &panGesture); + QCOMPARE(physicsState->pointerPressed, false); + QCOMPARE(physicsState->pointerMoved, false); + QCOMPARE(physicsState->pointerReleased, false); + QCOMPARE(event.isAccepted(&panGesture), false); } -void Ut_MPannableWidget::testPanState() +void Ut_MPannableWidget::panGestureCancelsMouseEvents() { - // Set the pannable widget into pan state - static_cast<MPannableWidgetPrivate *>(_widget->d_ptr)->state = MPannableWidgetPrivate::Pan; + QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); + QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); + QTimerEvent timerEvent(1); - testStateTransitions(); -} + widget->glassMousePressEvent(&pressEvent); -void Ut_MPannableWidget::createTestData(QList<StateTransitionResult> results) -{ - qRegisterMetaType< QList<QEvent *> >(); - qRegisterMetaType< StateTransitionResult >(); - - Q_ASSERT(results.size() == 6); - - QTest::addColumn< QList<QEvent *> >("events"); - QTest::addColumn<StateTransitionResult>("result"); - - // Sequence of events to be passed to the test widget. - QList<QEvent *> sequence; - - // Iterator to results that the widget should reach when - // input events are send to the test widget. - QListIterator<StateTransitionResult> resIt(results); - - // No events sent to the widget - QTest::newRow("initial") << sequence << resIt.next(); - - QGraphicsSceneMouseEvent *mouseEvent; - - // Send a mouse press event - mouseEvent = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMousePress); - mouseEvent->setButton(Qt::LeftButton); - sequence.push_back(mouseEvent); - QTest::newRow("left mouse button pressed") << sequence << resIt.next(); - sequence.clear(); - - // Send a mouse release event - mouseEvent = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseRelease); - mouseEvent->setButton(Qt::LeftButton); - sequence.push_back(mouseEvent); - QTest::newRow("left mouse button released") << sequence << resIt.next(); - sequence.clear(); - - // Send a mouse move event - mouseEvent = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseMove); - mouseEvent->setButton(Qt::LeftButton); - mouseEvent->setScreenPos(QPoint(0, 1)); - sequence.push_back(mouseEvent); - QTest::newRow("mouse move") << sequence << resIt.next(); - sequence.clear(); - - // Send a mouse move over passive threshold - mouseEvent = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseMove); - mouseEvent->setButton(Qt::LeftButton); - mouseEvent->setPos(QPoint(31, 0)); - sequence.push_back(mouseEvent); - QTest::newRow("mouse move over passive") << sequence << resIt.next(); - sequence.clear(); - - // Send a mouse move over active threshold - mouseEvent = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseMove); - mouseEvent->setButton(Qt::LeftButton); - mouseEvent->setPos(QPoint(0, 31)); - sequence.push_back(mouseEvent); - QTest::newRow("mouse move over active") << sequence << resIt.next(); - sequence.clear(); -} + QCOMPARE(widget->d_func()->mouseGrabber, (QGraphicsItem*)0); + widget->d_func()->pressDeliveryTimerId = 1; + widget->glassTimerEvent(&timerEvent); -void Ut_MPannableWidget::testStateTransitions() -{ - QFETCH(QList<QEvent *>, events); - QFETCH(StateTransitionResult, result); - - // Iterate through the events in the event list - QListIterator<QEvent *> i(events); - while (i.hasNext()) { - QEvent *event = i.next(); - switch (event->type()) { - case QEvent::GraphicsSceneMousePress: - _widget->glassMousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); - break; - case QEvent::GraphicsSceneMouseMove: - _widget->glassMouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); - break; - case QEvent::GraphicsSceneMouseRelease: - _widget->glassMouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); - break; - default: - break; - } - } + QCOMPARE(widget->d_func()->mouseGrabber, dummyItem); + QVERIFY2(widget->d_func()->resentList.at(0).type == QEvent::GraphicsSceneMousePress, "Mouse press was not sent"); - QCOMPARE(static_cast<MPannableWidgetPrivate *>(_widget->d_ptr)->state, result._targetState); + QPanGesture panGesture; - _currentResult->compare(result); -} + QList<QGesture*> gestureList; + gestureList.append(&panGesture); + QGestureEvent event(gestureList); -void Ut_MPannableWidget::testRightMouseButton() -{ - QGraphicsSceneMouseEvent *mouseEvent; - mouseEvent = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMousePress); - mouseEvent->setButton(Qt::RightButton); - mouseEvent->setScenePos(QPoint(100, 100)); - _widget->glassMousePressEvent(mouseEvent); - delete mouseEvent; - // State should not change with right mousebutton - QVERIFY(static_cast<MPannableWidgetPrivate *>(_widget->d_ptr)->state == MPannableWidgetPrivate::Wait); - - mouseEvent = new QGraphicsSceneMouseEvent(QEvent::GraphicsSceneMouseRelease); - mouseEvent->setButton(Qt::RightButton); - mouseEvent->setScenePos(QPoint(100, 100)); - _widget->glassMouseReleaseEvent(mouseEvent); - delete mouseEvent; - // State should stay the same after button release - QVERIFY(static_cast<MPannableWidgetPrivate *>(_widget->d_ptr)->state == MPannableWidgetPrivate::Wait); + currentPanState = Qt::GestureStarted; + widget->glassPanEvent(&event, &panGesture); + QCOMPARE(physicsState->pointerPressed, true); + QCOMPARE(physicsState->pointerMoved, false); + QCOMPARE(physicsState->pointerReleased, false); + + QCOMPARE(dummyItem->cancelReceived, true); } class CustomPhysics : public MPhysics2DPanning @@ -502,32 +344,32 @@ public: void Ut_MPannableWidget::usingCustomPhysics() { - CustomPhysics *customPhysics = new CustomPhysics(_widget); - _widget->setPhysics(customPhysics); + CustomPhysics *customPhysics = new CustomPhysics(widget); + widget->setPhysics(customPhysics); - QVERIFY(static_cast<MPannableWidgetPrivate *>(_widget->d_ptr)->physics == customPhysics); + QVERIFY(static_cast<MPannableWidgetPrivate *>(widget->d_ptr)->physics == customPhysics); - _widget->setPhysics(new MPhysics2DPanning(_widget)); + widget->setPhysics(new MPhysics2DPanning(widget)); } void Ut_MPannableWidget::settingNewPhysicsShouldEmitPhysicsChangeSignal() { - CustomPhysics *customPhysics = new CustomPhysics(_widget); + CustomPhysics *customPhysics = new CustomPhysics(widget); - QSignalSpy spyPhysicsChange(_widget, SIGNAL(physicsChanged())); + QSignalSpy spyPhysicsChange(widget, SIGNAL(physicsChanged())); - _widget->setPhysics(customPhysics); + widget->setPhysics(customPhysics); QCOMPARE(spyPhysicsChange.count(),1); - _widget->setPhysics(new MPhysics2DPanning(_widget)); + widget->setPhysics(new MPhysics2DPanning(widget)); } void Ut_MPannableWidget::settingPhysicsToNULLShouldNotBreakTheWidget() { - _widget->setPhysics(NULL); - QVERIFY(static_cast<MPannableWidgetPrivate *>(_widget->d_ptr)->physics != NULL); + widget->setPhysics(NULL); + QVERIFY(static_cast<MPannableWidgetPrivate *>(widget->d_ptr)->physics != NULL); } diff --git a/tests/ut_mpannablewidget/ut_mpannablewidget.h b/tests/ut_mpannablewidget/ut_mpannablewidget.h index e15e6e09..ad0f610f 100644 --- a/tests/ut_mpannablewidget/ut_mpannablewidget.h +++ b/tests/ut_mpannablewidget/ut_mpannablewidget.h @@ -25,11 +25,7 @@ #include <QObject> #include "mapplication.h" class MPannableWidget; -class QGraphicsWidget; -class StateTransitionResult; - -// Required to insert QList<QEvent*> instances to the test data. -Q_DECLARE_METATYPE(QList<QEvent *>); +class DummyGraphicsItem; class Ut_MPannableWidget : public QObject { @@ -37,17 +33,7 @@ class Ut_MPannableWidget : public QObject public: - /** Result generated by running a test case. */ - StateTransitionResult *_currentResult; - private: - MApplication *app; - - /** Pannable widget instance under testing. */ - MPannableWidget *_widget; - -// /** Event enumerator for timeout events. */ -// int _timeoutType; private slots: void initTestCase(); @@ -56,32 +42,19 @@ private slots: void init(); void cleanup(); - void testWaitState_data(); - void testEvaluateState_data(); - void testPanState_data(); - void testWaitState(); - void testEvaluateState(); - void testPanState(); - void testRightMouseButton(); + void mousePressAndReleaseAreDeliveredToGrabber(); + void mouseMoveIsDelieveredToGrabberIfNoPanningIsRecognized(); void usingCustomPhysics(); void settingNewPhysicsShouldEmitPhysicsChangeSignal(); void settingPhysicsToNULLShouldNotBreakTheWidget(); -private: - - /** - * Helper method to create test data with all possible input events - * @param results List of results that the test widget should reach - * when events are triggered. - */ - void createTestData(QList<StateTransitionResult> results); + void panGestureMovesPhysicsPointer(); + void panGestureAgainstPanningDirectionIsIgnored(); + void panGestureCancelsMouseEvents(); - /** - * Helper method which tests state transitions using the already set-up - * test data and already set-up test widget. - */ - void testStateTransitions(); +private: + MPannableWidget *widget; }; diff --git a/tests/ut_mpannablewidget/ut_mpannablewidget.pro b/tests/ut_mpannablewidget/ut_mpannablewidget.pro index d049999f..a3190bfb 100644 --- a/tests/ut_mpannablewidget/ut_mpannablewidget.pro +++ b/tests/ut_mpannablewidget/ut_mpannablewidget.pro @@ -1,23 +1,11 @@ include(../common_top.pri) - +INCLUDEPATH += $$MSRCDIR/corelib/widgets TARGET = ut_mpannablewidget -support_files.files += \ - ut_mpannablewidget_image.svg \ - ut_mpannablewidget_template.css \ - -# Input HEADERS += \ ut_mpannablewidget.h \ -# $$STUBSDIR/mpannableviewport_stub.h \ -# $$STUBSDIR/mstyledescription_stub.h \ -# $$STUBSDIR/mstyle_stub.h \ -# $$STUBSDIR/mtheme_stub.h \ - -TEST_SOURCES += \ -# $$MSRCDIR/mpannablewidget.cpp \ -SOURCES += ut_mpannablewidget.cpp \ -# stubbase.cpp \ +SOURCES += \ + ut_mpannablewidget.cpp \ include(../common_bot.pri) diff --git a/tests/ut_mpanrecognizer/.gitignore b/tests/ut_mpanrecognizer/.gitignore new file mode 100644 index 00000000..16b6704e --- /dev/null +++ b/tests/ut_mpanrecognizer/.gitignore @@ -0,0 +1 @@ +ut_mpanrecognizer diff --git a/tests/ut_mpanrecognizer/ut_mpanrecognizer.cpp b/tests/ut_mpanrecognizer/ut_mpanrecognizer.cpp new file mode 100644 index 00000000..2ae67b06 --- /dev/null +++ b/tests/ut_mpanrecognizer/ut_mpanrecognizer.cpp @@ -0,0 +1,105 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** 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_mpanrecognizer.h" +#include "mpanrecognizer.h" +#include "mpanrecognizer_p.h" + +#include "mpangesture_p.h" + +#include <QGraphicsSceneMouseEvent> +#include <QtTest/QtTest> + +// QGesture stubs: +Qt::GestureState currentGestureState = Qt::NoGesture; +Qt::GestureState QGesture::state() const +{ + return currentGestureState; +} + + +void Ut_MPanRecognizer::init() +{ + currentGestureState = Qt::NoGesture; + recognizer = new MPanRecognizer(); +} + +void Ut_MPanRecognizer::cleanup() +{ + delete recognizer; +} + +void Ut_MPanRecognizer::testCreateGesture() +{ + PanGesture = static_cast<MPanGesture*>(recognizer->create(this)); +} + +void Ut_MPanRecognizer::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(0,100)); + moveEvent.setScenePos(QPointF(0,100)); + moveEvent.setScreenPos(QPoint(0,100)); + + QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); + releaseEvent.setPos(QPointF(0,100)); + releaseEvent.setScenePos(QPointF(0,100)); + releaseEvent.setScreenPos(QPoint(0,100)); + + QGestureRecognizer::Result currentState; + currentState = recognizer->recognize(PanGesture, 0, &pressEvent); + QCOMPARE( currentState, QGestureRecognizer::MayBeGesture); + + currentState = recognizer->recognize(PanGesture, 0, &moveEvent); + QCOMPARE( currentState, QGestureRecognizer::TriggerGesture); + + //Artificially setting state of QGesture object. + currentGestureState = Qt::GestureUpdated; + + currentState = recognizer->recognize(PanGesture, 0, &releaseEvent); + QCOMPARE( currentState, QGestureRecognizer::FinishGesture); +} + +void Ut_MPanRecognizer::testTapIsNotRecognizedAsPan() +{ + QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); + pressEvent.setPos(QPointF(0,0)); + pressEvent.setScenePos(QPointF(0,0)); + pressEvent.setScreenPos(QPoint(0,0)); + + QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); + pressEvent.setPos(QPointF(0,0)); + pressEvent.setScenePos(QPointF(0,0)); + pressEvent.setScreenPos(QPoint(0,0)); + + QGestureRecognizer::Result currentState; + currentState = recognizer->recognize(PanGesture, 0, &pressEvent); + QCOMPARE( currentState, QGestureRecognizer::MayBeGesture); + + currentState = recognizer->recognize(PanGesture, 0, &releaseEvent); + QCOMPARE( currentState, QGestureRecognizer::CancelGesture); +} + +QTEST_APPLESS_MAIN(Ut_MPanRecognizer) + diff --git a/tests/ut_mpanrecognizer/ut_mpanrecognizer.h b/tests/ut_mpanrecognizer/ut_mpanrecognizer.h new file mode 100644 index 00000000..9ebb5ecb --- /dev/null +++ b/tests/ut_mpanrecognizer/ut_mpanrecognizer.h @@ -0,0 +1,44 @@ +/*************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (directui@nokia.com) +** +** This file is part of libdui. +** +** 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_MPANRECOGNIZER_H +#define UT_MPANRECOGNIZER_H + +#include <QObject> + +class MPanRecognizer; +class MPanGesture; + +class Ut_MPanRecognizer : public QObject +{ + Q_OBJECT + +private: + MPanRecognizer* recognizer; + MPanGesture* PanGesture; +private slots: + void init(); + void cleanup(); + + void testCreateGesture(); + void testRecognize(); + void testTapIsNotRecognizedAsPan(); +}; + +#endif // UT_MPANRECOGNIZER_H diff --git a/tests/ut_mpanrecognizer/ut_mpanrecognizer.pro b/tests/ut_mpanrecognizer/ut_mpanrecognizer.pro new file mode 100644 index 00000000..c083b280 --- /dev/null +++ b/tests/ut_mpanrecognizer/ut_mpanrecognizer.pro @@ -0,0 +1,16 @@ +include(../common_top.pri) +INCLUDEPATH += $$MSRCDIR/corelib/events +TARGET = ut_mpanrecognizer + +# unit test and unit classes +SOURCES += \ + ut_mpanrecognizer.cpp \ + ../../src/corelib/events/mpanrecognizer.cpp \ + ../../src/corelib/events/mpangesture.cpp \ + +# unit test and unit classes +HEADERS += \ + ut_mpanrecognizer.h \ + ../../src/corelib/events/mpangesture_p.h \ + +include(../common_bot.pri) |