From 33cd95e61dcb5947e7671a8eb21d67014376495e Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 16 Jun 2021 22:54:43 +0200 Subject: Skip elipsizing if max characters are 0 - data/org.ayatana.common.gschema.xml.in: Set min value to 0 + update description - src/utils.c: Include hadling max allowed length of 0 - tests/CMakeLists.txt: Compile schema locally for testing - tests/tst_utils.cpp: Include handling max allowed length of 0 - po/ayatana-common.pot: Update translation strings - po/*.po: Update translation strings fixes https://github.com/AyatanaIndicators/libayatana-common/issues/29 --- tests/tst_utils.cpp | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) (limited to 'tests/tst_utils.cpp') diff --git a/tests/tst_utils.cpp b/tests/tst_utils.cpp index 25099fd..99821ef 100644 --- a/tests/tst_utils.cpp +++ b/tests/tst_utils.cpp @@ -90,44 +90,34 @@ public: 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); - } - } + g_setenv("GSETTINGS_SCHEMA_DIR", SCHEMA_DIR, TRUE); + g_setenv("GSETTINGS_BACKEND", "memory", TRUE); } 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, "öüóőúéáűšđß"); + GSettings *pSettings = g_settings_new("org.ayatana.common"); + gchar *sTest = g_strdup("123456789012345678901234567890123456789012345öüóőúéáűšđß"); + g_settings_set_uint(pSettings, "max-menu-text-length", 0); + ayatana_common_utils_elipsize(sTest); + + EXPECT_STREQ(sTest, "123456789012345678901234567890123456789012345öüóőúéáűšđß"); + + g_settings_set_uint(pSettings, "max-menu-text-length", 100); + ayatana_common_utils_elipsize(sTest); + + EXPECT_STREQ(sTest, "123456789012345678901234567890123456789012345öüóőúéáűšđß"); + + g_settings_set_uint(pSettings, "max-menu-text-length", 50); + ayatana_common_utils_elipsize(sTest); + + EXPECT_STREQ(sTest, "123456789012345678901234567890123456789012345öüóőú..."); - gchar *sTest2 = g_strdup("123456789012345678901234567890123456789012345öüóőúéáűšđß"); - ayatana_common_utils_elipsize((gchar*)sTest2); - EXPECT_STREQ(sTest2, "123456789012345678901234567890123456789012345öüóőú..."); + g_free(sTest); + g_object_unref(pSettings); } -- cgit v1.2.3 From 07a34255244a71f6b92a9861dd9571742cd1762b Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Mon, 21 Jun 2021 02:48:40 +0200 Subject: Rename ayatana_common_utils_elipsize to ayatana_common_utils_ellipsize --- tests/tst_utils.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/tst_utils.cpp') diff --git a/tests/tst_utils.cpp b/tests/tst_utils.cpp index 99821ef..9216b1f 100644 --- a/tests/tst_utils.cpp +++ b/tests/tst_utils.cpp @@ -99,22 +99,22 @@ public: } }; -TEST_F(StringFunctionsTest, elipsize) +TEST_F(StringFunctionsTest, ellipsize) { GSettings *pSettings = g_settings_new("org.ayatana.common"); gchar *sTest = g_strdup("123456789012345678901234567890123456789012345öüóőúéáűšđß"); g_settings_set_uint(pSettings, "max-menu-text-length", 0); - ayatana_common_utils_elipsize(sTest); + ayatana_common_utils_ellipsize(sTest); EXPECT_STREQ(sTest, "123456789012345678901234567890123456789012345öüóőúéáűšđß"); g_settings_set_uint(pSettings, "max-menu-text-length", 100); - ayatana_common_utils_elipsize(sTest); + ayatana_common_utils_ellipsize(sTest); EXPECT_STREQ(sTest, "123456789012345678901234567890123456789012345öüóőúéáűšđß"); g_settings_set_uint(pSettings, "max-menu-text-length", 50); - ayatana_common_utils_elipsize(sTest); + ayatana_common_utils_ellipsize(sTest); EXPECT_STREQ(sTest, "123456789012345678901234567890123456789012345öüóőú..."); -- cgit v1.2.3