summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2011-02-24 11:26:59 -0500
committerNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2011-02-24 11:26:59 -0500
commit2be08a05b3ba8d610acab5098b07740c36ee53f9 (patch)
tree384d5391bf7a79f101f376c0bef64eae0f205549
parente2d666386638fef562769b7c4cebb3a957612f12 (diff)
parent5105c0ce3e94f9c912fda95a046b566cc4b68842 (diff)
downloadtelepathy-logger-2be08a05b3ba8d610acab5098b07740c36ee53f9.tar.gz
Merge branch 'tests-fix'
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/dbus/Makefile.am2
-rw-r--r--tests/dbus/test-log-manager.c (renamed from tests/dbus/test-searches.c)213
-rw-r--r--tests/test-searches.c91
-rw-r--r--tests/test-tpl-log-manager.c20
5 files changed, 137 insertions, 191 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index baaa38c..388bc63 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -10,7 +10,6 @@ noinst_PROGRAMS = \
test-tpl-channel \
test-tpl-conf \
test-tpl-log-store-sqlite \
- test-tpl-log-manager \
test-tpl-observer \
$(NULL)
@@ -66,7 +65,6 @@ check_c_sources = \
test-tpl-channel.c \
test-tpl-conf.c \
test-tpl-observer.c \
- test-searches.c \
$(NULL)
include $(top_srcdir)/tools/check-coding-style.mk
diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am
index 9fca25d..2465d38 100644
--- a/tests/dbus/Makefile.am
+++ b/tests/dbus/Makefile.am
@@ -1,6 +1,6 @@
noinst_PROGRAMS = \
test-entity \
- test-searches \
+ test-log-manager \
test-tpl-log-store-pidgin \
test-tpl-log-store-xml \
$(NULL)
diff --git a/tests/dbus/test-searches.c b/tests/dbus/test-log-manager.c
index 6b5b4d3..36736da 100644
--- a/tests/dbus/test-searches.c
+++ b/tests/dbus/test-log-manager.c
@@ -27,6 +27,8 @@ typedef struct
TpAccount *account;
TpTestsSimpleAccount *account_service;
+ GList *ret;
+
TplLogManager *manager;
} TestCaseFixture;
@@ -86,83 +88,6 @@ log_handler (const gchar *log_domain,
#endif /* ENABLE_DEBUG */
-
-static void
-test_get_dates (TestCaseFixture *fixture,
- gconstpointer user_data)
-{
- GList *ret, *loc;
- TplEntity *entity;
-
- entity = tpl_entity_new (ID, TPL_ENTITY_CONTACT, NULL, NULL);
- ret = _tpl_log_manager_get_dates (fixture->manager, fixture->account, entity,
- TPL_EVENT_MASK_ANY);
- g_object_unref (entity);
-
- /* it includes 1 date from libpurple logs, 5 from TpLogger. Empathy
- * log-store date are the same of the TpLogger store, and wont' be present,
- * being duplicates */
- g_assert_cmpint (g_list_length (ret), ==, 6);
-
- /* we do not want duplicates */
- ret = g_list_sort (ret, (GCompareFunc) g_strcmp0);
- for (loc = ret; loc != NULL; loc = g_list_next (loc))
- if (loc->next)
- g_assert (g_date_compare (loc->data, loc->next->data) != 0);
-
- g_list_foreach (ret, (GFunc) g_free, NULL);
- g_list_free (ret);
-}
-
-static void
-test_get_entities (TestCaseFixture *fixture,
- gconstpointer user_data)
-{
- GList *ret, *loc;
-
- ret = _tpl_log_manager_get_entities (fixture->manager, fixture->account);
-
- g_assert_cmpint (g_list_length (ret), ==, 2);
-
- /* we do not want duplicates */
- ret = g_list_sort (ret, (GCompareFunc) _tpl_entity_compare);
- for (loc = ret; loc != NULL; loc = g_list_next (loc))
- if (loc->next)
- g_assert (_tpl_entity_compare (loc->data, loc->next->data) != 0);
-
- g_list_foreach (ret, (GFunc) g_object_unref, NULL);
- g_list_free (ret);
-}
-
-
-static void
-test_get_events_for_date (TestCaseFixture *fixture,
- gconstpointer user_data)
-{
- TplEntity *entity;
- GDate *date;
- GList *ret;
-
- entity = tpl_entity_new (ID, TPL_ENTITY_CONTACT, NULL, NULL);
- date = g_date_new_dmy (13, 1, 2010);
-
- ret = _tpl_log_manager_get_events_for_date (fixture->manager,
- fixture->account,
- entity,
- TPL_EVENT_MASK_TEXT,
- date);
-
- g_object_unref (entity);
- g_date_free (date);
-
- /* We got 6 events in old Empathy and 6 in new TpLogger storage */
- g_assert_cmpint (g_list_length (ret), ==, 12);
-
- g_list_foreach (ret, (GFunc) g_object_unref, NULL);
- g_list_free (ret);
-}
-
-
static void
teardown_service (TestCaseFixture* fixture,
gconstpointer user_data)
@@ -271,6 +196,7 @@ setup_service (TestCaseFixture* fixture,
tp_g_value_slice_free (boxed_params);
}
+
static void
setup (TestCaseFixture* fixture,
gconstpointer user_data)
@@ -288,6 +214,7 @@ setup (TestCaseFixture* fixture,
DEBUG ("set up finished");
}
+
static void
setup_debug (void)
{
@@ -304,6 +231,138 @@ setup_debug (void)
}
+static void
+get_dates_async_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ TestCaseFixture *fixture = user_data;
+ GError *error = NULL;
+
+ tpl_log_manager_get_dates_finish (TPL_LOG_MANAGER (object),
+ result, &fixture->ret, &error);
+
+ g_assert_no_error (error);
+ g_main_loop_quit (fixture->main_loop);
+}
+
+static void
+test_get_dates (TestCaseFixture *fixture,
+ gconstpointer user_data)
+{
+ GList *loc;
+ TplEntity *entity;
+
+ entity = tpl_entity_new (ID, TPL_ENTITY_CONTACT, NULL, NULL);
+
+ tpl_log_manager_get_dates_async (fixture->manager,
+ fixture->account, entity, TPL_EVENT_MASK_ANY,
+ get_dates_async_cb, fixture);
+ g_main_loop_run (fixture->main_loop);
+
+ g_object_unref (entity);
+
+ /* it includes 1 date from libpurple logs, 5 from TpLogger. Empathy
+ * log-store date are the same of the TpLogger store, and wont' be present,
+ * being duplicates */
+ g_assert_cmpint (g_list_length (fixture->ret), ==, 6);
+
+ /* we do not want duplicates, dates are suppose to be ordered */
+ fixture->ret = g_list_sort (fixture->ret, (GCompareFunc) g_date_compare);
+ for (loc = fixture->ret; loc != NULL; loc = g_list_next (loc))
+ if (loc->next)
+ g_assert (g_date_compare (loc->data, loc->next->data) != 0);
+
+ g_list_foreach (fixture->ret, (GFunc) g_date_free, NULL);
+ g_list_free (fixture->ret);
+}
+
+
+static void
+get_entities_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ TestCaseFixture *fixture = user_data;
+ GError *error = NULL;
+
+ tpl_log_manager_get_entities_finish (TPL_LOG_MANAGER (object), result,
+ &fixture->ret, &error);
+
+ g_assert_no_error (error);
+ g_main_loop_quit (fixture->main_loop);
+}
+
+
+static void
+test_get_entities (TestCaseFixture *fixture,
+ gconstpointer user_data)
+{
+ GList *loc;
+
+ tpl_log_manager_get_entities_async (fixture->manager, fixture->account,
+ get_entities_cb, fixture);
+ g_main_loop_run (fixture->main_loop);
+
+ g_assert_cmpint (g_list_length (fixture->ret), ==, 2);
+
+ /* we do not want duplicates */
+ fixture->ret = g_list_sort (fixture->ret, (GCompareFunc) _tpl_entity_compare);
+ for (loc = fixture->ret; loc != NULL; loc = g_list_next (loc))
+ if (loc->next)
+ g_assert (_tpl_entity_compare (loc->data, loc->next->data) != 0);
+
+ g_list_foreach (fixture->ret, (GFunc) g_object_unref, NULL);
+ g_list_free (fixture->ret);
+}
+
+
+static void
+get_events_for_date_cb (GObject *object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ TestCaseFixture *fixture = user_data;
+ GError *error = NULL;
+
+ tpl_log_manager_get_events_for_date_finish (TPL_LOG_MANAGER (object),
+ result, &fixture->ret, &error);
+
+ g_assert_no_error (error);
+ g_main_loop_quit (fixture->main_loop);
+}
+
+
+static void
+test_get_events_for_date (TestCaseFixture *fixture,
+ gconstpointer user_data)
+{
+ TplEntity *entity;
+ GDate *date;
+
+ entity = tpl_entity_new (ID, TPL_ENTITY_CONTACT, NULL, NULL);
+ date = g_date_new_dmy (13, 1, 2010);
+
+ tpl_log_manager_get_events_for_date_async (fixture->manager,
+ fixture->account,
+ entity,
+ TPL_EVENT_MASK_TEXT,
+ date,
+ get_events_for_date_cb,
+ fixture);
+ g_main_loop_run (fixture->main_loop);
+
+ g_object_unref (entity);
+ g_date_free (date);
+
+ /* We got 6 events in old Empathy and 6 in new TpLogger storage */
+ g_assert_cmpint (g_list_length (fixture->ret), ==, 12);
+
+ g_list_foreach (fixture->ret, (GFunc) g_object_unref, NULL);
+ g_list_free (fixture->ret);
+}
+
+
int
main (int argc, char **argv)
{
diff --git a/tests/test-searches.c b/tests/test-searches.c
deleted file mode 100644
index d498d53..0000000
--- a/tests/test-searches.c
+++ /dev/null
@@ -1,91 +0,0 @@
-#include "constants.h"
-
-#include <glib.h>
-
-#include <telepathy-logger/debug-internal.h>
-#include <telepathy-logger/log-manager.h>
-#include <telepathy-logger/log-manager-internal.h>
-#include <telepathy-logger/log-store-internal.h>
-#include <telepathy-logger/log-store-xml-internal.h>
-
-
-static GMainLoop *loop = NULL;
-
-static void
-got_dates_cb (GObject *obj, GAsyncResult *result, gpointer user_data)
-{
- GList *ret;
- GError *error = NULL;
-
- tpl_log_manager_get_dates_finish (TPL_LOG_MANAGER (obj), result, &ret,
- &error);
- g_assert_no_error (error);
-
- for (; ret != NULL; ret = g_list_next (ret))
- {
- GDate *date = ret->data;
- /* g_assert (!tp_strdiff (date, "12345678")); */
- g_date_free (date);
- }
- g_list_free (ret);
- g_main_loop_quit (loop);
-}
-
-int
-main (int argc, char *argv[])
-{
- GError *error = NULL;
- TpDBusDaemon *dbus;
- TpAccount *acc;
- TplLogManager *manager;
- TplLogStore *logstore;
- GList *ret, *loc;
-
- g_type_init ();
-
- dbus = tp_dbus_daemon_dup (&error);
- if (error != NULL)
- {
- g_debug ("%s", error->message);
- }
- acc = tp_account_new (dbus, ACCOUNT_PATH, NULL);
- if (acc == NULL)
- {
- g_debug ("error during TpAccount creation");
- }
-
- /* get the LogManager and register a non-default LogManager */
- manager = tpl_log_manager_dup_singleton ();
- logstore = g_object_new (TPL_TYPE_LOG_STORE_XML,
- "name", "Empathy", NULL);
- _tpl_log_manager_register_log_store (manager, logstore);
-
- /* we are using the blocking API, the non-blocking one is a wrap around, so
- * it's assured to work as long as the blocking API and the wapper work */
-
- /* we do not want duplicates */
- ret = _tpl_log_manager_get_dates (manager, acc, ID, FALSE);
- ret = g_list_sort (ret, (GCompareFunc) g_strcmp0);
- for (loc = ret; loc; loc = g_list_next (loc))
- if (loc->next)
- g_assert (g_date_compare (loc->data, loc->next->data) != 0);
- g_list_foreach (ret, (GFunc) g_free, NULL);
- g_list_free (ret);
-
-
- /* we do not want duplicates */
- ret = _tpl_log_manager_get_entities (manager, acc);
- ret = g_list_sort (ret, (GCompareFunc) _tpl_entity_compare);
- for (loc = ret; loc; loc = g_list_next (loc))
- if (loc->next)
- g_assert (_tpl_entity_compare (loc->data,
- loc->next->data) != 0);
- g_list_foreach (ret, (GFunc) g_object_unref, NULL);
- g_list_free (ret);
-
-
- tpl_log_manager_get_dates_async (manager, acc, ID, FALSE, got_dates_cb, NULL);
-
- loop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run (loop);
-}
diff --git a/tests/test-tpl-log-manager.c b/tests/test-tpl-log-manager.c
deleted file mode 100644
index 672d011..0000000
--- a/tests/test-tpl-log-manager.c
+++ /dev/null
@@ -1,20 +0,0 @@
-#include <telepathy-logger/text-event.h>
-
-#define gconf_client_get_bool(obj,key,err) g_print ("%s", key)
-
-#define LOG_ID 0
-#define CHAT_ID "echo@test.collabora.co.uk"
-
-int main (int argc, char **argv)
-{
-// TplLogManager *manager;
-
- g_type_init ();
-
- // manager = tpl_log_manager_dup_singleton ();
-
-
-
- return 0;
-}
-