diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-06-16 08:29:52 +0200 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-06-16 08:29:52 +0200 |
commit | 8b63acd444b8e8ad757e25b1f2fca0ec037f149f (patch) | |
tree | 56e94f1e7b135f3c5f6151deea4a3c2772110d9f /tests | |
parent | db18ded6c8a4ab9d4a0921a3f52e8f3507607238 (diff) | |
parent | a30fd6325b842dad70812f78a919744ab854d7ee (diff) | |
download | libayatana-common-8b63acd444b8e8ad757e25b1f2fca0ec037f149f.tar.gz libayatana-common-8b63acd444b8e8ad757e25b1f2fca0ec037f149f.tar.bz2 libayatana-common-8b63acd444b8e8ad757e25b1f2fca0ec037f149f.zip |
Merge branch 'tari01-pr/add-menu-item-lengths'
Attributes GH PR #25: https://github.com/AyatanaIndicators/libayatana-common/pull/25
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/tst_utils.cpp | 52 |
2 files changed, 53 insertions, 1 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c6e26ae..d0d05c0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,7 +9,7 @@ include_directories( add_executable(tst_utils tst_utils.cpp) target_link_libraries(tst_utils ayatana-common - + ${GLIB_LIBRARIES} ${GTEST_LIBRARIES} ${GTEST_BOTH_LIBRARIES} ${GMOCK_LIBRARIES} diff --git a/tests/tst_utils.cpp b/tests/tst_utils.cpp index c62bf43..25099fd 100644 --- a/tests/tst_utils.cpp +++ b/tests/tst_utils.cpp @@ -79,3 +79,55 @@ TEST_F(XdgCurrentDesktopUtilsTest, isBudgie) setenv("XDG_CURRENT_DESKTOP", "Budgie:GNOME", 1); EXPECT_TRUE(ayatana_common_utils_is_budgie()); } + +class StringFunctionsTest : public ::testing::Test +{ +public: + + StringFunctionsTest() + { + } + + void SetUp() + { + GSettingsSchemaSource *pSource = g_settings_schema_source_get_default(); + + if (pSource != NULL) + { + GSettingsSchema *pSchema = g_settings_schema_source_lookup(pSource, "org.ayatana.common", FALSE); + + if (pSchema != NULL) + { + g_settings_schema_unref(pSchema); + this->pSettings = g_settings_new("org.ayatana.common"); + this->nMaxLetters = g_settings_get_uint(pSettings, "max-menu-text-length"); + g_settings_set_uint(this->pSettings, "max-menu-text-length", 50); + } + } + } + + void TearDown() + { + if (this->pSettings != NULL) + { + g_settings_set_uint(pSettings, "max-menu-text-length", this->nMaxLetters); + g_object_unref(this->pSettings); + } + } + +private: + + GSettings *pSettings; + guint nMaxLetters; +}; + +TEST_F(StringFunctionsTest, elipsize) +{ + gchar *sTest1 = g_strdup("öüóőúéáűšđß"); + ayatana_common_utils_elipsize((gchar*)sTest1); + EXPECT_STREQ(sTest1, "öüóőúéáűšđß"); + + gchar *sTest2 = g_strdup("123456789012345678901234567890123456789012345öüóőúéáűšđß"); + ayatana_common_utils_elipsize((gchar*)sTest2); + EXPECT_STREQ(sTest2, "123456789012345678901234567890123456789012345öüóőú..."); +} |