aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/datetime/settings-live.h12
-rw-r--r--include/datetime/settings-shared.h9
-rw-r--r--include/datetime/settings.h6
-rw-r--r--src/settings-live.cpp115
-rw-r--r--src/snap.cpp45
-rw-r--r--tests/test-notification.cpp26
-rw-r--r--tests/test-settings.cpp111
7 files changed, 173 insertions, 151 deletions
diff --git a/include/datetime/settings-live.h b/include/datetime/settings-live.h
index 330b8e8..4aeaa9b 100644
--- a/include/datetime/settings-live.h
+++ b/include/datetime/settings-live.h
@@ -39,9 +39,9 @@ public:
private:
static void on_changed_ccid(GSettings*, gchar*, gpointer);
- static void on_changed_cunh(GSettings*, gchar*, gpointer);
+ static void on_changed_cal_notification(GSettings*, gchar*, gpointer);
void update_key_ccid(const std::string& key);
- void update_key_cunh(const std::string& key);
+ void update_key_cal_notification(const std::string& key);
void update_custom_time_format();
void update_locations();
@@ -62,10 +62,14 @@ private:
void update_alarm_duration();
void update_alarm_haptic();
void update_snooze_duration();
- void update_muted_apps();
+ void update_cal_notification_enabled();
+ void update_cal_notification_sounds();
+ void update_cal_notification_vibrations();
+ void update_cal_notification_bubbles();
+ void update_cal_notification_list();
GSettings* m_settings;
- GSettings* m_settings_cunh;
+ GSettings* m_settings_cal_notification;
// we've got a raw pointer here, so disable copying
LiveSettings(const LiveSettings&) =delete;
diff --git a/include/datetime/settings-shared.h b/include/datetime/settings-shared.h
index f385e7a..236b8f1 100644
--- a/include/datetime/settings-shared.h
+++ b/include/datetime/settings-shared.h
@@ -51,7 +51,12 @@ TimeFormatMode;
#define SETTINGS_ALARM_HAPTIC_S "alarm-haptic-feedback"
#define SETTINGS_SNOOZE_DURATION_S "snooze-duration-minutes"
-#define SETTINGS_CUNH_SCHEMA_ID "com.lomiri.notifications.hub"
-#define SETTINGS_CUNH_BLACKLIST_S "blacklist"
+#define SETTINGS_NOTIFY_SCHEMA_ID "com.lomiri.notifications.settings"
+#define SETTINGS_NOTIFY_CALENDAR_PATH "/com/lomiri/NotificationSettings/com.lomiri.calendar/calendar/"
+#define SETTINGS_NOTIFY_ENABLED_KEY "enable-notifications"
+#define SETTINGS_NOTIFY_SOUNDS_KEY "use-sounds-notifications"
+#define SETTINGS_NOTIFY_VIBRATIONS_KEY "use-vibrations-notifications"
+#define SETTINGS_NOTIFY_BUBBLES_KEY "use-bubbles-notifications"
+#define SETTINGS_NOTIFY_LIST_KEY "use-list-notifications"
#endif // INDICATOR_DATETIME_SETTINGS_SHARED
diff --git a/include/datetime/settings.h b/include/datetime/settings.h
index d5e81c6..5ae00f6 100644
--- a/include/datetime/settings.h
+++ b/include/datetime/settings.h
@@ -61,7 +61,11 @@ public:
core::Property<unsigned int> alarm_volume;
core::Property<unsigned int> alarm_duration;
core::Property<unsigned int> snooze_duration;
- core::Property<std::set<std::pair<std::string,std::string>>> muted_apps;
+ core::Property<bool> cal_notification_enabled;
+ core::Property<bool> cal_notification_sounds;
+ core::Property<bool> cal_notification_vibrations;
+ core::Property<bool> cal_notification_bubbles;
+ core::Property<bool> cal_notification_list;
};
} // namespace datetime
diff --git a/src/settings-live.cpp b/src/settings-live.cpp
index 6504d7d..f908c05 100644
--- a/src/settings-live.cpp
+++ b/src/settings-live.cpp
@@ -34,7 +34,7 @@ namespace datetime {
LiveSettings::~LiveSettings()
{
- g_clear_object(&m_settings_cunh);
+ g_clear_object(&m_settings_cal_notification);
g_clear_object(&m_settings);
}
@@ -44,8 +44,8 @@ LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE))
if (ayatana_common_utils_is_lomiri())
{
- m_settings_cunh = g_settings_new(SETTINGS_CUNH_SCHEMA_ID);
- g_signal_connect (m_settings_cunh, "changed", G_CALLBACK(on_changed_cunh), this);
+ 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);
}
// init the Properties from the GSettings backend
@@ -68,7 +68,11 @@ LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE))
update_alarm_duration();
update_alarm_haptic();
update_snooze_duration();
- update_muted_apps();
+ update_cal_notification_enabled();
+ update_cal_notification_sounds();
+ update_cal_notification_vibrations();
+ update_cal_notification_bubbles();
+ update_cal_notification_list();
// now listen for clients to change the properties s.t. we can sync update GSettings
@@ -76,20 +80,6 @@ LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE))
g_settings_set_string(m_settings, SETTINGS_CUSTOM_TIME_FORMAT_S, value.c_str());
});
- if (ayatana_common_utils_is_lomiri())
- {
- muted_apps.changed().connect([this](const std::set<std::pair<std::string,std::string>>& value){
- GVariantBuilder builder;
- g_variant_builder_init(&builder, G_VARIANT_TYPE("a(ss)"));
- for(const auto& app : value){
- const std::string& pkgname {app.first};
- const std::string& appname {app.second};
- g_variant_builder_add(&builder, "(ss)", pkgname.c_str(), appname.c_str());
- }
- g_settings_set_value(m_settings_cunh, SETTINGS_CUNH_BLACKLIST_S, g_variant_builder_end(&builder));
- });
- }
-
locations.changed().connect([this](const std::vector<std::string>& value){
const int n = value.size();
gchar** strv = g_new0(gchar*, n+1);
@@ -166,6 +156,26 @@ LiveSettings::LiveSettings(): m_settings(g_settings_new(SETTINGS_INTERFACE))
snooze_duration.changed().connect([this](unsigned int value){
g_settings_set_uint(m_settings, SETTINGS_SNOOZE_DURATION_S, value);
});
+
+ cal_notification_enabled.changed().connect([this](bool value){
+ g_settings_set_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_ENABLED_KEY, value);
+ });
+
+ cal_notification_sounds.changed().connect([this](bool value){
+ g_settings_set_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_SOUNDS_KEY, value);
+ });
+
+ cal_notification_vibrations.changed().connect([this](bool value){
+ g_settings_set_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_VIBRATIONS_KEY, value);
+ });
+
+ cal_notification_bubbles.changed().connect([this](bool value){
+ g_settings_set_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_BUBBLES_KEY, value);
+ });
+
+ cal_notification_list.changed().connect([this](bool value){
+ g_settings_set_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_LIST_KEY, value);
+ });
}
/***
@@ -189,27 +199,6 @@ void LiveSettings::update_locations()
locations.set(l);
}
-void LiveSettings::update_muted_apps()
-{
- if (ayatana_common_utils_is_lomiri())
- {
- std::set<std::pair<std::string,std::string>> apps;
-
- auto blacklist = g_settings_get_value(m_settings_cunh, SETTINGS_CUNH_BLACKLIST_S);
- GVariantIter* iter {nullptr};
- g_variant_get (blacklist, "a(ss)", &iter);
- gchar* pkgname;
- gchar* appname;
- while (g_variant_iter_loop (iter, "(ss)", &pkgname, &appname)) {
- apps.insert(std::make_pair(pkgname,appname));
- }
- g_variant_iter_free (iter);
- g_clear_pointer(&blacklist, g_variant_unref);
-
- muted_apps.set(apps);
- }
-}
-
void LiveSettings::update_show_calendar()
{
const auto val = g_settings_get_boolean(m_settings, SETTINGS_SHOW_CALENDAR_S);
@@ -308,21 +297,55 @@ void LiveSettings::update_snooze_duration()
snooze_duration.set(g_settings_get_uint(m_settings, SETTINGS_SNOOZE_DURATION_S));
}
+void LiveSettings::update_cal_notification_enabled()
+{
+ cal_notification_enabled.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_ENABLED_KEY));
+}
+
+void LiveSettings::update_cal_notification_sounds()
+{
+ cal_notification_sounds.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_SOUNDS_KEY));
+}
+
+void LiveSettings::update_cal_notification_vibrations()
+{
+ cal_notification_vibrations.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_VIBRATIONS_KEY));
+}
+
+void LiveSettings::update_cal_notification_bubbles()
+{
+ cal_notification_bubbles.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_BUBBLES_KEY));
+}
+
+void LiveSettings::update_cal_notification_list()
+{
+ cal_notification_list.set(g_settings_get_boolean(m_settings_cal_notification, SETTINGS_NOTIFY_LIST_KEY));
+}
+
/***
****
***/
-void LiveSettings::on_changed_cunh(GSettings* /*settings*/,
- gchar* key,
- gpointer gself)
+void LiveSettings::on_changed_cal_notification(GSettings* /*settings*/,
+ gchar* key,
+ gpointer gself)
{
- static_cast<LiveSettings*>(gself)->update_key_cunh(key);
+ static_cast<LiveSettings*>(gself)->update_key_cal_notification(key);
}
-void LiveSettings::update_key_cunh(const std::string& key)
+
+void LiveSettings::update_key_cal_notification(const std::string& key)
{
- if (key == SETTINGS_CUNH_BLACKLIST_S)
- update_muted_apps();
+ if (key == SETTINGS_NOTIFY_ENABLED_KEY)
+ update_cal_notification_enabled();
+ else if (key == SETTINGS_NOTIFY_SOUNDS_KEY)
+ update_cal_notification_sounds();
+ else if (key == SETTINGS_NOTIFY_VIBRATIONS_KEY)
+ update_cal_notification_vibrations();
+ else if (key == SETTINGS_NOTIFY_BUBBLES_KEY)
+ update_cal_notification_bubbles();
+ else if (key == SETTINGS_NOTIFY_LIST_KEY)
+ update_cal_notification_list();
}
/***
diff --git a/src/snap.cpp b/src/snap.cpp
index 51d04ae..1e71e7b 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -83,9 +83,9 @@ public:
const Alarm& alarm,
response_func on_response)
{
- // If calendar notifications are muted, don't show them
- if (!appointment.is_ubuntu_alarm() && calendar_events_are_muted()) {
- g_debug("Skipping muted calendar event '%s' notification", appointment.summary.c_str());
+ // If calendar notifications are disabled, don't show them
+ if (!appointment.is_ubuntu_alarm() && !calendar_notifications_are_enabled()) {
+ g_debug("Skipping disabled calendar event '%s' notification", appointment.summary.c_str());
return;
}
@@ -96,13 +96,14 @@ public:
const bool interactive = appointment.is_ubuntu_alarm() && m_engine->supports_actions();
// force the system to stay awake
- auto awake = std::make_shared<ain::Awake>(m_engine->app_name());
+ std::shared_ptr<ain::Awake> awake;
+ if (calendar_bubbles_enabled()) {
+ awake = std::make_shared<uin::Awake>(m_engine->app_name());
+ }
// calendar events are muted in silent mode; alarm clocks never are
std::shared_ptr<ain::Sound> sound;
- // FIXME: only play sounds for alarms for now, we should itegrate it with
- // system settings to decide if we should play sounds for calendar notification or not
- if (appointment.is_ubuntu_alarm()) {
+ if (appointment.is_ubuntu_alarm() || calendar_sounds_enabled()) {
// create the sound.
const auto role = appointment.is_ubuntu_alarm() ? "alarm" : "alert";
const auto uri = get_alarm_uri(appointment, alarm, m_settings);
@@ -113,7 +114,7 @@ public:
// create the haptic feedback...
std::shared_ptr<ain::Haptic> haptic;
- if (should_vibrate()) {
+ if (should_vibrate() && calendar_vibrations_enabled()) {
const auto haptic_mode = m_settings->alarm_haptic.get();
if (haptic_mode == "pulse")
haptic = std::make_shared<ain::Haptic>(ain::Haptic::MODE_PULSE, appointment.is_ubuntu_alarm());
@@ -189,15 +190,29 @@ public:
private:
- bool calendar_events_are_muted() const
+ bool calendar_notifications_are_enabled() const
{
- for(const auto& app : m_settings->muted_apps.get()) {
- if (app.first == "com.ubuntu.calendar") {
- return true;
- }
- }
+ return m_settings->cal_notification_enabled.get();
+ }
+
+ bool calendar_sounds_enabled() const
+ {
+ return m_settings->cal_notification_sounds.get();
+ }
- return false;
+ bool calendar_vibrations_enabled() const
+ {
+ return m_settings->cal_notification_vibrations.get();
+ }
+
+ bool calendar_bubbles_enabled() const
+ {
+ return m_settings->cal_notification_bubbles.get();
+ }
+
+ bool calendar_list_enabled() const
+ {
+ return m_settings->cal_notification_list.get();
}
static void on_sound_proxy_ready(GObject* /*source_object*/, GAsyncResult* res, gpointer gself)
diff --git a/tests/test-notification.cpp b/tests/test-notification.cpp
index 50d7b57..b84c6f8 100644
--- a/tests/test-notification.cpp
+++ b/tests/test-notification.cpp
@@ -87,18 +87,16 @@ TEST_F(NotificationFixture,Notification)
{ false, true, false }
};
- // combinatorial factor #4: system settings' notifications app blacklist
- const std::set<std::pair<std::string,std::string>> blacklist_calendar { std::make_pair(std::string{"com.lomiri.calendar"}, std::string{"calendar-app"}) };
- const std::set<std::pair<std::string,std::string>> blacklist_empty;
+ // combinatorial factor #4: system settings' notifications disabled
struct {
- std::set<std::pair<std::string,std::string>> muted_apps; // apps that should not trigger notifications
+ bool cal_notification_enabled; // calendar app can trigger notifications
std::set<Appointment::Type> expected_notify_called; // do we expect the notification to show?
std::set<Appointment::Type> expected_vibrate_called; // do we expect the phone to vibrate?
- } test_muted_apps[] = {
- { blacklist_empty, std::set<Appointment::Type>{ Appointment::Type::UBUNTU_ALARM, Appointment::Type::EVENT },
- std::set<Appointment::Type>{ Appointment::Type::UBUNTU_ALARM, Appointment::Type::EVENT } },
- { blacklist_calendar, std::set<Appointment::Type>{ Appointment::Type::UBUNTU_ALARM },
- std::set<Appointment::Type>{ Appointment::Type::UBUNTU_ALARM } }
+ } test_cal_disabled[] = {
+ { true, std::set<Appointment::Type>{ Appointment::Type::UBUNTU_ALARM, Appointment::Type::EVENT },
+ std::set<Appointment::Type>{ Appointment::Type::UBUNTU_ALARM, Appointment::Type::EVENT } },
+ { false, std::set<Appointment::Type>{ Appointment::Type::UBUNTU_ALARM },
+ std::set<Appointment::Type>{ Appointment::Type::UBUNTU_ALARM } }
};
for (const auto& test_appt : test_appts)
@@ -107,20 +105,20 @@ TEST_F(NotificationFixture,Notification)
{
for (const auto& test_vibes : test_other_vibrations)
{
- for (const auto& test_muted : test_muted_apps)
+ for (const auto& test_disabled : test_cal_disabled)
{
const bool expected_notify_called = test_appt.expected_notify_called
&& test_vibes.expected_notify_called
- && (test_muted.expected_notify_called.count(test_appt.appt.type) > 0)
+ && (test_disabled.expected_notify_called.count(test_appt.appt.type) > 0)
&& test_haptic.expected_notify_called;
const bool expected_vibrate_called = test_appt.expected_vibrate_called
&& test_vibes.expected_vibrate_called
- && (test_muted.expected_vibrate_called.count(test_appt.appt.type) > 0)
+ && (test_disabled.expected_vibrate_called.count(test_appt.appt.type) > 0)
&& test_haptic.expected_vibrate_called;
- // set test case properties: blacklist
- settings->muted_apps.set(test_muted.muted_apps);
+ // set test case properties: cal_notification_enabled
+ settings->cal_notification_enabled.set(test_disabled.cal_notification_enabled);
// set test case properties: haptic mode
settings->alarm_haptic.set(test_haptic.haptic_mode);
diff --git a/tests/test-settings.cpp b/tests/test-settings.cpp
index d18b58a..d0ee369 100644
--- a/tests/test-settings.cpp
+++ b/tests/test-settings.cpp
@@ -43,7 +43,7 @@ protected:
std::shared_ptr<LiveSettings> m_live;
std::shared_ptr<Settings> m_settings;
GSettings * m_gsettings;
- GSettings * m_gsettings_cunh;
+ GSettings * m_gsettings_cal_notification;
void SetUp() override
{
@@ -53,7 +53,7 @@ protected:
if (ayatana_common_utils_is_lomiri())
{
- m_gsettings_cunh = g_settings_new(SETTINGS_CUNH_SCHEMA_ID);
+ m_gsettings_cal_notification = g_settings_new_with_path(SETTINGS_NOTIFY_SCHEMA_ID, SETTINGS_NOTIFY_CALENDAR_PATH);
}
m_live.reset(new LiveSettings);
@@ -62,7 +62,7 @@ protected:
void TearDown() override
{
- g_clear_object(&m_gsettings_cunh);
+ g_clear_object(&m_gsettings_cal_notification);
g_clear_object(&m_gsettings);
m_settings.reset();
m_live.reset();
@@ -70,62 +70,62 @@ protected:
super::TearDown();
}
- void TestBoolProperty(core::Property<bool>& property, const gchar* key)
+ void TestBoolProperty(GSettings* gsettings, core::Property<bool>& property, const gchar* key)
{
- EXPECT_EQ(g_settings_get_boolean(m_gsettings, key), property.get());
- g_settings_set_boolean(m_gsettings, key, false);
+ EXPECT_EQ(g_settings_get_boolean(gsettings, key), property.get());
+ g_settings_set_boolean(gsettings, key, false);
EXPECT_FALSE(property.get());
- g_settings_set_boolean(m_gsettings, key, true);
+ g_settings_set_boolean(gsettings, key, true);
EXPECT_TRUE(property.get());
property.set(false);
- EXPECT_FALSE(g_settings_get_boolean(m_gsettings, key));
+ EXPECT_FALSE(g_settings_get_boolean(gsettings, key));
property.set(true);
- EXPECT_TRUE(g_settings_get_boolean(m_gsettings, key));
+ EXPECT_TRUE(g_settings_get_boolean(gsettings, key));
}
- void TestStringProperty(core::Property<std::string>& property, const gchar* key)
+ void TestStringProperty(GSettings* gsettings, core::Property<std::string>& property, const gchar* key)
{
gchar* tmp;
std::string str;
- tmp = g_settings_get_string(m_gsettings, key);
+ tmp = g_settings_get_string(gsettings, key);
EXPECT_EQ(tmp, property.get());
g_clear_pointer(&tmp, g_free);
str = "a";
- g_settings_set_string(m_gsettings, key, str.c_str());
+ g_settings_set_string(gsettings, key, str.c_str());
EXPECT_EQ(str, property.get());
str = "b";
- g_settings_set_string(m_gsettings, key, str.c_str());
+ g_settings_set_string(gsettings, key, str.c_str());
EXPECT_EQ(str, property.get());
str = "a";
property.set(str);
- tmp = g_settings_get_string(m_gsettings, key);
+ tmp = g_settings_get_string(gsettings, key);
EXPECT_EQ(str, tmp);
g_clear_pointer(&tmp, g_free);
str = "b";
property.set(str);
- tmp = g_settings_get_string(m_gsettings, key);
+ tmp = g_settings_get_string(gsettings, key);
EXPECT_EQ(str, tmp);
g_clear_pointer(&tmp, g_free);
}
- void TestUIntProperty(core::Property<unsigned int>& property, const gchar* key)
+ void TestUIntProperty(GSettings* gsettings, core::Property<unsigned int>& property, const gchar* key)
{
- EXPECT_EQ(g_settings_get_uint(m_gsettings, key), property.get());
+ EXPECT_EQ(g_settings_get_uint(gsettings, key), property.get());
unsigned int expected_values[] = { 1, 2, 3 };
// modify GSettings and confirm that the new value is propagated
for(const auto& expected_value : expected_values)
{
- g_settings_set_uint(m_gsettings, key, expected_value);
+ g_settings_set_uint(gsettings, key, expected_value);
EXPECT_EQ(expected_value, property.get());
- EXPECT_EQ(expected_value, g_settings_get_uint(m_gsettings, key));
+ EXPECT_EQ(expected_value, g_settings_get_uint(gsettings, key));
}
// modify the property and confirm that the new value is propagated
@@ -133,7 +133,7 @@ protected:
{
property.set(expected_value);
EXPECT_EQ(expected_value, property.get());
- EXPECT_EQ(expected_value, g_settings_get_uint(m_gsettings, key));
+ EXPECT_EQ(expected_value, g_settings_get_uint(gsettings, key));
}
}
};
@@ -149,31 +149,31 @@ TEST_F(SettingsFixture, HelloWorld)
TEST_F(SettingsFixture, BoolProperties)
{
- TestBoolProperty(m_settings->show_seconds, SETTINGS_SHOW_SECONDS_S);
- TestBoolProperty(m_settings->show_calendar, SETTINGS_SHOW_CALENDAR_S);
- TestBoolProperty(m_settings->show_date, SETTINGS_SHOW_DATE_S);
- TestBoolProperty(m_settings->show_day, SETTINGS_SHOW_DAY_S);
- TestBoolProperty(m_settings->show_detected_location, SETTINGS_SHOW_DETECTED_S);
- TestBoolProperty(m_settings->show_events, SETTINGS_SHOW_EVENTS_S);
- TestBoolProperty(m_settings->show_locations, SETTINGS_SHOW_LOCATIONS_S);
- TestBoolProperty(m_settings->show_week_numbers, SETTINGS_SHOW_WEEK_NUMBERS_S);
- TestBoolProperty(m_settings->show_year, SETTINGS_SHOW_YEAR_S);
+ TestBoolProperty(m_gsettings, m_settings->show_seconds, SETTINGS_SHOW_SECONDS_S);
+ TestBoolProperty(m_gsettings, m_settings->show_calendar, SETTINGS_SHOW_CALENDAR_S);
+ TestBoolProperty(m_gsettings, m_settings->show_date, SETTINGS_SHOW_DATE_S);
+ TestBoolProperty(m_gsettings, m_settings->show_day, SETTINGS_SHOW_DAY_S);
+ TestBoolProperty(m_gsettings, m_settings->show_detected_location, SETTINGS_SHOW_DETECTED_S);
+ TestBoolProperty(m_gsettings, m_settings->show_events, SETTINGS_SHOW_EVENTS_S);
+ TestBoolProperty(m_gsettings, m_settings->show_locations, SETTINGS_SHOW_LOCATIONS_S);
+ TestBoolProperty(m_gsettings, m_settings->show_week_numbers, SETTINGS_SHOW_WEEK_NUMBERS_S);
+ TestBoolProperty(m_gsettings, m_settings->show_year, SETTINGS_SHOW_YEAR_S);
}
TEST_F(SettingsFixture, UIntProperties)
{
- TestUIntProperty(m_settings->alarm_duration, SETTINGS_ALARM_DURATION_S);
- TestUIntProperty(m_settings->alarm_volume, SETTINGS_ALARM_VOLUME_S);
- TestUIntProperty(m_settings->snooze_duration, SETTINGS_SNOOZE_DURATION_S);
+ TestUIntProperty(m_gsettings, m_settings->alarm_duration, SETTINGS_ALARM_DURATION_S);
+ TestUIntProperty(m_gsettings, m_settings->alarm_volume, SETTINGS_ALARM_VOLUME_S);
+ TestUIntProperty(m_gsettings, m_settings->snooze_duration, SETTINGS_SNOOZE_DURATION_S);
}
TEST_F(SettingsFixture, StringProperties)
{
- TestStringProperty(m_settings->custom_time_format, SETTINGS_CUSTOM_TIME_FORMAT_S);
- TestStringProperty(m_settings->timezone_name, SETTINGS_TIMEZONE_NAME_S);
- TestStringProperty(m_settings->alarm_sound, SETTINGS_ALARM_SOUND_S);
- TestStringProperty(m_settings->calendar_sound, SETTINGS_CALENDAR_SOUND_S);
- TestStringProperty(m_settings->alarm_haptic, SETTINGS_ALARM_HAPTIC_S);
+ TestStringProperty(m_gsettings, m_settings->custom_time_format, SETTINGS_CUSTOM_TIME_FORMAT_S);
+ TestStringProperty(m_gsettings, m_settings->timezone_name, SETTINGS_TIMEZONE_NAME_S);
+ TestStringProperty(m_gsettings, m_settings->alarm_sound, SETTINGS_ALARM_SOUND_S);
+ TestStringProperty(m_gsettings, m_settings->calendar_sound, SETTINGS_CALENDAR_SOUND_S);
+ TestStringProperty(m_gsettings, m_settings->alarm_haptic, SETTINGS_ALARM_HAPTIC_S);
}
TEST_F(SettingsFixture, TimeFormatMode)
@@ -237,36 +237,9 @@ TEST_F(SettingsFixture, Locations)
TEST_F(SettingsFixture, MutedApps)
{
- const auto key = SETTINGS_CUNH_BLACKLIST_S;
-
- struct {
- std::string pkgname;
- std::string appname;
- } apps[] = {
- { "", "lomiri-system-settings" },
- { "com.lomiri.calendar", "calendar" },
- { "com.lomiri.developer.webapps.webapp-facebook", "webapp-facebook" },
- { "com.lomiri.reminders", "reminders" }
- };
- std::set<std::pair<std::string,std::string>> apps_set;
- for (const auto& app : apps)
- apps_set.insert(std::make_pair(app.pkgname, app.appname));
-
- // test that changing Settings is reflected in the schema
- m_settings->muted_apps.set(apps_set);
- auto v = g_settings_get_value(m_gsettings_cunh, key);
- auto str = g_variant_print(v, true);
- EXPECT_STREQ("[('', 'lomiri-system-settings'), ('com.lomiri.calendar', 'calendar'), ('com.lomiri.developer.webapps.webapp-facebook', 'webapp-facebook'), ('com.lomiri.reminders', 'reminders')]", str);
- g_clear_pointer(&str, g_free);
-
- // test that clearing the schema clears the settings
- g_settings_reset(m_gsettings_cunh, key);
- EXPECT_EQ(0, m_settings->muted_apps.get().size());
-
- // test thst setting the schema updates the settings
- g_settings_set_value(m_gsettings_cunh, key, v);
- EXPECT_EQ(apps_set, m_settings->muted_apps.get());
-
- // cleanup
- g_clear_pointer(&v, g_variant_unref);
+ 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);
+ TestBoolProperty(m_gsettings_cal_notification, m_settings->cal_notification_bubbles, SETTINGS_NOTIFY_BUBBLES_KEY);
+ TestBoolProperty(m_gsettings_cal_notification, m_settings->cal_notification_list, SETTINGS_NOTIFY_LIST_KEY);
}