diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index 787b2b6a40d52a91cb391dfdfadcdd3d5499aae4..fcd3d92d2f883f24a31452ff1ec8e4a730893ae2 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -33,7 +33,6 @@ #include <dbus.h> #include <actions.h> #include <string.h> -#include <dbus/dbus-glib.h> DBusGConnection * connection; DBusGProxy * callManagerProxy; diff --git a/sflphone-client-gnome/src/dbus/dbus.h b/sflphone-client-gnome/src/dbus/dbus.h index 6f64cfe30a1afa9cf1a1af72c27150f561dd16dd..a891bfc42a12447ce7027d9bda20663353372958 100644 --- a/sflphone-client-gnome/src/dbus/dbus.h +++ b/sflphone-client-gnome/src/dbus/dbus.h @@ -23,6 +23,8 @@ #ifndef __DBUS_H__ #define __DBUS_H__ +#include <dbus/dbus-glib.h> + #include <accountlist.h> #include <calllist.h> #include <sflnotify.h> diff --git a/sflphone-client-gnome/tests/Makefile.am b/sflphone-client-gnome/tests/Makefile.am index ce42663bf6971f595866d77434733149554e1ae8..ba1161ae750bf07180fc71504a88bcf0e97dda49 100644 --- a/sflphone-client-gnome/tests/Makefile.am +++ b/sflphone-client-gnome/tests/Makefile.am @@ -15,7 +15,6 @@ SFLPHONE_OBJ = $(top_builddir)/src/accountlist.o \ $(top_builddir)/src/dialpad.o \ $(top_builddir)/src/errors.o \ $(top_builddir)/src/mainwindow.o \ - $(top_builddir)/src/marshaller.o \ $(top_builddir)/src/menus.o \ $(top_builddir)/src/reqaccount.o \ $(top_builddir)/src/sflnotify.o \ @@ -28,13 +27,13 @@ SFLPHONE_OBJ = $(top_builddir)/src/accountlist.o \ check_global_SOURCES = check_global.c check_global_CFLAGS = @CHECK_CFLAGS@ @DEPS_CFLAGS@ -check_global_LDADD = @CHECK_LIBS@ +check_global_LDADD = $(SFLPHONE_LIBS) $(SFLPHONE_OBJ) @CHECK_LIBS@ $(DEPS_LIBS) @LIBSEXY_LIBS@ -llog4c ########################################################### check_contacts_SOURCES = check_contacts.c check_contacts_CFLAGS = @CHECK_CFLAGS@ @DEPS_CFLAGS@ -check_contacts_LDADD = $(SFLPHONE_LIBS) $(SFLPHONE_OBJ) @CHECK_LIBS@ @DEPS_LIBS@ @LIBSEXY_LIBS@ -llog4c +check_contacts_LDADD = $(SFLPHONE_LIBS) $(SFLPHONE_OBJ) @CHECK_LIBS@ $(DEPS_LIBS) @LIBSEXY_LIBS@ -llog4c ########################################################### diff --git a/sflphone-client-gnome/tests/check_contacts.c b/sflphone-client-gnome/tests/check_contacts.c index bca0d15777c380652cb30d08000f184b9eb98e29..55625a5fc8f8a78fc8b5266098004d9f8f7dc64d 100644 --- a/sflphone-client-gnome/tests/check_contacts.c +++ b/sflphone-client-gnome/tests/check_contacts.c @@ -31,7 +31,6 @@ void plop() START_TEST (test_eds) { - fail_unless (5 == 2,"Error"); } END_TEST diff --git a/sflphone-client-gnome/tests/check_dbus.c b/sflphone-client-gnome/tests/check_dbus.c index 67423ee2c29df51bd14749d950450f1b9f02c19f..ef7fc2a6f9ff72cae072ab0d275603b901656dbc 100644 --- a/sflphone-client-gnome/tests/check_dbus.c +++ b/sflphone-client-gnome/tests/check_dbus.c @@ -20,10 +20,22 @@ #include <check.h> #include <stdlib.h> +#include "../src/dbus/dbus.h" + +START_TEST (test_dbus_connect) +{ + fail_unless (dbus_connect () == TRUE, "dbus_connect () returns FALSE"); +} +END_TEST + Suite * dbus_suite (void) { - Suite *s = suite_create ("DBus"); + Suite *s = suite_create ("D-Bus"); + + TCase *tc_cases = tcase_create ("D-BUS connection"); + tcase_add_test (tc_cases, test_dbus_connect); + suite_add_tcase (s, tc_cases); return s; } diff --git a/sflphone-client-gnome/tests/check_global.c b/sflphone-client-gnome/tests/check_global.c index 5d64a94e93e5eab9104786d1a2d5bbc6064e63bf..f464eefb27e8d859f7ddc430e0bde03ff34f420b 100644 --- a/sflphone-client-gnome/tests/check_global.c +++ b/sflphone-client-gnome/tests/check_global.c @@ -19,12 +19,104 @@ #include <check.h> #include <stdlib.h> +#include <gtk/gtk.h> + +#include "../src/accountlist.h" +#include "../src/sflphone_const.h" + +account_t* create_test_account () +{ + account_t *test; + + test = g_new0 (account_t, 1); + test->accountID = "test"; + test->state = ACCOUNT_STATE_REGISTERED; + test->properties = g_hash_table_new(NULL, g_str_equal); + + // Populate the properties + g_hash_table_replace (test->properties, ACCOUNT_ENABLED, "1"); + g_hash_table_replace (test->properties, ACCOUNT_ALIAS, "test account"); + g_hash_table_replace (test->properties, ACCOUNT_TYPE, "SIP"); + g_hash_table_replace (test->properties, ACCOUNT_HOSTNAME, "192.168.1.1"); + g_hash_table_replace (test->properties, ACCOUNT_USERNAME, "test"); + g_hash_table_replace (test->properties, ACCOUNT_PASSWORD, "my-password"); + g_hash_table_replace (test->properties, ACCOUNT_MAILBOX, "888"); + g_hash_table_replace (test->properties, ACCOUNT_SIP_STUN_SERVER, ""); + g_hash_table_replace (test->properties, ACCOUNT_SIP_STUN_ENABLED, "0"); + + return test; + +} + +START_TEST (test_add_account) +{ + account_t *test = create_test_account (); + + account_list_init (); + account_list_add (test); + fail_unless (account_list_get_registered_accounts () == 1, "ERROR"); + account_list_remove (test->accountID); + fail_unless (account_list_get_registered_accounts () == 0, "ERROR"); +} +END_TEST + +START_TEST (test_ordered_list) +{ + account_t *test = create_test_account (); + + account_list_init (); + account_list_add (test); + account_list_add (test); + fail_unless (g_strcasecmp (account_list_get_ordered_list (), "test/test/") == 0, "ERROR - BAD ACCOUNT LIST SERIALIZING"); +} +END_TEST + +START_TEST (test_get_by_id) +{ + account_t *test = create_test_account (); + account_t *tmp; + + account_list_init (); + account_list_add (test); + tmp = account_list_get_by_id (test->accountID); + fail_unless (g_strcasecmp (tmp->accountID, test->accountID) == 0, "ERROR - ACCOUNTLIST_GET_BY_ID"); +} +END_TEST + +START_TEST (test_sip_account) +{ + account_t *test = create_test_account (); + + account_list_init (); + account_list_add (test); + fail_unless (account_list_get_sip_account_number () == 1, "ERROR - BAD SIP ACCOUNT NUMBER"); +} +END_TEST + +START_TEST (test_set_current_account) +{ + account_t *test = create_test_account (); + + account_list_init (); + account_list_add (test); + account_list_set_current_id (test->accountID); + fail_unless (account_list_get_sip_account_number () == 1, "ERROR - BAD CURRENT ACCOUNT"); +} +END_TEST + Suite * global_suite (void) { Suite *s = suite_create ("Global"); + TCase *tc_cases = tcase_create ("Accounts"); + tcase_add_test (tc_cases, test_add_account); + tcase_add_test (tc_cases, test_ordered_list); + tcase_add_test (tc_cases, test_sip_account); + tcase_add_test (tc_cases, test_get_by_id); + suite_add_tcase (s, tc_cases); + return s; }