[glib/new-gsettings] Add a nonworking test for localized defaults



commit 94fbea8297a7c08487491bc2a85a0ec65eabfcff
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Apr 15 09:54:59 2010 -0400

    Add a nonworking test for localized defaults

 gio/tests/gsettings.c          |   33 +++++++++++++++++++++++++++++++++
 gio/tests/org.gtk.test.gschema |   10 ++++++++--
 2 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c
index 6ffc834..4827880 100644
--- a/gio/tests/gsettings.c
+++ b/gio/tests/gsettings.c
@@ -1,4 +1,6 @@
 #include <stdlib.h>
+#include <locale.h>
+#include <libintl.h>
 #include <gio.h>
 #include <gstdio.h>
 
@@ -429,6 +431,36 @@ test_atomic (void)
   g_assert_cmpstr (str, ==, "atomic bye-bye");
 }
 
+static void
+test_l10n (void)
+{
+  GSettings *settings;
+  gchar *str;
+  gchar *locale;
+
+  bindtextdomain ("glib20", "/usr/share");
+  bind_textdomain_codeset ("glib20", "UTF-8");
+
+  locale = g_strdup (setlocale (LC_MESSAGES, NULL));
+
+  settings = g_settings_new ("org.gtk.test.localized");
+
+  setlocale (LC_MESSAGES, "C");
+  g_settings_get (settings, "error_message", "s", &str);
+  setlocale (LC_MESSAGES, locale);
+
+  g_assert_cmpstr (str, ==, "Unnamed");
+  str = NULL;
+
+  setlocale (LC_MESSAGES, "de_DE");
+  g_settings_get (settings, "error_message", "s", &str);
+  setlocale (LC_MESSAGES, locale);
+
+  g_assert_cmpstr (str, ==, "Unbenannt");
+
+  g_free (locale);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -448,6 +480,7 @@ main (int argc, char *argv[])
   g_test_add_func ("/gsettings/basic-types", test_basic_types);
   g_test_add_func ("/gsettings/complex-types", test_complex_types);
   g_test_add_func ("/gsettings/changes", test_changes);
+  g_test_add_func ("/gsettings/l10n", test_l10n);
   g_test_add_func ("/gsettings/delay-apply", test_delay_apply);
   g_test_add_func ("/gsettings/delay-revert", test_delay_revert);
   g_test_add_func ("/gsettings/atomic", test_atomic);
diff --git a/gio/tests/org.gtk.test.gschema b/gio/tests/org.gtk.test.gschema
index ccc6bc3..b893988 100644
--- a/gio/tests/org.gtk.test.gschema
+++ b/gio/tests/org.gtk.test.gschema
@@ -13,8 +13,9 @@
 
     <child name='basic-types' schema='org.gtk.test.basic-types'/>
     <child name='complex-types' schema='org.gtk.test.complex-types'/>
+    <child name='localized' schema='org.gtk.test.localized'/>
   </schema>
-  <schema id="org.gtk.test.basic-types" path="/tests/basic_types/" gettext-domain="test">
+  <schema id="org.gtk.test.basic-types" path="/tests/basic_types/">
     <key name="test_boolean" type="b">
       <default>true</default>
     </key>
@@ -49,7 +50,7 @@
       <default>"/a/object/path"</default>
     </key>
   </schema>
-  <schema id="org.gtk.test.complex-types" path="/tests/complex_types/" gettext-domain="test">
+  <schema id="org.gtk.test.complex-types" path="/tests/complex_types/">
     <key name="test_tuple" type="(s(ii))">
       <default>("one",(2,3))</default>
     </key>
@@ -57,4 +58,9 @@
       <default>[0,1,2,3,4,5]</default>
     </key>
   </schema>
+  <schema id="org.gtk.test.localized" path="/tests/localized/" gettext-domain="glib20">
+    <key name="error_message" type="s">
+      <default l10n="messages">"Unnamed"</default>
+    </key>
+  </schema>
 </schemalist>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]