aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Mello <arthur.mello@canonical.com>2016-06-24 11:45:30 -0300
committerRobert Tari <robert@tari.in>2021-07-08 00:48:29 +0200
commit2203d0b2031b7dc99fe7381a9efac431bc3ad410 (patch)
tree41e8c60daa4af938646e2e2c399bb00b74f41011
parentc0f53270674c6dbfe2eadf38e999c2536c4af4e3 (diff)
downloadayatana-indicator-datetime-2203d0b2031b7dc99fe7381a9efac431bc3ad410.tar.gz
ayatana-indicator-datetime-2203d0b2031b7dc99fe7381a9efac431bc3ad410.tar.bz2
ayatana-indicator-datetime-2203d0b2031b7dc99fe7381a9efac431bc3ad410.zip
Do not fail tests if schema is not installed
-rw-r--r--src/settings-live.cpp12
-rw-r--r--tests/test-settings.cpp10
2 files changed, 18 insertions, 4 deletions
diff --git a/src/settings-live.cpp b/src/settings-live.cpp
index 39d8e18..17c0ef7 100644
--- a/src/settings-live.cpp
+++ b/src/settings-live.cpp
@@ -38,14 +38,20 @@ LiveSettings::~LiveSettings()
g_clear_object(&m_settings);
}
-LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE))
+LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE)), m_gsettings_cal_notification(NULL)
{
g_signal_connect (m_settings, "changed", G_CALLBACK(on_changed_ccid), this);
if (ayatana_common_utils_is_lomiri())
{
- m_settings_cal_notification = g_settings_new_with_path(SETTINGS_NOTIFY_SCHEMA_ID, SETTINGS_NOTIFY_CALENDAR_PATH);
- g_signal_connect (m_settings_cal_notification, "changed", G_CALLBACK(on_changed_cal_notification), this);
+ GSettingsSchemaSource *source = g_settings_schema_source_get_default();
+ if (g_settings_schema_source_lookup(source, SETTINGS_NOTIFY_SCHEMA_ID, true)) {
+ m_gsettings_cal_notification = g_settings_new_with_path(SETTINGS_NOTIFY_SCHEMA_ID, SETTINGS_NOTIFY_CALENDAR_PATH);
+ }
+
+ if (m_gsettings_cal_notification) {
+ g_signal_connect (m_settings_cal_notification, "changed", G_CALLBACK(on_changed_cal_notification), this);
+ }
}
// init the Properties from the GSettings backend
diff --git a/tests/test-settings.cpp b/tests/test-settings.cpp
index d0ee369..104750a 100644
--- a/tests/test-settings.cpp
+++ b/tests/test-settings.cpp
@@ -44,6 +44,7 @@ protected:
std::shared_ptr<Settings> m_settings;
GSettings * m_gsettings;
GSettings * m_gsettings_cal_notification;
+ GSettingsSchemaSource *source = g_settings_schema_source_get_default();
void SetUp() override
{
@@ -53,7 +54,10 @@ protected:
if (ayatana_common_utils_is_lomiri())
{
- m_gsettings_cal_notification = g_settings_new_with_path(SETTINGS_NOTIFY_SCHEMA_ID, SETTINGS_NOTIFY_CALENDAR_PATH);
+
+ if (g_settings_schema_source_lookup(source, SETTINGS_NOTIFY_SCHEMA_ID, true)) {
+ m_gsettings_cal_notification = g_settings_new_with_path(SETTINGS_NOTIFY_SCHEMA_ID, SETTINGS_NOTIFY_CALENDAR_PATH);
+ }
}
m_live.reset(new LiveSettings);
@@ -237,6 +241,10 @@ TEST_F(SettingsFixture, Locations)
TEST_F(SettingsFixture, MutedApps)
{
+ if (!m_gsettings_cal_notification) {
+ return;
+ }
+
TestBoolProperty(m_gsettings_cal_notification, m_settings->cal_notification_enabled, SETTINGS_NOTIFY_ENABLED_KEY);
TestBoolProperty(m_gsettings_cal_notification, m_settings->cal_notification_sounds, SETTINGS_NOTIFY_SOUNDS_KEY);
TestBoolProperty(m_gsettings_cal_notification, m_settings->cal_notification_vibrations, SETTINGS_NOTIFY_VIBRATIONS_KEY);