aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2016-02-01 18:08:13 -0600
committerRobert Tari <robert@tari.in>2021-06-30 15:41:30 +0200
commit12c6fdc0676521cf5ce6e7b92c9cc2da44a7c3db (patch)
treeead3f1bcffc399012594505f47c4875fe5dc7597
parent0b4ad877e1a5b083eda5c31227e476d969d00925 (diff)
downloadayatana-indicator-datetime-12c6fdc0676521cf5ce6e7b92c9cc2da44a7c3db.tar.gz
ayatana-indicator-datetime-12c6fdc0676521cf5ce6e7b92c9cc2da44a7c3db.tar.bz2
ayatana-indicator-datetime-12c6fdc0676521cf5ce6e7b92c9cc2da44a7c3db.zip
add Settings tests for blacklisting apps' notifications
-rw-r--r--tests/test-settings.cpp49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/test-settings.cpp b/tests/test-settings.cpp
index 3af9eab..d18b58a 100644
--- a/tests/test-settings.cpp
+++ b/tests/test-settings.cpp
@@ -22,6 +22,11 @@
#include <datetime/settings-live.h>
#include <datetime/settings-shared.h>
+extern "C"
+{
+ #include <ayatana/common/utils.h>
+}
+
using namespace ayatana::indicator::datetime;
/***
@@ -38,18 +43,26 @@ protected:
std::shared_ptr<LiveSettings> m_live;
std::shared_ptr<Settings> m_settings;
GSettings * m_gsettings;
+ GSettings * m_gsettings_cunh;
void SetUp() override
{
super::SetUp();
m_gsettings = g_settings_new(SETTINGS_INTERFACE);
+
+ if (ayatana_common_utils_is_lomiri())
+ {
+ m_gsettings_cunh = g_settings_new(SETTINGS_CUNH_SCHEMA_ID);
+ }
+
m_live.reset(new LiveSettings);
m_settings = std::dynamic_pointer_cast<Settings>(m_live);
}
void TearDown() override
{
+ g_clear_object(&m_gsettings_cunh);
g_clear_object(&m_gsettings);
m_settings.reset();
m_live.reset();
@@ -221,3 +234,39 @@ TEST_F(SettingsFixture, Locations)
g_strfreev(tmp);
EXPECT_EQ(bv, vtmp);
}
+
+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);
+}