on xenial help sign in
removed InputWindow
c56d828Nick Dedekind
tests/mocks/Unity/InputInfo/InputWindow.qmldeleted−68
@@ -1,68 +0,0 @@
1−import QtQuick 2.4
2−import Ubuntu.Components 1.3
3−import Unity.InputInfo 0.1
4−
5−Rectangle {
6− id: rect
7− color: "white"
8− width: parent.width
9− height: parent.height
10−
11− Action {
12− id: mouseAction
13− text: checked ? "Remove Mouse" : "Add Mouse"
14− onTriggered: {
15− if (checked) {
16− console.log("ADD")
17− MockInputDeviceBackend.addMockDevice("/mouse0", InputInfo.Mouse);
18− } else {
19− console.log("REMOVE")
20− MockInputDeviceBackend.removeDevice("/mouse0");
21− }
22− }
23− iconName: "input-mouse-symbolic"
24− checkable: true
25− checked: false
26− }
27−
28− Action {
29− id: kbAction
30− text: checked ? "Remove Keyboard" : "Add Keyboard"
31− onTriggered: {
32− if (checked) {
33− MockInputDeviceBackend.addMockDevice("/kbd0", InputInfo.Keyboard);
34− } else {
35− MockInputDeviceBackend.removeDevice("/kbd0");
36− }
37− }
38− iconName: "input-keyboard-symbolic"
39− checkable: true
40− checked: false
41− }
42−
43− Column {
44− anchors {
45− fill: parent
46− margins: units.gu(1)
47− }
48− spacing: units.gu(1)
49−
50− Button {
51− anchors {
52− left: parent.left
53− right: parent.right
54− }
55− action: mouseAction
56− color: mouseAction.checked ? UbuntuColors.red : UbuntuColors.green
57− }
58−
59− Button {
60− anchors {
61− left: parent.left
62− right: parent.right
63− }
64− action: kbAction
65− color: kbAction.checked ? UbuntuColors.red : UbuntuColors.green
66− }
67− }
68−}
tests/mocks/Unity/InputInfo/mockcontroller.cpp+4−16
@@ -23,26 +23,14 @@
23#include <QQuickItem>
23#include <QQuickItem>
24#include <paths.h>
24#include <paths.h>
25
25
26−MockController::MockController(QQmlEngine *engine)
26+MockController::MockController(QObject *parent):
27+ QObject(parent)
27{
28{
28− QQmlComponent component(engine);
29− component.setData("import QtQuick 2.4; import Unity.InputInfo 0.1; InputWindow { }", ::qmlDirectory());
30− QObject *myObject = component.create();
31− QQuickItem *item = qobject_cast<QQuickItem*>(myObject);
32− if (item) {
33− auto window = new QQuickView();
34− window->setTitle("Input");
35− item->setParentItem(window->contentItem());
36− window->setResizeMode(QQuickView::SizeRootObjectToView);
37− window->setWidth(200);
38− window->setHeight(100);
39− window->show();
40− }
41}
29}
42
30
43−MockController *MockController::instance(QQmlEngine *engine)
31+MockController *MockController::instance()
44{
32{
45− static MockController* controller = new MockController(engine);
33+ static MockController* controller = new MockController();
46 return controller;
34 return controller;
47}
35}
48
36
tests/mocks/Unity/InputInfo/mockcontroller.h+2−4
@@ -20,16 +20,14 @@
20#include <QObject>
20#include <QObject>
21#include "qinputinfo.h"
21#include "qinputinfo.h"
22
22
23−class QQmlEngine;
24−
25class MockController: public QObject
23class MockController: public QObject
26{
24{
27 Q_OBJECT
25 Q_OBJECT
28public:
26public:
29− MockController(QQmlEngine *engine);
27+ MockController(QObject *parent = nullptr);
30 ~MockController() = default;
28 ~MockController() = default;
31
29
32− static MockController *instance(QQmlEngine *engine);
30+ static MockController *instance();
33
31
34 Q_INVOKABLE QInputDevice* addMockDevice(const QString &devicePath, QInputDevice::InputType type);
32 Q_INVOKABLE QInputDevice* addMockDevice(const QString &devicePath, QInputDevice::InputType type);
35 Q_INVOKABLE void removeDevice(const QString &devicePath);
33 Q_INVOKABLE void removeDevice(const QString &devicePath);
tests/mocks/Unity/InputInfo/plugin.cpp+1−1
@@ -27,7 +27,7 @@
27static QObject *backendProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
27static QObject *backendProvider(QQmlEngine *engine, QJSEngine *scriptEngine)
28{
28{
29 Q_UNUSED(scriptEngine)
29 Q_UNUSED(scriptEngine)
30− return MockController::instance(engine);
30+ return MockController::instance();
31}
31}
32
32
33void InputInfoPlugin::registerTypes(const char *uri)
33void InputInfoPlugin::registerTypes(const char *uri)
tests/mocks/Unity/InputInfo/qmldir−2
@@ -1,4 +1,2 @@
1module Unity.InputInfo
1module Unity.InputInfo
2plugin MockInputInfo
2plugin MockInputInfo
3−
4−InputWindow 0.1 InputWindow.qml