[evolution-data-server/openismus-work-master: 31/37] tests/libedata-book: Added a facility to modify the currently set locale.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work-master: 31/37] tests/libedata-book: Added a facility to modify the currently set locale.
- Date: Thu, 23 May 2013 08:06:20 +0000 (UTC)
commit 0e2983fbef8e5b15971282bb8f927b4ae683714c
Author: Tristan Van Berkom <tristanvb openismus com>
Date: Fri May 17 18:31:50 2013 +0900
tests/libedata-book: Added a facility to modify the currently set locale.
Added test-localed.xml to mimic the org.freedesktop.locale1 interface and
set the system locale.
tests/libedata-book/Makefile.am | 19 ++++++++++++++++
tests/libedata-book/data-test-utils.c | 38 +++++++++++++++++++++++++++++++++
tests/libedata-book/data-test-utils.h | 7 +++++-
tests/libedata-book/test-localed.xml | 15 +++++++++++++
4 files changed, 78 insertions(+), 1 deletions(-)
---
diff --git a/tests/libedata-book/Makefile.am b/tests/libedata-book/Makefile.am
index 98726c6..1e2509a 100644
--- a/tests/libedata-book/Makefile.am
+++ b/tests/libedata-book/Makefile.am
@@ -1,6 +1,23 @@
+
+# Test service mimicking the "org.freedesktop.locale1" interface
+#
+GENERATED_TEST_LOCALE_SERVICE = \
+ e-test-localed.c \
+ e-test-localed.h \
+ $(NULL)
+
+$(GENERATED_TEST_LOCALE_SERVICE) : Makefile.am test-localed.xml
+ $(AM_V_GEN) gdbus-codegen \
+ --interface-prefix org.freedesktop. \
+ --c-namespace E_Test \
+ --generate-c-code e-test-localed \
+ $(top_srcdir)/tests/libedata-book/test-localed.xml \
+ $(NULL)
+
noinst_LTLIBRARIES = libdata-test-utils.la
libdata_test_utils_la_SOURCES = \
+ $(GENERATED_TEST_LOCALE_SERVICE) \
data-test-utils.c \
data-test-utils.h \
$(NULL)
@@ -22,6 +39,7 @@ libdata_test_utils_la_CPPFLAGS = \
-DSRCDIR=\""$(abs_srcdir)"\" \
-DBUILDDIR=\""$(abs_topbuilddir)"\" \
$(EVOLUTION_ADDRESSBOOK_CFLAGS) \
+ $(GIO_UNIX_CFLAGS) \
$(CAMEL_CFLAGS) \
$(NULL)
@@ -31,6 +49,7 @@ libdata_test_utils_la_LIBADD = \
$(top_builddir)/addressbook/libebook/libebook-1.2.la \
$(top_builddir)/tests/test-server-utils/libetestserverutils.la \
$(EVOLUTION_ADDRESSBOOK_LIBS) \
+ $(GIO_UNIX_LIBS) \
$(CAMEL_LIBS) \
$(NULL)
diff --git a/tests/libedata-book/data-test-utils.c b/tests/libedata-book/data-test-utils.c
index 9e548ce..4d07c85 100644
--- a/tests/libedata-book/data-test-utils.c
+++ b/tests/libedata-book/data-test-utils.c
@@ -223,6 +223,7 @@ e_sqlitedb_cursor_fixture_setup (EbSdbCursorFixture *fixture,
gconstpointer user_data)
{
ETestServerFixture *base_fixture = (ETestServerFixture *)fixture;
+ EbSdbCursorClosure *data = (EbSdbCursorClosure *)user_data;
EContactField sort_fields[] = { E_CONTACT_FAMILY_NAME, E_CONTACT_GIVEN_NAME };
EBookSortType sort_types[] = { E_BOOK_SORT_ASCENDING, E_BOOK_SORT_ASCENDING };
EBookClient *book_client;
@@ -232,6 +233,11 @@ e_sqlitedb_cursor_fixture_setup (EbSdbCursorFixture *fixture,
gchar *sexp = NULL;
const gchar *source_name;
+ if (data->locale)
+ e_sqlitedb_cursor_fixture_set_locale (fixture, data->locale);
+ else
+ e_sqlitedb_cursor_fixture_set_locale (fixture, "en_US.UTF-8");
+
/* Support the migration tests */
source_name = g_getenv ("MIGRATION_TEST_SOURCE_NAME");
if (source_name != NULL)
@@ -305,10 +311,42 @@ e_sqlitedb_cursor_fixture_teardown (EbSdbCursorFixture *fixture,
g_object_unref (fixture->contacts[i]);
}
+ if (fixture->locale1)
+ g_object_unref (fixture->locale1);
+
e_book_backend_sqlitedb_cursor_free (((ESqliteDBFixture *) fixture)->ebsdb, fixture->cursor);
e_sqlitedb_fixture_teardown ((ESqliteDBFixture *)fixture, user_data);
}
+void
+e_sqlitedb_cursor_fixture_set_locale (EbSdbCursorFixture *fixture,
+ const gchar *locale)
+{
+ gchar *strv[2] = { NULL, NULL };
+
+ if (!fixture->locale1) {
+ GDBusConnection *bus;
+ GError *error = NULL;
+
+ bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+ if (!bus)
+ g_error ("Failed to get system bus: %s", error->message);
+
+
+ fixture->locale1 = e_test_locale1_skeleton_new ();
+
+ if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (fixture->locale1),
+ bus, "/org/freedesktop/locale1", &error))
+ g_error ("Failed to export org.freedesktop.locale1: %s", error->message);
+
+ }
+
+ /* Send locale change message */
+ strv[0] = g_strdup_printf ("LANG=%s", locale);
+ e_test_locale1_set_locale (fixture->locale1, (const gchar * const *)strv);
+ g_free (strv[0]);
+}
+
static gint
find_contact_data (EbSdbSearchData *data,
const gchar *uid)
diff --git a/tests/libedata-book/data-test-utils.h b/tests/libedata-book/data-test-utils.h
index 3c413f8..a9fea89 100644
--- a/tests/libedata-book/data-test-utils.h
+++ b/tests/libedata-book/data-test-utils.h
@@ -25,7 +25,7 @@
#include <libebook/libebook.h>
#include <libedata-book/libedata-book.h>
#include "e-test-server-utils.h"
-
+#include "e-test-localed.h"
/* This legend shows the add order, and various sort order of the sorted
* vcards. The UIDs of these contacts are formed as 'sorted-1', 'sorted-2' etc
@@ -82,11 +82,14 @@ typedef struct {
EbSdbCursor *cursor;
EContact *contacts[N_SORTED_CONTACTS];
EBookQuery *query;
+
+ ETestLocale1 *locale1;
} EbSdbCursorFixture;
typedef struct {
ETestServerClosure parent;
+ const gchar *locale;
} EbSdbCursorClosure;
typedef struct {
@@ -114,6 +117,8 @@ void e_sqlitedb_cursor_fixture_setup (EbSdbCursorFixture *fixture,
gconstpointer user_data);
void e_sqlitedb_cursor_fixture_teardown (EbSdbCursorFixture *fixture,
gconstpointer user_data);
+void e_sqlitedb_cursor_fixture_set_locale (EbSdbCursorFixture *fixture,
+ const gchar *locale);
/* Filters contacts with E_CONTACT_EMAIL ending with '.com' */
void e_sqlitedb_cursor_fixture_filtered_setup (EbSdbCursorFixture *fixture,
diff --git a/tests/libedata-book/test-localed.xml b/tests/libedata-book/test-localed.xml
new file mode 100644
index 0000000..a22a373
--- /dev/null
+++ b/tests/libedata-book/test-localed.xml
@@ -0,0 +1,15 @@
+<!DOCTYPE node PUBLIC
+"-//freedesktop//DTD D-Bus Object Introspection 1.0//EN"
+"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
+<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
+
+ <!--
+ org.freedesktop.locale1:
+ Mimicks the 'org.freedesktop.locale1' interface to test the
+ switching of locales, see: http://www.freedesktop.org/wiki/Software/systemd/localed
+ -->
+<interface name="org.freedesktop.locale1">
+
+ <property name="Locale" type="as" access="read"/>
+
+</interface>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]