aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMarius Gripsgard <marius@ubports.com>2021-01-12 12:18:03 +0100
committerMarius Gripsgard <marius@ubports.com>2021-01-12 12:18:03 +0100
commit3cc2c952f3ec6d93649328a550f3ec5d10b238e2 (patch)
tree50dd30cb7ab1061ce45abd406656d82da537d8a2 /tests
downloadlibayatana-common-3cc2c952f3ec6d93649328a550f3ec5d10b238e2.tar.gz
libayatana-common-3cc2c952f3ec6d93649328a550f3ec5d10b238e2.tar.bz2
libayatana-common-3cc2c952f3ec6d93649328a550f3ec5d10b238e2.zip
Inital commit
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt14
-rw-r--r--tests/tst_utils.cpp74
2 files changed, 88 insertions, 0 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
new file mode 100644
index 0000000..d4c068c
--- /dev/null
+++ b/tests/CMakeLists.txt
@@ -0,0 +1,14 @@
+find_package(GMock)
+
+include_directories(
+ ${CMAKE_SOURCE_DIR}/src
+)
+
+add_executable(tst_utils tst_utils.cpp)
+target_link_libraries(tst_utils
+ ayatana-common
+
+ ${GTEST_LIBRARIES}
+ ${GTEST_BOTH_LIBRARIES}
+)
+add_test(TstUtils tst_utils)
diff --git a/tests/tst_utils.cpp b/tests/tst_utils.cpp
new file mode 100644
index 0000000..d7a4946
--- /dev/null
+++ b/tests/tst_utils.cpp
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2021 Marius Gripsgard <marius@ubports.com>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 3, as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranties of
+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtest/gtest.h>
+#include <memory>
+
+extern "C" {
+ #include "utils.h"
+}
+
+class XdgCurrentDesktopUtilsTest : public ::testing::Test
+{
+public:
+ XdgCurrentDesktopUtilsTest() {}
+
+ void SetUp() {
+ unsetenv("XDG_CURRENT_DESKTOP");
+ }
+
+ void TearDown() {
+ unsetenv("XDG_CURRENT_DESKTOP");
+ }
+};
+
+TEST_F(XdgCurrentDesktopUtilsTest, isLomiri)
+{
+ EXPECT_FALSE(is_lomiri());
+ setenv("XDG_CURRENT_DESKTOP", "Lomiri", 1);
+ EXPECT_TRUE(is_lomiri());
+}
+
+TEST_F(XdgCurrentDesktopUtilsTest, isGnome)
+{
+ EXPECT_FALSE(is_gnome());
+ setenv("XDG_CURRENT_DESKTOP", "GNOME", 1);
+ EXPECT_TRUE(is_gnome());
+}
+TEST_F(XdgCurrentDesktopUtilsTest, isUnity)
+{
+ EXPECT_FALSE(is_unity());
+ setenv("XDG_CURRENT_DESKTOP", "Unity", 1);
+ EXPECT_TRUE(is_unity());
+}
+TEST_F(XdgCurrentDesktopUtilsTest, isMate)
+{
+ EXPECT_FALSE(is_mate());
+ setenv("XDG_CURRENT_DESKTOP", "MATE", 1);
+ EXPECT_TRUE(is_mate());
+}
+TEST_F(XdgCurrentDesktopUtilsTest, isXfce)
+{
+ EXPECT_FALSE(is_xfce());
+ setenv("XDG_CURRENT_DESKTOP", "XFCE", 1);
+ EXPECT_TRUE(is_xfce());
+}
+TEST_F(XdgCurrentDesktopUtilsTest, isPantheon)
+{
+ EXPECT_FALSE(is_pantheon());
+ setenv("XDG_CURRENT_DESKTOP", "PANTHEON", 1);
+ EXPECT_TRUE(is_pantheon());
+}