From 3cc2c952f3ec6d93649328a550f3ec5d10b238e2 Mon Sep 17 00:00:00 2001 From: Marius Gripsgard Date: Tue, 12 Jan 2021 12:18:03 +0100 Subject: Inital commit --- tests/CMakeLists.txt | 14 ++++++++++ tests/tst_utils.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 tests/CMakeLists.txt create mode 100644 tests/tst_utils.cpp (limited to 'tests') 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 + * + * 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 . + */ + +#include +#include + +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()); +} -- cgit v1.2.3