aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2016-02-01 18:08:13 -0600
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-29 14:27:03 +0200
commit56a68ff8c80f439ff245e0be95464f4bf6e83d96 (patch)
tree5d346edbe68b516626b54e2915b5a2a2b0b208d2 /tests
parentfee2f8fdbe5a851643bed55decb14e1cff84cb8a (diff)
downloadayatana-indicator-datetime-56a68ff8c80f439ff245e0be95464f4bf6e83d96.tar.gz
ayatana-indicator-datetime-56a68ff8c80f439ff245e0be95464f4bf6e83d96.tar.bz2
ayatana-indicator-datetime-56a68ff8c80f439ff245e0be95464f4bf6e83d96.zip
add Settings tests for blacklisting apps' notifications
Diffstat (limited to 'tests')
-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);
+}