on xenial help sign in
cleanup
3b4a836Michael Zanetti
plugins/UInput/uinput.cpp+1−2
@@ -32,7 +32,6 @@ UInput::UInput(QObject *parent) :
32 m_uinput_mouse_dev.id.bustype = BUS_USB;
32 m_uinput_mouse_dev.id.bustype = BUS_USB;
33 m_uinput_mouse_dev.id.version = 1;
33 m_uinput_mouse_dev.id.version = 1;
34 strncpy(m_uinput_mouse_dev.name, m_devName.toLocal8Bit().data(), m_devName.length());
34 strncpy(m_uinput_mouse_dev.name, m_devName.toLocal8Bit().data(), m_devName.length());
35−
36}
35}
37
36
38UInput::~UInput()
37UInput::~UInput()
@@ -91,7 +90,7 @@ void UInput::removeMouse()
91 }
90 }
92
91
93 if (!m_uinput.isOpen() && !m_uinput.open(QFile::WriteOnly)) {
92 if (!m_uinput.isOpen() && !m_uinput.open(QFile::WriteOnly)) {
94− qDebug() << "cannot open uinput... ";
93+ qWarning() << "cannot open uinput... ";
95 return;
94 return;
96 }
95 }
97
96
plugins/UInput/uinput.h+1−1
@@ -36,7 +36,7 @@ public:
36 ButtonMiddle
36 ButtonMiddle
37 };
37 };
38
38
39− explicit UInput(QObject *parent = 0);
39+ explicit UInput(QObject *parent = nullptr);
40 ~UInput();
40 ~UInput();
41
41
42 Q_INVOKABLE void createMouse();
42 Q_INVOKABLE void createMouse();
qml/Components/VirtualTouchPad.qml−1
@@ -34,7 +34,6 @@ Item {
34 property bool pressed: false
34 property bool pressed: false
35
35
36 onPressed: {
36 onPressed: {
37− print("pressed", point1.pressed, point2.pressed)
38 // If double-tapping *really* fast, it could happen that we end up having only point2 pressed
37 // If double-tapping *really* fast, it could happen that we end up having only point2 pressed
39 // Make sure we check for both combos, only point1 or only point2
38 // Make sure we check for both combos, only point1 or only point2
40 if (((point1.pressed && !point2.pressed) || (!point1.pressed && point2.pressed))
39 if (((point1.pressed && !point2.pressed) || (!point1.pressed && point2.pressed))
tests/mocks/UInput/CMakeLists.txt+1−1
@@ -1,6 +1,6 @@
1add_library(FakeUInput-qml MODULE
1add_library(FakeUInput-qml MODULE
2 plugin.cpp
2 plugin.cpp
3− uinput.cpp
3+ mockuinput.cpp
4)
4)
5
5
6qt5_use_modules(FakeUInput-qml Qml)
6qt5_use_modules(FakeUInput-qml Qml)
tests/mocks/UInput/uinput.cpp → tests/mocks/UInput/mockuinput.cpprenamed+9−16
@@ -15,7 +15,7 @@
15 */
15 */
16
16
17
17
18−#include "uinput.h"
18+#include "mockuinput.h"
19
19
20#include <QFile>
20#include <QFile>
21#include <QDebug>
21#include <QDebug>
@@ -23,16 +23,16 @@
23
23
24#include <unistd.h>
24#include <unistd.h>
25
25
26−UInput::UInput(QObject *parent) :
26+MockUInput::MockUInput(QObject *parent) :
27 QObject(parent)
27 QObject(parent)
28{
28{
29}
29}
30
30
31−UInput::~UInput()
31+MockUInput::~MockUInput()
32{
32{
33}
33}
34
34
35−void UInput::createMouse()
35+void MockUInput::createMouse()
36{
36{
37 if (m_mouseCreated) {
37 if (m_mouseCreated) {
38 qDebug() << "Already have a virtual device. Not creating another one.";
38 qDebug() << "Already have a virtual device. Not creating another one.";
@@ -42,7 +42,7 @@ void UInput::createMouse()
42 Q_EMIT mouseCreated();
42 Q_EMIT mouseCreated();
43}
43}
44
44
45−void UInput::removeMouse()
45+void MockUInput::removeMouse()
46{
46{
47 if (!m_mouseCreated) {
47 if (!m_mouseCreated) {
48 return;
48 return;
@@ -52,31 +52,24 @@ void UInput::removeMouse()
52 Q_EMIT mouseRemoved();
52 Q_EMIT mouseRemoved();
53}
53}
54
54
55−void UInput::moveMouse(int dx, int dy)
55+void MockUInput::moveMouse(int dx, int dy)
56{
56{
57− qDebug() << "moving mouse" << dx << dy;
58 Q_EMIT mouseMoved(dx, dy);
57 Q_EMIT mouseMoved(dx, dy);
59}
58}
60
59
61−void UInput::pressMouse(Button button)
60+void MockUInput::pressMouse(Button button)
62{
61{
63 injectMouse(button, 1);
62 injectMouse(button, 1);
64 Q_EMIT mousePressed(button);
63 Q_EMIT mousePressed(button);
65}
64}
66
65
67−void UInput::releaseMouse(Button button)
66+void MockUInput::releaseMouse(Button button)
68{
67{
69 injectMouse(button, 0);
68 injectMouse(button, 0);
70 Q_EMIT mouseReleased(button);
69 Q_EMIT mouseReleased(button);
71}
70}
72
71
73−void UInput::scrollMouse(int dh, int dv)
72+void MockUInput::scrollMouse(int dh, int dv)
74{
73{
75− qDebug() << "scrolling" << dh << dv;
76 Q_EMIT mouseScrolled(dh, dv);
74 Q_EMIT mouseScrolled(dh, dv);
77}
75}
78−
79−void UInput::injectMouse(Button button, int down)
80−{
81− qDebug() << "mouse event" << button << down;
82−}
tests/mocks/UInput/uinput.h → tests/mocks/UInput/mockuinput.hrenamed+5−8
@@ -15,8 +15,8 @@
15 */
15 */
16
16
17
17
18−#ifndef UINPUT_H
18+#ifndef MOCKUINPUT_H
19−#define UINPUT_H
19+#define MOCKUINPUT_H
20
20
21#include <QObject>
21#include <QObject>
22#include <QFile>
22#include <QFile>
@@ -24,7 +24,7 @@
24#include <linux/uinput.h>
24#include <linux/uinput.h>
25
25
26
26
27−class UInput : public QObject
27+class MockUInput : public QObject
28{
28{
29 Q_OBJECT
29 Q_OBJECT
30 Q_ENUMS(Button)
30 Q_ENUMS(Button)
@@ -36,7 +36,7 @@ public:
36 ButtonMiddle
36 ButtonMiddle
37 };
37 };
38
38
39− explicit UInput(QObject *parent = 0);
39+ explicit MockUInput(QObject *parent = 0);
40 ~UInput();
40 ~UInput();
41
41
42 Q_INVOKABLE void createMouse();
42 Q_INVOKABLE void createMouse();
@@ -56,11 +56,8 @@ Q_SIGNALS:
56 void mouseReleased(Button button);
56 void mouseReleased(Button button);
57 void mouseScrolled(int dh, int dv);
57 void mouseScrolled(int dh, int dv);
58
58
59−private:
60− void injectMouse(Button button, int down);
61−
62private:
59private:
63 bool m_mouseCreated = false;
60 bool m_mouseCreated = false;
64};
61};
65
62
66−#endif // UINPUT_H
63+#endif // MOCKUINPUT_H
tests/mocks/UInput/plugin.cpp+2−2
@@ -15,12 +15,12 @@
15 */
15 */
16
16
17#include "plugin.h"
17#include "plugin.h"
18−#include "uinput.h"
18+#include "mockuinput.h"
19
19
20#include <QtQml/qqml.h>
20#include <QtQml/qqml.h>
21
21
22void UInputPlugin::registerTypes(const char *uri)
22void UInputPlugin::registerTypes(const char *uri)
23{
23{
24 Q_ASSERT(uri == QLatin1String("UInput"));
24 Q_ASSERT(uri == QLatin1String("UInput"));
25− qmlRegisterType<UInput>(uri, 0, 1, "UInput");
25+ qmlRegisterType<MockUInput>(uri, 0, 1, "UInput");
26}
26}
tests/mocks/UInput/plugin.h+3−3
@@ -14,13 +14,13 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17−#ifndef UINPUT_PLUGIN_H
17+#ifndef MOCKUINPUT_PLUGIN_H
18−#define UINPUT_PLUGIN_H
18+#define MOCKUINPUT_PLUGIN_H
19
19
20#include <QtQml/QQmlEngine>
20#include <QtQml/QQmlEngine>
21#include <QtQml/QQmlExtensionPlugin>
21#include <QtQml/QQmlExtensionPlugin>
22
22
23−class UInputPlugin : public QQmlExtensionPlugin
23+class MockUInputPlugin : public QQmlExtensionPlugin
24{
24{
25 Q_OBJECT
25 Q_OBJECT
26 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")