aboutsummaryrefslogtreecommitdiff
path: root/tests/tst_utils.vala
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-26 07:33:21 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-26 07:33:21 +0200
commitb32fac907b6e61f0f94d28d0e44d77bf0883c8e2 (patch)
treec32ed6a4be5b03d5e5bccd8f7c510cac278a8854 /tests/tst_utils.vala
parent7f9519e1b54d4e864f2573583945419ef56f8a05 (diff)
parentc7320dab38cb2dda29226eab2c8705b5a132ac87 (diff)
downloadlibayatana-common-b32fac907b6e61f0f94d28d0e44d77bf0883c8e2.tar.gz
libayatana-common-b32fac907b6e61f0f94d28d0e44d77bf0883c8e2.tar.bz2
libayatana-common-b32fac907b6e61f0f94d28d0e44d77bf0883c8e2.zip
Merge branch 'tari01-pr/add-vala-bindings'
Attributes GH PR #35: https://github.com/AyatanaIndicators/libayatana-common/pull/35
Diffstat (limited to 'tests/tst_utils.vala')
-rw-r--r--tests/tst_utils.vala57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/tst_utils.vala b/tests/tst_utils.vala
new file mode 100644
index 0000000..b46fb24
--- /dev/null
+++ b/tests/tst_utils.vala
@@ -0,0 +1,57 @@
+using AyatanaCommon;
+using Environment;
+
+static int main(string[] args)
+{
+ assert_true(args.length == 2);
+
+ unset_variable("XDG_CURRENT_DESKTOP");
+
+ assert_false(utils_is_lomiri());
+ set_variable("XDG_CURRENT_DESKTOP", "Lomiri", true);
+ assert_true(utils_is_lomiri());
+
+ assert_false(utils_is_gnome());
+ set_variable("XDG_CURRENT_DESKTOP", "GNOME", true);
+ assert_true(utils_is_gnome());
+
+ assert_false(utils_is_unity());
+ set_variable("XDG_CURRENT_DESKTOP", "Unity", true);
+ assert_true(utils_is_unity());
+
+ assert_false(utils_is_mate());
+ set_variable("XDG_CURRENT_DESKTOP", "MATE", true);
+ assert_true(utils_is_mate());
+
+ assert_false(utils_is_xfce());
+ set_variable("XDG_CURRENT_DESKTOP", "XFCE", true);
+ assert_true(utils_is_xfce());
+
+ assert_false(utils_is_pantheon());
+ set_variable("XDG_CURRENT_DESKTOP", "PANTHEON", true);
+ assert_true(utils_is_pantheon());
+
+ assert_false(utils_is_budgie());
+ set_variable("XDG_CURRENT_DESKTOP", "Budgie:GNOME", true);
+ assert_true(utils_is_budgie());
+
+ unset_variable("XDG_CURRENT_DESKTOP");
+ set_variable("GSETTINGS_SCHEMA_DIR", args[1], true);
+ set_variable("GSETTINGS_BACKEND", "memory", true);
+
+ Settings pSettings = new Settings("org.ayatana.common");
+ string sTest = "123456789012345678901234567890123456789012345öüóőúéáűšđß";
+ pSettings.set_uint("max-menu-text-length", 0);
+ utils_ellipsize(sTest);
+ assert_true(sTest == "123456789012345678901234567890123456789012345öüóőúéáűšđß");
+
+ pSettings.set_uint("max-menu-text-length", 100);
+ utils_ellipsize(sTest);
+ assert_true(sTest == "123456789012345678901234567890123456789012345öüóőúéáűšđß");
+
+ pSettings.set_uint("max-menu-text-length", 50);
+ utils_ellipsize(sTest);
+ assert_true(sTest == "123456789012345678901234567890123456789012345öüóőú...");
+
+ return 0;
+}