From: Konstantin Drabeniuk Date: Thu, 8 Sep 2016 11:44:15 +0000 (+0300) Subject: [libeom] Move unit tests from ws-testcase and change test framework X-Git-Tag: accepted/tizen/3.0/ivi/20161011.044326~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bdc1dd198fdd9791419af3c798b2f83ee7340bb6;p=platform%2Fcore%2Fuifw%2Flibeom.git [libeom] Move unit tests from ws-testcase and change test framework 1) change unit testing framework (Check to gtest); 2) move unit test from the ws-testcase project to the project libeom; Change-Id: Ic96d969bd3e5433e88547e18acf94ab0a01c5192 Signed-off-by: Konstantin Drabeniuk --- diff --git a/Makefile.am b/Makefile.am index c7596e5..c2108dc 100755 --- a/Makefile.am +++ b/Makefile.am @@ -24,5 +24,9 @@ # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +if HAVE_UTEST +SUBDIRS = include src ut +else SUBDIRS = include src +endif diff --git a/configure.ac b/configure.ac index 6445313..71c95ec 100755 --- a/configure.ac +++ b/configure.ac @@ -42,6 +42,7 @@ AH_BOTTOM([ AC_DISABLE_STATIC AC_PROG_LIBTOOL AC_PROG_CC +AC_PROG_CXX AC_HEADER_STDC AC_SYS_LARGEFILE @@ -62,7 +63,11 @@ AC_ARG_WITH(tizen-version, AS_HELP_STRING([--with-tizen-version=T_VERSION], [eom [ TIZEN_VERSION="TIZEN_2_X" ]) AC_SUBST(TIZEN_VERSION) +AC_ARG_WITH(utest, AS_HELP_STRING([--with-utest=yes/no], [whether build/run unit tests or not]), + [ utest="$withval" ], + [ utest="no" ]) +AM_CONDITIONAL(HAVE_UTEST, test "x$utest" = "xyes") # Checks for pkg-config packages PKG_CHECK_MODULES(DBUS, dbus-1) @@ -136,7 +141,8 @@ AC_OUTPUT([Makefile src/Makefile include/Makefile include/eom.pc - tests/Makefile]) + tests/Makefile + ut/Makefile]) echo "CFLAGS : $CFLAGS" echo "LDFLAGS : $LDFLAGS" diff --git a/packaging/libeom.spec b/packaging/libeom.spec index ec749b3..3cb819a 100644 --- a/packaging/libeom.spec +++ b/packaging/libeom.spec @@ -1,5 +1,6 @@ %bcond_with x %bcond_with wayland +%bcond_with utest Name: libeom Summary: External Output Manager Library @@ -23,6 +24,10 @@ BuildRequires: pkgconfig(gio-unix-2.0) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(elementary) +%if %{with utest} +BuildRequires: gtest-devel +%endif + %description This package provides the runtime library to manage eo(External Output) @@ -44,18 +49,28 @@ cp %{SOURCE1001} . %build export CFLAGS="-g -O0 -Wall -Werror -Wno-error=deprecated-declarations" export LDFLAGS="$LDFLAGS -Wl,--hash-style=both -Wl,--as-needed" +UTEST="no" + +%if %{with utest} +UTEST="yes" +%endif + %if %{with wayland} -%reconfigure --disable-dlog --disable-static --with-eom-platform=WAYLAND +%reconfigure --disable-dlog --disable-static --with-eom-platform=WAYLAND --with-utest=${UTEST} %else %if 0%{?tizen_version_major} == 2 -%reconfigure --disable-dlog --disable-static --with-eom-platform=X11 --with-tizen-version=TIZEN_2_X +%reconfigure --disable-dlog --disable-static --with-eom-platform=X11 --with-tizen-version=TIZEN_2_X --with-utest=${UTEST} %else -%reconfigure --disable-dlog --disable-static --with-eom-platform=X11 --with-tizen-version=TIZEN_3_X +%reconfigure --disable-dlog --disable-static --with-eom-platform=X11 --with-tizen-version=TIZEN_3_X --with-utest=${UTEST} %endif %endif make %{?_smp_mflags} +%if %{with utest} +make -C ut check +%endif + %install rm -rf %{buildroot} mkdir -p %{buildroot}/%{TZ_SYS_RO_SHARE}/license @@ -69,6 +84,9 @@ cp -af COPYING %{buildroot}/%{TZ_SYS_RO_SHARE}/license/%{name} %defattr(-,root,root,-) %{TZ_SYS_RO_SHARE}/license/%{name} %{_libdir}/libeom.so.* +%if %{with utest} +%{_bindir}/ut +%endif %files devel %manifest %{name}.manifest diff --git a/ut/Makefile.am b/ut/Makefile.am new file mode 100644 index 0000000..cab8a98 --- /dev/null +++ b/ut/Makefile.am @@ -0,0 +1,25 @@ +bin_PROGRAMS = ut + +ut_SOURCES = \ + main_tests.cpp \ + ut_eom.cpp \ + stubs/eom_wayland.cpp + +ut_CXXFLAGS = \ + ${CXXFLAGS} \ + @LIBEOM_CFLAGS@ \ + -I./stubs \ + -I../src \ + -I../src/dbus \ + -I../src/wayland \ + -I../include \ + -fpermissive + +ut_LDFLAGS = \ + ${LDFLAGS} \ + @LIBEOM_LIBS@ \ + -lgtest \ + -pthread + +check: + ./ut diff --git a/ut/main_tests.cpp b/ut/main_tests.cpp new file mode 100644 index 0000000..168b134 --- /dev/null +++ b/ut/main_tests.cpp @@ -0,0 +1,40 @@ +/************************************************************************** + * + * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: + * Konstantin Drabeniuk + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * +**************************************************************************/ + +#include +#include +#include + +#include "gtest/gtest.h" + +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/ut/stubs/eom_wayland.cpp b/ut/stubs/eom_wayland.cpp new file mode 100644 index 0000000..48c0cbf --- /dev/null +++ b/ut/stubs/eom_wayland.cpp @@ -0,0 +1,137 @@ +/************************************************************************** + * + * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: + * Konstantin Drabeniuk + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * +**************************************************************************/ + +#include "eom-wayland.h" +#include + +int EOM_WAYLEND_ERROR; +int EOM_WAYLEND_RET_ERROR; +int EOM_WAYLAND_CLIENT_INIT_ERROR; + +GValue value[10]; + +bool eom_wayland_client_init(notify_func func) +{ + if (EOM_WAYLAND_CLIENT_INIT_ERROR) { + return false; + } + + return true; +} + +void eom_wayland_client_deinit(GList *cb_info_list) +{ +} + +GArray *eom_wayland_client_get_output_ids(void) +{ + if (EOM_WAYLEND_ERROR) { + return NULL; + } + + memset(value, 0, 10 * sizeof(GValue)); + GArray *ret_array = g_array_new(false, false, sizeof(GValue)); + g_value_init(&value[0], G_TYPE_INT); + g_value_init(&value[1], G_TYPE_INT); + if (EOM_WAYLEND_RET_ERROR) { + g_value_set_int(&value[0], 0); + ret_array->len = 0; + } else { + g_value_set_int(&value[0], 1); + g_value_set_int(&value[1], 2); + ret_array->len = 2; + } + ret_array->data = (gchar *)&value; + return ret_array; +} + +GArray *eom_wayland_client_get_output_info(eom_output_id output_id) +{ + memset(value, 0, 10 * sizeof(GValue)); + GArray *ret_array = g_array_new(false, false, sizeof(GValue)); + g_value_init(&value[0], G_TYPE_INT); + g_value_init(&value[1], G_TYPE_INT); + g_value_init(&value[2], G_TYPE_INT); + g_value_init(&value[3], G_TYPE_INT); + g_value_init(&value[4], G_TYPE_INT); + g_value_init(&value[5], G_TYPE_INT); + g_value_init(&value[6], G_TYPE_INT); + g_value_init(&value[7], G_TYPE_INT); + g_value_set_int(&value[0], 1); + g_value_set_int(&value[1], 2); + g_value_set_int(&value[2], 3); + g_value_set_int(&value[3], 4); + g_value_set_int(&value[4], 5); + g_value_set_int(&value[5], 6); + g_value_set_int(&value[6], 7); + g_value_set_int(&value[7], 8); + ret_array->data = (gchar *)&value; + ret_array->len = 8; + return ret_array; +} + +GArray *eom_wayland_client_set_attribute(eom_output_id output_id, + eom_output_attribute_e attry) +{ + if (EOM_WAYLEND_ERROR) { + return NULL; + } + + memset(value, 0, 10 * sizeof(GValue)); + GArray *ret_array = g_array_new(false, false, sizeof(GValue)); + g_value_init(&value[0], G_TYPE_INT); + g_value_init(&value[1], G_TYPE_INT); + if (EOM_WAYLEND_RET_ERROR) { + g_value_set_int(&value[0], 0); + } else { + g_value_set_int(&value[0], 1); + } + ret_array->data = (gchar *)&value; + return ret_array; +} + +GArray *eom_wayland_client_set_window(eom_output_id output_id, + Evas_Object *win) +{ + if (EOM_WAYLEND_ERROR) { + return NULL; + } + + memset(value, 0, 10 * sizeof(GValue)); + GArray *ret_array = g_array_new(false, false, sizeof(GValue)); + g_value_init(&value[0], G_TYPE_INT); + g_value_init(&value[1], G_TYPE_INT); + if (EOM_WAYLEND_RET_ERROR) { + g_value_set_int(&value[0], 0); + } else { + g_value_set_int(&value[0], 1); + } + ret_array->data = (gchar *)&value; + return ret_array; +} diff --git a/ut/stubs/pthread_stubs.h b/ut/stubs/pthread_stubs.h new file mode 100644 index 0000000..0fa4e83 --- /dev/null +++ b/ut/stubs/pthread_stubs.h @@ -0,0 +1,58 @@ +/************************************************************************** + * + * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: + * Konstantin Drabeniuk + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * +**************************************************************************/ + +#ifndef _PTHREAD_STUBS_H +#define _PTHREAD_STUBS_H + +#include +#include + +static int PTHREAD_MUTEX_INIT_ERROR; + +static int ut_pthread_mutex_lock(pthread_mutex_t * __mutex) +{ + +} + +static int ut_pthread_mutex_unlock(pthread_mutex_t * __mutex) +{ + +} + +static int ut_pthread_mutex_init(pthread_mutex_t * __mutex, + const pthread_mutexattr_t * __mutexattr) +{ + if (PTHREAD_MUTEX_INIT_ERROR) { + return PTHREAD_MUTEX_INIT_ERROR; + } + + return 0; +} + +#endif /* _PTHREAD_STUBS_H */ diff --git a/ut/stubs/stdlib_stubs.h b/ut/stubs/stdlib_stubs.h new file mode 100644 index 0000000..978823a --- /dev/null +++ b/ut/stubs/stdlib_stubs.h @@ -0,0 +1,63 @@ +/************************************************************************** + * + * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: + * Konstantin Drabeniuk + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * +**************************************************************************/ + +#ifndef _STDLIB_STUBS_H +#define _STDLIB_STUBS_H + +#include + +int CALLOC_ERROR; +int CALLOC_RETURN_BUFFER; +int FREE_CALLED; +void *FREE_PTR; +void *FREE_TESTED_PTR; +int free_called_for_tested_ptr = 0; +int free_call_count = 0; + +static void *ut_calloc(size_t nmemb, size_t size) +{ + if (CALLOC_ERROR) { + return NULL; + } + + return calloc(nmemb, size); +} + +static void ut_free(void *ptr) +{ + if (FREE_TESTED_PTR == ptr) { + free_called_for_tested_ptr = 1; + } + FREE_PTR = ptr; + FREE_CALLED = 1; + free(ptr); + free_call_count++; +} + +#endif /* _STDLIB_STUBS_H */ diff --git a/ut/ut_eom.cpp b/ut/ut_eom.cpp new file mode 100644 index 0000000..b2c81f6 --- /dev/null +++ b/ut/ut_eom.cpp @@ -0,0 +1,1562 @@ +/************************************************************************** + * + * Copyright 2016 Samsung Electronics co., Ltd. All Rights Reserved. + * + * Contact: + * Konstantin Drabeniuk + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * +**************************************************************************/ +#include "gtest/gtest.h" + +#include "pthread_stubs.h" +#include "stdlib_stubs.h" + +extern int EOM_WAYLEND_ERROR; +extern int EOM_WAYLEND_RET_ERROR; +extern int EOM_WAYLAND_CLIENT_INIT_ERROR; + +#define pthread_mutex_lock ut_pthread_mutex_lock +#define calloc ut_calloc +#define free ut_free +#define pthread_mutex_init ut_pthread_mutex_init +#define pthread_mutex_unlock ut_pthread_mutex_unlock + +#include "eom.c" + +/* HELPER FUNCTIONS */ + +void ut_eom_cb(eom_output_id output_id, void *user_data) {} + +void ut_eom_cb1(eom_output_id output_id, void *user_data) {} + +static void _init_test() +{ + EOM_WAYLEND_ERROR = 0; + EOM_WAYLEND_RET_ERROR = 0; + EOM_WAYLAND_CLIENT_INIT_ERROR = 0; + PTHREAD_MUTEX_INIT_ERROR = 0; + CALLOC_ERROR = 0; + CALLOC_RETURN_BUFFER = 0; + FREE_CALLED = 0; + FREE_PTR = NULL; + FREE_TESTED_PTR = NULL; + free_called_for_tested_ptr = 0; + free_call_count = 0; + output_info_list = NULL; + cb_info_list = NULL; + + set_last_result(EOM_ERROR_NONE); +} + +/* eom_set_output_window() */ + +TEST(eom_set_output_window, work_flow_success_5) +{ + eom_output_id output_id = 1; + eom_error_e error = EOM_ERROR_MESSAGE_OPERATION_FAILURE; + eom_error_e expected_error = EOM_ERROR_NONE; + Evas_Object *win = (Evas_Object *)25; + eom_output_info output_info; + GList list; + + _init_test(); + + output_info.id = output_id; + list.data = &output_info; + list.next = list.prev = NULL; + output_info_list = &list; + + error = eom_set_output_window(output_id, win); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_output_window, work_flow_success_4) +{ + eom_output_id output_id = 1; + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_MESSAGE_OPERATION_FAILURE; + Evas_Object *win = (Evas_Object *)25; + eom_output_info output_info; + GList list; + + _init_test(); + + output_info.id = output_id; + list.data = &output_info; + list.next = list.prev = NULL; + output_info_list = &list; + EOM_WAYLEND_RET_ERROR = 1; + + error = eom_set_output_window(output_id, win); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_output_window, work_flow_success_3) +{ + eom_output_id output_id = 1; + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_MESSAGE_SENDING_FAILURE; + Evas_Object *win = (Evas_Object *)25; + eom_output_info output_info; + GList list; + + _init_test(); + + output_info.id = output_id; + list.data = &output_info; + list.next = list.prev = NULL; + output_info_list = &list; + EOM_WAYLEND_ERROR = 1; + + error = eom_set_output_window(output_id, win); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_output_window, work_flow_success_2) +{ + eom_output_id output_id = 1; + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_NO_SUCH_DEVICE; + Evas_Object *win = (Evas_Object *)25; + + _init_test(); + + error = eom_set_output_window(output_id, win); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_output_window, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + Evas_Object *win = (Evas_Object *)25; + + _init_test(); + + error = eom_set_output_window(0, win); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_output_window, null_ptr_fail_1) +{ + eom_output_id output_id = 1; + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = eom_set_output_window(output_id, NULL); + + ASSERT_EQ(error, expected_error); +} + +/* eom_get_output_physical_size() */ + +TEST(eom_get_output_physical_size, work_flow_success_3) +{ + eom_output_id output_id = 1; + int last_result = EOM_ERROR_NONE; + eom_error_e error = EOM_ERROR_NO_SUCH_DEVICE; + eom_error_e expected_error = EOM_ERROR_NONE; + int phy_width = 0; + int phy_height = 0; + int expected_phy_width = 1024; + int expected_phy_height = 768; + eom_output_info output_info; + GList list; + + _init_test(); + + output_info.id = output_id; + output_info.mm_width = expected_phy_width; + output_info.mm_height = expected_phy_height; + list.data = &output_info; + list.next = list.prev = NULL; + output_info_list = &list; + + error = eom_get_output_physical_size(output_id, &phy_width, &phy_height); + + last_result = get_last_result(); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(last_result, expected_error); + ASSERT_EQ(phy_width, expected_phy_width); + ASSERT_EQ(phy_height, expected_phy_height); +} + +TEST(eom_get_output_physical_size, work_flow_success_2) +{ + eom_output_id output_id = 1; + int last_result = EOM_ERROR_NONE; + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_NO_SUCH_DEVICE; + + _init_test(); + + error = eom_get_output_physical_size(output_id, NULL, NULL); + + last_result = get_last_result(); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(last_result, expected_error); +} + +TEST(eom_get_output_physical_size, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = eom_get_output_physical_size(0, NULL, NULL); + + ASSERT_EQ(error, expected_error); +} + +/* eom_get_output_resolution() */ + +TEST(eom_get_output_resolution, work_flow_success_3) +{ + eom_output_id output_id = 1; + int last_result = EOM_ERROR_NONE; + eom_error_e error = EOM_ERROR_NO_SUCH_DEVICE; + eom_error_e expected_error = EOM_ERROR_NONE; + int width = 0; + int height = 0; + int expected_width = 1024; + int expected_height = 768; + eom_output_info output_info; + GList list; + + _init_test(); + + output_info.id = output_id; + output_info.width = expected_width; + output_info.height = expected_height; + list.data = &output_info; + list.next = list.prev = NULL; + output_info_list = &list; + + error = eom_get_output_resolution(output_id, &width, &height); + + last_result = get_last_result(); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(last_result, expected_error); + ASSERT_EQ(width, expected_width); + ASSERT_EQ(height, expected_height); +} + +TEST(eom_get_output_resolution, work_flow_success_2) +{ + eom_output_id output_id = 1; + int last_result = EOM_ERROR_NONE; + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_NO_SUCH_DEVICE; + + _init_test(); + + error = eom_get_output_resolution(output_id, NULL, NULL); + + last_result = get_last_result(); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(last_result, expected_error); +} + +TEST(eom_get_output_resolution, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = eom_get_output_resolution(0, NULL, NULL); + + ASSERT_EQ(error, expected_error); +} + +/* eom_get_output_attribute_state() */ + +TEST(eom_get_output_attribute_state, work_flow_success_3) +{ + eom_output_id output_id = 1; + int last_result = EOM_ERROR_NONE; + eom_error_e error = EOM_ERROR_NO_SUCH_DEVICE; + eom_error_e expected_error = EOM_ERROR_NONE; + eom_output_attribute_state_e state = EOM_OUTPUT_ATTRIBUTE_STATE_NONE; + eom_output_attribute_state_e expected_state = EOM_OUTPUT_ATTRIBUTE_STATE_ACTIVE; + eom_output_info output_info; + GList list; + + _init_test(); + + output_info.id = output_id; + output_info.state = expected_state; + list.data = &output_info; + list.next = list.prev = NULL; + output_info_list = &list; + + error = eom_get_output_attribute_state(output_id, &state); + + last_result = get_last_result(); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(last_result, expected_error); + ASSERT_EQ(state, expected_state); +} + +TEST(eom_get_output_attribute_state, work_flow_success_2) +{ + eom_output_id output_id = 1; + int last_result = EOM_ERROR_NONE; + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_NO_SUCH_DEVICE; + eom_output_attribute_state_e state; + + _init_test(); + + error = eom_get_output_attribute_state(output_id, &state); + + last_result = get_last_result(); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(last_result, expected_error); +} + +TEST(eom_get_output_attribute_state, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + eom_output_attribute_state_e state; + + _init_test(); + + error = eom_get_output_attribute_state(0, &state); + + ASSERT_EQ(error, expected_error); +} + +/* eom_get_output_attribute() */ + +TEST(eom_get_output_attribute, work_flow_success_3) +{ + eom_output_id output_id = 1; + int last_result = EOM_ERROR_NONE; + eom_error_e error = EOM_ERROR_NO_SUCH_DEVICE; + eom_error_e expected_error = EOM_ERROR_NONE; + eom_output_attribute_e attribute = EOM_OUTPUT_ATTRIBUTE_NONE; + eom_output_attribute_e expected_attribute = EOM_OUTPUT_ATTRIBUTE_NORMAL; + eom_output_info output_info; + GList list; + + _init_test(); + + output_info.id = output_id; + output_info.attribute = expected_attribute; + list.data = &output_info; + list.next = list.prev = NULL; + output_info_list = &list; + + error = eom_get_output_attribute(output_id, &attribute); + + last_result = get_last_result(); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(last_result, expected_error); + ASSERT_EQ(attribute, expected_attribute); +} + +TEST(eom_get_output_attribute, work_flow_success_2) +{ + eom_output_id output_id = 1; + int last_result = EOM_ERROR_NONE; + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_NO_SUCH_DEVICE; + eom_output_attribute_e attribute; + + _init_test(); + + error = eom_get_output_attribute(output_id, &attribute); + + last_result = get_last_result(); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(last_result, expected_error); +} + +TEST(eom_get_output_attribute, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + eom_output_attribute_e attribute; + + _init_test(); + + error = eom_get_output_attribute(0, &attribute); + + ASSERT_EQ(error, expected_error); +} + +/* eom_get_output_mode() */ + +TEST(eom_get_output_mode, work_flow_success_3) +{ + eom_output_id output_id = 1; + int last_result = EOM_ERROR_NONE; + eom_error_e error = EOM_ERROR_NO_SUCH_DEVICE; + eom_error_e expected_error = EOM_ERROR_NONE; + eom_output_mode_e mode = EOM_OUTPUT_MODE_NONE; + eom_output_mode_e expected_mode = EOM_OUTPUT_MODE_MIRROR; + eom_output_info output_info; + GList list; + + _init_test(); + + output_info.id = output_id; + output_info.output_mode = expected_mode; + list.data = &output_info; + list.next = list.prev = NULL; + output_info_list = &list; + + error = eom_get_output_mode(output_id, &mode); + + last_result = get_last_result(); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(last_result, expected_error); + ASSERT_EQ(mode, expected_mode); +} + +TEST(eom_get_output_mode, work_flow_success_2) +{ + eom_output_id output_id = 1; + int last_result = EOM_ERROR_NONE; + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_NO_SUCH_DEVICE; + eom_output_mode_e mode; + + _init_test(); + + error = eom_get_output_mode(output_id, &mode); + + last_result = get_last_result(); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(last_result, expected_error); +} + +TEST(eom_get_output_mode, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + eom_output_mode_e mode; + + _init_test(); + + error = eom_get_output_mode(0, &mode); + + ASSERT_EQ(error, expected_error); +} + +/* eom_get_output_type() */ + +TEST(eom_get_output_type, work_flow_success_3) +{ + eom_output_id output_id = 1; + int last_result = EOM_ERROR_NONE; + eom_error_e error = EOM_ERROR_NO_SUCH_DEVICE; + eom_error_e expected_error = EOM_ERROR_NONE; + eom_output_type_e type = EOM_OUTPUT_TYPE_UNKNOWN; + eom_output_type_e expected_type = EOM_OUTPUT_TYPE_VGA; + eom_output_info output_info; + GList list; + + _init_test(); + + output_info.id = output_id; + output_info.type = expected_type; + list.data = &output_info; + list.next = list.prev = NULL; + output_info_list = &list; + + error = eom_get_output_type(output_id, &type); + + last_result = get_last_result(); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(last_result, expected_error); + ASSERT_EQ(type, expected_type); +} + +TEST(eom_get_output_type1, work_flow_success_2) +{ + eom_output_id output_id = 1; + int last_result = EOM_ERROR_NONE; + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_NO_SUCH_DEVICE; + eom_output_type_e type; + + _init_test(); + + error = eom_get_output_type(output_id, &type); + + last_result = get_last_result(); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(last_result, expected_error); +} + +TEST(eom_get_output_type2, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + eom_output_type_e type; + + _init_test(); + + error = eom_get_output_type(0, &type); + + ASSERT_EQ(error, expected_error); +} + +/* eom_set_output_attribute() */ + +TEST(eom_set_output_attribute, work_flow_success_7) +{ + eom_output_id output_id = 9849; + eom_error_e error = EOM_ERROR_MESSAGE_OPERATION_FAILURE; + eom_error_e expected_error = EOM_ERROR_NONE; + eom_output_attribute_e attr = EOM_OUTPUT_ATTRIBUTE_NORMAL; + eom_output_info output_info; + GList list; + + _init_test(); + + output_info.id = output_id; + list.data = &output_info; + list.next = list.prev = NULL; + output_info_list = &list; + + error = eom_set_output_attribute(output_id, attr); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(output_info.attribute, attr); +} + +TEST(eom_set_output_attribute, work_flow_success_6) +{ + eom_output_id output_id = 9849; + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_MESSAGE_OPERATION_FAILURE; + eom_output_attribute_e attr = EOM_OUTPUT_ATTRIBUTE_NORMAL; + eom_output_info output_info; + GList list; + + _init_test(); + + output_info.id = output_id; + list.data = &output_info; + list.next = list.prev = NULL; + output_info_list = &list; + EOM_WAYLEND_RET_ERROR = 1; + + error = eom_set_output_attribute(output_id, attr); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_output_attribute, work_flow_success_5) +{ + eom_output_id output_id = 9849; + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_MESSAGE_SENDING_FAILURE; + eom_output_attribute_e attr = EOM_OUTPUT_ATTRIBUTE_NORMAL; + eom_output_info output_info; + GList list; + + _init_test(); + + output_info.id = output_id; + list.data = &output_info; + list.next = list.prev = NULL; + output_info_list = &list; + EOM_WAYLEND_ERROR = 1; + + error = eom_set_output_attribute(output_id, attr); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_output_attribute, work_flow_success_4) +{ + eom_output_id output_id = 1; + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_NO_SUCH_DEVICE; + eom_output_attribute_e attr = EOM_OUTPUT_ATTRIBUTE_NORMAL; + int last_result = EOM_ERROR_NONE; + + _init_test(); + + error = eom_set_output_attribute(output_id, attr); + + last_result = get_last_result(); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(last_result, expected_error); +} + +TEST(eom_set_output_attribute, work_flow_success_3) +{ + eom_output_id output_id = 1; + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + eom_output_attribute_e attr = EOM_OUTPUT_ATTRIBUTE_MAX; + + _init_test(); + + error = eom_set_output_attribute(output_id, attr); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_output_attribute, work_flow_success_2) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + eom_output_attribute_e attr = EOM_OUTPUT_ATTRIBUTE_NONE; + + _init_test(); + + error = eom_set_output_attribute(1, attr); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_output_attribute, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + eom_output_attribute_e attr; + + _init_test(); + + error = eom_set_output_attribute(0, attr); + + ASSERT_EQ(error, expected_error); +} + +/* eom_unset_attribute_changed_cb() */ + +TEST(eom_unset_attribute_changed_cb, work_flow_success_3) +{ + eom_error_e error = EOM_ERROR_INVALID_PARAMETER; + eom_error_e expected_error = EOM_ERROR_NONE; + eom_output_notify_cb_info cb_info1; + eom_output_notify_cb_info *cb_info2; + + _init_test(); + + cb_info1.attribute_change_func = ut_eom_cb1; + cb_info2 = calloc(1, sizeof(eom_output_notify_cb_info)); + cb_info2->attribute_change_func = ut_eom_cb; + cb_info_list = g_list_append(cb_info_list, &cb_info1); + cb_info_list = g_list_append(cb_info_list, cb_info2); + FREE_TESTED_PTR = cb_info2; + + error = eom_unset_attribute_changed_cb(ut_eom_cb); + + cb_info_list = g_list_remove(cb_info_list, &cb_info1); + cb_info_list = g_list_remove(cb_info_list, cb_info2); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(free_called_for_tested_ptr, 1); +} + +TEST(eom_unset_attribute_changed_cb, work_flow_success_2) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + eom_output_notify_cb_info cb_info1; + eom_output_notify_cb_info cb_info2; + + _init_test(); + + cb_info1.attribute_change_func = ut_eom_cb1; + cb_info2.attribute_change_func = ut_eom_cb1; + cb_info_list = g_list_append(cb_info_list, &cb_info1); + cb_info_list = g_list_append(cb_info_list, &cb_info2); + + error = eom_unset_attribute_changed_cb(ut_eom_cb); + + cb_info_list = g_list_remove(cb_info_list, &cb_info1); + cb_info_list = g_list_remove(cb_info_list, &cb_info2); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_unset_attribute_changed_cb, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = eom_unset_attribute_changed_cb(ut_eom_cb); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_unset_attribute_changed_cb, null_ptr_fail_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = eom_unset_attribute_changed_cb(NULL); + + ASSERT_EQ(error, expected_error); +} + +/* eom_set_attribute_changed_cb() */ + +TEST(eom_set_attribute_changed_cb, work_flow_success_4) +{ + eom_error_e error = EOM_ERROR_OUT_OF_MEMORY; + eom_error_e expected_error = EOM_ERROR_NONE; + eom_output_notify_type_e expected_type = EOM_OUTPUT_NOTIFY_ATTRIBUTE_CHANGED; + int user_data = 324; + eom_output_notify_cb_info *cb_info; + eom_output_notify_cb_info info; + GList *l; + + _init_test(); + + error = eom_set_attribute_changed_cb(ut_eom_cb, &user_data); + + ASSERT_EQ(error, expected_error); + ASSERT_TRUE(cb_info_list != NULL); + for (l = cb_info_list; l != NULL; l = g_list_next(l)) { + cb_info = (eom_output_notify_cb_info *)l->data; + if (cb_info) + break; + } + cb_info_list = g_list_remove_all(cb_info_list, cb_info); + ASSERT_TRUE(cb_info != NULL); + info = *cb_info; + free(cb_info); + ASSERT_TRUE(info.attribute_change_func == ut_eom_cb); + ASSERT_TRUE(info.user_data == &user_data); + ASSERT_EQ(info.type, expected_type); +} + +TEST(eom_set_attribute_changed_cb, work_flow_success_3) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_OUT_OF_MEMORY; + + _init_test(); + + CALLOC_ERROR = 1; + + error = eom_set_attribute_changed_cb(ut_eom_cb, NULL); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_attribute_changed_cb, work_flow_success_2) +{ + eom_error_e error = EOM_ERROR_INVALID_PARAMETER; + eom_error_e expected_error = EOM_ERROR_NONE; + GList list1; + eom_output_notify_cb_info cb_info1; + GList list; + eom_output_notify_cb_info cb_info; + + _init_test(); + + cb_info1.attribute_change_func = ut_eom_cb1; + list1.data = &cb_info1; + cb_info_list = &list1; + list1.next = list1.prev = NULL; + + cb_info.attribute_change_func = ut_eom_cb; + list.data = &cb_info; + list.next = list.prev = NULL; + list1.next = &list; + list.prev = &list1; + + error = eom_set_attribute_changed_cb(ut_eom_cb, NULL); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_attribute_changed_cb, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_INVALID_PARAMETER; + eom_error_e expected_error = EOM_ERROR_NONE; + GList list; + eom_output_notify_cb_info cb_info; + + _init_test(); + + cb_info.attribute_change_func = ut_eom_cb; + list.data = &cb_info; + cb_info_list = &list; + list.next = list.prev = NULL; + + error = eom_set_attribute_changed_cb(ut_eom_cb, NULL); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_attribute_changed_cb, null_ptr_fail_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = eom_set_attribute_changed_cb(NULL, NULL); + + ASSERT_EQ(error, expected_error); +} + +/* eom_unset_mode_changed_cb() */ + +TEST(eom_unset_mode_changed_cb, work_flow_success_3) +{ + eom_error_e error = EOM_ERROR_INVALID_PARAMETER; + eom_error_e expected_error = EOM_ERROR_NONE; + eom_output_notify_cb_info cb_info1; + eom_output_notify_cb_info *cb_info2; + + _init_test(); + + cb_info1.mode_change_func = ut_eom_cb1; + cb_info2 = calloc(1, sizeof(eom_output_notify_cb_info)); + cb_info2->mode_change_func = ut_eom_cb; + cb_info_list = g_list_append(cb_info_list, &cb_info1); + cb_info_list = g_list_append(cb_info_list, cb_info2); + FREE_TESTED_PTR = cb_info2; + + error = eom_unset_mode_changed_cb(ut_eom_cb); + + cb_info_list = g_list_remove(cb_info_list, &cb_info1); + cb_info_list = g_list_remove(cb_info_list, cb_info2); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(free_called_for_tested_ptr, 1); +} + +TEST(eom_unset_mode_changed_cb, work_flow_success_2) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + eom_output_notify_cb_info cb_info1; + eom_output_notify_cb_info cb_info2; + + _init_test(); + + cb_info1.mode_change_func = ut_eom_cb1; + cb_info2.mode_change_func = ut_eom_cb1; + cb_info_list = g_list_append(cb_info_list, &cb_info1); + cb_info_list = g_list_append(cb_info_list, &cb_info2); + + error = eom_unset_mode_changed_cb(ut_eom_cb); + + cb_info_list = g_list_remove(cb_info_list, &cb_info1); + cb_info_list = g_list_remove(cb_info_list, &cb_info2); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_unset_mode_changed_cb, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = eom_unset_mode_changed_cb(ut_eom_cb); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_unset_mode_changed_cb, null_ptr_fail_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = eom_unset_mode_changed_cb(NULL); + + ASSERT_EQ(error, expected_error); +} + +/* eom_set_mode_changed_cb() */ + +TEST(eom_set_mode_changed_cb, work_flow_success_4) +{ + eom_error_e error = EOM_ERROR_OUT_OF_MEMORY; + eom_error_e expected_error = EOM_ERROR_NONE; + eom_output_notify_type_e expected_type = EOM_OUTPUT_NOTIFY_MODE_CHANGED; + int user_data = 324; + eom_output_notify_cb_info *cb_info; + eom_output_notify_cb_info info; + GList *l; + + _init_test(); + + error = eom_set_mode_changed_cb(ut_eom_cb, &user_data); + + ASSERT_EQ(error, expected_error); + ASSERT_TRUE(cb_info_list != NULL); + for (l = cb_info_list; l; l = g_list_next(l)) { + cb_info = (eom_output_notify_cb_info *)l->data; + if (cb_info) + break; + } + cb_info_list = g_list_remove_all(cb_info_list, cb_info); + ASSERT_TRUE(cb_info != NULL); + info = *cb_info; + free(cb_info); + ASSERT_TRUE(info.mode_change_func == ut_eom_cb); + ASSERT_TRUE(info.user_data == &user_data); + ASSERT_EQ(info.type, expected_type); +} + +TEST(eom_set_mode_changed_cb, work_flow_success_3) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_OUT_OF_MEMORY; + + _init_test(); + + cb_info_list = NULL; + CALLOC_ERROR = 1; + + error = eom_set_mode_changed_cb(ut_eom_cb, NULL); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_mode_changed_cb, work_flow_success_2) +{ + eom_error_e error = EOM_ERROR_INVALID_PARAMETER; + eom_error_e expected_error = EOM_ERROR_NONE; + GList list1; + eom_output_notify_cb_info cb_info1; + GList list; + eom_output_notify_cb_info cb_info; + + _init_test(); + + cb_info1.mode_change_func = ut_eom_cb1; + list1.data = &cb_info1; + cb_info_list = &list1; + list1.next = list1.prev = NULL; + + cb_info.mode_change_func = ut_eom_cb; + list.data = &cb_info; + list.next = list.prev = NULL; + list1.next = &list; + list.prev = &list1; + + error = eom_set_mode_changed_cb(ut_eom_cb, NULL); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_mode_changed_cb, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_INVALID_PARAMETER; + eom_error_e expected_error = EOM_ERROR_NONE; + GList list; + eom_output_notify_cb_info cb_info; + + _init_test(); + + cb_info.mode_change_func = ut_eom_cb; + list.data = &cb_info; + cb_info_list = &list; + list.next = list.prev = NULL; + + error = eom_set_mode_changed_cb(ut_eom_cb, NULL); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_mode_changed_cb, null_ptr_fail_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = eom_set_mode_changed_cb(NULL, NULL); + + ASSERT_EQ(error, expected_error); +} + +/* eom_unset_output_removed_cb() */ + +TEST(eom_unset_output_removed_cb, work_flow_success_3) +{ + eom_error_e error = EOM_ERROR_INVALID_PARAMETER; + eom_error_e expected_error = EOM_ERROR_NONE; + eom_output_notify_cb_info cb_info1; + eom_output_notify_cb_info *cb_info2; + + _init_test(); + + cb_info1.remove_func = ut_eom_cb1; + cb_info2 = calloc(1, sizeof(eom_output_notify_cb_info)); + cb_info2->remove_func = ut_eom_cb; + cb_info_list = g_list_append(cb_info_list, &cb_info1); + cb_info_list = g_list_append(cb_info_list, cb_info2); + FREE_TESTED_PTR = cb_info2; + + error = eom_unset_output_removed_cb(ut_eom_cb); + + cb_info_list = g_list_remove(cb_info_list, &cb_info1); + cb_info_list = g_list_remove(cb_info_list, cb_info2); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(free_called_for_tested_ptr, 1); +} + +TEST(eom_unset_output_removed_cb, work_flow_success_2) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + eom_output_notify_cb_info cb_info1; + eom_output_notify_cb_info cb_info2; + + _init_test(); + + cb_info1.remove_func = ut_eom_cb1; + cb_info2.remove_func = ut_eom_cb1; + cb_info_list = g_list_append(cb_info_list, &cb_info1); + cb_info_list = g_list_append(cb_info_list, &cb_info2); + + error = eom_unset_output_removed_cb(ut_eom_cb); + + cb_info_list = g_list_remove(cb_info_list, &cb_info1); + cb_info_list = g_list_remove(cb_info_list, &cb_info2); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_unset_output_removed_cb, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = eom_unset_output_removed_cb(ut_eom_cb); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_unset_output_removed_cb, null_ptr_fail_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = eom_unset_output_removed_cb(NULL); + + ASSERT_EQ(error, expected_error); +} + +/* eom_set_output_removed_cb() */ + +TEST(eom_set_output_removed_cb, work_flow_success_4) +{ + eom_error_e error = EOM_ERROR_OUT_OF_MEMORY; + eom_error_e expected_error = EOM_ERROR_NONE; + eom_output_notify_type_e expected_type = EOM_OUTPUT_NOTIFY_REMOVE; + int user_data = 324; + eom_output_notify_cb_info *cb_info; + eom_output_notify_cb_info info; + GList *l; + + _init_test(); + + error = eom_set_output_removed_cb(ut_eom_cb, &user_data); + + ASSERT_EQ(error, expected_error); + ASSERT_TRUE(cb_info_list != NULL); + for (l = cb_info_list; l; l = g_list_next(l)) { + cb_info = (eom_output_notify_cb_info *)l->data; + if (cb_info) + break; + } + cb_info_list = g_list_remove_all(cb_info_list, cb_info); + ASSERT_TRUE(cb_info != NULL); + info = *cb_info; + free(cb_info); + ASSERT_TRUE(info.remove_func == ut_eom_cb); + ASSERT_TRUE(info.user_data == &user_data); + ASSERT_EQ(info.type, expected_type); +} + +TEST(eom_set_output_removed_cb, work_flow_success_3) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_OUT_OF_MEMORY; + + _init_test(); + + CALLOC_ERROR = 1; + + error = eom_set_output_removed_cb(ut_eom_cb, NULL); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_output_removed_cb, work_flow_success_2) +{ + eom_error_e error = EOM_ERROR_INVALID_PARAMETER; + eom_error_e expected_error = EOM_ERROR_NONE; + GList list1; + eom_output_notify_cb_info cb_info1; + GList list; + eom_output_notify_cb_info cb_info; + + _init_test(); + + cb_info1.remove_func = ut_eom_cb1; + list1.data = &cb_info1; + cb_info_list = &list1; + list1.next = list1.prev = NULL; + + cb_info.remove_func = ut_eom_cb; + list.data = &cb_info; + list.next = list.prev = NULL; + list1.next = &list; + list.prev = &list1; + + error = eom_set_output_removed_cb(ut_eom_cb, NULL); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_output_removed_cb, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_INVALID_PARAMETER; + eom_error_e expected_error = EOM_ERROR_NONE; + GList list; + eom_output_notify_cb_info cb_info; + + _init_test(); + + cb_info.remove_func = ut_eom_cb; + list.data = &cb_info; + cb_info_list = &list; + list.next = list.prev = NULL; + + error = eom_set_output_removed_cb(ut_eom_cb, NULL); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_output_removed_cb, null_ptr_fail_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = eom_set_output_removed_cb(NULL, NULL); + + ASSERT_EQ(error, expected_error); +} + +/* eom_unset_output_added_cb() */ + +TEST(eom_unset_output_added_cb, work_flow_success_3) +{ + eom_error_e error = EOM_ERROR_INVALID_PARAMETER; + eom_error_e expected_error = EOM_ERROR_NONE; + eom_output_notify_cb_info cb_info1; + eom_output_notify_cb_info *cb_info2; + + _init_test(); + + cb_info1.add_func = ut_eom_cb1; + cb_info2 = calloc(1, sizeof(eom_output_notify_cb_info)); + cb_info2->add_func = ut_eom_cb; + cb_info_list = g_list_append(cb_info_list, &cb_info1); + cb_info_list = g_list_append(cb_info_list, cb_info2); + FREE_TESTED_PTR = cb_info2; + + error = eom_unset_output_added_cb(ut_eom_cb); + + cb_info_list = g_list_remove(cb_info_list, &cb_info1); + cb_info_list = g_list_remove(cb_info_list, cb_info2); + + ASSERT_EQ(error, expected_error); + ASSERT_EQ(free_called_for_tested_ptr, 1); +} + +TEST(eom_unset_output_added_cb, work_flow_success_2) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + eom_output_notify_cb_info cb_info1; + eom_output_notify_cb_info cb_info2; + + _init_test(); + + cb_info1.add_func = ut_eom_cb1; + cb_info2.add_func = ut_eom_cb1; + cb_info_list = g_list_append(cb_info_list, &cb_info1); + cb_info_list = g_list_append(cb_info_list, &cb_info2); + + error = eom_unset_output_added_cb(ut_eom_cb); + + cb_info_list = g_list_remove(cb_info_list, &cb_info1); + cb_info_list = g_list_remove(cb_info_list, &cb_info2); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_unset_output_added_cb, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = eom_unset_output_added_cb(ut_eom_cb); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_unset_output_added_cb, null_ptr_fail_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = eom_unset_output_added_cb(NULL); + + ASSERT_EQ(error, expected_error); +} + +/* eom_set_output_added_cb() */ + +TEST(eom_set_output_added_cb, work_flow_success_4) +{ + eom_error_e error = EOM_ERROR_OUT_OF_MEMORY; + eom_error_e expected_error = EOM_ERROR_NONE; + eom_output_notify_type_e expected_type = EOM_OUTPUT_NOTIFY_ADD; + int user_data = 324; + eom_output_notify_cb_info *cb_info; + eom_output_notify_cb_info info; + GList *l; + + _init_test(); + + error = eom_set_output_added_cb(ut_eom_cb, &user_data); + + ASSERT_EQ(error, expected_error); + ASSERT_TRUE(cb_info_list != NULL); + for (l = cb_info_list; l; l = g_list_next(l)) { + cb_info = (eom_output_notify_cb_info *)l->data; + if (cb_info) + break; + } + cb_info_list = g_list_remove_all(cb_info_list, cb_info); + ASSERT_TRUE(cb_info != NULL); + info = *cb_info; + free(cb_info); + ASSERT_TRUE(info.add_func == ut_eom_cb); + ASSERT_TRUE(info.user_data == &user_data); + ASSERT_EQ(info.type, expected_type); +} + +TEST(eom_set_output_added_cb, work_flow_success_3) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_OUT_OF_MEMORY; + + _init_test(); + + CALLOC_ERROR = 1; + + error = eom_set_output_added_cb(ut_eom_cb, NULL); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_output_added_cb, work_flow_success_2) +{ + eom_error_e error = EOM_ERROR_INVALID_PARAMETER; + eom_error_e expected_error = EOM_ERROR_NONE; + GList list1; + eom_output_notify_cb_info cb_info1; + GList list; + eom_output_notify_cb_info cb_info; + + _init_test(); + + cb_info1.add_func = ut_eom_cb1; + list1.data = &cb_info1; + cb_info_list = &list1; + list1.next = list1.prev = NULL; + + cb_info.add_func = ut_eom_cb; + list.data = &cb_info; + list.next = list.prev = NULL; + list1.next = &list; + list.prev = &list1; + + error = eom_set_output_added_cb(ut_eom_cb, NULL); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_output_added_cb, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_INVALID_PARAMETER; + eom_error_e expected_error = EOM_ERROR_NONE; + GList list; + eom_output_notify_cb_info cb_info; + + _init_test(); + + cb_info.add_func = ut_eom_cb; + list.data = &cb_info; + cb_info_list = &list; + list.next = list.prev = NULL; + + error = eom_set_output_added_cb(ut_eom_cb, NULL); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_set_output_added_cb, null_ptr_fail_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_INVALID_PARAMETER; + + _init_test(); + + error = eom_set_output_added_cb(NULL, NULL); + + ASSERT_EQ(error, expected_error); +} + +/* eom_get_eom_output_ids() */ + +TEST(eom_get_eom_output_ids, work_flow_success_5) +{ + int count = 0; + int expected_error = EOM_ERROR_NONE; + eom_output_id *not_expected = NULL; + eom_output_id *actual; + int last_result = EOM_ERROR_NONE; + + _init_test(); + + actual = eom_get_eom_output_ids(&count); + + last_result = get_last_result(); + + ASSERT_TRUE(actual != not_expected); + free(actual); + ASSERT_EQ(last_result, expected_error); + ASSERT_TRUE(output_info_list != NULL); + while (output_info_list) { + eom_output_info *output_info = (eom_output_info *)output_info_list->data; + output_info_list = g_list_remove(output_info_list, output_info); + free(output_info); + + } +} + +TEST(eom_get_eom_output_ids, work_flow_success_4) +{ + int count = 0; + int expected_error = EOM_ERROR_OUT_OF_MEMORY; + eom_output_id *expected = NULL; + eom_output_id *actual; + int last_result = EOM_ERROR_NONE; + + _init_test(); + + CALLOC_ERROR = 1; + + actual = eom_get_eom_output_ids(&count); + + last_result = get_last_result(); + + ASSERT_EQ(actual, expected); + ASSERT_EQ(last_result, expected_error); +} + +TEST(eom_get_eom_output_ids, work_flow_success_3) +{ + int count = 0; + int expected_error = EOM_ERROR_NONE; + eom_output_id *expected = NULL; + eom_output_id *actual; + int last_result = EOM_ERROR_NONE; + + _init_test(); + + EOM_WAYLEND_RET_ERROR = 1; + + actual = eom_get_eom_output_ids(&count); + + last_result = get_last_result(); + + ASSERT_EQ(actual, expected); + ASSERT_EQ(last_result, expected_error); +} + +TEST(eom_get_eom_output_ids, work_flow_success_2) +{ + int count = 0; + int expected_error = EOM_ERROR_NONE; + eom_output_id *expected = NULL; + eom_output_id *actual; + int last_result = EOM_ERROR_NONE; + + _init_test(); + + EOM_WAYLEND_ERROR = 1; + + actual = eom_get_eom_output_ids(&count); + + last_result = get_last_result(); + + ASSERT_EQ(actual, expected); + ASSERT_EQ(last_result, expected_error); +} + +TEST(eom_get_eom_output_ids, work_flow_success_1) +{ + eom_output_id *expected = NULL; + int expected_error = EOM_ERROR_INVALID_PARAMETER; + eom_output_id *actual; + int last_result = EOM_ERROR_NONE; + + _init_test(); + + actual = eom_get_eom_output_ids(NULL); + + last_result = get_last_result(); + + ASSERT_EQ(actual, expected); + ASSERT_EQ(last_result, expected_error); +} + +/* eom_deinit() */ + +TEST(eom_deinit, work_flow_success_2) +{ + GList *expected_list = NULL; + GList list; + + _init_test(); + + list.next = list.prev = list.data = NULL; + output_info_list = &list; + + eom_output_info *data1 = calloc(1, sizeof(eom_output_info)); + data1->width = 1; + eom_output_info *data2 = calloc(1, sizeof(eom_output_info)); + data2->width = 2; + eom_output_info *data3 = calloc(1, sizeof(eom_output_info)); + data3->width = 3; + output_info_list = g_list_append(output_info_list, data1); + output_info_list = g_list_append(output_info_list, data2); + output_info_list = g_list_append(output_info_list, data3); + + eom_deinit(); + + ASSERT_GE(free_call_count, 3); + ASSERT_TRUE(output_info_list == expected_list); +} + +TEST(eom_deinit, work_flow_success_1) +{ + GList *expected_list = NULL; + + GList list; + + _init_test(); + + list.next = list.prev = list.data = NULL; + output_info_list = &list; + + eom_output_info *data = calloc(1, sizeof(eom_output_info)); + output_info_list = g_list_append(output_info_list, data); + + eom_deinit(); + + ASSERT_TRUE(output_info_list == expected_list); + ASSERT_TRUE(FREE_PTR == data); +} + +/* eom_init() */ + +TEST(eom_init, work_flow_success_2) +{ + eom_error_e error = EOM_ERROR_INVALID_PARAMETER; + eom_error_e expected_error = EOM_ERROR_NONE; + + _init_test(); + + error = eom_init(); + + ASSERT_EQ(error, expected_error); +} + +TEST(eom_init, work_flow_success_1) +{ + eom_error_e error = EOM_ERROR_NONE; + eom_error_e expected_error = EOM_ERROR_CONNECTION_FAILURE; + + _init_test(); + + EOM_WAYLAND_CLIENT_INIT_ERROR = 1; + + error = eom_init(); + + ASSERT_EQ(error, expected_error); +}