~dandrader/qtmir/frozenApps-lp1295623

« back to all changes in this revision

Viewing changes to tests/mirserver/QtEventFeeder/mock_qtwindowsystem.h

  • Committer: CI bot
  • Author(s): Daniel d'Andrada
  • Date: 2014-09-07 19:42:14 UTC
  • mfrom: (239.1.6 missingTouchEnd-lp1295623)
  • Revision ID: ps-jenkins@lists.canonical.com-20140907194214-1eq13l827gavf65i
QtEventFeeder: validate touches before sending them to Qt

Make sure we send a tidy touch event stream to Qt as some of it
(QQuickWindow) is vulnerable to things like missing touch releases.

Also properly ignore unsupported motion event actions such as hovering.
 Fixes: 1295623
Approved by: Gerry Boland, PS Jenkins bot

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2014 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it under
 
5
 * the terms of the GNU Lesser General Public License version 3, as published by
 
6
 * the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but WITHOUT
 
9
 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
 
10
 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
11
 * Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 */
 
17
 
 
18
#ifndef MOCK_QTWINDOWSYSTEM_H
 
19
#define MOCK_QTWINDOWSYSTEM_H
 
20
 
 
21
#include <qteventfeeder.h>
 
22
 
 
23
class MockQtWindowSystem : public QtEventFeeder::QtWindowSystemInterface {
 
24
public:
 
25
    MOCK_METHOD0(hasTargetWindow, bool());
 
26
    MOCK_METHOD0(targetWindowGeometry, QRect());
 
27
    MOCK_METHOD1(registerTouchDevice, void(QTouchDevice* device));
 
28
    MOCK_METHOD10(handleExtendedKeyEvent, void(ulong timestamp, QEvent::Type type, int key,
 
29
            Qt::KeyboardModifiers modifiers,
 
30
            quint32 nativeScanCode, quint32 nativeVirtualKey,
 
31
            quint32 nativeModifiers,
 
32
            const QString& text, bool autorep,
 
33
            ushort count));
 
34
    MOCK_METHOD4(handleTouchEvent, void(ulong timestamp, QTouchDevice *device,
 
35
            const QList<struct QWindowSystemInterface::TouchPoint> &points,
 
36
            Qt::KeyboardModifiers mods));
 
37
};
 
38
 
 
39
namespace testing
 
40
{
 
41
 
 
42
MATCHER(IsPressed, std::string(negation ? "isn't" : "is") + " pressed")
 
43
{
 
44
    return arg.state == Qt::TouchPointPressed;
 
45
}
 
46
 
 
47
MATCHER(IsReleased, std::string(negation ? "isn't" : "is") + " released")
 
48
{
 
49
    return arg.state == Qt::TouchPointReleased;
 
50
}
 
51
 
 
52
MATCHER(StateIsMoved, "state " + std::string(negation ? "isn't" : "is") + " 'moved'")
 
53
{
 
54
    return arg.state == Qt::TouchPointMoved;
 
55
}
 
56
 
 
57
MATCHER_P(HasId, expectedId, "id " + std::string(negation ? "isn't " : "is ") + PrintToString(expectedId))
 
58
{
 
59
    return arg.id == expectedId;
 
60
}
 
61
 
 
62
} // namespace testing
 
63
 
 
64
 
 
65
#endif // MOCK_QTWINDOWSYSTEM_H