on xenial help sign in
cleanup
commit3b4a836bf515dea524ecd381a79e67d7c4846e7a authorMichael Zanetti <michael.zanetti@canonical.com> dateMon 23 Nov 2015, 17:44 (11 years ago) parent9d2abac
8 files changed+22−34
plugins/UInput/uinput.cpp+1−2 plugins/UInput/uinput.h+1−1 qml/Components/VirtualTouchPad.qml−1 tests/mocks/UInput/CMakeLists.txt+1−1 tests/mocks/UInput/uinput.cpp → tests/mocks/UInput/mockuinput.cpp+9−16 tests/mocks/UInput/uinput.h → tests/mocks/UInput/mockuinput.h+5−8 tests/mocks/UInput/plugin.cpp+2−2 tests/mocks/UInput/plugin.h+3−3
plugins/UInput/uinput.cpp+1−2
@@ -32,7 +32,6 @@ UInput::UInput(QObject *parent) :
3232 m_uinput_mouse_dev.id.bustype = BUS_USB;
3333 m_uinput_mouse_dev.id.version = 1;
3434 strncpy(m_uinput_mouse_dev.name, m_devName.toLocal8Bit().data(), m_devName.length());
35−
3635}
3736
3837UInput::~UInput()
@@ -91,7 +90,7 @@ void UInput::removeMouse()
9190 }
9291
9392 if (!m_uinput.isOpen() && !m_uinput.open(QFile::WriteOnly)) {
94− qDebug() << "cannot open uinput... ";
93+ qWarning() << "cannot open uinput... ";
9594 return;
9695 }
9796
plugins/UInput/uinput.h+1−1
@@ -36,7 +36,7 @@ public:
3636 ButtonMiddle
3737 };
3838
39− explicit UInput(QObject *parent = 0);
39+ explicit UInput(QObject *parent = nullptr);
4040 ~UInput();
4141
4242 Q_INVOKABLE void createMouse();
qml/Components/VirtualTouchPad.qml−1
@@ -34,7 +34,6 @@ Item {
3434 property bool pressed: false
3535
3636 onPressed: {
37− print("pressed", point1.pressed, point2.pressed)
3837 // If double-tapping *really* fast, it could happen that we end up having only point2 pressed
3938 // Make sure we check for both combos, only point1 or only point2
4039 if (((point1.pressed && !point2.pressed) || (!point1.pressed && point2.pressed))
tests/mocks/UInput/CMakeLists.txt+1−1
@@ -1,6 +1,6 @@
11add_library(FakeUInput-qml MODULE
22 plugin.cpp
3− uinput.cpp
3+ mockuinput.cpp
44)
55
66qt5_use_modules(FakeUInput-qml Qml)
tests/mocks/UInput/uinput.cpp → tests/mocks/UInput/mockuinput.cpprenamed+9−16
@@ -15,7 +15,7 @@
1515 */
1616
1717
18−#include "uinput.h"
18+#include "mockuinput.h"
1919
2020#include <QFile>
2121#include <QDebug>
@@ -23,16 +23,16 @@
2323
2424#include <unistd.h>
2525
26−UInput::UInput(QObject *parent) :
26+MockUInput::MockUInput(QObject *parent) :
2727 QObject(parent)
2828{
2929}
3030
31−UInput::~UInput()
31+MockUInput::~MockUInput()
3232{
3333}
3434
35−void UInput::createMouse()
35+void MockUInput::createMouse()
3636{
3737 if (m_mouseCreated) {
3838 qDebug() << "Already have a virtual device. Not creating another one.";
@@ -42,7 +42,7 @@ void UInput::createMouse()
4242 Q_EMIT mouseCreated();
4343}
4444
45−void UInput::removeMouse()
45+void MockUInput::removeMouse()
4646{
4747 if (!m_mouseCreated) {
4848 return;
@@ -52,31 +52,24 @@ void UInput::removeMouse()
5252 Q_EMIT mouseRemoved();
5353}
5454
55−void UInput::moveMouse(int dx, int dy)
55+void MockUInput::moveMouse(int dx, int dy)
5656{
57− qDebug() << "moving mouse" << dx << dy;
5857 Q_EMIT mouseMoved(dx, dy);
5958}
6059
61−void UInput::pressMouse(Button button)
60+void MockUInput::pressMouse(Button button)
6261{
6362 injectMouse(button, 1);
6463 Q_EMIT mousePressed(button);
6564}
6665
67−void UInput::releaseMouse(Button button)
66+void MockUInput::releaseMouse(Button button)
6867{
6968 injectMouse(button, 0);
7069 Q_EMIT mouseReleased(button);
7170}
7271
73−void UInput::scrollMouse(int dh, int dv)
72+void MockUInput::scrollMouse(int dh, int dv)
7473{
75− qDebug() << "scrolling" << dh << dv;
7674 Q_EMIT mouseScrolled(dh, dv);
7775}
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 @@
1515 */
1616
1717
18−#ifndef UINPUT_H
19−#define UINPUT_H
18+#ifndef MOCKUINPUT_H
19+#define MOCKUINPUT_H
2020
2121#include <QObject>
2222#include <QFile>
@@ -24,7 +24,7 @@
2424#include <linux/uinput.h>
2525
2626
27−class UInput : public QObject
27+class MockUInput : public QObject
2828{
2929 Q_OBJECT
3030 Q_ENUMS(Button)
@@ -36,7 +36,7 @@ public:
3636 ButtonMiddle
3737 };
3838
39− explicit UInput(QObject *parent = 0);
39+ explicit MockUInput(QObject *parent = 0);
4040 ~UInput();
4141
4242 Q_INVOKABLE void createMouse();
@@ -56,11 +56,8 @@ Q_SIGNALS:
5656 void mouseReleased(Button button);
5757 void mouseScrolled(int dh, int dv);
5858
59−private:
60− void injectMouse(Button button, int down);
61−
6259private:
6360 bool m_mouseCreated = false;
6461};
6562
66−#endif // UINPUT_H
63+#endif // MOCKUINPUT_H
tests/mocks/UInput/plugin.cpp+2−2
@@ -15,12 +15,12 @@
1515 */
1616
1717#include "plugin.h"
18−#include "uinput.h"
18+#include "mockuinput.h"
1919
2020#include <QtQml/qqml.h>
2121
2222void UInputPlugin::registerTypes(const char *uri)
2323{
2424 Q_ASSERT(uri == QLatin1String("UInput"));
25− qmlRegisterType<UInput>(uri, 0, 1, "UInput");
25+ qmlRegisterType<MockUInput>(uri, 0, 1, "UInput");
2626}
tests/mocks/UInput/plugin.h+3−3
@@ -14,13 +14,13 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17−#ifndef UINPUT_PLUGIN_H
18−#define UINPUT_PLUGIN_H
17+#ifndef MOCKUINPUT_PLUGIN_H
18+#define MOCKUINPUT_PLUGIN_H
1919
2020#include <QtQml/QQmlEngine>
2121#include <QtQml/QQmlExtensionPlugin>
2222
23−class UInputPlugin : public QQmlExtensionPlugin
23+class MockUInputPlugin : public QQmlExtensionPlugin
2424{
2525 Q_OBJECT
2626 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")