on xenial help sign in
Replace own lights plugin with hfd leds
bc6776dMarius Gripsgard
debian/control+1−3
@@ -25,7 +25,6 @@ Build-Depends: cmake,
25 libgles2-mesa-dev[arm64 armhf],
25 libgles2-mesa-dev[arm64 armhf],
26 libglib2.0-dev,
26 libglib2.0-dev,
27 libgsettings-qt-dev,
27 libgsettings-qt-dev,
28− libhardware-dev,
29 liblightdm-qt5-3-dev,
28 liblightdm-qt5-3-dev,
30 libpam0g-dev,
29 libpam0g-dev,
31 libpulse-dev,
30 libpulse-dev,
@@ -75,7 +74,6 @@ Build-Depends: cmake,
75 qtdeclarative5-ubuntu-settings-components (>= 0.11),
74 qtdeclarative5-ubuntu-settings-components (>= 0.11),
76 ttf-ubuntu-font-family,
75 ttf-ubuntu-font-family,
77 xvfb,
76 xvfb,
78− android-headers,
79Standards-Version: 3.9.4
77Standards-Version: 3.9.4
80Homepage: http://launchpad.net/unity
78Homepage: http://launchpad.net/unity
81# If you aren't a member of ~unity-team but need to upload
79# If you aren't a member of ~unity-team but need to upload
@@ -122,6 +120,7 @@ Depends: dmz-cursor-theme,
122 qml-module-qtquick-xmllistmodel,
120 qml-module-qtquick-xmllistmodel,
123 qml-module-qtsysteminfo,
121 qml-module-qtsysteminfo,
124# qml-module-ubuntu-web,
122# qml-module-ubuntu-web,
123+ qml-module-hfd,
125 qtdeclarative5-qtmir-plugin (>= 0.4.8),
124 qtdeclarative5-qtmir-plugin (>= 0.4.8),
126 qtdeclarative5-ubuntu-telephony0.1,
125 qtdeclarative5-ubuntu-telephony0.1,
127 ubuntu-system-settings (>= 0.4),
126 ubuntu-system-settings (>= 0.4),
@@ -220,7 +219,6 @@ Multi-Arch: same
220Pre-Depends: ${misc:Pre-Depends},
219Pre-Depends: ${misc:Pre-Depends},
221Depends: accountsservice-ubuntu-schemas (>= 0.0.7),
220Depends: accountsservice-ubuntu-schemas (>= 0.0.7),
222 gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815),
221 gsettings-ubuntu-schemas (>= 0.0.2+14.10.20140815),
223− libhardware2,
224 unity8-schemas,
222 unity8-schemas,
225 qtdeclarative5-gsettings1.0,
223 qtdeclarative5-gsettings1.0,
226 qml-module-qtmultimedia,
224 qml-module-qtmultimedia,
debian/unity8-private.install−1
@@ -4,7 +4,6 @@ usr/lib/*/unity8/qml/Cursor
4usr/lib/*/unity8/qml/GlobalShortcut
4usr/lib/*/unity8/qml/GlobalShortcut
5usr/lib/*/unity8/qml/Greeter
5usr/lib/*/unity8/qml/Greeter
6usr/lib/*/unity8/qml/LightDM
6usr/lib/*/unity8/qml/LightDM
7−usr/lib/*/unity8/qml/Lights
8usr/lib/*/unity8/qml/Powerd
7usr/lib/*/unity8/qml/Powerd
9usr/lib/*/unity8/qml/ScreenshotDirectory
8usr/lib/*/unity8/qml/ScreenshotDirectory
10usr/lib/*/unity8/qml/SessionBroadcast
9usr/lib/*/unity8/qml/SessionBroadcast
plugins/CMakeLists.txt−1
@@ -16,7 +16,6 @@ add_subdirectory(Cursor)
16add_subdirectory(GlobalShortcut)
16add_subdirectory(GlobalShortcut)
17add_subdirectory(Greeter)
17add_subdirectory(Greeter)
18add_subdirectory(LightDM)
18add_subdirectory(LightDM)
19−add_subdirectory(Lights)
20add_subdirectory(Powerd)
19add_subdirectory(Powerd)
21add_subdirectory(ScreenshotDirectory)
20add_subdirectory(ScreenshotDirectory)
22add_subdirectory(SessionBroadcast)
21add_subdirectory(SessionBroadcast)
plugins/Lights/CMakeLists.txtdeleted−19
@@ -1,19 +0,0 @@
1−pkg_check_modules(ANDROID_HEADERS REQUIRED android-headers)
2−pkg_check_modules(ANDROID_HARDWARE REQUIRED libhardware)
3−
4−include_directories(
5− SYSTEM
6− ${ANDROID_HEADERS_INCLUDE_DIRS}
7−)
8−
9−add_library(Lights-qml MODULE
10− plugin.cpp
11− Lights.cpp
12− )
13−
14−target_link_libraries(Lights-qml
15− Qt5::Qml Qt5::Gui
16− ${ANDROID_HARDWARE_LIBRARIES}
17− )
18−
19−add_unity8_plugin(Lights 0.1 Lights TARGETS Lights-qml)
plugins/Lights/Lights.cppdeleted−166
@@ -1,166 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Author: Renato Araujo Oliveira Filho <renato.filho@canonical.com>
17− */
18−
19−#include "Lights.h"
20−#include <QtCore/QDebug>
21−
22−extern "C" {
23−#include "android-hardware.h"
24−#include <string.h>
25−}
26−
27−Lights::Lights(QObject* parent)
28− : QObject(parent),
29− m_lightDevice(0),
30− m_color("blue"),
31− m_state(Lights::Off),
32− m_onMs(1000),
33− m_offMs(3000)
34−{
35−}
36−
37−Lights::~Lights()
38−{
39− if (m_lightDevice) {
40− hw_device_t* device = (hw_device_t*) m_lightDevice;
41− device->close(device);
42− }
43−}
44−
45−void Lights::setState(Lights::State newState)
46−{
47− if (!init()) {
48− qWarning() << "No lights device";
49− return;
50− }
51−
52− if (m_state != newState) {
53− if (newState == Lights::On) {
54− turnOn();
55− } else {
56− turnOff();
57− }
58−
59− m_state = newState;
60− Q_EMIT stateChanged(m_state);
61− }
62−}
63−
64−Lights::State Lights::state() const
65−{
66− return m_state;
67−}
68−
69−void Lights::setColor(const QColor &color)
70−{
71− if (m_color != color) {
72− m_color = color;
73− Q_EMIT colorChanged(m_color);
74− // FIXME: update the color if the light is already on
75− }
76−}
77−
78−QColor Lights::color() const
79−{
80− return m_color;
81−}
82−
83−int Lights::onMillisec() const
84−{
85− return m_onMs;
86−}
87−
88−void Lights::setOnMillisec(int onMs)
89−{
90− if (m_onMs != onMs) {
91− m_onMs = onMs;
92− Q_EMIT onMillisecChanged(m_onMs);
93− // FIXME: update the property if the light is already on
94− }
95−}
96−
97−int Lights::offMillisec() const
98−{
99− return m_offMs;
100−}
101−
102−void Lights::setOffMillisec(int offMs)
103−{
104− if (m_offMs != offMs) {
105− m_offMs = offMs;
106− Q_EMIT offMillisecChanged(m_offMs);
107− // FIXME: update the property if the light is already on
108− }
109−}
110−
111−bool Lights::init()
112−{
113− if (m_lightDevice) {
114− return true;
115− }
116−
117− int err;
118− hw_module_t* module;
119−
120− err = hw_get_module(LIGHTS_HARDWARE_MODULE_ID, (hw_module_t const**)&module);
121− if (err == 0) {
122− hw_device_t* device;
123− err = module->methods->open(module, LIGHT_ID_NOTIFICATIONS, &device);
124− if (err == 0) {
125− m_lightDevice = (light_device_t*)device;
126− turnOff();
127− return true;
128− } else {
129− qWarning() << "Failed to access notification lights";
130− }
131− } else {
132− qWarning() << "Failed to initialize lights hardware.";
133− }
134− return false;
135−}
136−
137−void Lights::turnOn()
138−{
139− // pulse
140− light_state_t state;
141− memset(&state, 0, sizeof(light_state_t));
142− state.color = m_color.rgba();
143− state.flashMode = LIGHT_FLASH_TIMED;
144− state.flashOnMS = m_onMs;
145− state.flashOffMS = m_offMs;
146− state.brightnessMode = BRIGHTNESS_MODE_USER;
147−
148− if (m_lightDevice->set_light(m_lightDevice, &state) != 0) {
149− qWarning() << "Failed to turn the light off";
150− }
151−}
152−
153−void Lights::turnOff()
154−{
155− light_state_t state;
156− memset(&state, 0, sizeof(light_state_t));
157− state.color = 0x00000000;
158− state.flashMode = LIGHT_FLASH_NONE;
159− state.flashOnMS = 0;
160− state.flashOffMS = 0;
161− state.brightnessMode = 0;
162−
163− if (m_lightDevice->set_light(m_lightDevice, &state) != 0) {
164− qWarning() << "Failed to turn the light off";
165− }
166−}
plugins/Lights/Lights.hdeleted−75
@@ -1,75 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Author: Renato Araujo Oliveira Filho <renato.filho@canonical.com>
17− */
18−
19−#ifndef UNITY_LIGHTS_H
20−#define UNITY_LIGHTS_H
21−
22−#include <QtCore/QObject>
23−#include <QtGui/QColor>
24−
25−struct light_device_t;
26−
27−class Lights: public QObject
28−{
29− Q_OBJECT
30− Q_PROPERTY(State state READ state WRITE setState NOTIFY stateChanged)
31− Q_PROPERTY(QColor color READ color WRITE setColor NOTIFY colorChanged)
32− Q_PROPERTY(int onMillisec READ onMillisec WRITE setOnMillisec NOTIFY onMillisecChanged)
33− Q_PROPERTY(int offMillisec READ offMillisec WRITE setOffMillisec NOTIFY offMillisecChanged)
34−
35−public:
36− enum State {
37− Off,
38− On,
39− };
40− Q_ENUM(State)
41−
42− explicit Lights(QObject *parent = 0);
43− ~Lights();
44−
45− void setState(State newState);
46− State state() const;
47−
48− void setColor(const QColor &color);
49− QColor color() const;
50−
51− int onMillisec() const;
52− void setOnMillisec(int onMs);
53−
54− int offMillisec() const;
55− void setOffMillisec(int offMs);
56−
57−Q_SIGNALS:
58− void stateChanged(State newState);
59− void colorChanged(const QColor &color);
60− void onMillisecChanged(int onMs);
61− void offMillisecChanged(int offMs);
62−
63−private:
64− light_device_t* m_lightDevice;
65− QColor m_color;
66− State m_state;
67− int m_onMs;
68− int m_offMs;
69−
70− bool init();
71− void turnOff();
72− void turnOn();
73−};
74−
75−#endif
plugins/Lights/android-hardware.hdeleted−19
@@ -1,19 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− */
17−
18−#include <hardware/hardware.h>
19−#include <hardware/lights.h>
plugins/Lights/plugin.cppdeleted−35
@@ -1,35 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Author: Renato Araujo Oliveira Filho <renato.filho@canonical.com>
17− */
18−
19−#include "plugin.h"
20−#include "Lights.h"
21−
22−#include <QtQml/qqml.h>
23−
24−static QObject *lights_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
25−{
26− Q_UNUSED(engine)
27− Q_UNUSED(scriptEngine)
28− return new Lights();
29−}
30−
31−void LightsPlugin::registerTypes(const char *uri)
32−{
33− Q_ASSERT(uri == QLatin1String("Lights"));
34− qmlRegisterSingletonType<Lights>(uri, 0, 1, "Lights", lights_provider);
35−}
plugins/Lights/plugin.hdeleted−34
@@ -1,34 +0,0 @@
1−/*
2− * Copyright (C) 2014 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− *
16− * Author: Renato Araujo Oliveira Filho <renato.filho@canonical.com>
17− */
18−
19−#ifndef LIGHTS_PLUGIN_H
20−#define LIGHTS_PLUGIN_H
21−
22−#include <QtQml/QQmlEngine>
23−#include <QtQml/QQmlExtensionPlugin>
24−
25−class LightsPlugin : public QQmlExtensionPlugin
26−{
27− Q_OBJECT
28− Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
29−
30−public:
31− void registerTypes(const char *uri) override;
32−};
33−
34−#endif
plugins/Lights/qmldirdeleted−3
@@ -1,3 +0,0 @@
1−module Lights
2−plugin Lights-qml
3−typeinfo Lights.qmltypes
qml/Panel/Indicators/IndicatorsLight.qml+8−8
@@ -20,7 +20,7 @@
20
20
21import QtQuick 2.4
21import QtQuick 2.4
22import Powerd 0.1
22import Powerd 0.1
23−import Lights 0.1
23+import Hfd 0.1
24import QMenuModel 0.1 as QMenuModel
24import QMenuModel 0.1 as QMenuModel
25import Unity.Indicators 0.1 as Indicators
25import Unity.Indicators 0.1 as Indicators
26import Wizard 0.1
26import Wizard 0.1
@@ -171,9 +171,9 @@ console.log("no support for Multicolor LED. " + indicatorState)
171 }
171 }
172
172
173 // HACK: led is only updated after turn on so first always turn off
173 // HACK: led is only updated after turn on so first always turn off
174− Lights.state = Lights.Off
174+ Leds.state = Leds.Off
175 if (indicatorState != "INDICATOR_OFF")
175 if (indicatorState != "INDICATOR_OFF")
176− Lights.state = Lights.On
176+ Leds.state = Leds.On
177 }
177 }
178
178
179 // Existence of unread notifications is determined by checking for a specific icon name in a dbus signal.
179 // Existence of unread notifications is determined by checking for a specific icon name in a dbus signal.
@@ -213,23 +213,23 @@ console.log("no support for Multicolor LED. " + indicatorState)
213 }
213 }
214 }
214 }
215
215
216− Component.onCompleted: Lights.state = Lights.Off
216+ Component.onCompleted: Leds.state = Lights.Off
217− Component.onDestruction: Lights.state = Lights.Off
217+ Component.onDestruction: Leds.state = Leds.Off
218
218
219 property var _colorBinding: Binding {
219 property var _colorBinding: Binding {
220− target: Lights
220+ target: Leds
221 property: "color"
221 property: "color"
222 value: root.color
222 value: root.color
223 }
223 }
224
224
225 property var _onMillisecBinding: Binding {
225 property var _onMillisecBinding: Binding {
226− target: Lights
226+ target: Leds
227 property: "onMillisec"
227 property: "onMillisec"
228 value: root.onMillisec
228 value: root.onMillisec
229 }
229 }
230
230
231 property var _offMillisecBinding: Binding {
231 property var _offMillisecBinding: Binding {
232− target: Lights
232+ target: Leds
233 property: "offMillisec"
233 property: "offMillisec"
234 value: root.offMillisec
234 value: root.offMillisec
235 }
235 }
tests/mocks/CMakeLists.txt+1−1
@@ -35,7 +35,7 @@ add_subdirectory(indicator-service)
35add_subdirectory(liblightdm)
35add_subdirectory(liblightdm)
36add_subdirectory(libusermetrics)
36add_subdirectory(libusermetrics)
37add_subdirectory(LightDMController)
37add_subdirectory(LightDMController)
38−add_subdirectory(Lights)
38+add_subdirectory(Hfd)
39add_subdirectory(MeeGo)
39add_subdirectory(MeeGo)
40add_subdirectory(Powerd)
40add_subdirectory(Powerd)
41add_subdirectory(QMenuModel)
41add_subdirectory(QMenuModel)
tests/mocks/Hfd/CMakeLists.txtnew file+8
@@ -0,0 +1,8 @@
1+add_library(MockHfd-qml MODULE
2+ plugin.cpp
3+ Leds.cpp
4+ )
5+
6+qt5_use_modules(MockHfd-qml Qml Gui)
7+
8+add_unity8_mock(Hfd 0.1 Hfd TARGETS MockHfd-qml)
tests/mocks/Lights/Lights.cpp → tests/mocks/Hfd/Leds.cpprenamed+12−12
@@ -14,24 +14,24 @@
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−#include "Lights.h"
17+#include "Leds.h"
18
18
19#include <QDebug>
19#include <QDebug>
20
20
21−Lights::Lights(QObject* parent)
21+Leds::Leds(QObject* parent)
22 : QObject(parent),
22 : QObject(parent),
23 m_color("blue"),
23 m_color("blue"),
24− m_state(Lights::Off),
24+ m_state(Leds::Off),
25 m_onMs(1000),
25 m_onMs(1000),
26 m_offMs(3000)
26 m_offMs(3000)
27{
27{
28}
28}
29
29
30−Lights::~Lights()
30+Leds::~Leds()
31{
31{
32}
32}
33
33
34−void Lights::setState(Lights::State newState)
34+void Leds::setState(Leds::State newState)
35{
35{
36 if (m_state != newState) {
36 if (m_state != newState) {
37 m_state = newState;
37 m_state = newState;
@@ -39,12 +39,12 @@ void Lights::setState(Lights::State newState)
39 }
39 }
40}
40}
41
41
42−Lights::State Lights::state() const
42+Leds::State Leds::state() const
43{
43{
44 return m_state;
44 return m_state;
45}
45}
46
46
47−void Lights::setColor(const QColor &color)
47+void Leds::setColor(const QColor &color)
48{
48{
49 if (m_color != color) {
49 if (m_color != color) {
50 m_color = color;
50 m_color = color;
@@ -52,17 +52,17 @@ void Lights::setColor(const QColor &color)
52 }
52 }
53}
53}
54
54
55−QColor Lights::color() const
55+QColor Leds::color() const
56{
56{
57 return m_color;
57 return m_color;
58}
58}
59
59
60−int Lights::onMillisec() const
60+int Leds::onMillisec() const
61{
61{
62 return m_onMs;
62 return m_onMs;
63}
63}
64
64
65−void Lights::setOnMillisec(int onMs)
65+void Leds::setOnMillisec(int onMs)
66{
66{
67 if (m_onMs != onMs) {
67 if (m_onMs != onMs) {
68 m_onMs = onMs;
68 m_onMs = onMs;
@@ -70,12 +70,12 @@ void Lights::setOnMillisec(int onMs)
70 }
70 }
71}
71}
72
72
73−int Lights::offMillisec() const
73+int Leds::offMillisec() const
74{
74{
75 return m_offMs;
75 return m_offMs;
76}
76}
77
77
78−void Lights::setOffMillisec(int offMs)
78+void Leds::setOffMillisec(int offMs)
79{
79{
80 if (m_offMs != offMs) {
80 if (m_offMs != offMs) {
81 m_offMs = offMs;
81 m_offMs = offMs;
tests/mocks/Lights/Lights.h → tests/mocks/Hfd/Leds.hrenamed+4−7
@@ -14,13 +14,12 @@
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 UNITY_MOCK_LIGHTS_H
17+#pragma once
18−#define UNITY_MOCK_LIGHTS_H
19
18
20#include <QtCore/QObject>
19#include <QtCore/QObject>
21#include <QtGui/QColor>
20#include <QtGui/QColor>
22
21
23−class Lights: public QObject
22+class Leds: public QObject
24{
23{
25 Q_OBJECT
24 Q_OBJECT
26 Q_PROPERTY(State state READ state WRITE setState NOTIFY stateChanged)
25 Q_PROPERTY(State state READ state WRITE setState NOTIFY stateChanged)
@@ -35,8 +34,8 @@ public:
35 };
34 };
36 Q_ENUM(State)
35 Q_ENUM(State)
37
36
38− explicit Lights(QObject *parent = 0);
37+ explicit Leds(QObject *parent = 0);
39− ~Lights();
38+ ~Leds();
40
39
41 void setState(State newState);
40 void setState(State newState);
42 State state() const;
41 State state() const;
@@ -62,5 +61,3 @@ private:
62 int m_onMs;
61 int m_onMs;
63 int m_offMs;
62 int m_offMs;
64};
63};
65−
66−#endif
tests/mocks/Lights/plugin.cpp → tests/mocks/Hfd/plugin.cpprenamed+5−5
@@ -15,19 +15,19 @@
15 */
15 */
16
16
17#include "plugin.h"
17#include "plugin.h"
18−#include "Lights.h"
18+#include "Leds.h"
19
19
20#include <QtQml/qqml.h>
20#include <QtQml/qqml.h>
21
21
22−static QObject *lights_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
22+static QObject *leds_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
23{
23{
24 Q_UNUSED(engine)
24 Q_UNUSED(engine)
25 Q_UNUSED(scriptEngine)
25 Q_UNUSED(scriptEngine)
26− return new Lights();
26+ return new Leds();
27}
27}
28
28
29void PowerdPlugin::registerTypes(const char *uri)
29void PowerdPlugin::registerTypes(const char *uri)
30{
30{
31− Q_ASSERT(uri == QLatin1String("Lights"));
31+ Q_ASSERT(uri == QLatin1String("Hfd"));
32− qmlRegisterSingletonType<Lights>(uri, 0, 1, "Lights", lights_provider);
32+ qmlRegisterSingletonType<Leds>(uri, 0, 1, "Leds", leds_provider);
33}
33}
tests/mocks/Lights/plugin.h → tests/mocks/Hfd/plugin.hrenamed+1−4
@@ -14,8 +14,7 @@
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 MOCK_POWER_PLUGIN_H
17+#pragma once
18−#define MOCK_POWER_PLUGIN_H
19
18
20#include <QtQml/QQmlEngine>
19#include <QtQml/QQmlEngine>
21#include <QtQml/QQmlExtensionPlugin>
20#include <QtQml/QQmlExtensionPlugin>
@@ -28,5 +27,3 @@ class PowerdPlugin : public QQmlExtensionPlugin
28public:
27public:
29 void registerTypes(const char *uri) override;
28 void registerTypes(const char *uri) override;
30};
29};
31−
32−#endif
tests/mocks/Hfd/qmldirnew file+3
@@ -0,0 +1,3 @@
1+module Hfd
2+plugin MockHfd-qml
3+typeinfo hfd.qmltypes
tests/mocks/Lights/CMakeLists.txtdeleted−8
@@ -1,8 +0,0 @@
1−add_library(MockLights-qml MODULE
2− plugin.cpp
3− Lights.cpp
4− )
5−
6−target_link_libraries(MockLights-qml Qt5::Qml Qt5::Gui)
7−
8−add_unity8_mock(Lights 0.1 Lights TARGETS MockLights-qml)
tests/mocks/Lights/qmldirdeleted−3
@@ -1,3 +0,0 @@
1−module Lights
2−plugin MockLights-qml
3−typeinfo Lights.qmltypes
tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml+25−25
@@ -20,7 +20,7 @@ import Unity.Test 0.1 as UT
20import Unity.Indicators 0.1 as Indicators
20import Unity.Indicators 0.1 as Indicators
21import Ubuntu.Components 1.3
21import Ubuntu.Components 1.3
22import Powerd 0.1
22import Powerd 0.1
23−import Lights 0.1
23+import Hfd 0.1
24import QMenuModel 0.1
24import QMenuModel 0.1
25import "../../../../qml/Panel/Indicators"
25import "../../../../qml/Panel/Indicators"
26
26
@@ -75,7 +75,7 @@ Item {
75 radius: width / 2
75 radius: width / 2
76 anchors.centerIn: parent
76 anchors.centerIn: parent
77
77
78− color: Lights.state === Lights.On ? Lights.color : "transparent"
78+ color: Leds.state === Leds.On ? Leds.color : "transparent"
79
79
80 border.color: "black"
80 border.color: "black"
81 border.width: 1
81 border.width: 1
@@ -162,79 +162,79 @@ Item {
162 //
162 //
163 // new messages
163 // new messages
164 //
164 //
165− { tag: "Powerd.On with No Message", powerd: Powerd.On, actionData: noNewMessage, expectedLightsState: Lights.Off },
165+ { tag: "Powerd.On with No Message", powerd: Powerd.On, actionData: noNewMessage, expectedLightsState: Leds.Off },
166− { tag: "Powerd.Off with No Message", powerd: Powerd.Off, actionData: noNewMessage, expectedLightsState: Lights.Off },
166+ { tag: "Powerd.Off with No Message", powerd: Powerd.Off, actionData: noNewMessage, expectedLightsState: Leds.Off },
167− { tag: "Powerd.On with New Message", powerd: Powerd.On, actionData: newMessage, expectedLightsState: Lights.Off },
167+ { tag: "Powerd.On with New Message", powerd: Powerd.On, actionData: newMessage, expectedLightsState: Leds.Off },
168− { tag: "Powerd.Off with New Message", powerd: Powerd.Off, actionData: newMessage, expectedLightsState: Lights.On },
168+ { tag: "Powerd.Off with New Message", powerd: Powerd.Off, actionData: newMessage, expectedLightsState: Leds.On },
169
169
170 //
170 //
171 // show charging
171 // show charging
172 //
172 //
173 { tag: "Powerd.Off while charging",
173 { tag: "Powerd.Off while charging",
174− expectedLightsState: Lights.On,
174+ expectedLightsState: Leds.On,
175 powerd: Powerd.Off, actionData: deviceStateDBusSignals.charging },
175 powerd: Powerd.Off, actionData: deviceStateDBusSignals.charging },
176
176
177 { tag: "Powerd.On while charging",
177 { tag: "Powerd.On while charging",
178− expectedLightsState: Lights.Off,
178+ expectedLightsState: Leds.Off,
179 powerd: Powerd.On, actionData: deviceStateDBusSignals.charging },
179 powerd: Powerd.On, actionData: deviceStateDBusSignals.charging },
180
180
181 { tag: "Powerd.On while charging",
181 { tag: "Powerd.On while charging",
182− expectedLightsState: Lights.Off,
182+ expectedLightsState: Leds.Off,
183 powerd: Powerd.On, wizardStatus: batteryIconNames.charging },
183 powerd: Powerd.On, wizardStatus: batteryIconNames.charging },
184
184
185 //
185 //
186 // show charging and full
186 // show charging and full
187 //
187 //
188 { tag: "Powerd.Off while charging and battery full",
188 { tag: "Powerd.Off while charging and battery full",
189− expectedLightsState: Lights.On, expectedLightsColor: green,
189+ expectedLightsState: Leds.On, expectedLightsColor: green,
190 powerd: Powerd.Off, actionData: deviceStateDBusSignals.fullyCharged },
190 powerd: Powerd.Off, actionData: deviceStateDBusSignals.fullyCharged },
191
191
192 { tag: "Powerd.On while charging and battery full",
192 { tag: "Powerd.On while charging and battery full",
193− expectedLightsState: Lights.Off,
193+ expectedLightsState: Leds.Off,
194 powerd: Powerd.On, actionData: deviceStateDBusSignals.fullyCharged },
194 powerd: Powerd.On, actionData: deviceStateDBusSignals.fullyCharged },
195
195
196 { tag: "Powerd.Off while discharging and battery full",
196 { tag: "Powerd.Off while discharging and battery full",
197− expectedLightsState: Lights.Off,
197+ expectedLightsState: Leds.Off,
198 powerd: Powerd.Off, actionData: deviceStateDBusSignals.discharging, wizardStatus: batteryIconNames.fullyCharged },
198 powerd: Powerd.Off, actionData: deviceStateDBusSignals.discharging, wizardStatus: batteryIconNames.fullyCharged },
199
199
200 //
200 //
201 // show empty
201 // show empty
202 //
202 //
203 { tag: "Powerd.Off while discharging and battery empty",
203 { tag: "Powerd.Off while discharging and battery empty",
204− expectedLightsState: Lights.On, expectedLightsColor: orangeRed,
204+ expectedLightsState: Leds.On, expectedLightsColor: orangeRed,
205 powerd: Powerd.Off, wizardStatus: batteryIconNames.caution },
205 powerd: Powerd.Off, wizardStatus: batteryIconNames.caution },
206
206
207 { tag: "Powerd.On while discharging and battery empty",
207 { tag: "Powerd.On while discharging and battery empty",
208− expectedLightsState: Lights.Off,
208+ expectedLightsState: Leds.Off,
209 powerd: Powerd.On, wizardStatus: batteryIconNames.caution },
209 powerd: Powerd.On, wizardStatus: batteryIconNames.caution },
210
210
211 { tag: "Powerd.On while discharging and battery empty",
211 { tag: "Powerd.On while discharging and battery empty",
212− expectedLightsState: Lights.Off,
212+ expectedLightsState: Leds.Off,
213 powerd: Powerd.On, wizardStatus: batteryIconNames.empty },
213 powerd: Powerd.On, wizardStatus: batteryIconNames.empty },
214
214
215 { tag: "Powerd.Off while charging and battery empty",
215 { tag: "Powerd.Off while charging and battery empty",
216− expectedLightsState: Lights.On, expectedLightsColor: white,
216+ expectedLightsState: Leds.On, expectedLightsColor: white,
217 powerd: Powerd.Off, actionData: deviceStateDBusSignals.charging },
217 powerd: Powerd.Off, actionData: deviceStateDBusSignals.charging },
218
218
219 //
219 //
220 // new message has highest priority
220 // new message has highest priority
221 //
221 //
222 { tag: "Powerd.Off with New Message, discharging and battery empty",
222 { tag: "Powerd.Off with New Message, discharging and battery empty",
223− expectedLightsState: Lights.On,
223+ expectedLightsState: Leds.On,
224 expectedLightsColor: darkGreen,
224 expectedLightsColor: darkGreen,
225 expectedLightsOnMillisec: 1000,
225 expectedLightsOnMillisec: 1000,
226 expectedLightsOffMillisec: 3000,
226 expectedLightsOffMillisec: 3000,
227 powerd: Powerd.Off, actionData: newMessage, wizardStatus: batteryIconNames.caution },
227 powerd: Powerd.Off, actionData: newMessage, wizardStatus: batteryIconNames.caution },
228
228
229 { tag: "Powerd.Off with New Message and charging",
229 { tag: "Powerd.Off with New Message and charging",
230− expectedLightsState: Lights.On,
230+ expectedLightsState: Leds.On,
231 expectedLightsColor: darkGreen,
231 expectedLightsColor: darkGreen,
232 expectedLightsOnMillisec: 1000,
232 expectedLightsOnMillisec: 1000,
233 expectedLightsOffMillisec: 3000,
233 expectedLightsOffMillisec: 3000,
234 powerd: Powerd.Off, actionData: combinedDBusSignals.hasMessageAndCharging },
234 powerd: Powerd.Off, actionData: combinedDBusSignals.hasMessageAndCharging },
235
235
236 { tag: "Powerd.Off with New Message, charging and battery full",
236 { tag: "Powerd.Off with New Message, charging and battery full",
237− expectedLightsState: Lights.On,
237+ expectedLightsState: Leds.On,
238 expectedLightsColor: darkGreen,
238 expectedLightsColor: darkGreen,
239 expectedLightsOnMillisec: 1000,
239 expectedLightsOnMillisec: 1000,
240 expectedLightsOffMillisec: 3000,
240 expectedLightsOffMillisec: 3000,
@@ -244,11 +244,11 @@ Item {
244 // use battery level
244 // use battery level
245 //
245 //
246 { tag: "Powerd.Off while charging and battery level at 80%",
246 { tag: "Powerd.Off while charging and battery level at 80%",
247− expectedLightsState: Lights.On, expectedLightsColor: white,
247+ expectedLightsState: Leds.On, expectedLightsColor: white,
248 powerd: Powerd.Off, actionData: batteryLevelDBusSignals["80"], wizardStatus: batteryIconNames.charging },
248 powerd: Powerd.Off, actionData: batteryLevelDBusSignals["80"], wizardStatus: batteryIconNames.charging },
249
249
250 { tag: "Powerd.Off while charging and battery level at 100%",
250 { tag: "Powerd.Off while charging and battery level at 100%",
251− expectedLightsState: Lights.On, expectedLightsColor: green,
251+ expectedLightsState: Leds.On, expectedLightsColor: green,
252 expectedLightsOnMillisec: 1000,
252 expectedLightsOnMillisec: 1000,
253 expectedLightsOffMillisec: 0,
253 expectedLightsOffMillisec: 0,
254 powerd: Powerd.Off, actionData: batteryLevelDBusSignals["100"], wizardStatus: batteryIconNames.charging },
254 powerd: Powerd.Off, actionData: batteryLevelDBusSignals["100"], wizardStatus: batteryIconNames.charging },
@@ -280,13 +280,13 @@ Item {
280 if (data.hasOwnProperty("wizardStatus"))
280 if (data.hasOwnProperty("wizardStatus"))
281 loader.item.batteryIconName = data.wizardStatus
281 loader.item.batteryIconName = data.wizardStatus
282
282
283− compare(Lights.state, data.expectedLightsState, "Lights state does not match expected value");
283+ compare(Leds.state, data.expectedLightsState, "Lights state does not match expected value");
284 if (data.hasOwnProperty("expectedLightsColor"))
284 if (data.hasOwnProperty("expectedLightsColor"))
285− compare(Lights.color, data.expectedLightsColor, "Lights color does not match expected value")
285+ compare(Leds.color, data.expectedLightsColor, "Lights color does not match expected value")
286 if (data.hasOwnProperty("expectedLightsOnMillisec"))
286 if (data.hasOwnProperty("expectedLightsOnMillisec"))
287− compare(Lights.onMillisec, data.expectedLightsOnMillisec, "Lights OnMillisec does not match expected value")
287+ compare(Leds.onMillisec, data.expectedLightsOnMillisec, "Lights OnMillisec does not match expected value")
288 if (data.hasOwnProperty("expectedLightsOffMillisec"))
288 if (data.hasOwnProperty("expectedLightsOffMillisec"))
289− compare(Lights.offMillisec, data.expectedLightsOffMillisec, "Lights OffMillisec does not match expected value")
289+ compare(Leds.offMillisec, data.expectedLightsOffMillisec, "Lights OffMillisec does not match expected value")
290 }
290 }
291 }
291 }
292}
292}