on xenial help sign in
update tests
commit2e9b2482797303b7ba6402e28af65c4b8455bdbb authorMichael Zanetti <michael.zanetti@canonical.com> dateThu 22 Oct 2015, 12:14 (11 years ago) parent02d63fe
11 files changed+122−457
plugins/Unity/InputInfo/qinputinfo.cpp+3−1 qml/OrientedShell.qml+17−7 tests/mocks/Unity/InputInfo/CMakeLists.txt+6−2 tests/mocks/Unity/InputInfo/mockqdeclarativeinputdeviceinfo.cpp−173 tests/mocks/Unity/InputInfo/mockqinputinfo.h−139 tests/mocks/Unity/InputInfo/plugin.cpp+12−2 tests/mocks/Unity/InputInfo/mockqinputinfo.cpp → tests/mocks/Unity/InputInfo/qinputdeviceinfo_mock.cpp+27−71 tests/mocks/Unity/InputInfo/mockqdeclarativeinputdeviceinfo_p.h → tests/mocks/Unity/InputInfo/qinputdeviceinfo_mock_p.h+30−41 tests/qmltests/Notifications/tst_Notifications.qml+5−6 tests/qmltests/Notifications/tst_SwipeToAct.qml+5−6 tests/qmltests/tst_OrientedShell.qml+17−9
plugins/Unity/InputInfo/qinputinfo.cpp+3−1
@@ -41,7 +41,9 @@
4141
4242#include "qinputinfo.h"
4343
44−#if defined(Q_OS_LINUX)
44+#if defined(UNITY_MOCKS)
45+#include "qinputdeviceinfo_mock.h"
46+#elif defined(Q_OS_LINUX)
4547#include "linux/qinputdeviceinfo_linux_p.h"
4648#endif
4749
qml/OrientedShell.qml+17−7
@@ -16,13 +16,12 @@
1616
1717import QtQuick 2.0
1818import QtQuick.Window 2.0
19+import Unity.InputInfo 0.1
1920import Unity.Session 0.1
2021import GSettings 1.0
2122import "Components"
22−import "Components/UnityInputInfo"
2323import "Rotation"
24−// Backup Workaround https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1473471
25−// in case we remove the UnityInputInfo import
24+// Workaround https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1473471
2625import Ubuntu.Components 1.2
2726
2827Rectangle {
@@ -53,6 +52,17 @@ Rectangle {
5352 property bool orientationLocked: OrientationLock.enabled
5453 property var orientationLock: OrientationLock
5554
55+ InputDeviceModel {
56+ id: miceModel
57+ deviceFilter: InputInfo.Mouse
58+ onCountChanged: print("*****************", count)
59+ }
60+
61+ InputDeviceModel {
62+ id: keyboardsModel
63+ deviceFilter: InputInfo.Keyboard
64+ }
65+
5666 property int orientation
5767 onPhysicalOrientationChanged: {
5868 if (!orientationLocked) {
@@ -72,14 +82,14 @@ Rectangle {
7282 }
7383 // We need to manually update this on startup as the binding
7484 // below doesn't seem to have any effect at that stage
75− oskSettings.stayHidden = UnityInputInfo.keyboards > 0
85+ oskSettings.stayHidden = keyboardsModel.count > 0
7686 oskSettings.disableHeight = shell.usageScenario == "desktop"
7787 }
7888
7989 Binding {
8090 target: oskSettings
8191 property: "stayHidden"
82− value: UnityInputInfo.keyboards > 0
92+ value: keyboardsModel.count > 0
8393 }
8494
8595 Binding {
@@ -155,7 +165,7 @@ Rectangle {
155165 nativeWidth: root.width
156166 nativeHeight: root.height
157167 mode: applicationArguments.mode
158− hasMouse: UnityInputInfo.mice > deviceConfiguration.ignoredMice
168+ hasMouse: miceModel.count > deviceConfiguration.ignoredMice
159169
160170 // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
161171 // what's the output device (eg: big TV, desktop monitor, phone display), etc.
@@ -169,7 +179,7 @@ Rectangle {
169179 return "tablet";
170180 }
171181 } else { // automatic
172− if (UnityInputInfo.mice > deviceConfiguration.ignoredMice) {
182+ if (miceModel.count > deviceConfiguration.ignoredMice) {
173183 return "desktop";
174184 } else {
175185 return deviceConfiguration.category;
tests/mocks/Unity/InputInfo/CMakeLists.txt+6−2
@@ -9,12 +9,16 @@ find_package(Qt5Quick REQUIRED)
99include_directories(
1010 ${CMAKE_CURRENT_SOURCE_DIR}
1111 ${CMAKE_CURRENT_BINARY_DIR}
12+ ${CMAKE_SOURCE_DIR}/plugins/Unity/InputInfo/
1213)
1314
15+add_definitions(-DUNITY_MOCKS)
16+
1417set(MockInputInfo_SOURCES
1518 plugin.cpp
16− mockqinputinfo.cpp
17− mockqdeclarativeinputdeviceinfo.cpp
19+ qinputdeviceinfo_mock.cpp
20+ ${CMAKE_SOURCE_DIR}/plugins/Unity/InputInfo/qinputinfo.cpp
21+ ${CMAKE_SOURCE_DIR}/plugins/Unity/InputInfo/qdeclarativeinputdevicemodel.cpp
1822)
1923
2024add_library(MockInputInfo SHARED
tests/mocks/Unity/InputInfo/mockqdeclarativeinputdeviceinfo.cppdeleted−173
@@ -1,173 +0,0 @@
1−/****************************************************************************
2−**
3−** Copyright (C) 2015 Jolla.
4−** Copyright (C) 2015 Canonical Ltd.
5−** Contact: http://www.qt-project.org/legal
6−**
7−** This file is part of the QtSystems module of the Qt Toolkit.
8−**
9−** $QT_BEGIN_LICENSE:LGPL$
10−** Commercial License Usage
11−** Licensees holding valid commercial Qt licenses may use this file in
12−** accordance with the commercial license agreement provided with the
13−** Software or, alternatively, in accordance with the terms contained in
14−** a written agreement between you and Digia. For licensing terms and
15−** conditions see http://qt.digia.com/licensing. For further information
16−** use the contact form at http://qt.digia.com/contact-us.
17−**
18−** GNU Lesser General Public License Usage
19−** Alternatively, this file may be used under the terms of the GNU Lesser
20−** General Public License version 2.1 as published by the Free Software
21−** Foundation and appearing in the file LICENSE.LGPL included in the
22−** packaging of this file. Please review the following information to
23−** ensure the GNU Lesser General Public License version 2.1 requirements
24−** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25−**
26−** In addition, as a special exception, Digia gives you certain additional
27−** rights. These rights are described in the Digia Qt LGPL Exception
28−** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29−**
30−** GNU General Public License Usage
31−** Alternatively, this file may be used under the terms of the GNU
32−** General Public License version 3.0 as published by the Free Software
33−** Foundation and appearing in the file LICENSE.GPL included in the
34−** packaging of this file. Please review the following information to
35−** ensure the GNU General Public License version 3.0 requirements will be
36−** met: http://www.gnu.org/copyleft/gpl.html.
37−**
38−**
39−** $QT_END_LICENSE$
40−**
41−****************************************************************************/
42−#include "mockqdeclarativeinputdeviceinfo_p.h"
43−
44−QDeclarativeInputDeviceInfo::QDeclarativeInputDeviceInfo(QObject *parent) :
45− QAbstractListModel(parent),
46− deviceInfo(new QInputDeviceInfo)
47−{
48− connect(deviceInfo, &QInputDeviceInfo::deviceAdded,this,&QDeclarativeInputDeviceInfo::addedDevice);
49− connect(deviceInfo, &QInputDeviceInfo::deviceRemoved,this,&QDeclarativeInputDeviceInfo::removedDevice);
50−}
51−
52−QDeclarativeInputDeviceInfo::~QDeclarativeInputDeviceInfo()
53−{
54− delete deviceInfo;
55−}
56−
57−QVariant QDeclarativeInputDeviceInfo::data(const QModelIndex &index, int role) const
58−{
59− switch (role) {
60− case ServiceRole:
61− return QVariant::fromValue(static_cast<QObject *>(inputDevices.value(index.row())));
62− }
63−
64− return QVariant();
65−}
66−
67−int QDeclarativeInputDeviceInfo::rowCount(const QModelIndex &parent) const
68−{
69− Q_UNUSED(parent);
70−
71− return inputDevices.count();
72−}
73−
74−int QDeclarativeInputDeviceInfo::indexOf(const QString &devicePath) const
75−{
76− int idx(-1);
77− Q_FOREACH (QInputDevice *device, inputDevices) {
78− idx++;
79− if (device->devicePath() == devicePath) return idx;
80− }
81−
82− return -1;
83−}
84−
85−QInputDevice *QDeclarativeInputDeviceInfo::get(int index) const
86−{
87− if (index < 0 || index > inputDevices.count())
88− return 0;
89− return inputDevices.value(index);
90−}
91−
92−void QDeclarativeInputDeviceInfo::addMockMouse()
93−{
94− deviceInfo->addMockDevice(QInputDeviceInfo::Mouse);
95−}
96−
97−void QDeclarativeInputDeviceInfo::addMockKeyboard()
98−{
99− deviceInfo->addMockDevice(QInputDeviceInfo::Keyboard);
100−}
101−
102−void QDeclarativeInputDeviceInfo::removeMockMouse()
103−{
104− for (int i = 0; i < inputDevices.count(); i++) {
105− if (inputDevices.at(i)->types().testFlag(QInputDeviceInfo::Mouse)) {
106− deviceInfo->removeMockDevice(i);
107− return;
108− }
109− }
110−}
111−
112−void QDeclarativeInputDeviceInfo::removeMockKeyboard()
113−{
114− for (int i = 0; i < inputDevices.count(); i++) {
115− if (inputDevices.at(i)->types().testFlag(QInputDeviceInfo::Keyboard)) {
116− deviceInfo->removeMockDevice(i);
117− return;
118− }
119− }
120−}
121−
122−void QDeclarativeInputDeviceInfo::updateDeviceList()
123−{
124− QVector <QInputDevice *> newDevices = deviceInfo->deviceList();
125−
126− int numNew = newDevices.count();
127−
128− for (int i = 0; i < numNew; i++) {
129− int j = inputDevices.indexOf(newDevices.value(i));
130− if (j == -1) {
131− // not found -> remove from list
132− beginInsertRows(QModelIndex(), i, i);
133− inputDevices.insert(i, newDevices.value(i));
134− endInsertRows();
135− } else if (i != j) {
136− // changed its position -> move it
137− QInputDevice* device = inputDevices.value(j);
138− beginMoveRows(QModelIndex(), j, j, QModelIndex(), i);
139− inputDevices.remove(j);
140− inputDevices.insert(i, device);
141− endMoveRows();
142− } else {
143− QModelIndex changedIndex(this->index(j, 0, QModelIndex()));
144− Q_EMIT dataChanged(changedIndex, changedIndex);
145− }
146− }
147−
148− int numOld = inputDevices.count();
149− if (numOld > numNew) {
150− beginRemoveRows(QModelIndex(), numNew, numOld - 1);
151− inputDevices.remove(numNew, numOld - numNew);
152− endRemoveRows();
153− }
154−}
155−
156−void QDeclarativeInputDeviceInfo::addedDevice(const QString &devicePath)
157−{
158− updateDeviceList();
159− Q_EMIT newDevice(devicePath);
160−}
161−
162−void QDeclarativeInputDeviceInfo::removedDevice(const QString &devicePath)
163−{
164− updateDeviceList();
165− Q_EMIT deviceRemoved(devicePath);
166−}
167−
168−QHash<int, QByteArray> QDeclarativeInputDeviceInfo::roleNames() const
169−{
170− QHash<int, QByteArray> roles;
171− roles.insert(ServiceRole, "service");
172− return roles;
173−}
tests/mocks/Unity/InputInfo/mockqinputinfo.hdeleted−139
@@ -1,139 +0,0 @@
1−/****************************************************************************
2−**
3−** Copyright (C) 2015 Canonical, Ltd. and/or its subsidiary(-ies).
4−** Contact: http://www.qt-project.org/legal
5−**
6−** This file is part of the QtSystems module of the Qt Toolkit.
7−**
8−** $QT_BEGIN_LICENSE:LGPL$
9−** Commercial License Usage
10−** Licensees holding valid commercial Qt licenses may use this file in
11−** accordance with the commercial license agreement provided with the
12−** Software or, alternatively, in accordance with the terms contained in
13−** a written agreement between you and Digia. For licensing terms and
14−** conditions see http://qt.digia.com/licensing. For further information
15−** use the contact form at http://qt.digia.com/contact-us.
16−**
17−** GNU Lesser General Public License Usage
18−** Alternatively, this file may be used under the terms of the GNU Lesser
19−** General Public License version 2.1 as published by the Free Software
20−** Foundation and appearing in the file LICENSE.LGPL included in the
21−** packaging of this file. Please review the following information to
22−** ensure the GNU Lesser General Public License version 2.1 requirements
23−** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24−**
25−** In addition, as a special exception, Digia gives you certain additional
26−** rights. These rights are described in the Digia Qt LGPL Exception
27−** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28−**
29−** GNU General Public License Usage
30−** Alternatively, this file may be used under the terms of the GNU
31−** General Public License version 3.0 as published by the Free Software
32−** Foundation and appearing in the file LICENSE.GPL included in the
33−** packaging of this file. Please review the following information to
34−** ensure the GNU General Public License version 3.0 requirements will be
35−** met: http://www.gnu.org/copyleft/gpl.html.
36−**
37−**
38−** $QT_END_LICENSE$
39−**
40−****************************************************************************/
41−
42−#ifndef MOCKQINPUTINFO_H
43−#define MOCKQINPUTINFO_H
44−
45−#include <QObject>
46−#include <QVector>
47−#include <QMap>
48−#include <QSocketNotifier>
49−#include <QDebug>
50−
51−class QInputDevicePrivate;
52−class QInputDevice;
53−
54−class QInputDeviceInfoPrivate;
55−class QInputDeviceInfo : public QObject
56−{
57− Q_OBJECT
58− Q_PROPERTY(int deviceCount READ deviceCount)
59−public:
60−
61− enum InputType {
62− Unknown = 0,
63− Button = 1,
64− Mouse = 2,
65− TouchPad = 4,
66− TouchScreen = 8,
67− Keyboard = 16,
68− Switch = 32
69− };
70− Q_ENUMS(InputType)
71− Q_FLAGS(InputTypes)
72− Q_DECLARE_FLAGS(InputTypes, InputType)
73−
74− explicit QInputDeviceInfo(QObject *parent = 0);
75−
76− Q_INVOKABLE QVector <QInputDevice *> deviceList();
77−
78− int deviceCount() { return deviceList().count(); }
79−
80− Q_INVOKABLE void addMockDevice(InputType inputType);
81− Q_INVOKABLE void removeMockDevice(int index);
82−
83−Q_SIGNALS:
84−
85− void deviceAdded(const QString & devicePath);
86− void deviceRemoved(const QString & devicePath);
87−
88−private:
89− QVector<QInputDevice*> m_list;
90−
91− int m_counter = 0;
92−};
93−
94−class QInputDevice : public QObject
95−{
96− friend class QInputDeviceInfoPrivate;
97− Q_OBJECT
98− Q_ENUMS(InputType)
99− Q_FLAGS(InputTypes)
100− Q_PROPERTY(QString name READ name NOTIFY nameChanged)
101− Q_PROPERTY(QString devicePath READ devicePath NOTIFY devicePathChanged)
102− Q_PROPERTY(QList <int> buttons READ buttons NOTIFY buttonsChanged)
103− Q_PROPERTY(QList <int> switches READ switches NOTIFY switchesChanged)
104− Q_PROPERTY(QList <int> relativeAxis READ relativeAxis NOTIFY relativeAxisChanged)
105− Q_PROPERTY(QList <int> absoluteAxis READ absoluteAxis NOTIFY absoluteAxisChanged)
106− Q_PROPERTY(QInputDeviceInfo::InputTypes types READ types NOTIFY typesChanged)
107−
108−public:
109− explicit QInputDevice(QObject *parent = 0);
110−
111− QString name() const;
112− QString devicePath() const;
113− QList <int> buttons() const; //keys event code
114− QList <int> switches() const;
115− QList <int> relativeAxis() const;
116− QList <int> absoluteAxis() const;
117−
118− QInputDeviceInfo::InputTypes types();
119−Q_SIGNALS:
120− void nameChanged();
121− void devicePathChanged();
122− void buttonsChanged();
123− void switchesChanged();
124− void relativeAxisChanged();
125− void absoluteAxisChanged();
126− void typesChanged();
127−private:
128− void setName(const QString &name);
129− void setTypes(QInputDeviceInfo::InputTypes types);
130− void setDevicePath(const QString &path);
131−
132− QString m_name;
133− QInputDeviceInfo::InputTypes m_types;
134− QString m_devicePath;
135−
136− friend class QInputDeviceInfo;
137−};
138−
139−#endif // MOCKQINPUTINFO_H
tests/mocks/Unity/InputInfo/plugin.cpp+12−2
@@ -21,12 +21,22 @@
2121#include "plugin.h"
2222
2323// local
24−#include "mockqdeclarativeinputdeviceinfo_p.h"
24+#include "qdeclarativeinputdevicemodel_p.h"
25+#include "qinputdeviceinfo_mock_p.h"
26+
27+static QObject *backendProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
28+{
29+ Q_UNUSED(engine)
30+ Q_UNUSED(scriptEngine)
31+ return QInputDeviceManagerPrivate::instance();
32+}
2533
2634void InputInfoPlugin::registerTypes(const char *uri)
2735{
2836 int major = 0;
2937 int minor = 1;
30− qmlRegisterType<QDeclarativeInputDeviceInfo>(uri, major, minor, "InputDeviceInfo");
38+ qmlRegisterType<QDeclarativeInputDeviceModel>(uri, major, minor, "InputDeviceModel");
3139 qmlRegisterType<QInputDevice>(uri, major, minor, "InputInfo");
40+
41+ qmlRegisterSingletonType<QInputDeviceManagerPrivate>(uri, major, minor, "MockInputDeviceBackend", backendProvider);
3242}
tests/mocks/Unity/InputInfo/mockqinputinfo.cpp → tests/mocks/Unity/InputInfo/qinputdeviceinfo_mock.cpprenamed+27−71
@@ -1,6 +1,6 @@
11/****************************************************************************
22**
3−** Copyright (C) 2015 Canonical, Ltd. and/or its subsidiary(-ies).
3+** Copyright (C) 2014 Canonical, Ltd. and/or its subsidiary(-ies).
44** Contact: http://www.qt-project.org/legal
55**
66** This file is part of the QtSystems module of the Qt Toolkit.
@@ -39,86 +39,42 @@
3939**
4040****************************************************************************/
4141
42−#include "mockqinputinfo.h"
42+#include "qinputdeviceinfo_mock_p.h"
4343
44+#include <QTimer>
45+#include <QDebug>
4446
45−QInputDevice::QInputDevice(QObject *parent) :
46− QObject(parent)
47+QInputDeviceManagerPrivate::QInputDeviceManagerPrivate(QObject *parent) :
48+ QObject(parent),
49+ currentFilter(QInputDevice::Unknown)
4750{
51+ QTimer::singleShot(1, SIGNAL(ready()));
4852}
4953
50−QString QInputDevice::name() const
54+QInputDeviceManagerPrivate::~QInputDeviceManagerPrivate()
5155{
52− return m_name;
5356}
5457
55−void QInputDevice::setName(const QString &name)
58+QInputDevice *QInputDeviceManagerPrivate::addMockDevice(const QString &devicePath, QInputDevice::InputType type)
5659{
57− m_name = name;
60+ QInputDevice *inputDevice = new QInputDevice(this);
61+ inputDevice->setDevicePath(devicePath);
62+ inputDevice->setName("Mock Device " + devicePath);
63+ inputDevice->setType(type);
64+ deviceMap.insert(devicePath, inputDevice);
65+ qDebug() << "Adding mock input device" << devicePath << type;
66+ Q_EMIT deviceAdded(devicePath);
67+ return inputDevice;
5868}
5969
60−QString QInputDevice::devicePath() const
70+void QInputDeviceManagerPrivate::removeDevice(const QString &path)
6171{
62− return m_devicePath;
63−}
64−
65−void QInputDevice::setDevicePath(const QString &path)
66−{
67− m_devicePath = path;
68−}
69−
70−QList <int> QInputDevice::buttons() const
71−{
72− return {1, 2 ,3};
73−}
74−
75−QList <int> QInputDevice::switches() const
76−{
77− return {};
78−}
79−
80−QList <int> QInputDevice::relativeAxis() const
81−{
82− return {};
83−}
84−
85−QList <int> QInputDevice::absoluteAxis() const
86−{
87− return {};
88−}
89−
90−QInputDeviceInfo::InputTypes QInputDevice::types()
91−{
92− return m_types;
93−}
94−
95−void QInputDevice::setTypes(QInputDeviceInfo::InputTypes types)
96−{
97− m_types = types;
98−}
99−
100−QInputDeviceInfo::QInputDeviceInfo(QObject *parent) :
101− QObject(parent)
102−{
103−}
104−
105−QVector <QInputDevice *> QInputDeviceInfo::deviceList()
106−{
107− return m_list;
108−}
109−
110−void QInputDeviceInfo::removeMockDevice(int index)
111−{
112− QInputDevice *device = m_list.takeAt(index);
113− Q_EMIT deviceRemoved(device->devicePath());
114− device->deleteLater();
115−}
116−
117−void QInputDeviceInfo::addMockDevice(QInputDeviceInfo::InputType inputType)
118−{
119− QInputDevice *device = new QInputDevice(this);
120− device->setDevicePath("/mock/device/" + QString::number(m_counter++));
121− device->setTypes({inputType});
122− m_list.append(device);
123− Q_EMIT deviceAdded(device->devicePath());
72+ qDebug() << "should remove" << path;
73+ Q_FOREACH (const QString devicePath, deviceMap.keys()) {
74+ qDebug() << "comparing" << devicePath << path;
75+ if (devicePath.contains(path)) {
76+ deviceMap.remove(devicePath);
77+ Q_EMIT deviceRemoved(devicePath);
78+ }
79+ }
12480}
tests/mocks/Unity/InputInfo/mockqdeclarativeinputdeviceinfo_p.h → tests/mocks/Unity/InputInfo/qinputdeviceinfo_mock_p.hrenamed+30−41
@@ -1,7 +1,6 @@
11/****************************************************************************
22**
3−** Copyright (C) 2015 Jolla.
4−** Copyright (C) 2015 Canoncal Ltd.
3+** Copyright (C) 2014 Canonical, Ltd. and/or its subsidiary(-ies).
54** Contact: http://www.qt-project.org/legal
65**
76** This file is part of the QtSystems module of the Qt Toolkit.
@@ -40,55 +39,45 @@
4039**
4140****************************************************************************/
4241
43−#ifndef QDECLARATIVEINPUTDEVICEINFO_H
44−#define QDECLARATIVEINPUTDEVICEINFO_H
42+#ifndef QINPUTDEVICEINFO_MOCK_H
43+#define QINPUTDEVICEINFO_MOCK_H
4544
4645#include <QObject>
47−#include <QAbstractListModel>
48−#include "mockqinputinfo.h"
46+#include "qinputinfo.h"
4947
50−class QDeclarativeInputDeviceInfo : public QAbstractListModel
48+class QInputDevicePrivate : public QObject
5149{
5250 Q_OBJECT
53− Q_DISABLE_COPY(QDeclarativeInputDeviceInfo)
54−
5551public:
56− enum ItemRoles {
57− ServiceRole = Qt::UserRole + 1
58− };
59−
60− explicit QDeclarativeInputDeviceInfo(QObject *parent = 0);
61− virtual ~QDeclarativeInputDeviceInfo();
62−
63− QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
64− int rowCount(const QModelIndex &parent = QModelIndex()) const;
52+ explicit QInputDevicePrivate(QObject *parent = 0);
6553
66− QHash<int, QByteArray> roleNames() const;
67−
68− Q_INVOKABLE int indexOf(const QString &devicePath) const;
54+ QString name;
55+ QString devicePath;
56+ QList <int> buttons; //keys
57+ QList <int> switches;
58+ QList <int> relativeAxis;
59+ QList <int> absoluteAxis;
60+ QInputDevice::InputTypeFlags type;
61+};
6962
70− Q_INVOKABLE QInputDevice *get(int index) const;
63+class QInputDeviceManagerPrivate : public QObject
64+{
65+ Q_OBJECT
66+public:
67+ explicit QInputDeviceManagerPrivate(QObject *parent = 0);
68+ ~QInputDeviceManagerPrivate();
69+ QVector <QInputDevice *> deviceList;
70+ QMap <QString, QInputDevice *> deviceMap;
71+ static QInputDeviceManagerPrivate * instance();
72+ QInputDevice::InputType currentFilter;
7173
72− // For testing
73− Q_INVOKABLE void addMockMouse();
74− Q_INVOKABLE void addMockKeyboard();
75− Q_INVOKABLE void removeMockMouse();
76− Q_INVOKABLE void removeMockKeyboard();
74+ Q_INVOKABLE QInputDevice* addMockDevice(const QString &devicePath, QInputDevice::InputType type);
75+ Q_INVOKABLE void removeDevice(const QString &devicePath);
7776
7877Q_SIGNALS:
79− void newDevice(const QString &devicePath);
80− void deviceRemoved(const QString &devicePath);
81−
82−public Q_SLOTS:
83− void updateDeviceList();
84−
85−private:
86− QInputDeviceInfo *deviceInfo;
87− QVector<QInputDevice *> inputDevices;
88−private Q_SLOTS:
89− void addedDevice(const QString &);
90− void removedDevice(const QString &path);
91−
78+ void deviceAdded(const QString &);
79+ void deviceRemoved(const QString &);
80+ void ready();
9281};
9382
94−#endif // QDECLARATIVEINPUTDEVICEINFO_H
83+#endif // QINPUTDEVICEINFO_MOCK_H
tests/qmltests/Notifications/tst_Notifications.qml+5−6
@@ -19,7 +19,6 @@ import QtQuick.Layouts 1.1
1919import QtTest 1.0
2020import ".."
2121import "../../../qml/Notifications"
22−import "../../../qml/Components/UnityInputInfo"
2322import Ubuntu.Components 1.2
2423import Unity.Test 0.1
2524import Unity.Notifications 1.0
@@ -188,7 +187,7 @@ Item {
188187
189188 anchors.fill: parent
190189 model: mockModel
191− hasMouse: UnityInputInfo.mice > 0 // for testing, we add/remove only a mock mouse
190+ hasMouse: false
192191 }
193192 }
194193
@@ -264,9 +263,9 @@ Item {
264263 id: fakeMouseCB
265264 onClicked: {
266265 if (checked) {
267− UnityInputInfo.inputInfo.addMockMouse();
266+ notifications.hasMouse = true;
268267 } else {
269− UnityInputInfo.inputInfo.removeMockMouse();
268+ notifications.hasMouse = false;
270269 }
271270 }
272271 }
@@ -695,7 +694,7 @@ Item {
695694 }
696695
697696 function test_clickToClose_data() { // reuse the data
698− UnityInputInfo.inputInfo.addMockMouse();
697+ notifications.hasMouse = true;
699698 return test_NotificationRenderer_data();
700699 }
701700
@@ -726,7 +725,7 @@ Item {
726725 }
727726
728727 function cleanupTestCase() {
729− UnityInputInfo.inputInfo.removeMockMouse();
728+ notifications.hasMouse = false;
730729 }
731730 }
732731 }
tests/qmltests/Notifications/tst_SwipeToAct.qml+5−6
@@ -19,7 +19,6 @@ import QtQuick.Layouts 1.1
1919import QtTest 1.0
2020import ".."
2121import "../../../qml/Notifications"
22−import "../../../qml/Components/UnityInputInfo"
2322import Ubuntu.Components 0.1
2423import Unity.Test 0.1
2524import Unity.Notifications 1.0
@@ -112,7 +111,7 @@ Item {
112111
113112 anchors.fill: parent
114113 model: mockModel
115− hasMouse: UnityInputInfo.mice > 0 // for testing, we add/remove only a mock mouse
114+ hasMouse: false
116115 }
117116 }
118117
@@ -152,9 +151,9 @@ Item {
152151 id: fakeMouseCB
153152 onClicked: {
154153 if (checked) {
155− UnityInputInfo.inputInfo.addMockMouse();
154+ notifications.hasMouse = true;
156155 } else {
157− UnityInputInfo.inputInfo.removeMockMouse();
156+ notifications.hasMouse = false;
158157 }
159158 }
160159 }
@@ -301,7 +300,7 @@ Item {
301300 }
302301
303302 // add a mock mouse, test clicking the left/right buttons
304− UnityInputInfo.inputInfo.addMockMouse();
303+ notifications.hasMouse = true;
305304 var leftButton = findChild(swipeButton, "leftButton");
306305 var rightButton = findChild(swipeButton, "rightButton");
307306
@@ -316,7 +315,7 @@ Item {
316315 compare(actionSpy.signalArguments[0][0], data.actions.data(1, ActionModel.RoleActionId), "got wrong id for negative action");
317316 actionSpy.clear();
318317 }
319− UnityInputInfo.inputInfo.removeMockMouse();
318+ notifications.hasMouse = false;
320319 }
321320 }
322321 }
tests/qmltests/tst_OrientedShell.qml+17−9
@@ -26,7 +26,6 @@ import Powerd 0.1
2626import Unity.InputInfo 0.1
2727
2828import "../../qml"
29−import "../../qml/Components/UnityInputInfo"
3029
3130Rectangle {
3231 id: root
@@ -55,6 +54,15 @@ Rectangle {
5554 property bool stayHidden: false;
5655 }
5756
57+ InputDeviceModel {
58+ id: miceModel
59+ deviceFilter: InputInfo.Mouse
60+ }
61+ InputDeviceModel {
62+ id: keyboardsModel
63+ deviceFilter: InputInfo.Keyboard
64+ }
65+
5866 property int physicalOrientation0
5967 property int physicalOrientation90
6068 property int physicalOrientation180
@@ -307,13 +315,13 @@ Rectangle {
307315 Button {
308316 text: "Add mouse"
309317 onClicked: {
310− UnityInputInfo.inputInfo.addMockMouse()
318+ MockInputDeviceBackend.addMockDevice("/mouse" + miceModel.count, InputInfo.Mouse)
311319 }
312320 }
313321 Button {
314322 text: "Remove mouse"
315323 onClicked: {
316− UnityInputInfo.inputInfo.removeMockMouse()
324+ MockInputDeviceBackend.removeDevice("/mouse" + (miceModel.count - 1))
317325 }
318326 }
319327 }
@@ -321,13 +329,13 @@ Rectangle {
321329 Button {
322330 text: "Add kbd"
323331 onClicked: {
324− UnityInputInfo.inputInfo.addMockKeyboard()
332+ MockInputDeviceBackend.addMockDevice("/kbd" + keyboardsModel.count, InputInfo.Keyboard)
325333 }
326334 }
327335 Button {
328336 text: "Remove kbd"
329337 onClicked: {
330− UnityInputInfo.inputInfo.removeMockKeyboard()
338+ MockInputDeviceBackend.removeDevice("/kbd" + (keyboardsModel.count - 1))
331339 }
332340 }
333341 }
@@ -934,19 +942,19 @@ Rectangle {
934942 tryCompare(shell, "usageScenario", "phone");
935943 tryCompare(mockOskSettings, "stayHidden", false);
936944
937− UnityInputInfo.inputInfo.addMockKeyboard();
945+ MockInputDeviceBackend.addMockDevice("/kbd0", InputInfo.Keyboard);
938946 tryCompare(shell, "usageScenario", "phone");
939947 tryCompare(mockOskSettings, "stayHidden", true);
940948
941− UnityInputInfo.inputInfo.addMockMouse();
949+ MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
942950 tryCompare(shell, "usageScenario", "desktop");
943951 tryCompare(mockOskSettings, "stayHidden", true);
944952
945− UnityInputInfo.inputInfo.removeMockKeyboard();
953+ MockInputDeviceBackend.removeDevice("/kbd0");
946954 tryCompare(shell, "usageScenario", "desktop");
947955 tryCompare(mockOskSettings, "stayHidden", false);
948956
949− UnityInputInfo.inputInfo.removeMockMouse();
957+ MockInputDeviceBackend.removeDevice("/mouse0");
950958 tryCompare(shell, "usageScenario", "phone");
951959 tryCompare(mockOskSettings, "stayHidden", false);
952960 }