diff --git a/src/tests/eldbus/eldbus_test_eldbus_message.c b/src/tests/eldbus/eldbus_test_eldbus_message.c index 6f8eb23a23..5b8fa495bc 100644 --- a/src/tests/eldbus/eldbus_test_eldbus_message.c +++ b/src/tests/eldbus/eldbus_test_eldbus_message.c @@ -1,1621 +1,1606 @@ #include #include #include #include #include "eldbus_suite.h" static Eldbus_Message *message_vparam = NULL; static Eldbus_Message *message_vget = NULL; static Eina_Bool is_success = EINA_FALSE; static Eina_Bool is_register_service = EINA_FALSE; static Eina_Bool is_iter_vget = EINA_FALSE; static Eina_Bool is_receive = EINA_FALSE; static const int value_from_client = 10; static const int value_from_server = 11; static Ecore_Timer *timeout = NULL; static const char *empty_string = ""; static const char *bus = "org.freedesktop.DBus"; static const char *interface = "org.freedesktop.DBus"; static const char *path = "/org/freedesktop/DBus"; static const char *method_name = "GetId"; static const char *signal_name = "NameOwnerChanged"; const char *dbus_session_path = "/org/freedesktop/Test"; const char *interface_session = "org.freedesktop.Test"; const char *bus_session = "org.freedesktop.Test"; #define CONTAINER_COUNT 2 static const char *container_data[CONTAINER_COUNT] = {"first", "second"}; static unsigned int numbers_int[] = { 10, 9, 8, 7, 6, 5 }; static int cb_data = 5; static Eldbus_Message_Iter *iter_value_swap = NULL; /** * @addtogroup eldbus * @{ * @defgroup eldbus_message * * * @precondition * @step 1 Initialize eldbus with eldbus_init() */ static Eina_Bool _ecore_loop_close(void *data EINA_UNUSED) { ecore_main_loop_quit(); return ECORE_CALLBACK_CANCEL; } static void _varg_iter_add(char *str,...) { va_list ap; va_start(ap, str); eldbus_message_iter_arguments_vappend(iter_value_swap, str, ap); va_end(ap); } static Eldbus_Message * _swap_value(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg) { Eldbus_Message *reply = eldbus_message_method_return_new(msg); int num; if (eldbus_message_arguments_get(msg, "i", &num)) { if (num == value_from_client) { iter_value_swap = eldbus_message_iter_get(reply); _varg_iter_add("i", value_from_server); } return reply; } return reply; } static Eldbus_Message * _receive_container_data(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg) { Eldbus_Message *reply = eldbus_message_method_return_new(msg); Eldbus_Message_Iter *array; const char *txt; Eina_Bool fail = EINA_FALSE; if (eldbus_message_arguments_get(msg, "as", &array)) { int int_iter = 0; while (eldbus_message_iter_get_and_next(array, 's', &txt)) { if (!txt || strcmp(txt, container_data[int_iter])) { fail = EINA_TRUE; break; } ++int_iter; } if (!fail) { int numbers[] = {10, 9}; Eldbus_Message_Iter *iter = eldbus_message_iter_get(reply); Eldbus_Message_Iter *array = eldbus_message_iter_container_new(iter, 'a', "i"); if (array) { eldbus_message_iter_fixed_array_append(array, 'i', numbers, EINA_C_ARRAY_LENGTH(numbers)); eldbus_message_iter_container_close(iter, array); } } } is_success = fail ? EINA_FALSE : EINA_TRUE; return reply; } static void _on_send_bool(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) { const char *errname, *errmsg; if (eldbus_message_error_get(msg, &errname, &errmsg)) { if (!strcmp(errmsg, "Invalid type")) is_success = EINA_TRUE; } } static Eldbus_Message * _send_bool(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg) { return eldbus_message_error_new(msg, "org.freedesktop.DBus.Error.InvalidSignature", "Invalid type"); } static void _on_send_array_int(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) { Eldbus_Message_Iter *array = NULL; if (!eldbus_message_error_get(msg, NULL, NULL)) { if (eldbus_message_arguments_get(msg, "ai", &array)) { unsigned int *array_int; int array_count; if (eldbus_message_iter_fixed_array_get(array, 'i', &array_int, &array_count)) { if (EINA_C_ARRAY_LENGTH(numbers_int) == array_count) { int i = 0; Eina_Bool is_equal = EINA_TRUE; for (i = 0; i < array_count; ++i) { if (numbers_int[i] != array_int[i]) { is_equal = EINA_FALSE; break; } } is_success = is_equal; } } } } } static Eldbus_Message * _send_array_int(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg) { Eldbus_Message *reply = eldbus_message_method_return_new(msg); Eldbus_Message_Iter *iter, *array; iter = eldbus_message_iter_get(reply); array = eldbus_message_iter_container_new(iter, 'a', "i"); eldbus_message_iter_fixed_array_append(array, 'i', numbers_int, EINA_C_ARRAY_LENGTH(numbers_int)); eldbus_message_iter_container_close(iter, array); return reply; } static const Eldbus_Method methods[] = { { "SwapValue", ELDBUS_ARGS({"i", "integer"}), ELDBUS_ARGS({"i", "swap_value"}), _swap_value, 0 }, { "ArrayContainer", ELDBUS_ARGS({"as", "container_of_strings"}), ELDBUS_ARGS({"ai", "array_of_int"}), _receive_container_data, 0 }, { "SendBool", ELDBUS_ARGS({"b", "bool"}), ELDBUS_ARGS({"b", "bool"}), _send_bool }, { "SendArrayInt", NULL, ELDBUS_ARGS({"ai", "array_of_int"}), _send_array_int, 0 }, { } }; static const Eldbus_Service_Interface_Desc iface_desc = { "org.freedesktop.Test", methods, NULL }; static void _varg_add(char *str,...) { va_list ap; va_start(ap, str); eldbus_message_arguments_vappend(message_vparam, str, ap); va_end(ap); } static void _response_message_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) { if (timeout != NULL) { ecore_timer_del(timeout); timeout = NULL; } const char *errname, *errmsg; if (eldbus_message_error_get(msg, &errname, &errmsg)) { ecore_main_loop_quit(); return; } Eldbus_Message_Iter *iter_main = eldbus_message_iter_get(msg); if (!iter_main) { ecore_main_loop_quit(); return; } const char *signature = eldbus_message_iter_signature_get(iter_main); if ((!signature) || (!strcmp(signature, empty_string))) { ecore_main_loop_quit(); return; } Eldbus_Message_Iter *iterator; if (!eldbus_message_iter_arguments_get(iter_main, signature, &iterator)) { ecore_main_loop_quit(); return; } const char *bus_name; Eina_Bool is_has_data = EINA_FALSE; while(eldbus_message_iter_get_and_next(iterator, 's', &bus_name)) { if ((!bus_name) || (!strcmp(bus_name, empty_string))) { ecore_main_loop_quit(); return; } is_has_data = EINA_TRUE; } is_success = is_has_data; ecore_main_loop_quit(); } static void _message_method_cb(void *data EINA_UNUSED, const Eldbus_Message *msg EINA_UNUSED, Eldbus_Pending *pending EINA_UNUSED) { if (timeout != NULL) { ecore_timer_del(timeout); timeout = NULL; } const char *errname, *errmsg; if (!eldbus_message_error_get(msg, &errname, &errmsg)) { char *txt; if (eldbus_message_arguments_get(msg, "s", &txt)) { if ((txt) && (strcmp(txt, empty_string))) { if (!strcmp(bus, eldbus_message_sender_get(msg)) && strcmp(eldbus_message_destination_get(msg), empty_string)) { is_success = EINA_TRUE; } } } } ecore_main_loop_quit(); } static void _activatable_list_response_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) { if (timeout != NULL) { ecore_timer_del(timeout); timeout = NULL; } const char *errname, *errmsg; if (eldbus_message_error_get(msg, &errname, &errmsg)) { ecore_main_loop_quit(); return; } Eldbus_Message_Iter *iter_main = eldbus_message_iter_get(msg); if (!iter_main) { ecore_main_loop_quit(); return; } const char *signature = eldbus_message_iter_signature_get(iter_main); if ((!signature) || (!strcmp(signature, empty_string))) { ecore_main_loop_quit(); return; } Eldbus_Message_Iter *iterator; if (!eldbus_message_iter_arguments_get(iter_main, signature, &iterator)) { ecore_main_loop_quit(); return; } const char *bus_name; Eina_Bool is_has_data = EINA_FALSE; do { eldbus_message_iter_arguments_get(iterator, "s", &bus_name); if ((!bus_name) || (!strcmp(bus_name, empty_string))) { ecore_main_loop_quit(); return; } is_has_data = EINA_TRUE; }while (eldbus_message_iter_next(iterator)); is_success = is_has_data; ecore_main_loop_quit(); } static void _signal_name_owner_changed(void *data EINA_UNUSED, const Eldbus_Message *msg) { if (timeout != NULL) { ecore_timer_del(timeout); timeout = NULL; } const char *errname, *errmsg; if (!eldbus_message_error_get(msg, &errname, &errmsg)) { is_success = EINA_TRUE; } ecore_main_loop_quit(); } static void _response_owner_has_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) { if (timeout != NULL) { ecore_timer_del(timeout); timeout = NULL; } const char *errname, *errmsg; if (!eldbus_message_error_get(msg, &errname, &errmsg)) { Eldbus_Message_Iter *iter = eldbus_message_iter_get(msg); if (iter) { Eina_Bool bool_basic = EINA_FALSE; eldbus_message_iter_basic_get(iter, &bool_basic); Eina_Value *eina_value = eldbus_message_to_eina_value(msg); if (eina_value) { Eina_Bool eina_bool_value = EINA_FALSE; eina_value_struct_get(eina_value, "arg0", &eina_bool_value); if (bool_basic && eina_bool_value) { is_success = EINA_TRUE; } eina_value_free(eina_value); } } } ecore_main_loop_quit(); } static void _message_without_body_cb(void *data EINA_UNUSED, const Eldbus_Message *msg EINA_UNUSED, Eldbus_Pending *pending EINA_UNUSED) { } static void _message_response_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) { if (timeout != NULL) { ecore_timer_del(timeout); timeout = NULL; } const char *errname, *errmsg; if (!eldbus_message_error_get(msg, &errname, &errmsg)) { char *txt; if (eldbus_message_arguments_get(msg, "s", &txt)) { if ((txt) && (strcmp(txt, empty_string))) { is_success = EINA_TRUE; } } } ecore_main_loop_quit(); } static void _vget_response(char *str,...) { va_list ap; va_start(ap, str); if (!eldbus_message_arguments_vget(message_vget, str, ap)) return; va_end(ap); } static void _message_vget_response_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) { if (timeout != NULL) { ecore_timer_del(timeout); timeout = NULL; } const char *errname, *errmsg; if (!eldbus_message_error_get(msg, &errname, &errmsg)) { Eina_Bool *result_response = malloc(sizeof(Eina_Bool)); if (result_response) { message_vget = (Eldbus_Message *)msg; *result_response = EINA_FALSE; _vget_response("b", result_response); if (*result_response == EINA_TRUE) is_success = EINA_TRUE; free(result_response); } } ecore_main_loop_quit(); } static void _name_request(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) { unsigned int reply; const char *errname, *errmsg; if (!eldbus_message_error_get(msg, &errname, &errmsg)) { if (eldbus_message_arguments_get(msg, "u", &reply)) { if (reply == ELDBUS_NAME_REQUEST_REPLY_PRIMARY_OWNER) { is_register_service = EINA_TRUE; } } } } static void _response_swap_value(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) { Eina_Value *eina_value; int swap_value; if (!eldbus_message_error_get(msg, NULL, NULL)) { Eldbus_Message_Iter *iter = eldbus_message_iter_get(msg); eina_value = eldbus_message_iter_struct_like_to_eina_value(iter); eina_value_struct_get(eina_value, "arg0", &swap_value); if (swap_value == value_from_server) is_success = EINA_TRUE; eina_value_free(eina_value); } } static void _vget_iter_response(Eldbus_Message_Iter *iter,...) { va_list ap; va_start(ap, iter); if (!eldbus_message_iter_arguments_vget(iter, "i", ap)) return; va_end(ap); } static void _response_swap_iter_vget(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) { int swap_value; if (!eldbus_message_error_get(msg, NULL, NULL)) { if (!strcmp(eldbus_message_signature_get(msg), "i")) { Eldbus_Message_Iter *iter = eldbus_message_iter_get(msg); _vget_iter_response(iter, &swap_value); if (swap_value == value_from_server) is_iter_vget = EINA_TRUE; } } } static void _fill_value_to_server(Eldbus_Message *msg) { Eina_Value *eina_value; Eina_Value_Struct_Member main_members[] = { {"value", EINA_VALUE_TYPE_INT, 0} }; Eina_Value_Struct_Desc desc_struct = { EINA_VALUE_STRUCT_DESC_VERSION, NULL, main_members, 1, sizeof(int) }; eina_value = eina_value_struct_new(&desc_struct); eina_value_struct_set(eina_value, "value", value_from_client); eldbus_message_from_eina_value("i", msg, eina_value); eina_value_free(eina_value); } static void _container_receive_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) { if (timeout != NULL) { ecore_timer_del(timeout); timeout = NULL; } if (!eldbus_message_error_get(msg, NULL, NULL)) { int check_numbers[] = {10, 9}; Eldbus_Message_Iter *array = NULL; int num; Eina_Bool fail = EINA_FALSE; if (eldbus_message_arguments_get(msg, "ai", &array)) { int iter = 0; while (eldbus_message_iter_get_and_next(array, 'i', &num)) { if (check_numbers[iter] != num) { fail = EINA_TRUE; break; } ++iter; } } is_receive = fail ? EINA_FALSE : EINA_TRUE; } ecore_main_loop_quit(); } static void _hello_cb(void *data, const Eldbus_Message *msg EINA_UNUSED, Eldbus_Pending *pending EINA_UNUSED) { int *user_data = data; if (user_data && *user_data == cb_data) is_success = EINA_TRUE; } static void _activable_list_get(Eldbus_Message_Cb message_cb) { is_success = EINA_FALSE; Eldbus_Connection *conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); ck_assert_ptr_ne(NULL, conn); Eldbus_Pending *pending = eldbus_names_activatable_list(conn, message_cb, NULL); ck_assert_ptr_ne(NULL, pending); timeout = ecore_timer_add(1.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); ck_assert_msg(is_success, "Method ListActivatableNames is not call"); eldbus_connection_unref(conn); } /** * @addtogroup eldbus_message * @{ * @defgroup eldbus_message_iterator_activatable_list * @li eldbus_message_iter_get() * @li eldbus_message_iter_signature_get() * @li eldbus_message_iter_arguments_get() * @li eldbus_message_iter_get_and_next() * @li eldbus_message_error_get() * @{ * @objective Positive test case checks if function get response from DBus service. * Get valid iterator from message response, current signature of a message iterator, * get data from iterator and move the next field to end, and without segmentation fault. * * @n Input Data: * @li the conn object connection with bus * * @procedure * @step 1 Call eldbus_connection_get function to get connection object * @step 2 Check returned connection object on NULL. * @step 3 Call eldbus_names_activatable_list send a "ListActivatableNames" method call in proxy. * @step 4 Check returned object on NULL. * @step 5 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 6 Start of main loop and wait for tested response in callback executing. * @step 7 Check static variables named is_success. * If are equals 1, that callback was executed and method "ListActivatableNames" send valid message response. * Message iterator returned valid iteration data. In other cases error. * @step 8 Call eldbus_connection_unref function to delete connection object * * @passcondition Message response should returned valid iteration data, and worked correctly. * @} * @} */ EFL_START_TEST(utc_eldbus_message_iterator_activatable_list_p) { _activable_list_get(_response_message_cb); } EFL_END_TEST /** * @addtogroup eldbus_message * @{ * @defgroup eldbus_message_info_data_get * @li eldbus_message_method_call_new() * @li eldbus_message_interface_get() * @li eldbus_message_member_get() * @li eldbus_message_path_get() * @li eldbus_message_sender_get() * @li eldbus_message_destination_get() * @li eldbus_message_arguments_get() * @li eldbus_message_error_get() * @{ * @objective Positive test case checks if function create a new message to invoke a method. * Get from message object expected valid information data about DBus service. Without segmentation fault. * * @n Input Data: * @li the conn object connection with bus * * @procedure * @step 1 Call eldbus_connection_get function to get connection object. * @step 2 Check returned connection object on NULL. * @step 3 Call eldbus_message_method_call_new for create a new message to invoke a method on a remote object. * @step 4 Check returned object on NULL. * @step 5 Call eldbus_message_interface_get function to get valid string and check on expected string. * @step 6 Call eldbus_message_member_get function to get valid string and check on expected string. * @step 7 Call eldbus_message_path_get function to get valid string and check on expected string. * @step 8 Call eldbus_connection_send function to send a message a dbus object with timeout. * @step 9 Check returned pending on NULL. * @step 10 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 11 Start of main loop and wait for tested response in callback executing. * @step 12 Check static variables named is_success. * If are equals 1, that callback was executed and method send valid message response * from expected sender and not empty destination * @step 13 Call eldbus_message_unref function to delete message object * @step 14 Call eldbus_connection_unref function to delete connection object * * @passcondition Function should get valid expected message information about service. * Variables named is_success must equals 1. Without segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_message_info_data_get_p) { const int timeout_send_ms = 1000; is_success = EINA_FALSE; Eldbus_Connection *conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); ck_assert_ptr_ne(NULL, conn); Eldbus_Message *msg = eldbus_message_method_call_new(bus, path, interface, method_name); ck_assert_ptr_ne(NULL, msg); const char *interface_msg = eldbus_message_interface_get(msg); ck_assert_msg(strcmp(interface, interface_msg) == 0, "%s != %s", interface, interface_msg); const char *method_msg = eldbus_message_member_get(msg); ck_assert_msg(strcmp(method_name, method_msg) == 0, "%s != %s", method_name, method_msg); const char *path_msg = eldbus_message_path_get(msg); ck_assert_msg(strcmp(path, path_msg) == 0, "%s != %s", path, path_msg); Eldbus_Pending *pending = eldbus_connection_send(conn, msg, _message_method_cb, NULL, timeout_send_ms); ck_assert_ptr_ne(NULL, pending); timeout = ecore_timer_add(1.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); ck_assert_msg(is_success, "Method %s is not call", method_name); - eldbus_message_unref(msg); eldbus_connection_unref(conn); } EFL_END_TEST /** * @addtogroup eldbus_message * @{ * @defgroup eldbus_message_signal_new eldbus_message_signal_new() * @{ * @objective Positive test case checks if function create a new signal message without error. * * @n Input Data: * @li the conn object connection with bus * * @procedure * @step 1 Get eldbus connection object and check on NULL * @step 2 Call eldbus_signal_handler_add with callback function * to be called when this signal is received. * @step 3 Check returned signal handler object on NULL. * @step 4 Call eldbus_message_signal_new to create a new signal message. * @step 5 Check returned message object on NULL. * @step 6 Call eldbus_connection_send to send a signal a dbus object. * @step 7 Check returned pending object on NULL. * @step 8 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 9 Start of main loop and wait for tested response in callback executing. * @step 10 Check static variables named is_success. * If are equals 1, that callback was executed and signal response arrives. * @step 11 Call eldbus_signal_handler_unref function to delete signal handler object * @step 12 Call eldbus_message_unref function to delete message object * @step 13 Call eldbus_connection_unref function to delete connection object * * @passcondition Variables named is_success_cb must equals 1, and there is no segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_message_signal_new_p) { const int timeout_send_ms = 1000; is_success = EINA_FALSE; Eldbus_Connection *conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); ck_assert_ptr_ne(NULL, conn); Eldbus_Signal_Handler *signal_handler = eldbus_signal_handler_add(conn, NULL, path, interface, signal_name, _signal_name_owner_changed, NULL); ck_assert_ptr_ne(NULL, signal_handler); Eldbus_Message *msg = eldbus_message_signal_new(path, interface, signal_name); ck_assert_ptr_ne(NULL, msg); Eldbus_Pending *pending = eldbus_connection_send(conn, msg, _message_without_body_cb, NULL, timeout_send_ms); ck_assert_ptr_ne(NULL, pending); timeout = ecore_timer_add(1.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); ck_assert_msg(is_success, "Signal NameOwnerChanged is not emit"); - eldbus_signal_handler_unref(signal_handler); - eldbus_message_unref(msg); + eldbus_signal_handler_del(signal_handler); eldbus_connection_unref(conn); } EFL_END_TEST /** * @addtogroup eldbus_message * @{ * @defgroup eldbus_message_ref_unref * @li eldbus_message_ref() * @li eldbus_message_unref() * @{ * @objective Positive test case checks if function increase, decrease message reference, * and without segmentation fault. * * @n Input Data: * @li the conn object connection with bus * @li the msg message object * * @procedure * @step 1 Call eldbus_connection_get function to get connection object * @step 2 Check returned connection object on NULL. * @step 3 Call eldbus_message_method_call_new to create a new message to invoke a method on a remote object. * @step 4 Check returned object on NULL. * @step 5 Call eldbus_message_ref to increase message reference (message counter == 2). * @step 6 Check two message objects on the same adress. * @step 7 Call eldbus_message_unref to decrease message reference (message counter == 1). * @step 8 Call eldbus_message_path_get and check return string on expected value. * @step 9 Call eldbus_message_unref to decrease message reference (message counter == 0). * @step 10 Call eldbus_message_path_get and check return string on NULL. * @step 11 Call eldbus_connection_unref function to delete connection object * * @passcondition Function should increase, decrease message reference count, * return expected result and without segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_message_ref_unref_p) { Eldbus_Connection *conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); ck_assert_ptr_ne(NULL, conn); Eldbus_Message *msg = eldbus_message_method_call_new(bus, path, interface, method_name); ck_assert_ptr_ne(NULL, msg); Eldbus_Message *msg_ref = eldbus_message_ref(msg); ck_assert_ptr_eq(msg_ref, msg); eldbus_message_unref(msg_ref); const char *path_msg = eldbus_message_path_get(msg); ck_assert_msg(strcmp(path, path_msg) == 0, "%s != %s", path, path_msg); eldbus_message_unref(msg); ck_assert_ptr_eq(NULL, eldbus_message_path_get(msg)); eldbus_connection_unref(conn); } EFL_END_TEST /** * @addtogroup eldbus_message * @{ * @defgroup eldbus_message_basic_eina_value * @li eldbus_message_to_eina_value() * @li eldbus_message_iter_basic_get() * @li eldbus_message_error_get() * @{ * @objective Positive test case checks if function convert message object to eina value, * get a basic type from message iterator, and without segmentation fault. * * @n Input Data: * @li the conn object connection with bus * * @procedure * @step 1 Call eldbus_connection_get function to get connection object * @step 2 Check returned connection object on NULL. * @step 3 Call eldbus_name_owner_get with callback function * to be called when method sended response. * @step 4 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 5 Start of main loop and wait for tested response in callback executing. * @step 6 Check static variables named is_success. * If are equals 1, that callback was executed and tested function return expeccted values. * @step 7 Call eldbus_connection_unref function to delete connection object * * @passcondition Variables named is_success_cb must equals 1, and there is no segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_message_basic_eina_value_p) { is_success = EINA_FALSE; Eldbus_Connection *conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); ck_assert_ptr_ne(NULL, conn); Eldbus_Pending *pending = eldbus_name_owner_has(conn, bus, _response_owner_has_cb, NULL); ck_assert_ptr_ne(NULL, pending); timeout = ecore_timer_add(1.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); ck_assert_msg(is_success, "Problem with eldbus eina value"); eldbus_connection_unref(conn); } EFL_END_TEST /** * @addtogroup eldbus_message * @{ * @defgroup eldbus_message_iter_next eldbus_message_iter_next() * @{ * @objective Positive test case checks if function get response from DBus service. * Get valid iterator from message response, get data from iterator * and move the next field to end, and without segmentation fault. * * @n Input Data: * @li the conn object connection with bus * * @procedure * @step 1 Call eldbus_connection_get function to get connection object * @step 2 Check returned connection object on NULL. * @step 3 Call eldbus_names_activatable_list send a "ListActivatableNames" method call in proxy. * @step 4 Check returned object on NULL. * @step 5 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 6 Start of main loop and wait for tested response in callback executing. * @step 7 Check static variables named is_success. * If are equals 1, that callback was executed and method "ListActivatableNames" send valid message response. * Message iterator returned valid iteration data. In other cases error. * @step 8 Call eldbus_connection_unref function to delete connection object * * @passcondition Message response should returned valid iteration data, and worked correctly. * @} * @} */ EFL_START_TEST(utc_eldbus_message_iter_next_p) { _activable_list_get(_activatable_list_response_cb); } EFL_END_TEST /** * @addtogroup eldbus_message * @{ * @defgroup eldbus_message_arguments_vappend eldbus_message_arguments_vappend() * @{ * @objective Positive test case checks if function append arguments into an message object * call the method and get valid response in callback function, and without segmentation fault. * * @n Input Data: * @li the conn object connection with bus * @li the ap va_list arguments to message object * * @procedure * @step 1 Call eldbus_connection_get function to get connection object * @step 2 Check returned connection object on NULL. * @step 3 Call eldbus_message_method_call_new to create a new message to invoke a method on a remote object. * @step 4 Check returned object on NULL. * @step 5 Call eldbus_message_method_call_new to append arguments into an message object. * @step 6 Call eldbus_connection_send function to send a message a dbus object. * @step 7 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 8 Start of main loop and wait for tested response in callback executing. * @step 9 Check static variables named is_success. * If are equals 1, that callback was executed and method send valid message response. * In other cases error. * @step 10 Call eldbus_message_unref function to delete message object * @step 11 Call eldbus_connection_unref function to delete connection object * * @passcondition Variables named is_success must equals EINA_TRUE. Without segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_message_arguments_vappend_p) { is_success = EINA_FALSE; Eldbus_Connection *conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); ck_assert_ptr_ne(NULL, conn); message_vparam = eldbus_message_method_call_new(bus, path, interface, "GetNameOwner"); ck_assert_ptr_ne(NULL, message_vparam); _varg_add("s", bus); Eldbus_Pending *pending = eldbus_connection_send(conn, message_vparam, _message_response_cb, NULL, -1); ck_assert_ptr_ne(NULL, pending); timeout = ecore_timer_add(1.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); ck_assert_msg(is_success, "Method GetNameOwner is not call"); - eldbus_message_unref(message_vparam); eldbus_connection_unref(conn); } EFL_END_TEST /** * @addtogroup eldbus_message * @{ * @defgroup eldbus_message_arguments_vget * @li eldbus_message_arguments_vget() * @li eldbus_message_arguments_append() * @li eldbus_message_error_get() * @{ * @objective Positive test case checks if function call the method * and get valid response in callback function used va_list, and without segmentation fault. * * @n Input Data: * @li the conn object connection with bus * * @procedure * @step 1 Call eldbus_connection_get function to get connection object * @step 2 Check returned connection object on NULL. * @step 3 Call eldbus_message_method_call_new to create a new message to invoke a method on a remote object. * @step 4 Check returned object on NULL. * @step 5 Call eldbus_message_method_call_new to append arguments into an message object. * @step 6 Call eldbus_message_arguments_append to append arguments into an message object. * @step 7 Call eldbus_connection_send function to send a message a dbus object. * @step 8 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 9 Start of main loop and wait for tested response in callback executing. * @step 10 Check static variables named is_success. * If are equals 1, that callback was executed and get the response arguments * from an message object using a va_list without error. In other cases error. * @step 11 Call eldbus_message_unref function to delete message object. * @step 12 Call eldbus_connection_unref function to delete connection object. * * @passcondition Variables named is_success must equals EINA_TRUE. Without segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_message_arguments_vget_p) { is_success = EINA_FALSE; Eldbus_Connection *conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); ck_assert_ptr_ne(NULL, conn); Eldbus_Message *message = eldbus_message_method_call_new(bus, path, interface, "NameHasOwner"); ck_assert_ptr_ne(NULL, message); Eina_Bool is_arguments_append = eldbus_message_arguments_append(message, "s", bus); ck_assert_msg(is_arguments_append, "Can't append arguments"); Eldbus_Pending *pending = eldbus_connection_send(conn, message, _message_vget_response_cb, NULL, -1); ck_assert_ptr_ne(NULL, pending); timeout = ecore_timer_add(1.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); ck_assert_msg(is_success, "Can't get arguments"); - eldbus_message_unref(message); eldbus_connection_unref(conn); } EFL_END_TEST /** * @addtogroup eldbus_message * @{ * @defgroup eldbus_message_eina * @li eldbus_message_from_eina_value() * @li eldbus_message_iter_struct_like_to_eina_value() * @li eldbus_message_iter_arguments_vappend() * @li eldbus_message_iter_arguments_vget() * @li eldbus_message_signature_get() * @li eldbus_message_method_return_new() * @li eldbus_message_error_get() * @{ * @objective Positive test case checks if function convert Eina_Value to message object * and backward using iterator to message object without error. Set data to message object iterator using va_list. * Get data from message iterator using va_list. Get the Eldbus message signature. Without segmentation fault. * * @n Input Data: * @li the conn_server object connection to server * @li the conn_client object connection to client * @li the iface object register an interface * * @procedure * @step 1 Call eldbus_connection_get function to get server connection object. * @step 2 Check returned connection object on NULL. * @step 3 Call eldbus_service_interface_register function to register an interface. * in the given path and connection. * @step 4 Check returned interface object on NULL. * @step 5 Call eldbus_name_request function to send a "RequestName" method call in proxy. * @step 6 Check returned pending object on NULL. * @step 7 Call eldbus_connection_get function to get client connection object. * @step 8 Check returned connection object on NULL. * @step 9 Call eldbus_object_get function to get an client object * of the given bus and path. * @step 10 Check returned object on NULL. * @step 11 Call eldbus_proxy_get function to get a proxy of the following interface name. * @step 12 Check returned proxy object on NULL. * @step 13 Call eldbus_proxy_method_call_new function to constructs * a new message to invoke a method on a remote interface. * @step 14 Check returned message object on NULL. * @step 15 Convert Eina_Value to message object. * @step 16 Call eldbus_proxy_send function to send a message by method on remote interface. * @step 17 Check returned pending object on NULL. * @step 18 Call eldbus_proxy_call function to Call a method in proxy. * @step 19 Check returned pending object on NULL. * @step 20 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 21 Start of main loop and wait for tested response in callback executing. * @step 22 Check static variables named is_success, is_register_service, is_iter_vget. * If are equals 1, that get and set property works correctly, * get expected response with expected signature from client and server without error. In other cases error. * @step 23 Call eldbus_message_unref function to delete message object. * @step 24 Call eldbus_proxy_unref function to delete proxy object. * @step 25 Call eldbus_object_unref function to delete connection dbus object. * @step 26 Call eldbus_connection_unref function to delete client connection object. * @step 27 Call eldbus_service_interface_unregister function to unregister a interface. * @step 28 Call eldbus_connection_unref function to delete server connection object * * @passcondition Variables named is_success_cb, is_register_service, is_iter_vget must equals 1, and there is no segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_message_eina_p) { is_success = EINA_FALSE; is_register_service = EINA_FALSE; is_iter_vget = EINA_FALSE; Eldbus_Connection *conn_server = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); ck_assert_ptr_ne(NULL, conn_server); Eldbus_Service_Interface *iface = eldbus_service_interface_register(conn_server, dbus_session_path, &iface_desc); ck_assert_ptr_ne(NULL, iface); Eldbus_Pending *pending_name = eldbus_name_request(conn_server, bus_session, ELDBUS_NAME_REQUEST_FLAG_DO_NOT_QUEUE, _name_request, iface); ck_assert_ptr_ne(NULL, pending_name); Eldbus_Connection *conn_client = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); ck_assert_ptr_ne(NULL, conn_client); Eldbus_Object *obj = eldbus_object_get(conn_client, bus_session, dbus_session_path); ck_assert_ptr_ne(NULL, obj); Eldbus_Proxy *proxy = eldbus_proxy_get(obj, interface_session); ck_assert_ptr_ne(NULL, proxy); Eldbus_Message *msg = eldbus_proxy_method_call_new(proxy, "SwapValue"); ck_assert_ptr_ne(NULL, msg); _fill_value_to_server(msg); Eldbus_Pending *pending = eldbus_proxy_send(proxy, msg, _response_swap_value, NULL, -1); ck_assert_ptr_ne(NULL, pending); pending = eldbus_proxy_call(proxy, "SwapValue", _response_swap_iter_vget, NULL, -1 , "i", value_from_client); ck_assert_ptr_ne(NULL, pending); timeout = ecore_timer_add(2.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); ck_assert_msg(is_success, "Can't get response"); ck_assert_msg(is_register_service, "Can't registered service"); ck_assert_msg(is_iter_vget, "Can't get argument"); - eldbus_message_unref(msg); - eldbus_proxy_unref(proxy); - eldbus_object_unref(obj); eldbus_connection_unref(conn_client); eldbus_service_interface_unregister(iface); eldbus_connection_unref(conn_server); } EFL_END_TEST /** * @addtogroup eldbus_message * @{ * @defgroup eldbus_message_container * @li eldbus_message_iter_container_new() * @li eldbus_message_iter_container_close() * @li eldbus_message_iter_fixed_array_append() * @li eldbus_message_method_return_new() * @{ * @objective Positive test case checks if function create and append a typed iterator to message iterator. * Closes a container-typed value appended to the message object. Append a array of basic type with fixed size * to message reply iterator. Without segmentation fault. * * @n Input Data: * @li the conn_server object connection to server * @li the conn_client object connection to client * @li the iface object register an interface * * @procedure * @step 1 Call eldbus_connection_get function to get server connection object. * @step 2 Check returned connection object on NULL. * @step 3 Call eldbus_service_interface_register function to register an interface. * in the given path and connection. * @step 4 Check returned interface object on NULL. * @step 5 Call eldbus_name_request function to send a "RequestName" method call in proxy. * @step 6 Check returned pending object on NULL. * @step 7 Call eldbus_connection_get function to get client connection object. * @step 8 Check returned connection object on NULL. * @step 9 Call eldbus_object_get function to get an client object * of the given bus and path. * @step 10 Check returned object on NULL. * @step 11 Call eldbus_proxy_get function to get a proxy of the following interface name. * @step 12 Check returned proxy object on NULL. * @step 13 Call eldbus_proxy_method_call_new function to constructs * a new message to invoke a method on a remote interface. * @step 14 Check returned message object on NULL. * @step 15 Call eldbus_message_iter_get function to get the main message iterator from the message object. * @step 16 Call eldbus_message_iter_container_new function to create and append a typed iterator to main iterator. * @step 17 Check returned iterator on NULL. * @step 18 In loop call eldbus_message_iter_basic_append function to append a basic type into an new iterator * @step 19 Call eldbus_message_iter_container_close function to closes a container-typed value appended to the message object. * @step 20 Call eldbus_proxy_send function to send a message by method on remote interface. * @step 21 Check returned pending object on NULL. * @step 22 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 23 Start of main loop and wait for tested response in callback executing. * @step 24 Check static variables named is_success, is_register_service, is_receive. * If are equals 1, that get and set property works correctly, * get expected response from client and server without error. In other cases error. * @step 25 Call eldbus_message_unref function to delete message object. * @step 26 Call eldbus_proxy_unref function to delete proxy object. * @step 27 Call eldbus_object_unref function to delete connection dbus object. * @step 28 Call eldbus_connection_unref function to delete client connection object. * @step 29 Call eldbus_service_interface_unregister function to unregister a interface. * @step 30 Call eldbus_connection_unref function to delete server connection object * * @passcondition Variables named is_success_cb, is_register_service, is_receive must equals 1, and there is no segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_message_container_p) { int i; is_success = EINA_FALSE; is_register_service = EINA_FALSE; is_receive = EINA_FALSE; Eldbus_Connection *conn_server = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); ck_assert_ptr_ne(NULL, conn_server); Eldbus_Service_Interface *iface = eldbus_service_interface_register(conn_server, dbus_session_path, &iface_desc); ck_assert_ptr_ne(NULL, iface); Eldbus_Pending *pending_name = eldbus_name_request(conn_server, bus_session, ELDBUS_NAME_REQUEST_FLAG_DO_NOT_QUEUE, _name_request, iface); ck_assert_ptr_ne(NULL, pending_name); Eldbus_Connection *conn_client = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); ck_assert_ptr_ne(NULL, conn_client); Eldbus_Object *obj = eldbus_object_get(conn_client, bus_session, dbus_session_path); ck_assert_ptr_ne(NULL, obj); Eldbus_Proxy *proxy = eldbus_proxy_get(obj, interface_session); ck_assert_ptr_ne(NULL, proxy); Eldbus_Message *msg = eldbus_proxy_method_call_new(proxy, "ArrayContainer"); ck_assert_ptr_ne(NULL, msg); Eldbus_Message_Iter *iter = eldbus_message_iter_get(msg); Eldbus_Message_Iter *container_iter = eldbus_message_iter_container_new(iter, 'a',"s"); ck_assert_ptr_ne(NULL, container_iter); for (i = 0; i < CONTAINER_COUNT; i++) eldbus_message_iter_basic_append(container_iter, 's', container_data[i]); Eina_Bool is_container_iter_closed = eldbus_message_iter_container_close(iter, container_iter); ck_assert_msg(is_container_iter_closed, "Can't closed container"); Eldbus_Pending *pending = eldbus_proxy_send(proxy, msg, _container_receive_cb, NULL, -1); ck_assert_ptr_ne(NULL, pending); timeout = ecore_timer_add(2.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); ck_assert_msg(is_success, "Can't get response"); ck_assert_msg(is_register_service, "Can't registered service"); ck_assert_msg(is_receive, "Can't get container data"); - eldbus_message_unref(msg); - eldbus_proxy_unref(proxy); - eldbus_object_unref(obj); eldbus_connection_unref(conn_client); eldbus_service_interface_unregister(iface); eldbus_connection_unref(conn_server); } EFL_END_TEST /** * @addtogroup eldbus_message * @{ * @defgroup eldbus_message_error_new eldbus_message_error_new() * @{ * @objective Positive test case checks if function create a new message that is an error reply to another message. * Without segmentation fault. * * @n Input Data: * @li the message object replying to * @li the error name "org.freedesktop.DBus.Error.InvalidSignature" * @li the error message "Invalid type" string * * @procedure * @step 1 Call eldbus_connection_get function to get server connection object. * @step 2 Check returned connection object on NULL. * @step 3 Call eldbus_service_interface_register function to register an interface. * in the given path and connection. * @step 4 Check returned interface object on NULL. * @step 5 Call eldbus_name_request function to send a "RequestName" method call in proxy. * @step 6 Check returned pending object on NULL. * @step 7 Call eldbus_connection_get function to get client connection object. * @step 8 Check returned connection object on NULL. * @step 9 Call eldbus_object_get function to get an client object * of the given bus and path. * @step 10 Check returned object on NULL. * @step 11 Call eldbus_proxy_get function to get a proxy of the following interface name. * @step 12 Check returned proxy object on NULL. * @step 13 Call eldbus_proxy_call function to call a method "SendBool" in proxy. * @step 14 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 15 Start of main loop and wait for tested response in callback executing. * @step 16 Call eldbus_proxy_unref function to delete proxy object. * @step 17 Call eldbus_object_unref function to delete connection dbus object. * @step 18 Call eldbus_connection_unref function to delete client connection object. * @step 19 Call eldbus_service_interface_unregister function to unregister a interface. * @step 20 Call eldbus_connection_unref function to delete server connection object * @step 21 Check static variable named is_success. * If is equal 1, that error reply to another message works correctly. In other cases error. * * @passcondition Variable named is_success_cb must equal 1, and there is no segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_message_error_new_p) { is_success = EINA_FALSE; Eldbus_Connection *conn_server = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); ck_assert_ptr_ne(NULL, conn_server); Eldbus_Service_Interface *iface = eldbus_service_interface_register(conn_server, dbus_session_path, &iface_desc); ck_assert_ptr_ne(NULL, iface); Eldbus_Pending *pending_name = eldbus_name_request(conn_server, bus_session, ELDBUS_NAME_REQUEST_FLAG_DO_NOT_QUEUE, _name_request, iface); ck_assert_ptr_ne(NULL, pending_name); Eldbus_Connection *conn_client = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); ck_assert_ptr_ne(NULL, conn_client); Eldbus_Object *obj = eldbus_object_get(conn_client, bus_session, dbus_session_path); ck_assert_ptr_ne(NULL, obj); Eldbus_Proxy *proxy = eldbus_proxy_get(obj, interface_session); ck_assert_ptr_ne(NULL, proxy); eldbus_proxy_call(proxy, "SendBool", _on_send_bool, NULL, -1, "b", NULL); timeout = ecore_timer_add(2.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); - eldbus_proxy_unref(proxy); - eldbus_object_unref(obj); eldbus_connection_unref(conn_client); eldbus_service_interface_unregister(iface); eldbus_connection_unref(conn_server); ck_assert_msg(is_success, "Can't get response"); } EFL_END_TEST /** * @addtogroup eldbus_message * @{ * @defgroup eldbus_message_iter_del eldbus_message_iter_del() * @{ * @objective Positive test case checks if function manually delete the iterator without segmentation fault. * * @n Input Data: * @li the iterator to be deleted * * @procedure * @step 1 Call eldbus_connection_get function to get server connection object. * @step 2 Check returned connection object on NULL. * @step 3 Call eldbus_service_interface_register function to register an interface. * in the given path and connection. * @step 4 Check returned interface object on NULL. * @step 5 Call eldbus_name_request function to send a "RequestName" method call in proxy. * @step 6 Check returned pending object on NULL. * @step 7 Call eldbus_connection_get function to get client connection object. * @step 8 Check returned connection object on NULL. * @step 9 Call eldbus_object_get function to get an client object * of the given bus and path. * @step 10 Check returned object on NULL. * @step 11 Create message object to call method "SendByte" and append arguments * @step 12 Get iterator from message object and check on NULL * @step 13 Manually delete the iterator * @step 14 Call eldbus_object_unref function to delete connection dbus object. * @step 15 Call eldbus_connection_unref function to delete client connection object. * @step 16 Call eldbus_service_interface_unregister function to unregister a interface. * @step 17 Call eldbus_connection_unref function to delete server connection object * * @passcondition Function should manually delete the message iterator without segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_message_iter_del_p) { Eldbus_Connection *conn_server = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); ck_assert_ptr_ne(NULL, conn_server); Eldbus_Service_Interface *iface = eldbus_service_interface_register(conn_server, dbus_session_path, &iface_desc); ck_assert_ptr_ne(NULL, iface); Eldbus_Pending *pending_name = eldbus_name_request(conn_server, bus_session, ELDBUS_NAME_REQUEST_FLAG_DO_NOT_QUEUE, _name_request, iface); ck_assert_ptr_ne(NULL, pending_name); Eldbus_Connection *conn_client = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); ck_assert_ptr_ne(NULL, conn_client); Eldbus_Object *obj = eldbus_object_get(conn_client, bus_session, dbus_session_path); ck_assert_ptr_ne(NULL, obj); Eldbus_Message *msg = eldbus_object_method_call_new(obj, "org.freedesktop.Test", "SendByte"); ck_assert_ptr_ne(NULL, msg); eldbus_message_arguments_append(msg, "y", 25); Eldbus_Message_Iter *iter = NULL; if ((iter = eldbus_message_iter_get(msg))) { eldbus_message_iter_del(iter); } - eldbus_object_unref(obj); eldbus_connection_unref(conn_client); eldbus_service_interface_unregister(iface); eldbus_connection_unref(conn_server); } EFL_END_TEST /** * @addtogroup eldbus_message * @{ * @defgroup eldbus_message_iter_fixed_array_get eldbus_message_iter_fixed_array_get() * @{ * @objective Positive test case checks if function gets a block of fixed-length values from the message iterator. Without segmentation fault. * * @n Input Data: * @li the message iterator * @li 'i' the signature block of fixed-length values * @li the block of fixed-length values * @li the count elemenats * * @procedure * @step 1 Call eldbus_connection_get function to get server connection object. * @step 2 Check returned connection object on NULL. * @step 3 Call eldbus_service_interface_register function to register an interface. * in the given path and connection. * @step 4 Check returned interface object on NULL. * @step 5 Call eldbus_name_request function to send a "RequestName" method call in proxy. * @step 6 Check returned pending object on NULL. * @step 7 Call eldbus_connection_get function to get client connection object. * @step 8 Check returned connection object on NULL. * @step 9 Call eldbus_object_get function to get an client object * of the given bus and path. * @step 10 Check returned object on NULL. * @step 11 Call eldbus_proxy_get function to get a proxy of the following interface name. * @step 12 Check returned proxy object on NULL. * @step 13 Call a method "SendArrayInt" in proxy * @step 14 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 15 Start of main loop and wait for tested response in callback executing. * @step 16 Call eldbus_proxy_unref function to delete proxy object. * @step 17 Call eldbus_object_unref function to delete connection dbus object. * @step 18 Call eldbus_connection_unref function to delete client connection object. * @step 19 Call eldbus_service_interface_unregister function to unregister a interface. * @step 20 Call eldbus_connection_unref function to delete server connection object * @step 21 Check static variable named is_success. * If is equal 1, that get expected block of fixed-length values without error. In other cases error. * * @passcondition Variable named is_success must equals 1, and there is no segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_message_iter_fixed_array_get_p) { is_success = EINA_FALSE; Eldbus_Connection *conn_server = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); ck_assert_ptr_ne(NULL, conn_server); Eldbus_Service_Interface *iface = eldbus_service_interface_register(conn_server, dbus_session_path, &iface_desc); ck_assert_ptr_ne(NULL, iface); Eldbus_Pending *pending_name = eldbus_name_request(conn_server, bus_session, ELDBUS_NAME_REQUEST_FLAG_DO_NOT_QUEUE, _name_request, iface); ck_assert_ptr_ne(NULL, pending_name); Eldbus_Connection *conn_client = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); ck_assert_ptr_ne(NULL, conn_client); Eldbus_Object *obj = eldbus_object_get(conn_client, bus_session, dbus_session_path); ck_assert_ptr_ne(NULL, obj); Eldbus_Proxy *proxy = eldbus_proxy_get(obj, interface_session); ck_assert_ptr_ne(NULL, proxy); Eldbus_Pending *pending = eldbus_proxy_call(proxy, "SendArrayInt", _on_send_array_int, NULL, -1 , ""); ck_assert_ptr_ne(NULL, pending); timeout = ecore_timer_add(2.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); - eldbus_proxy_unref(proxy); - eldbus_object_unref(obj); eldbus_connection_unref(conn_client); eldbus_service_interface_unregister(iface); eldbus_connection_unref(conn_server); ck_assert_msg(is_success, "Can't get response"); } EFL_END_TEST /** * @addtogroup eldbus_message * @{ * @defgroup eldbus_hello eldbus_hello() * @{ * @objective Positive test case checks if function send a "Hello" method call in proxy and get response. * Without segmentation fault. * * @n Input Data: * @li the сonnection object * @li the сallback to call when receiving answer * @li the 5 value data passed to callback * * @procedure * @step 1 Call eldbus_connection_get function to get server connection object * @step 2 Check returned connection object on NULL * @step 3 Call eldbus_hello function to send a "Hello" method call in proxy * @step 4 Set timer for preschedule termination of main loop if tested callback was executed * @step 5 Start of main loop and wait for tested response in callback executing * @step 6 Call eldbus_connection_unref function to delete server connection object * @step 7 Check static variable named is_success. * If is equal EINA_TRUE, that callback was executed. In other cases error * * @passcondition Variable named is_success must equal EINA_TRUE, and there is no segmentation fault * @} * @} */ EFL_START_TEST(utc_eldbus_hello_p) { is_success = EINA_FALSE; Eldbus_Connection *conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); ck_assert_ptr_ne(NULL, conn); eldbus_hello(conn, _hello_cb, &cb_data); timeout = ecore_timer_add(1.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); eldbus_connection_unref(conn); ck_assert_msg(is_success, "Can't get response"); } EFL_END_TEST void eldbus_test_eldbus_message(TCase *tc) { tcase_add_test(tc, utc_eldbus_message_iterator_activatable_list_p); tcase_add_test(tc, utc_eldbus_message_info_data_get_p); tcase_add_test(tc, utc_eldbus_message_signal_new_p); tcase_add_test(tc, utc_eldbus_message_ref_unref_p); tcase_add_test(tc, utc_eldbus_message_basic_eina_value_p); tcase_add_test(tc, utc_eldbus_message_iter_next_p); tcase_add_test(tc, utc_eldbus_message_arguments_vappend_p); tcase_add_test(tc, utc_eldbus_message_arguments_vget_p); tcase_add_test(tc, utc_eldbus_message_eina_p); tcase_add_test(tc, utc_eldbus_message_container_p); tcase_add_test(tc, utc_eldbus_message_error_new_p); tcase_add_test(tc, utc_eldbus_message_iter_del_p); tcase_add_test(tc, utc_eldbus_message_iter_fixed_array_get_p); tcase_add_test(tc, utc_eldbus_hello_p); } diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_method.c b/src/tests/eldbus/eldbus_test_eldbus_model_method.c index 5e561d4a5a..84b42bf454 100644 --- a/src/tests/eldbus/eldbus_test_eldbus_model_method.c +++ b/src/tests/eldbus/eldbus_test_eldbus_model_method.c @@ -1,185 +1,185 @@ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include "eldbus_fake_server.h" #include "eldbus_test_eldbus_model.h" #include "eldbus_suite.h" #define ARGUMENT_A "arg0" #define ARGUMENT_B "arg1" #define ARGUMENT_RESULT "arg2" static Eo *fake_server_object = NULL; static Eo *fake_server_proxy = NULL; static Eldbus_Service_Interface *fake_server = NULL; static Fake_Server_Data fake_server_data = {0}; static Eo *method = NULL; static void _setup(void) { fake_server = fake_server_start(&fake_server_data); fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(), eldbus_model_connect(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE), eldbus_model_object_bus_set(efl_added, FAKE_SERVER_BUS), eldbus_model_object_path_set(efl_added, FAKE_SERVER_PATH)); ck_assert_ptr_ne(NULL, fake_server_object); fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE); ck_assert_ptr_ne(NULL, fake_server_proxy); method = eldbus_model_method_from_proxy_get(fake_server_proxy, FAKE_SERVER_SUM_METHOD_NAME); ck_assert_ptr_ne(NULL, method); } static void _teardown(void) { - efl_unref(fake_server_object); + efl_del(fake_server_object); fake_server_stop(fake_server); } EFL_START_TEST(properties_get) { const Eina_Array *properties = NULL; properties = efl_model_properties_get(method); ck_assert_ptr_ne(NULL, properties); const unsigned int expected_properties_count = 3; // a, b and result arguments of 'sum' method const unsigned int actual_properties_count = eina_array_count(properties); ck_assert_int_eq(expected_properties_count, actual_properties_count); } EFL_END_TEST EFL_START_TEST(property_get) { // Input only property returns error Eina_Value *v; Eina_Value i = EINA_VALUE_EMPTY; int iv = -1; v = efl_model_property_get(method, ARGUMENT_A); fail_if(eina_value_type_get(v) != EINA_VALUE_TYPE_ERROR); eina_value_free(v); v = efl_model_property_get(method, ARGUMENT_RESULT); eina_value_setup(&i, EINA_VALUE_TYPE_INT); fail_if(eina_value_convert(v, &i) != EINA_TRUE); fail_if(eina_value_int_get(&i, &iv) != EINA_TRUE); fail_if(iv != 0); eina_value_flush(&i); eina_value_free(v); // Nonexistent property returns error v = efl_model_property_get(method, "nonexistent"); fail_if(eina_value_type_get(v) != EINA_VALUE_TYPE_ERROR); eina_value_free(v); } EFL_END_TEST static Eina_Value _expected_error(void *data, const Eina_Value v, const Eina_Future *dead_future EINA_UNUSED) { fail_if(eina_value_type_get(&v) != EINA_VALUE_TYPE_ERROR); if (data) { Eina_Error *expected = data; Eina_Error error; eina_value_error_get(&v, &error); fail_if(*expected != error); } ecore_main_loop_quit(); return v; } EFL_START_TEST(property_set) { // Output argument returns error Eina_Future *future; Eina_Value dummy = EINA_VALUE_EMPTY; future = efl_model_property_set(method, ARGUMENT_RESULT, &dummy); eina_future_then(future, _expected_error, NULL); } EFL_END_TEST static void _test_method_children_count(Eo *efl_model) { check_efl_model_children_count_eq(efl_model, 0); } EFL_START_TEST(children_count) { _test_method_children_count(method); } EFL_END_TEST EFL_START_TEST(children_slice_get) { Eina_Future *future; future = efl_model_children_slice_get(method, 1, 1); eina_future_then(future, _expected_error, &EFL_MODEL_ERROR_NOT_SUPPORTED); ecore_main_loop_begin(); } EFL_END_TEST EFL_START_TEST(child_add) { Eo *child; child = efl_model_child_add(method); ck_assert_ptr_eq(NULL, child); } EFL_END_TEST EFL_START_TEST(child_del) { // efl_model_child_del always returns ERROR Eo *child = NULL; efl_model_child_del(method, child); //ck_assert_int_eq(EFL_MODEL_LOAD_STATUS_ERROR, status); } EFL_END_TEST EFL_START_TEST(call) { check_efl_model_property_int_set(method, ARGUMENT_A, 12345678); check_efl_model_property_int_set(method, ARGUMENT_B, 87654321); eldbus_model_method_call(method); efl_model_wait_for_event(method, ELDBUS_MODEL_METHOD_EVENT_SUCCESSFUL_CALL); check_efl_model_property_int_eq(method, ARGUMENT_RESULT, 99999999); } EFL_END_TEST void eldbus_test_eldbus_model_method(TCase *tc) { tcase_add_checked_fixture(tc, _setup, _teardown); tcase_add_test(tc, properties_get); tcase_add_test(tc, property_get); tcase_add_test(tc, property_set); tcase_add_test(tc, children_count); tcase_add_test(tc, children_slice_get); tcase_add_test(tc, child_add); tcase_add_test(tc, child_del); tcase_add_test(tc, call); } diff --git a/src/tests/eldbus/eldbus_test_eldbus_model_signal.c b/src/tests/eldbus/eldbus_test_eldbus_model_signal.c index 1c362016b3..c4c416d161 100644 --- a/src/tests/eldbus/eldbus_test_eldbus_model_signal.c +++ b/src/tests/eldbus/eldbus_test_eldbus_model_signal.c @@ -1,155 +1,155 @@ #ifdef HAVE_CONFIG_H # include #endif #include #include #include #include #include "eldbus_fake_server.h" #include "eldbus_test_eldbus_model.h" #include "eldbus_suite.h" #define ARGUMENT_A "arg0" static Eo *fake_server_object = NULL; static Eo *fake_server_proxy = NULL; static Eldbus_Service_Interface *fake_server = NULL; static Fake_Server_Data fake_server_data = {0}; static Eo *pong_signal = NULL; static void _setup(void) { fake_server = fake_server_start(&fake_server_data); fake_server_object = efl_add(ELDBUS_MODEL_OBJECT_CLASS, efl_main_loop_get(), eldbus_model_connect(efl_added, ELDBUS_CONNECTION_TYPE_SESSION, NULL, EINA_FALSE), eldbus_model_object_bus_set(efl_added, FAKE_SERVER_BUS), eldbus_model_object_path_set(efl_added, FAKE_SERVER_PATH)); ck_assert_ptr_ne(NULL, fake_server_object); fake_server_proxy = eldbus_model_proxy_from_object_get(fake_server_object, FAKE_SERVER_INTERFACE); ck_assert_ptr_ne(NULL, fake_server_proxy); pong_signal = eldbus_model_signal_from_proxy_get(fake_server_proxy, FAKE_SERVER_PONG_SIGNAL_NAME); ck_assert_ptr_ne(NULL, pong_signal); } static void _teardown(void) { - efl_unref(fake_server_object); + efl_del(fake_server_object); fake_server_stop(fake_server); } EFL_START_TEST(properties_get) { const Eina_Array *properties = NULL; properties = efl_model_properties_get(pong_signal); ck_assert_ptr_ne(NULL, properties); const unsigned int expected_properties_count = 1; // 'response' only const unsigned int actual_properties_count = eina_array_count(properties); ck_assert_int_eq(expected_properties_count, actual_properties_count); } EFL_END_TEST EFL_START_TEST(property_get) { Eina_Value *value; Eina_Error err; // Signal properties always have output direction value = efl_model_property_get(pong_signal, ARGUMENT_A); fail_if(value == NULL); // Nonexistent property must return ERROR value = efl_model_property_get(pong_signal, "nonexistent"); fail_if(value == NULL); fail_if(eina_value_type_get(value) != EINA_VALUE_TYPE_ERROR); eina_value_error_get(value, &err); fail_if(err != EFL_MODEL_ERROR_NOT_FOUND); } EFL_END_TEST EFL_START_TEST(property_set) { // Signals have output arguments only. All returns error Eina_Value dummy = EINA_VALUE_EMPTY; Eina_Future *future; future = efl_model_property_set(pong_signal, ARGUMENT_A, &dummy); check_efl_model_future_error(future, NULL); } EFL_END_TEST static void _test_signal_children_count(Eo *efl_model) { check_efl_model_children_count_eq(efl_model, 0); } EFL_START_TEST(children_count) { _test_signal_children_count(pong_signal); } EFL_END_TEST EFL_START_TEST(children_slice_get) { Eina_Future *future; future = efl_model_children_slice_get(pong_signal, 1, 1); check_efl_model_future_error(future, &EFL_MODEL_ERROR_NOT_SUPPORTED); } EFL_END_TEST EFL_START_TEST(child_add) { Eo *child; child = efl_model_child_add(pong_signal); ck_assert_ptr_eq(NULL, child); } EFL_END_TEST EFL_START_TEST(child_del) { // efl_model_child_del always returns ERROR FIXME catch error Eo *child = NULL; efl_model_child_del(pong_signal, child); } EFL_END_TEST EFL_START_TEST(signals) { Eldbus_Model_Method *ping_method = eldbus_model_method_from_proxy_get(fake_server_proxy, FAKE_SERVER_PING_METHOD_NAME); ck_assert_ptr_ne(NULL, ping_method); check_efl_model_property_int_set(ping_method, ARGUMENT_A, 99); eldbus_model_method_call(ping_method); efl_model_wait_for_event(pong_signal, EFL_MODEL_EVENT_PROPERTIES_CHANGED); check_efl_model_property_int_eq(pong_signal, ARGUMENT_A, 100); } EFL_END_TEST void eldbus_test_eldbus_model_signal(TCase *tc) { tcase_add_checked_fixture(tc, _setup, _teardown); tcase_add_test(tc, properties_get); tcase_add_test(tc, property_get); tcase_add_test(tc, property_set); tcase_add_test(tc, children_count); tcase_add_test(tc, children_slice_get); tcase_add_test(tc, child_add); tcase_add_test(tc, child_del); tcase_add_test(tc, signals); } diff --git a/src/tests/eldbus/eldbus_test_eldbus_object.c b/src/tests/eldbus/eldbus_test_eldbus_object.c index a183330388..4c35d7a54f 100644 --- a/src/tests/eldbus/eldbus_test_eldbus_object.c +++ b/src/tests/eldbus/eldbus_test_eldbus_object.c @@ -1,391 +1,389 @@ #include #include #include #include #include #include "eldbus_suite.h" static Eina_Bool is_success = EINA_FALSE; static Eina_Bool is_register_service = EINA_FALSE; static Eina_Bool is_peer_ping = EINA_FALSE; static Ecore_Timer *timeout = NULL; static const char *empty_string = ""; static const char *bus = "org.freedesktop.DBus"; static const char *interface = "org.freedesktop.DBus"; static const char *path = "/org/freedesktop/DBus"; static const char *method_name = "GetId"; static int cb_data = 5; /** * @addtogroup eldbus * @{ * @defgroup eldbus_object * * @precondition * @step 1 Initialize eldbus with eldbus_init() */ static Eina_Bool _ecore_loop_close(void *data EINA_UNUSED) { ecore_main_loop_quit(); return ECORE_CALLBACK_CANCEL; } static void _object_message_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) { if (timeout != NULL) { ecore_timer_del(timeout); timeout = NULL; } const char *errname, *errmsg; int *user_data = data; if ((user_data) && (*user_data == cb_data)) { if (!eldbus_message_error_get(msg, &errname, &errmsg)) { char *txt; if (eldbus_message_arguments_get(msg, "s", &txt)) { if ((txt) && strcmp(txt, empty_string)) is_success = EINA_TRUE; } } } ecore_main_loop_quit(); } static void _name_request(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) { unsigned int reply; const char *errname, *errmsg; if (!eldbus_message_error_get(msg, &errname, &errmsg)) { if (eldbus_message_arguments_get(msg, "u", &reply)) { if (reply == ELDBUS_NAME_REQUEST_REPLY_PRIMARY_OWNER) { is_register_service = EINA_TRUE; } } } } static const Eldbus_Method methods[] = { { "Ping", NULL, NULL, NULL, 0 }, { "GetMachineId", NULL, ELDBUS_ARGS({"s", "machine_id"}), NULL, 0 }, { } }; static const Eldbus_Service_Interface_Desc iface_desc = { "org.freedesktop.DBus.Peer", methods, NULL }; static void _peer_ping_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) { int *user_data = data; if (user_data && (*user_data == cb_data)) { if (!eldbus_message_error_get(msg, NULL, NULL)) { is_peer_ping = EINA_TRUE; } } } static void _machine_id_get(void *data, const Eldbus_Message *msg, Eldbus_Pending *pending EINA_UNUSED) { int *user_data = data; if (user_data && (*user_data == cb_data)) { if (!eldbus_message_error_get(msg, NULL, NULL)) { char *txt; if (eldbus_message_arguments_get(msg, "s", &txt)) { if (txt && strcmp(txt, empty_string)) { is_success = EINA_TRUE; } } } } } /** * @addtogroup eldbus_object * @{ * @defgroup eldbus_object_send_info_get * @li eldbus_object_bus_name_get() * @li eldbus_object_connection_get() * @li eldbus_object_method_call_new() * @li eldbus_object_path_get() * @li eldbus_object_ref() * @li eldbus_object_send() * @li eldbus_object_get() * @{ * @objective Positive test case checks if functions get expected bus name, * get Eldbus_Connection expected associated with Eldbus_Object object, * get expected path associated with object, * create message object and send a message to DBus service, * increase object reference. Without segmentation fault. * * @n Input Data: * @li the conn object connection with bus * @li the obj Eldbus_Object object of the given bus and path. * * @procedure * @step 1 Call eldbus_connection_get function to get connection object. * @step 2 Check returned connection object on NULL. * @step 3 Call eldbus_object_get get an object of the given bus and path. * @step 4 Check returned object on NULL. * @step 5 Call eldbus_object_bus_name_get function to get valid string and check on expected string. * @step 6 Call eldbus_object_path_get function to get valid string and check on expected string. * @step 7 Call eldbus_object_ref function to increase object reference. * @step 8 Check two objects on the same address. * @step 9 Call eldbus_object_unref function to decrease object reference. * @step 10 Call eldbus_object_method_call_new function to call a dbus method on the object. * @step 11 Check returned message object on NULL. * @step 12 Call eldbus_object_send function to send a message. * @step 13 Check returned pending object on NULL. * @step 14 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 15 Start of main loop and wait for tested response in callback executing. * @step 16 Check static variable named is_success. * If is equal EINA_TRUE, that callback was executed and method send valid message response. * @step 17 Call eldbus_message_unref function to delete message object * @step 18 Call eldbus_object_unref function to delete connection dbus object * @step 19 Call eldbus_connection_unref function to delete connection object * * @passcondition Function should get valid expected object information about service. * Variables named is_success must equals EINA_TRUE. Without segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_object_send_info_get_p) { is_success = EINA_FALSE; Eldbus_Connection *conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); ck_assert_ptr_ne(NULL, conn); Eldbus_Object *obj = eldbus_object_get(conn, bus, path); ck_assert_ptr_ne(NULL, obj); const char *bus_from_object_ptr = eldbus_object_bus_name_get(obj); ck_assert_msg((strcmp(bus, bus_from_object_ptr) == 0), "'%s' != '%s'", bus, bus_from_object_ptr); const char *path_from_object_ptr = eldbus_object_path_get(obj); ck_assert_msg((strcmp(path, path_from_object_ptr) == 0), "'%s' != '%s'", path, path_from_object_ptr); Eldbus_Object *obj_ref = eldbus_object_ref(obj); ck_assert_ptr_eq(obj_ref, obj); eldbus_object_unref(obj_ref); Eldbus_Connection *connection_obj = eldbus_object_connection_get(obj); ck_assert_ptr_eq(connection_obj, conn); Eldbus_Message *msg = eldbus_object_method_call_new(obj, interface, method_name); ck_assert_ptr_ne(NULL, msg); Eldbus_Pending *pending = eldbus_object_send(obj, msg, _object_message_cb, &cb_data, -1); ck_assert_ptr_ne(NULL, pending); timeout = ecore_timer_add(1.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); ck_assert_msg(is_success, "Method %s is not call", method_name); - eldbus_message_unref(msg); - eldbus_object_unref(obj); eldbus_connection_unref(conn); } EFL_END_TEST /** * @addtogroup eldbus_object * @{ * @defgroup eldbus_introspect eldbus_object_introspect() * @{ * @objective Positive test case checks if function call the method "Introspect" * on the eldbus object and get valid response in callback function. Without segmentation fault. * * @n Input Data: * @li the conn object connection with bus * @li the obj Eldbus_Object object of the given bus and path. * * @procedure * @step 1 Call eldbus_connection_get function to get connection object. * @step 2 Check returned connection object on NULL. * @step 3 Call eldbus_object_get to get an object of the given bus and path. * @step 4 Check returned object on NULL. * @step 5 Call eldbus_object_introspect functiont to call the method "Introspect" on the eldbus object. * @step 6 Check returned pending object on NULL. * @step 7 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 8 Start of main loop and wait for tested response in callback executing. * @step 9 Check static variable named is_success. * If is equal EINA_TRUE, that callback was executed and method send valid message response. * @step 10 Call eldbus_object_unref function to delete connection dbus object. * @step 11 Call eldbus_connection_unref function to delete connection object. * * @passcondition Variables named is_success must equals EINA_TRUE, and there is no segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_introspect_p) { is_success = EINA_FALSE; Eldbus_Connection *conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); ck_assert_ptr_ne(NULL, conn); Eldbus_Object *obj = eldbus_object_get(conn, bus, path); ck_assert_ptr_ne(NULL, obj); Eldbus_Pending *pending = eldbus_object_introspect(obj, _object_message_cb, &cb_data); ck_assert_ptr_ne(NULL, pending); timeout = ecore_timer_add(1.0, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); ck_assert_msg(is_success, "Method Introspect is not call"); eldbus_object_unref(obj); eldbus_connection_unref(conn); } EFL_END_TEST /** * @addtogroup eldbus_object * @{ * @defgroup eldbus_object_peer * @li eldbus_object_peer_ping() * @li eldbus_object_peer_machine_id_get() * @li eldbus_object_get() * @{ * @objective Positive test case checks if function call the method "Ping", * "GetMachineId" and get expected response without error. Without segmentation fault. * * @n Input Data: * @li the conn_server object connection to server * @li the conn_client object connection to client * @li the iface object register an interface * * @procedure * @step 1 Call eldbus_connection_get function to get server connection object. * @step 2 Check returned connection object on NULL. * @step 3 Call eldbus_service_interface_register function to register an interface. * in the given path and connection. * @step 4 Check returned interface object on NULL. * @step 5 Call eldbus_name_request function to send a "RequestName" method call in proxy. * @step 6 Check returned pending object on NULL. * @step 7 Call eldbus_connection_get function to get client connection object. * @step 8 Check returned connection object on NULL. * @step 9 Call eldbus_object_get function to get an client object * of the given bus and path. * @step 10 Check returned object on NULL. * @step 11 Call eldbus_object_peer_machine_id_get function to call the * method "GetMachineId" on the dbus object. * @step 12 Check returned pending object on NULL. * @step 13 Call eldbus_object_peer_ping function to call the * method "Ping" on the dbus object. * @step 14 Check returned pending object on NULL. * @step 15 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 16 Start of main loop and wait for tested response in callback executing. * @step 17 Check static variables named is_success, is_register_service, is_peer_ping. * If are equals 1, that callbacks were executed and methods send valid message response. * In other cases error. * @step 18 Call eldbus_object_unref function to delete connection dbus object. * @step 19 Call eldbus_connection_unref function to delete client connection object. * @step 20 Call eldbus_service_interface_unregister function to unregister a interface. * @step 21 Call eldbus_connection_unref function to delete server connection object * * @passcondition Variables named is_success_cb, is_register_service, is_peer_ping must equals 1, and there is no segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_object_peer_p) { const char *dbus_path = "/org/freedesktop/Test"; const char *bus_session = "org.freedesktop.Test"; is_success = EINA_FALSE; is_register_service = EINA_FALSE; is_peer_ping = EINA_FALSE; Eldbus_Connection *conn_server = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); ck_assert_ptr_ne(NULL, conn_server); Eldbus_Service_Interface *iface = eldbus_service_interface_register(conn_server, dbus_path, &iface_desc); ck_assert_ptr_ne(NULL, iface); Eldbus_Pending *pending_name = eldbus_name_request(conn_server, bus_session, ELDBUS_NAME_REQUEST_FLAG_DO_NOT_QUEUE, _name_request, iface); ck_assert_ptr_ne(NULL, pending_name); Eldbus_Connection *conn_client = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION); ck_assert_ptr_ne(NULL, conn_client); Eldbus_Object *obj = eldbus_object_get(conn_client, bus_session, dbus_path); ck_assert_ptr_ne(NULL, obj); Eldbus_Pending *pending1 = eldbus_object_peer_machine_id_get(obj, _machine_id_get, &cb_data); ck_assert_ptr_ne(NULL, pending1); Eldbus_Pending *pending2 = eldbus_object_peer_ping(obj, _peer_ping_cb, &cb_data); ck_assert_ptr_ne(NULL, pending2); timeout = ecore_timer_add(2.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); ck_assert_msg(is_register_service, "Can not register interface"); ck_assert_msg(is_peer_ping, "Method Ping is not call"); ck_assert_msg(is_success, "Method GetMachineId is not call"); eldbus_object_unref(obj); eldbus_connection_unref(conn_client); eldbus_service_interface_unregister(iface); eldbus_connection_unref(conn_server); } EFL_END_TEST /** *@} */ void eldbus_test_eldbus_object(TCase *tc) { tcase_add_test(tc, utc_eldbus_object_send_info_get_p); tcase_add_test(tc, utc_eldbus_introspect_p); tcase_add_test(tc, utc_eldbus_object_peer_p); } diff --git a/src/tests/eldbus/eldbus_test_eldbus_pending_cancel.c b/src/tests/eldbus/eldbus_test_eldbus_pending_cancel.c index 899c01799c..64cf15cc18 100644 --- a/src/tests/eldbus/eldbus_test_eldbus_pending_cancel.c +++ b/src/tests/eldbus/eldbus_test_eldbus_pending_cancel.c @@ -1,191 +1,186 @@ #include #include #include #include #include #include "eldbus_suite.h" static Eina_Bool is_success_cb = EINA_FALSE; static Ecore_Timer *timeout = NULL; static Eldbus_Connection *conn = NULL; static Eldbus_Object *obj = NULL; static Eldbus_Message *message = NULL; const char *bus = "org.freedesktop.DBus"; const char *path = "/org/freedesktop/DBus"; const char *interface = "org.freedesktop.DBus"; const char *member = "GetId"; /** * @addtogroup eldbus * @{ * @defgroup eldbus_pending_info_get_cancel * @li eldbus_pending_cancel() * @li eldbus_pending_destination_get() * @li eldbus_pending_interface_get() * @li eldbus_pending_method_get() * @li eldbus_pending_path_get() * * @precondition * @step 1 Initialize eldbus with eldbus_init() */ static Eina_Bool _ecore_loop_close(void *data EINA_UNUSED) { ecore_main_loop_quit(); return ECORE_CALLBACK_CANCEL; } static void _response_message_cb(void *data EINA_UNUSED, const Eldbus_Message *msg, Eldbus_Pending *pending) { if (timeout != NULL) { ecore_timer_del(timeout); timeout = NULL; } if (!pending) { ecore_main_loop_quit(); return; } const char *pending_path = eldbus_pending_path_get(pending); if ((!pending_path) || (strcmp(pending_path, path))) { ecore_main_loop_quit(); return; } const char *pending_method = eldbus_pending_method_get(pending); if ((!pending_method) || (strcmp(pending_method, member))) { ecore_main_loop_quit(); return; } const char *pending_interface = eldbus_pending_interface_get(pending); if ((!pending_interface) || (strcmp(pending_interface, interface))) { ecore_main_loop_quit(); return; } const char *pending_destination = eldbus_pending_destination_get(pending); if ((!pending_destination) || (strcmp(pending_destination, bus))) { ecore_main_loop_quit(); return; } const char *errname, *errmsg; if (eldbus_message_error_get(msg, &errname, &errmsg)) { is_success_cb = EINA_TRUE; } ecore_main_loop_quit(); } static Eldbus_Pending * _pending_connection_get() { const int send_timeout_ms = 500; conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); if (!conn) { return NULL; } obj = eldbus_object_get(conn, bus, path); if (!obj) { eldbus_connection_unref(conn); return NULL; } message = eldbus_object_method_call_new(obj, interface, member); if (!message) { - eldbus_object_unref(obj); eldbus_connection_unref(conn); return NULL; } Eldbus_Pending *pending = eldbus_connection_send(conn, message, _response_message_cb, NULL, send_timeout_ms); if (!pending) { - eldbus_message_unref(message); - eldbus_object_unref(obj); eldbus_connection_unref(conn); return NULL; } return pending; } /** * @addtogroup eldbus_pending_info_get_cancel * @{ * @objective Positive test case checks if pending connection object canceled success. * If functions eldbus_pending_cancel() eldbus_pending_destination_get() * eldbus_pending_interface_get() eldbus_pending_method_get() eldbus_pending_path_get() * returned expected values * * @n Input Data: * @li the pending connection object * @li callback function to be called * @li the bus name of bus who listens * @li the path Dbus object path * @li the interface Dbus interface name * @li the member name of the method to be called. * * @procedure * @step 1 Get pendindig connection object and check on NULL * @step 2 Call eldbus_pending_cancel to cancel the pending message * @step 3 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 4 Start of main loop and wait for tested response in callback executing. * @step 5 Check static variable named is_success_cb. * If are equals 1, that pending message was canceled and pending object * returned expeted information about connection services. In other cases error. * @step 6 Call eldbus_message_unref function to delete message object * @step 7 Call eldbus_object_unref function to delete connection dbus object * @step 8 Call eldbus_connection_unref function to delete connection object * * @passcondition Variables named is_success_cb must equals 1, and there is no segmentation fault. * @} */ EFL_START_TEST(utc_eldbus_pending_info_get_cancel_p) { Eldbus_Pending *pending = _pending_connection_get(); ck_assert_ptr_ne(NULL, pending); eldbus_pending_cancel(pending); timeout = ecore_timer_add(1.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); ck_assert(is_success_cb == EINA_TRUE); - eldbus_message_unref(message); - eldbus_object_unref(obj); eldbus_connection_unref(conn); } EFL_END_TEST void eldbus_test_eldbus_pending_cancel(TCase *tc) { tcase_add_test(tc, utc_eldbus_pending_info_get_cancel_p); } diff --git a/src/tests/eldbus/eldbus_test_eldbus_signal_handler.c b/src/tests/eldbus/eldbus_test_eldbus_signal_handler.c index 2b5a394197..54a1e8cf34 100644 --- a/src/tests/eldbus/eldbus_test_eldbus_signal_handler.c +++ b/src/tests/eldbus/eldbus_test_eldbus_signal_handler.c @@ -1,465 +1,461 @@ #include #include #include #include #include #include "eldbus_suite.h" static const char *bus = "org.freedesktop.DBus"; static const char *path = "/org/freedesktop/DBus"; static const char *interface = "org.freedesktop.DBus"; static const char *signal_name = "NameOwnerChanged"; static int cb_data = 5; static Eina_Bool is_success_cb = EINA_FALSE; static Ecore_Timer *timeout = NULL; /** * @addtogroup eldbus * @{ * @defgroup eldbus_signal_handler * * @precondition * @step 1 Initialize eldbus with eldbus_init() */ static Eina_Bool _ecore_loop_close(void *data EINA_UNUSED) { ecore_main_loop_quit(); return ECORE_CALLBACK_CANCEL; } static void _signal_name_owner_changed(void *data, const Eldbus_Message *msg) { const char *errname, *errmsg; int *user_data = data; if (timeout != NULL) { ecore_timer_del(timeout); timeout = NULL; } if ((user_data) && (*user_data == cb_data)) { if (!eldbus_message_error_get(msg, &errname, &errmsg)) { is_success_cb = EINA_TRUE; } } ecore_main_loop_quit(); } static void _response_message_cb(void *data EINA_UNUSED, const Eldbus_Message *msg EINA_UNUSED, Eldbus_Pending *pending EINA_UNUSED) { } static void _signal_handler_free_cb(void *data, const void *deadptr EINA_UNUSED) { int *user_data = data; if (timeout != NULL) { ecore_timer_del(timeout); timeout = NULL; } if ((user_data) && (*user_data == cb_data)) is_success_cb = EINA_TRUE; ecore_main_loop_quit(); } static Eldbus_Signal_Handler * _signal_handler_get(Eldbus_Connection *conn) { is_success_cb = EINA_FALSE; Eldbus_Signal_Handler *signal_handler = eldbus_signal_handler_add(conn, NULL, path, interface, signal_name, _signal_name_owner_changed, &cb_data); if (!signal_handler) { return NULL; } timeout = ecore_timer_add(1.5, _ecore_loop_close, NULL); if (!timeout) { eldbus_signal_handler_unref(signal_handler); return NULL; } return signal_handler; } /** * @addtogroup eldbus_signal_handler * @{ * @defgroup eldbus_signal_handler_add eldbus_signal_handler_add() * @{ * @objective Positive test case checks that function add a signal handler without error. * * @n Input Data: * @li the conn connection object * @li the msg message connection object * @li callback function to be called * @li data passed to callback * * @procedure * @step 1 Get eldbus connection object and check on NULL * @step 2 Call eldbus_signal_handler_add with callback function and data * to be called when this signal is received. * @step 3 Check returned signal handler object on NULL. * @step 4 Call eldbus_message_signal_new to create a new signal message. * @step 5 Check returned message object on NULL. * @step 6 Call eldbus_connection_send to send a signal a dbus object. * @step 7 Check returned pending object on NULL. * @step 8 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 9 Start of main loop and wait for tested response in callback executing. * @step 10 Check static variables named is_success_cb. * If are equals 1, that callback was executed and signal is received without error. * In other cases error. * @step 11 Call eldbus_message_unref function to delete message object * @step 12 Call eldbus_signal_handler_unref function to delete signal handler object * @step 13 Call eldbus_connection_unref function to delete connection object * * @passcondition Variables named is_success_cb must equals 1, and there is no segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_signal_handler_add_p) { is_success_cb = EINA_FALSE; Eldbus_Connection *conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); ck_assert_ptr_ne(NULL, conn); Eldbus_Signal_Handler *signal_handler = eldbus_signal_handler_add(conn, NULL, path, interface, signal_name, _signal_name_owner_changed, &cb_data); ck_assert_ptr_ne(NULL, signal_handler); Eldbus_Message *msg = eldbus_message_signal_new(path, interface, signal_name); ck_assert_ptr_ne(NULL, signal_handler); Eldbus_Pending *pending = eldbus_connection_send(conn, msg, _response_message_cb, NULL, -1); ck_assert_ptr_ne(NULL, pending); timeout = ecore_timer_add(1.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); ck_assert_msg(is_success_cb, "Signal %s is not call", signal_name); - eldbus_message_unref(msg); eldbus_signal_handler_unref(signal_handler); eldbus_connection_unref(conn); } EFL_END_TEST /** * @addtogroup eldbus_signal_handler * @{ * @defgroup eldbus_signal_handler_del eldbus_signal_handler_del() * @{ * @objective Positive test case checks that function add and delete a signal handler without error. * * @n Input Data: * @li the conn connection object * @li the msg message connection object * @li callback function to be called * @li data passed to callback * * @procedure * @step 1 Get eldbus connection object and check on NULL * @step 2 Call eldbus_signal_handler_add with callback function and data * to be called when this signal is received. * @step 3 Check returned signal handler object on NULL. * @step 4 Call eldbus_signal_handler_del the signal handler will stop listening to signals. * @step 5 Call eldbus_message_signal_new to create a new signal message. * @step 6 Check returned message object on NULL. * @step 7 Call eldbus_connection_send to send a signal a dbus object. * @step 8 Check returned pending object on NULL. * @step 9 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 10 Start of main loop and wait for tested response in callback executing. * @step 11 Check static variables named is_success_cb. * If is equal 1, that callback was executed and this is error. * @step 12 Call eldbus_message_unref function to delete message object * @step 13 Call eldbus_signal_handler_unref function to delete signal handler object * @step 14 Call eldbus_connection_unref function to delete connection object * * @passcondition Variables named is_success_cb must equals 0 * and eldbus_signal_handler_del must be delete registered callback, and there is no segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_signal_handler_del_p) { is_success_cb = EINA_FALSE; Eldbus_Connection *conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); ck_assert_ptr_ne(NULL, conn); Eldbus_Signal_Handler *signal_handler = eldbus_signal_handler_add(conn, NULL, path, interface, signal_name, _signal_name_owner_changed, &cb_data); ck_assert_ptr_ne(NULL, signal_handler); eldbus_signal_handler_del(signal_handler); Eldbus_Message *msg = eldbus_message_signal_new(path, interface, signal_name); ck_assert_ptr_ne(NULL, msg); Eldbus_Pending *pending = eldbus_connection_send(conn, msg, _response_message_cb, NULL, -1); ck_assert_ptr_ne(NULL, pending); timeout = ecore_timer_add(1.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); ck_assert_msg(!is_success_cb, "Signal %s was called", signal_name); - eldbus_message_unref(msg); - eldbus_signal_handler_unref(signal_handler); eldbus_connection_unref(conn); } EFL_END_TEST /** * @addtogroup eldbus_signal_handler * @{ * @defgroup eldbus_signal_handler_get * @li eldbus_signal_handler_connection_get() * @li eldbus_signal_handler_interface_get() * @li eldbus_signal_handler_member_get() * @li eldbus_signal_handler_path_get() * @li eldbus_signal_handler_sender_get() * @{ * @objective Positive test case checks those functions return valid expected value. * * @n Input Data: * @li the conn connection object * @li the path to bus interface * @li the sender bus name * @li the interface bus interface * @li the signal_name bus signal name * * @procedure * @step 1 Get eldbus connection object and check on NULL * @step 2 Call eldbus_signal_handler_add with callback function and data * to be called when this signal is received. * @step 3 Check returned signal handler object on NULL. * @step 4 Call eldbus_signal_handler_connection_get and check on expected value. * @step 5 Call eldbus_signal_handler_path_get and check on expected value. * @step 6 Call eldbus_signal_handler_sender_get and check on expected value. * @step 7 Call eldbus_signal_handler_interface_get and check on expected value. * @step 8 Call eldbus_signal_handler_member_get and check on expected value. * @step 9 Call eldbus_connection_unref function to delete signal handler object * @step 10 Call eldbus_connection_unref function to delete connection object * * @passcondition Functions should returns valid expected value and without segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_signal_handler_get_p) { Eldbus_Connection *conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); ck_assert_ptr_ne(NULL, conn); Eldbus_Signal_Handler *signal_handler = eldbus_signal_handler_add(conn, bus, path, interface, signal_name, _signal_name_owner_changed, &cb_data); ck_assert_ptr_ne(NULL, signal_handler); Eldbus_Connection *conn_get = eldbus_signal_handler_connection_get(signal_handler); ck_assert_msg((conn_get == conn), "Connection objects are different"); const char *signal_path = eldbus_signal_handler_path_get(signal_handler); ck_assert_msg(NULL != signal_path, "Signal path is null"); ck_assert_msg((!strcmp(signal_path, path)), "Signal path is different than original"); const char *signal_sender = eldbus_signal_handler_sender_get(signal_handler); ck_assert_msg(NULL != signal_sender, "Signal sender is null"); ck_assert_msg((!strcmp(signal_sender, bus)), "Signal sender is different than original"); const char *signal_interface = eldbus_signal_handler_interface_get(signal_handler); ck_assert_msg(NULL != signal_interface, "Signal interface is null"); ck_assert_msg((!strcmp(signal_interface, interface)), "Signal interface is different than original"); const char *signal_handler_name = eldbus_signal_handler_member_get(signal_handler); ck_assert_msg(NULL != signal_handler_name, "Signal name is null"); ck_assert_msg((!strcmp(signal_handler_name, signal_name)), "Signal name is different than original"); eldbus_signal_handler_unref(signal_handler); eldbus_connection_unref(conn); } EFL_END_TEST /** * @addtogroup eldbus_signal_handler * @{ * @defgroup eldbus_signal_handler_ref_unref * @li eldbus_signal_handler_ref() * @li eldbus_signal_handler_unref() * @{ * @objective Positive test case checks that function increase, Decrease signal handler reference without error. * * @n Input Data: * @li the conn connection object * @li the signal_handler signal handler object * * @procedure * @step 1 Get eldbus connection object and check on NULL * @step 2 Call eldbus_signal_handler_add with callback function and data * to be called when this signal is received. * @step 3 Check returned signal handler object on NULL. * @step 4 Call eldbus_signal_handler_ref the increase signal handler reference. * @step 5 Check returned signal ref handler object with original signal handler object. * @step 6 Call eldbus_signal_handler_unref function decrease reference signal handler reference * @step 7 Call eldbus_signal_handler_unref function decrease original signal handler reference * @step 8 Call eldbus_message_signal_new to create a new signal message. * @step 9 Check returned message object on NULL. * @step 10 Call eldbus_connection_send to send a signal a dbus object. * @step 11 Check returned pending object on NULL. * @step 12 Set timer for preschedule termination of main loop if tested callback wasn't executed. * @step 13 Start of main loop and wait for tested response in callback executing. * @step 14 Check static variables named is_success_cb. * If is equal 1, that callback was executed and this is error. * @step 15 Call eldbus_message_unref function to delete message object * @step 16 Call eldbus_connection_unref function to delete connection object * * @passcondition Variables named is_success_cb must equals 0 * and eldbus_signal_handler_unref must be decrease signal handler reference, and there is no segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_signal_handler_ref_unref_p) { is_success_cb = EINA_FALSE; Eldbus_Connection *conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); ck_assert_ptr_ne(NULL, conn); Eldbus_Signal_Handler *signal_handler = eldbus_signal_handler_add(conn, NULL, path, interface, signal_name, _signal_name_owner_changed, &cb_data); ck_assert_ptr_ne(NULL, signal_handler); Eldbus_Signal_Handler* signal_ref = eldbus_signal_handler_ref(signal_handler); ck_assert_msg((signal_ref == signal_handler), "Signal references are different"); eldbus_signal_handler_unref(signal_ref); eldbus_signal_handler_unref(signal_handler); Eldbus_Message *msg = eldbus_message_signal_new(path, interface, signal_name); ck_assert_ptr_ne(NULL, msg); Eldbus_Pending *pending = eldbus_connection_send(conn, msg, _response_message_cb, NULL, -1); ck_assert_ptr_ne(NULL, pending); timeout = ecore_timer_add(1.5, _ecore_loop_close, NULL); ck_assert_ptr_ne(NULL, timeout); ecore_main_loop_begin(); ck_assert_msg(!is_success_cb, "Signal %s was called", signal_name); - eldbus_message_unref(msg); eldbus_connection_unref(conn); } EFL_END_TEST /** * @addtogroup eldbus_signal_handler * @{ * @defgroup eldbus_signal_handler_free_cb * @li eldbus_signal_handler_free_cb_add() * @li eldbus_signal_handler_free_cb_del() * @{ * @objective Positive test case checks that function add and delete a callback function without error. * * @n Input Data: * @li the conn connection object * @li the signal_handler signal handler object * * @procedure * @step 1 Get eldbus connection object and check on NULL * @step 2 Get signal handler object and check on NULL. * @step 3 Call eldbus_signal_handler_free_cb_add to add a callback function * to be called when signal handler will be freed. * @step 4 Call eldbus_signal_handler_unref function decrease reference signal handler reference * @step 5 Start of main loop and wait for tested response in callback executing. * @step 6 Check static variables named is_success_cb. * If is equal 1, that callback was executed ignal handler was freed is received without error. * @step 7 Get signal handler object and check on NULL. * @step 8 Call eldbus_signal_handler_free_cb_add to add a callback function * to be called when signal handler will be freed. * @step 9 Call eldbus_signal_handler_free_cb_del to remove callback registered * in eldbus_signal_handler_free_cb_add(). * @step 10 Call eldbus_signal_handler_unref function decrease reference signal handler reference * @step 11 Check static variables named is_success_cb. * If is equal 1, that callback was executed and this is error. * @step 12 Call eldbus_connection_unref function to delete connection object * * @passcondition The function should add and delete registered callback function, * and there is no segmentation fault. * @} * @} */ EFL_START_TEST(utc_eldbus_signal_handler_free_cb_add_del_p) { Eldbus_Connection *conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SYSTEM); ck_assert_ptr_ne(NULL, conn); Eldbus_Signal_Handler *signal_handler = _signal_handler_get(conn); ck_assert_ptr_ne(NULL, signal_handler); eldbus_signal_handler_free_cb_add(signal_handler, _signal_handler_free_cb, &cb_data); eldbus_signal_handler_unref(signal_handler); ecore_main_loop_begin(); ck_assert_msg(is_success_cb, "Callback is not called"); signal_handler = _signal_handler_get(conn); ck_assert_ptr_ne(NULL, signal_handler); eldbus_signal_handler_free_cb_add(signal_handler, _signal_handler_free_cb, &cb_data); eldbus_signal_handler_free_cb_del(signal_handler, _signal_handler_free_cb, &cb_data); eldbus_signal_handler_unref(signal_handler); ecore_main_loop_begin(); ck_assert_msg(!is_success_cb, "Callback was called"); eldbus_connection_unref(conn); } EFL_END_TEST /** *@} */ void eldbus_test_eldbus_signal_handler(TCase *tc) { tcase_add_test(tc, utc_eldbus_signal_handler_add_p); tcase_add_test(tc, utc_eldbus_signal_handler_del_p); tcase_add_test(tc, utc_eldbus_signal_handler_get_p); tcase_add_test(tc, utc_eldbus_signal_handler_ref_unref_p); tcase_add_test(tc, utc_eldbus_signal_handler_free_cb_add_del_p); }