From b17fe07aaeb07821290e24289928b3c8ae017e78 Mon Sep 17 00:00:00 2001 From: Willem-Jan de Hoog Date: Sat, 22 Feb 2020 12:38:08 -0500 Subject: [PATCH 01/11] allow to suppress charging state notification --- data/com.canonical.Unity8.gschema.xml | 8 ++++++++ qml/Panel/Indicators/IndicatorsLight.qml | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/data/com.canonical.Unity8.gschema.xml b/data/com.canonical.Unity8.gschema.xml index 417175864d..d6e1b913d9 100644 --- a/data/com.canonical.Unity8.gschema.xml +++ b/data/com.canonical.Unity8.gschema.xml @@ -72,4 +72,12 @@ If too many unsuccessful login attempts have been made in a row, the greeter locks you out for a while. This unix timestamp indicates when you were locked out, so unity8 knows when to let you back in. + + + + true + Whether the battery charging state should be shown using the notification led + Toggle the visibility of the battery charging state in the notification led patterns + + diff --git a/qml/Panel/Indicators/IndicatorsLight.qml b/qml/Panel/Indicators/IndicatorsLight.qml index db053bc25e..acd63123e8 100644 --- a/qml/Panel/Indicators/IndicatorsLight.qml +++ b/qml/Panel/Indicators/IndicatorsLight.qml @@ -24,6 +24,7 @@ import Lights 0.1 import QMenuModel 0.1 as QMenuModel import Unity.Indicators 0.1 as Indicators import Wizard 0.1 +import GSettings 1.0 import "../../.." @@ -45,10 +46,15 @@ QtObject { property string batteryIconName: Status.batteryIcon property string displayStatus: Powerd.status + onSupportsMultiColorLedChanged: { updateLightState("onSupportsMultiColorLedChanged") } + property var _unity8Settings: GSettings { + schema.id: "com.canonical.Unity8.LedIndication" + } + onDisplayStatusChanged: { updateLightState("onDisplayStatusChanged") } @@ -65,8 +71,11 @@ QtObject { + ", icon: " + batteryIconName + ", displayStatus: " + displayStatus + ", deviceState: " + deviceState - + ", batteryLevel: " + batteryLevel) + + ", batteryLevel: " + batteryLevel + + ", chargingStateVisible: " + _unity8Settings.chargingStateVisible) + // + // If charging state visibility is disabled then only show messages. // // priorities: // unread messsages (highest), full&charging, charging, low @@ -114,11 +123,16 @@ QtObject { // if device does not support a multi color led set led off if(!supportsMultiColorLed) { -console.log("no support for Multicolor LED. " + indicatorState) indicatorState = "INDICATOR_OFF" return } + // if charging state is not to be shown set led off + if(!_unity8Settings.chargingStateVisible) { + indicatorState = "INDICATOR_OFF" + return + } + var isCharging = batteryIconName.indexOf("charging") >= 0 || deviceState == "charging" || deviceState == "fully-charged" From 5ef1a06a741f44e419815c0daa5c1437c89533c5 Mon Sep 17 00:00:00 2001 From: Willem-Jan de Hoog Date: Sat, 22 Feb 2020 12:43:58 -0500 Subject: [PATCH 02/11] fix whitespace --- qml/Panel/Indicators/IndicatorsLight.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qml/Panel/Indicators/IndicatorsLight.qml b/qml/Panel/Indicators/IndicatorsLight.qml index acd63123e8..1cc8236e72 100644 --- a/qml/Panel/Indicators/IndicatorsLight.qml +++ b/qml/Panel/Indicators/IndicatorsLight.qml @@ -127,11 +127,11 @@ QtObject { return } - // if charging state is not to be shown set led off + // if charging state is not to be shown set led off if(!_unity8Settings.chargingStateVisible) { indicatorState = "INDICATOR_OFF" return - } + } var isCharging = batteryIconName.indexOf("charging") >= 0 || deviceState == "charging" From 13a676575372b8cbe881471311dbeb3e9d7c572c Mon Sep 17 00:00:00 2001 From: Willem-Jan de Hoog Date: Sun, 23 Feb 2020 04:51:35 -0500 Subject: [PATCH 03/11] added setting for IndicatorsLight test --- tests/mocks/GSettings.1.0/fake_gsettings.cpp | 23 ++++++++++++++++++++ tests/mocks/GSettings.1.0/fake_gsettings.h | 9 ++++++++ 2 files changed, 32 insertions(+) diff --git a/tests/mocks/GSettings.1.0/fake_gsettings.cpp b/tests/mocks/GSettings.1.0/fake_gsettings.cpp index cd6b57ef45..10c84c660e 100644 --- a/tests/mocks/GSettings.1.0/fake_gsettings.cpp +++ b/tests/mocks/GSettings.1.0/fake_gsettings.cpp @@ -29,6 +29,7 @@ GSettingsControllerQml::GSettingsControllerQml() , m_edgeDragWidth(2) , m_enableIndicatorMenu(true) , m_appstoreUri("http://uappexplorer.com") + , m_chargingStateVisible(true) { } @@ -160,6 +161,19 @@ void GSettingsControllerQml::setEnableIndicatorMenu(bool enableIndicatorMenu) } } +bool GSettingsControllerQml::chargingStateVisible() const +{ + return m_chargingStateVisible; +} + +void GSettingsControllerQml::setChargingStateVisible(bool chargingStateVisible) +{ + if (m_chargingStateVisible != chargingStateVisible) { + m_chargingStateVisible = chargingStateVisible; + Q_EMIT chargingStateVisibleChanged(chargingStateVisible); + } +} + QString GSettingsControllerQml::appstoreUri() const { return m_appstoreUri; @@ -398,3 +412,12 @@ void GSettingsQml::setEnableIndicatorMenu(const QVariant &enableIndicatorMenu) GSettingsControllerQml::instance()->setEnableIndicatorMenu(enableIndicatorMenu.toBool()); } } + +QVariant GSettingsQml::chargingStateVisible() const +{ + if (m_valid && m_schema->id() == "com.canonical.Unity8.LedIndication") { + return GSettingsControllerQml::instance()->chargingStateVisible(); + } else { + return QVariant(); + } +} diff --git a/tests/mocks/GSettings.1.0/fake_gsettings.h b/tests/mocks/GSettings.1.0/fake_gsettings.h index 8ce6fc7617..c59ae277f6 100644 --- a/tests/mocks/GSettings.1.0/fake_gsettings.h +++ b/tests/mocks/GSettings.1.0/fake_gsettings.h @@ -59,6 +59,7 @@ class GSettingsQml: public QObject, public QQmlParserStatus Q_PROPERTY(QVariant edgeDragWidth READ edgeDragWidth WRITE setEdgeDragWidth NOTIFY edgeDragWidthChanged) Q_PROPERTY(QVariant enableIndicatorMenu READ enableIndicatorMenu WRITE setEnableIndicatorMenu NOTIFY enableIndicatorMenuChanged) Q_PROPERTY(QVariant appstoreUri READ appstoreUri NOTIFY appstoreUriChanged) + Q_PROPERTY(QVariant chargingStateVisible READ chargingStateVisible NOTIFY chargingStateVisibleChanged) public: GSettingsQml(QObject *parent = nullptr); @@ -77,6 +78,7 @@ class GSettingsQml: public QObject, public QQmlParserStatus QVariant edgeDragWidth() const; QVariant enableIndicatorMenu() const; QVariant appstoreUri() const; + QVariant chargingStateVisible() const; void setDisableHeight(const QVariant &val); void setPictureUri(const QVariant &str); @@ -87,6 +89,7 @@ class GSettingsQml: public QObject, public QQmlParserStatus void setLauncherWidth(const QVariant &launcherWidth); void setEdgeDragWidth(const QVariant &edgeDragWidth); void setEnableIndicatorMenu(const QVariant &enableIndicatorMenu); + void setChargingStateVisible(const QVariant &chargingStateVisible); Q_SIGNALS: void disableHeightChanged(); @@ -100,6 +103,7 @@ class GSettingsQml: public QObject, public QQmlParserStatus void edgeDragWidthChanged(); void enableIndicatorMenuChanged(); void appstoreUriChanged(); + void chargingStateVisibleChanged(); private: GSettingsSchemaQml* m_schema; @@ -145,6 +149,9 @@ class GSettingsControllerQml: public QObject QString appstoreUri() const; + bool chargingStateVisible() const; + Q_INVOKABLE void setChargingStateVisible(bool chargingStateVisible); + Q_SIGNALS: void disableHeightChanged(); void pictureUriChanged(const QString&); @@ -156,6 +163,7 @@ class GSettingsControllerQml: public QObject void edgeDragWidthChanged(uint edgeDragWidth); void enableIndicatorMenuChanged(bool enableIndicatorMenu); void appstoreUriChanged(const QString &appstoreUri); + void chargingStateVisibleChanged(bool chargingStateVisible); private: GSettingsControllerQml(); @@ -170,6 +178,7 @@ class GSettingsControllerQml: public QObject uint m_edgeDragWidth; bool m_enableIndicatorMenu; QString m_appstoreUri; + bool m_chargingStateVisible; static GSettingsControllerQml* s_controllerInstance; QList m_registeredGSettings; From 0a59e26026adcfb6005d4f48c47fabea0e779485 Mon Sep 17 00:00:00 2001 From: Willem-Jan de Hoog Date: Sun, 23 Feb 2020 09:51:24 -0500 Subject: [PATCH 04/11] added test cases for charge-state-visibility setting --- tests/mocks/GSettings.1.0/fake_gsettings.cpp | 7 +++++ tests/mocks/GSettings.1.0/fake_gsettings.h | 2 +- .../Panel/Indicators/tst_IndicatorsLight.qml | 27 +++++++++++++++++++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/tests/mocks/GSettings.1.0/fake_gsettings.cpp b/tests/mocks/GSettings.1.0/fake_gsettings.cpp index 10c84c660e..27249c4aa2 100644 --- a/tests/mocks/GSettings.1.0/fake_gsettings.cpp +++ b/tests/mocks/GSettings.1.0/fake_gsettings.cpp @@ -421,3 +421,10 @@ QVariant GSettingsQml::chargingStateVisible() const return QVariant(); } } + +void GSettingsQml::setChargingStateVisible(const QVariant &chargingStateVisible) +{ + if (m_valid && m_schema->id() == "com.canonical.Unity8.LedIndication") { + GSettingsControllerQml::instance()->setChargingStateVisible(chargingStateVisible.toBool()); + } +} diff --git a/tests/mocks/GSettings.1.0/fake_gsettings.h b/tests/mocks/GSettings.1.0/fake_gsettings.h index c59ae277f6..596e125ef2 100644 --- a/tests/mocks/GSettings.1.0/fake_gsettings.h +++ b/tests/mocks/GSettings.1.0/fake_gsettings.h @@ -59,7 +59,7 @@ class GSettingsQml: public QObject, public QQmlParserStatus Q_PROPERTY(QVariant edgeDragWidth READ edgeDragWidth WRITE setEdgeDragWidth NOTIFY edgeDragWidthChanged) Q_PROPERTY(QVariant enableIndicatorMenu READ enableIndicatorMenu WRITE setEnableIndicatorMenu NOTIFY enableIndicatorMenuChanged) Q_PROPERTY(QVariant appstoreUri READ appstoreUri NOTIFY appstoreUriChanged) - Q_PROPERTY(QVariant chargingStateVisible READ chargingStateVisible NOTIFY chargingStateVisibleChanged) + Q_PROPERTY(QVariant chargingStateVisible READ chargingStateVisible WRITE setChargingStateVisible NOTIFY chargingStateVisibleChanged) public: GSettingsQml(QObject *parent = nullptr); diff --git a/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml b/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml index 0595c683b3..a4f4e3eac0 100644 --- a/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml +++ b/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml @@ -19,6 +19,7 @@ import QtQuick.Layouts 1.1 import Unity.Test 0.1 as UT import Unity.Indicators 0.1 as Indicators import Ubuntu.Components 1.3 +import GSettings 1.0 import Powerd 0.1 import Lights 0.1 import QMenuModel 0.1 @@ -61,6 +62,11 @@ Item { Powerd.setStatus(Powerd.On, Powerd.Unknown); } + GSettings { + id: unity8settings + schema.id: "com.canonical.Unity8.LedIndication" + } + RowLayout { anchors.fill: parent anchors.margins: units.gu(1) @@ -155,6 +161,11 @@ Item { ActionData.data = noNewMessage; loader.sourceComponent = undefined; loader.sourceComponent = light; +<<<<<<< 13a676575372b8cbe881471311dbeb3e9d7c572c +======= + Powerd.setStatus(Powerd.On, Powerd.Unknown); + unity8settings.chargingStateVisible = true; +>>>>>>> added test cases for charge-state-visibility setting } function test_LightsStatus_data() { @@ -254,6 +265,7 @@ Item { powerd: Powerd.Off, actionData: batteryLevelDBusSignals["100"], wizardStatus: batteryIconNames.charging }, // +<<<<<<< 13a676575372b8cbe881471311dbeb3e9d7c572c // Support for Multicolor LED // { tag: "Powerd.Off with New Message & no support for multicolor led", @@ -265,14 +277,29 @@ Item { { tag: "Powerd.Off while charging & no support for multicolor led", expectedLightsState: Lights.Off, powerd: Powerd.Off, actionData: deviceStateDBusSignals.charging, supportsMultiColorLed: false }, +======= + // disabled charging state visible + // + { tag: "Powerd.Off with New Message & chargingStateVisible=false", + expectedLightsState: Lights.On, + powerd: Powerd.Off, actionData: newMessage, chargingStateVisible: false }, + { tag: "Powerd.Off while charging & chargingStateVisible=false", + expectedLightsState: Lights.Off, + powerd: Powerd.Off, actionData: deviceStateDBusSignals.charging, chargingStateVisible: false }, +>>>>>>> added test cases for charge-state-visibility setting ] } function test_LightsStatus(data) { console.log("----------------------------------------------------------------") +<<<<<<< 13a676575372b8cbe881471311dbeb3e9d7c572c if (data.hasOwnProperty("supportsMultiColorLed")) loader.item.supportsMultiColorLed = data.supportsMultiColorLed +======= + if (data.hasOwnProperty("chargingStateVisible")) + unity8settings.chargingStateVisible = data.chargingStateVisible +>>>>>>> added test cases for charge-state-visibility setting if (data.hasOwnProperty("powerd")) Powerd.setStatus(data.powerd, Powerd.Unknown) if (data.hasOwnProperty("actionData")) From a032671151ef51696ce2c61fffbe2beccd9439fa Mon Sep 17 00:00:00 2001 From: Willem-Jan de Hoog Date: Sun, 23 Feb 2020 10:25:09 -0500 Subject: [PATCH 05/11] update when settings has changed --- qml/Panel/Indicators/IndicatorsLight.qml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qml/Panel/Indicators/IndicatorsLight.qml b/qml/Panel/Indicators/IndicatorsLight.qml index 1cc8236e72..239d183d39 100644 --- a/qml/Panel/Indicators/IndicatorsLight.qml +++ b/qml/Panel/Indicators/IndicatorsLight.qml @@ -53,6 +53,9 @@ QtObject { property var _unity8Settings: GSettings { schema.id: "com.canonical.Unity8.LedIndication" + onChanged: { + root.updateLightState("onChanged (settings)") + } } onDisplayStatusChanged: { From 32dbcd50a85471fa629595805988bc7a9f940ecb Mon Sep 17 00:00:00 2001 From: Willem-Jan de Hoog Date: Sun, 23 Feb 2020 10:36:21 -0500 Subject: [PATCH 06/11] added missing signal --- tests/mocks/GSettings.1.0/fake_gsettings.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/mocks/GSettings.1.0/fake_gsettings.h b/tests/mocks/GSettings.1.0/fake_gsettings.h index 596e125ef2..d4b727bbaa 100644 --- a/tests/mocks/GSettings.1.0/fake_gsettings.h +++ b/tests/mocks/GSettings.1.0/fake_gsettings.h @@ -105,6 +105,10 @@ class GSettingsQml: public QObject, public QQmlParserStatus void appstoreUriChanged(); void chargingStateVisibleChanged(); + // This signal is not implemented but it's declaration is required + // for qml elements using the GSettings onChanged event. + void changed(const QString &key, const QVariant &value); + private: GSettingsSchemaQml* m_schema; bool m_valid; From 83ad23e42c535c9a4a4553d4530a7b58bb456c02 Mon Sep 17 00:00:00 2001 From: Willem-Jan de Hoog Date: Thu, 5 Mar 2020 10:58:33 -0500 Subject: [PATCH 07/11] use com.lomiri namespace for new setting --- data/CMakeLists.txt | 1 + data/com.lomiri.gschema.xml | 11 +++++++++++ qml/Panel/Indicators/IndicatorsLight.qml | 8 ++++---- tests/mocks/GSettings.1.0/fake_gsettings.cpp | 4 ++-- .../Panel/Indicators/tst_IndicatorsLight.qml | 19 ++++++------------- 5 files changed, 24 insertions(+), 19 deletions(-) create mode 100644 data/com.lomiri.gschema.xml diff --git a/data/CMakeLists.txt b/data/CMakeLists.txt index 2cb8c2d5a2..d6d146d3a8 100644 --- a/data/CMakeLists.txt +++ b/data/CMakeLists.txt @@ -22,6 +22,7 @@ install(FILES add_custom_target(pkgversion ALL COMMAND dpkg-parsechangelog -l${CMAKE_SOURCE_DIR}/debian/changelog --show-field version > ${CMAKE_CURRENT_BINARY_DIR}/version) +install(FILES com.lomiri.gschema.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas) install(FILES com.canonical.Unity8.gschema.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas) install(FILES com.canonical.Unity.gschema.xml DESTINATION ${CMAKE_INSTALL_DATADIR}/glib-2.0/schemas) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/version DESTINATION ${CMAKE_INSTALL_LOCALSTATEDIR}/lib/unity8) diff --git a/data/com.lomiri.gschema.xml b/data/com.lomiri.gschema.xml new file mode 100644 index 0000000000..c4794f0cdb --- /dev/null +++ b/data/com.lomiri.gschema.xml @@ -0,0 +1,11 @@ + + + + + true + Whether the battery charging state should be shown using the notification led + Toggle the visibility of the battery charging state in the notification led patterns + + + + diff --git a/qml/Panel/Indicators/IndicatorsLight.qml b/qml/Panel/Indicators/IndicatorsLight.qml index 239d183d39..a5475d4762 100644 --- a/qml/Panel/Indicators/IndicatorsLight.qml +++ b/qml/Panel/Indicators/IndicatorsLight.qml @@ -51,8 +51,8 @@ QtObject { updateLightState("onSupportsMultiColorLedChanged") } - property var _unity8Settings: GSettings { - schema.id: "com.canonical.Unity8.LedIndication" + property var _lomiriSettings: GSettings { + schema.id: "com.lomiri.LedIndication" onChanged: { root.updateLightState("onChanged (settings)") } @@ -75,7 +75,7 @@ QtObject { + ", displayStatus: " + displayStatus + ", deviceState: " + deviceState + ", batteryLevel: " + batteryLevel - + ", chargingStateVisible: " + _unity8Settings.chargingStateVisible) + + ", chargingStateVisible: " + _lomiriSettings.chargingStateVisible) // // If charging state visibility is disabled then only show messages. @@ -131,7 +131,7 @@ QtObject { } // if charging state is not to be shown set led off - if(!_unity8Settings.chargingStateVisible) { + if(!_lomiriSettings.chargingStateVisible) { indicatorState = "INDICATOR_OFF" return } diff --git a/tests/mocks/GSettings.1.0/fake_gsettings.cpp b/tests/mocks/GSettings.1.0/fake_gsettings.cpp index 27249c4aa2..6f70afa063 100644 --- a/tests/mocks/GSettings.1.0/fake_gsettings.cpp +++ b/tests/mocks/GSettings.1.0/fake_gsettings.cpp @@ -415,7 +415,7 @@ void GSettingsQml::setEnableIndicatorMenu(const QVariant &enableIndicatorMenu) QVariant GSettingsQml::chargingStateVisible() const { - if (m_valid && m_schema->id() == "com.canonical.Unity8.LedIndication") { + if (m_valid && m_schema->id() == "com.lomiri.LedIndication") { return GSettingsControllerQml::instance()->chargingStateVisible(); } else { return QVariant(); @@ -424,7 +424,7 @@ QVariant GSettingsQml::chargingStateVisible() const void GSettingsQml::setChargingStateVisible(const QVariant &chargingStateVisible) { - if (m_valid && m_schema->id() == "com.canonical.Unity8.LedIndication") { + if (m_valid && m_schema->id() == "com.lomiri.LedIndication") { GSettingsControllerQml::instance()->setChargingStateVisible(chargingStateVisible.toBool()); } } diff --git a/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml b/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml index a4f4e3eac0..1d66a32d0b 100644 --- a/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml +++ b/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml @@ -63,8 +63,8 @@ Item { } GSettings { - id: unity8settings - schema.id: "com.canonical.Unity8.LedIndication" + id: lomiriSettings + schema.id: "com.lomiri.LedIndication" } RowLayout { @@ -161,11 +161,8 @@ Item { ActionData.data = noNewMessage; loader.sourceComponent = undefined; loader.sourceComponent = light; -<<<<<<< 13a676575372b8cbe881471311dbeb3e9d7c572c -======= Powerd.setStatus(Powerd.On, Powerd.Unknown); - unity8settings.chargingStateVisible = true; ->>>>>>> added test cases for charge-state-visibility setting + lomiriSettings.chargingStateVisible = true; } function test_LightsStatus_data() { @@ -265,7 +262,6 @@ Item { powerd: Powerd.Off, actionData: batteryLevelDBusSignals["100"], wizardStatus: batteryIconNames.charging }, // -<<<<<<< 13a676575372b8cbe881471311dbeb3e9d7c572c // Support for Multicolor LED // { tag: "Powerd.Off with New Message & no support for multicolor led", @@ -277,7 +273,7 @@ Item { { tag: "Powerd.Off while charging & no support for multicolor led", expectedLightsState: Lights.Off, powerd: Powerd.Off, actionData: deviceStateDBusSignals.charging, supportsMultiColorLed: false }, -======= + // disabled charging state visible // { tag: "Powerd.Off with New Message & chargingStateVisible=false", @@ -286,20 +282,17 @@ Item { { tag: "Powerd.Off while charging & chargingStateVisible=false", expectedLightsState: Lights.Off, powerd: Powerd.Off, actionData: deviceStateDBusSignals.charging, chargingStateVisible: false }, ->>>>>>> added test cases for charge-state-visibility setting + ] } function test_LightsStatus(data) { console.log("----------------------------------------------------------------") -<<<<<<< 13a676575372b8cbe881471311dbeb3e9d7c572c if (data.hasOwnProperty("supportsMultiColorLed")) loader.item.supportsMultiColorLed = data.supportsMultiColorLed -======= if (data.hasOwnProperty("chargingStateVisible")) - unity8settings.chargingStateVisible = data.chargingStateVisible ->>>>>>> added test cases for charge-state-visibility setting + lomiriSettings.chargingStateVisible = data.chargingStateVisible if (data.hasOwnProperty("powerd")) Powerd.setStatus(data.powerd, Powerd.Unknown) if (data.hasOwnProperty("actionData")) From 4701cbd76d51848651ed96d872fff96ca6c01465 Mon Sep 17 00:00:00 2001 From: Willem-Jan de Hoog Date: Tue, 10 Mar 2020 12:59:14 -0400 Subject: [PATCH 08/11] remove unused schema --- data/com.canonical.Unity8.gschema.xml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/data/com.canonical.Unity8.gschema.xml b/data/com.canonical.Unity8.gschema.xml index d6e1b913d9..0041fd35ae 100644 --- a/data/com.canonical.Unity8.gschema.xml +++ b/data/com.canonical.Unity8.gschema.xml @@ -73,11 +73,4 @@ - - - true - Whether the battery charging state should be shown using the notification led - Toggle the visibility of the battery charging state in the notification led patterns - - From b48e90b84bbbc4b52b5c055bf0cab8b51aef00bf Mon Sep 17 00:00:00 2001 From: Willem-Jan de Hoog Date: Sun, 16 Aug 2020 14:21:57 -0400 Subject: [PATCH 09/11] use createTemporaryQmlObject instead of a Loader to create the object to test. The combination Loader/Component results in another instance in memory which also starts to control the led making testing impossible. --- .../Panel/Indicators/tst_IndicatorsLight.qml | 29 +++++++------------ 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml b/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml index 1d66a32d0b..310c18b640 100644 --- a/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml +++ b/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml @@ -47,16 +47,6 @@ Item { } }; - Component { - id: light - IndicatorsLight {} - } - - Loader { - id: loader - sourceComponent: light - } - Component.onCompleted: { ActionData.data = newMessage; Powerd.setStatus(Powerd.On, Powerd.Unknown); @@ -153,16 +143,15 @@ Item { property color orangeRed: "orangeRed" UT.UnityTestCase { + id: testCase name: "IndicatorsLight" when: windowShown function init() { // reload ActionData.data = noNewMessage; - loader.sourceComponent = undefined; - loader.sourceComponent = light; - Powerd.setStatus(Powerd.On, Powerd.Unknown); lomiriSettings.chargingStateVisible = true; + Powerd.setStatus(Powerd.On, Powerd.Unknown); } function test_LightsStatus_data() { @@ -274,12 +263,13 @@ Item { expectedLightsState: Lights.Off, powerd: Powerd.Off, actionData: deviceStateDBusSignals.charging, supportsMultiColorLed: false }, + // // disabled charging state visible // - { tag: "Powerd.Off with New Message & chargingStateVisible=false", + { tag: "Powerd.Off with New Message & chargingStateVisible==false", expectedLightsState: Lights.On, powerd: Powerd.Off, actionData: newMessage, chargingStateVisible: false }, - { tag: "Powerd.Off while charging & chargingStateVisible=false", + { tag: "Powerd.Off while charging & chargingStateVisible==false", expectedLightsState: Lights.Off, powerd: Powerd.Off, actionData: deviceStateDBusSignals.charging, chargingStateVisible: false }, @@ -287,10 +277,11 @@ Item { } function test_LightsStatus(data) { - console.log("----------------------------------------------------------------") + var item = createTemporaryQmlObject("import QtQuick 2.0; import\"" + Qt.resolvedUrl("../../../../qml/Panel/Indicators") + "\"; IndicatorsLight {}", testCase); - if (data.hasOwnProperty("supportsMultiColorLed")) - loader.item.supportsMultiColorLed = data.supportsMultiColorLed + console.log("----------------------------------------------------------------") + if (data.hasOwnProperty("supportsMultiColorLed")) + item.supportsMultiColorLed = data.supportsMultiColorLed if (data.hasOwnProperty("chargingStateVisible")) lomiriSettings.chargingStateVisible = data.chargingStateVisible if (data.hasOwnProperty("powerd")) @@ -298,7 +289,7 @@ Item { if (data.hasOwnProperty("actionData")) ActionData.data = data.actionData if (data.hasOwnProperty("wizardStatus")) - loader.item.batteryIconName = data.wizardStatus + item.batteryIconName = data.wizardStatus compare(Lights.state, data.expectedLightsState, "Lights state does not match expected value"); if (data.hasOwnProperty("expectedLightsColor")) From c8b6c30e7efc91d7eebb46a4b9f0dabb980edf9c Mon Sep 17 00:00:00 2001 From: Willem-Jan de Hoog Date: Sun, 16 Aug 2020 16:52:28 -0400 Subject: [PATCH 10/11] whitespace and a ; --- tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml b/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml index 310c18b640..83762e0183 100644 --- a/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml +++ b/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml @@ -280,7 +280,7 @@ Item { var item = createTemporaryQmlObject("import QtQuick 2.0; import\"" + Qt.resolvedUrl("../../../../qml/Panel/Indicators") + "\"; IndicatorsLight {}", testCase); console.log("----------------------------------------------------------------") - if (data.hasOwnProperty("supportsMultiColorLed")) + if (data.hasOwnProperty("supportsMultiColorLed")) item.supportsMultiColorLed = data.supportsMultiColorLed if (data.hasOwnProperty("chargingStateVisible")) lomiriSettings.chargingStateVisible = data.chargingStateVisible @@ -291,7 +291,7 @@ Item { if (data.hasOwnProperty("wizardStatus")) item.batteryIconName = data.wizardStatus - compare(Lights.state, data.expectedLightsState, "Lights state does not match expected value"); + compare(Lights.state, data.expectedLightsState, "Lights state does not match expected value") if (data.hasOwnProperty("expectedLightsColor")) compare(Lights.color, data.expectedLightsColor, "Lights color does not match expected value") if (data.hasOwnProperty("expectedLightsOnMillisec")) From 872a87b357004ab2a6dd3e6e43a5e00b6c83dc2c Mon Sep 17 00:00:00 2001 From: Willem-Jan de Hoog Date: Mon, 17 Aug 2020 14:12:21 -0400 Subject: [PATCH 11/11] two new test cases --- tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml b/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml index 83762e0183..f3d7b24f76 100644 --- a/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml +++ b/tests/qmltests/Panel/Indicators/tst_IndicatorsLight.qml @@ -264,7 +264,7 @@ Item { powerd: Powerd.Off, actionData: deviceStateDBusSignals.charging, supportsMultiColorLed: false }, // - // disabled charging state visible + // Charging state visibility // { tag: "Powerd.Off with New Message & chargingStateVisible==false", expectedLightsState: Lights.On, @@ -272,6 +272,12 @@ Item { { tag: "Powerd.Off while charging & chargingStateVisible==false", expectedLightsState: Lights.Off, powerd: Powerd.Off, actionData: deviceStateDBusSignals.charging, chargingStateVisible: false }, + { tag: "Powerd.Off while charging & chargingStateVisible==true", + expectedLightsState: Lights.On, + powerd: Powerd.Off, actionData: deviceStateDBusSignals.charging, chargingStateVisible: true }, + { tag: "Powerd.Off while charging & chargingStateVisible==true & no support for multicolor led", + expectedLightsState: Lights.Off, + powerd: Powerd.Off, actionData: deviceStateDBusSignals.charging, chargingStateVisible: true, supportsMultiColorLed: false }, ] }