~unity-api-team/unity8/scopes-active-depends-on-screen-rtm

« back to all changes in this revision

Viewing changes to tests/plugins/Ubuntu/Gestures/tst_TouchDispatcher.cpp

  • Committer: CI bot
  • Author(s): Michael Terry, Michael Zanetti, Michał Sawicz, Daniel d'Andrada, Albert Astals, Nick Dedekind, Mirco Müller, Alberto Aguirre
  • Date: 2014-11-05 14:39:26 UTC
  • mfrom: (1396.3.14 rtm-1104-sync)
  • Revision ID: ps-jenkins@lists.canonical.com-20141105143926-gnigtgarofubbip2
[ Albert Astals ]
* Fix i18n (LP: #1389165)

[ Michael Zanetti ]
* Fix DBusVariant conversion for launcher emblems (LP: #1387261)
* Fix desktop file encoding in launcher (LP: #1387083)

[ Alberto Aguirre ]
* Add audioRole to QtMultimedia mock
* Add a plugin to take screenshots on vol up + vol down

[ Nick Dedekind ]
* Reset current item selection on deleted. (LP: #1378462)
* Added timer to re-assert server value after indicator menu item
  activation. (LP: #1336715)

[ Mirco Müller ]
* Added dedicated swipe-to-act button for snap-decisions, which avoids
  accidental taps/button-presses. (LP: #1358343)

[ Michael Terry ]
* Don't lock phone if user tries to switch back to an active call.
  (LP: #1388156)

[ Daniel d'Andrada ]
* TouchDispatcher: synthesize MouseButtonDblClick events (LP: #1388359) Fixes: 1336715, 1358343, 1378462, 1387083, 1387261, 1388156, 1388359, 1389165

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
#include <QtTest>
18
18
#include <QQuickView>
 
19
#include <QStyleHints>
19
20
 
20
21
#include "GestureTest.h"
21
22
 
29
30
private Q_SLOTS:
30
31
    void sendMouseEventIfTouchIgnored_data();
31
32
    void sendMouseEventIfTouchIgnored();
 
33
    void mouseDoubleClick_data();
 
34
    void mouseDoubleClick();
32
35
};
33
36
 
34
37
tst_TouchDispatcher::tst_TouchDispatcher()
85
88
    QCOMPARE(gotMousePressEvent, shouldGetMousePress);
86
89
}
87
90
 
 
91
void tst_TouchDispatcher::mouseDoubleClick_data()
 
92
{
 
93
    QTest::addColumn<ulong>("timeBetweenClicks");
 
94
    QTest::addColumn<bool>("shouldSendDoubleClick");
 
95
 
 
96
    QTest::newRow("double click") << static_cast<ulong>(qApp->styleHints()->mouseDoubleClickInterval() / 10) << true;
 
97
    QTest::newRow("two separate clicks") << static_cast<ulong>(qApp->styleHints()->mouseDoubleClickInterval() * 2) << false;
 
98
}
 
99
 
 
100
void tst_TouchDispatcher::mouseDoubleClick()
 
101
{
 
102
    QFETCH(ulong, timeBetweenClicks);
 
103
    QFETCH(bool, shouldSendDoubleClick);
 
104
    DummyItem *dummyItem = new DummyItem(m_view->rootObject());
 
105
    dummyItem->setAcceptedMouseButtons(Qt::LeftButton);
 
106
 
 
107
    TouchDispatcher touchDispatcher;
 
108
    touchDispatcher.setTargetItem(dummyItem);
 
109
 
 
110
    bool gotDoubleClickEvent = false;
 
111
    dummyItem->mouseDoubleClickEventHandler = [&](QMouseEvent *event) {
 
112
        gotDoubleClickEvent = true;
 
113
        event->accept();
 
114
    };
 
115
 
 
116
    dummyItem->touchEventHandler = [&](QTouchEvent *event) {
 
117
        event->ignore();
 
118
    };
 
119
 
 
120
    ulong doubleClickInterval = static_cast<ulong>(qApp->styleHints()->mouseDoubleClickInterval());
 
121
 
 
122
    QList<QTouchEvent::TouchPoint> touchPoints;
 
123
    {
 
124
        QTouchEvent::TouchPoint touchPoint;
 
125
        touchPoint.setId(0);
 
126
        touchPoint.setState(Qt::TouchPointPressed);
 
127
        touchPoints.append(touchPoint);
 
128
    }
 
129
    ulong timestamp = 12345;
 
130
 
 
131
    touchDispatcher.dispatch(QEvent::TouchBegin, m_device, Qt::NoModifier, touchPoints, m_view, timestamp);
 
132
 
 
133
    touchPoints[0].setState(Qt::TouchPointReleased);
 
134
    timestamp += doubleClickInterval / 10;
 
135
 
 
136
    touchDispatcher.dispatch(QEvent::TouchEnd, m_device, Qt::NoModifier, touchPoints, m_view, timestamp);
 
137
 
 
138
    touchPoints[0].setId(1);
 
139
    touchPoints[0].setState(Qt::TouchPointPressed);
 
140
    timestamp += timeBetweenClicks;
 
141
 
 
142
    touchDispatcher.dispatch(QEvent::TouchBegin, m_device, Qt::NoModifier, touchPoints, m_view, timestamp);
 
143
 
 
144
    QCOMPARE(gotDoubleClickEvent, shouldSendDoubleClick);
 
145
}
 
146
 
88
147
QTEST_MAIN(tst_TouchDispatcher)
89
148
 
90
149
#include "tst_TouchDispatcher.moc"