Skip to content
Snippets Groups Projects
Commit 32fa32ad authored by Emmanuel Milou's avatar Emmanuel Milou
Browse files

[#1146] Implement unitary tests on the client-side

parent 214804f7
Branches
Tags
No related merge requests found
......@@ -33,7 +33,6 @@
#include <dbus.h>
#include <actions.h>
#include <string.h>
#include <dbus/dbus-glib.h>
DBusGConnection * connection;
DBusGProxy * callManagerProxy;
......
......@@ -23,6 +23,8 @@
#ifndef __DBUS_H__
#define __DBUS_H__
#include <dbus/dbus-glib.h>
#include <accountlist.h>
#include <calllist.h>
#include <sflnotify.h>
......
......@@ -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
###########################################################
......
......@@ -31,7 +31,6 @@ void plop()
START_TEST (test_eds)
{
fail_unless (5 == 2,"Error");
}
END_TEST
......
......@@ -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;
}
......
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment