From: hyunho Date: Wed, 22 Jul 2020 08:36:23 +0000 (+0900) Subject: Add unittest X-Git-Tag: accepted/tizen/unified/20200825.142900~3 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fappfw%2Fappcore-widget.git;a=commitdiff_plain;h=ac5251199582de1a19f45101a4c97a988266d964 Add unittest Change-Id: Ibe2d80778ef7abb774a79d1139f262e9e464249f Signed-off-by: hyunho --- diff --git a/CMakeLists.txt b/CMakeLists.txt index c3ac5b6..7dc63e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,86 +1,53 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(appcore-widget C) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) + +PROJECT(appcore-widget) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) -SET(EXEC_PREFIX "\${prefix}") +SET(BINDIR "${CMAKE_INSTALL_PREFIX}/bin") +SET(LIBDIR ${LIB_INSTALL_DIR}) SET(INCLUDEDIR "\${prefix}/include") -SET(VERSION ${FULLVER}) -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) +## Compiler flags +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=hidden -g -Wall -Werror") -ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") +## Linker flags +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed,--gc-sections -pie") -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -Wall") -SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Werror") -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/") -SET(CMAKE_SKIP_BUILD_RPATH TRUE) +## Targets +SET(TARGET_WIDGET_BASE "appcore-widget-base") +SET(TARGET_WIDGET_APPLICATION "capi-appfw-widget-application") -################################################################# -# Build appcore-widget base Library -# ------------------------------ -SET(APPCORE_WIDGET_BASE "appcore-widget-base") -SET(SOURCES_base src/base/widget_base.c) +ENABLE_TESTING() +SET(TARGET_WIDGET_APPLICATION_UNIT_TEST "appcore-widget-unit-test") INCLUDE(FindPkgConfig) -pkg_check_modules(pkg_widget_base REQUIRED - dlog - appcore-common - capi-appfw-app-common - widget_service - capi-system-info - ecore-wl2 - capi-system-info - screen_connector_provider - appcore-multiwindow - ) - -FOREACH(flag ${pkg_widget_base_CFLAGS}) - SET(EXTRA_CFLAGS_widget "${EXTRA_CFLAGS_widget} ${flag}") -ENDFOREACH(flag) - -ADD_LIBRARY(${APPCORE_WIDGET_BASE} SHARED ${SOURCES_base}) -SET_TARGET_PROPERTIES(${APPCORE_WIDGET_BASE} PROPERTIES SOVERSION ${MAJORVER}) -SET_TARGET_PROPERTIES(${APPCORE_WIDGET_BASE} PROPERTIES VERSION ${FULLVER}) -SET_TARGET_PROPERTIES(${APPCORE_WIDGET_BASE} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_widget}) -TARGET_LINK_LIBRARIES(${APPCORE_WIDGET_BASE} ${pkg_widget_base_LDFLAGS} "-ldl -Wl,--no-undefined") - -CONFIGURE_FILE(${APPCORE_WIDGET_BASE}.pc.in ${APPCORE_WIDGET_BASE}.pc @ONLY) -INSTALL(TARGETS ${APPCORE_WIDGET_BASE} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPCORE_WIDGET_BASE}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) - - -################################################################# -# Build appcore-widget Library -# ------------------------------ -SET(APPCORE_WIDGET "capi-appfw-widget-application") -SET(SOURCES_efl src/efl_base/widget_app.c src/efl_base/widget_app_internal.c src/efl_base/widget_error.c) +INCLUDE(ApplyPkgConfig) + +ADD_DEFINITIONS("-DPROJECT_TAG=\"TIZEN_APPCORE_WIDGET\"") + +## Find all needed packages once +PKG_CHECK_MODULES(BUNDLE_DEPS REQUIRED bundle) +PKG_CHECK_MODULES(DLOG_DEPS REQUIRED dlog) +PKG_CHECK_MODULES(APPCORE_COMMON_DEPS REQUIRED appcore-common) +PKG_CHECK_MODULES(WIDGET_SERVICE_DEPS REQUIRED widget_service) +PKG_CHECK_MODULES(SYSTEM_INFO_DEPS REQUIRED capi-system-info) +PKG_CHECK_MODULES(ECORE_WL2_DEPS REQUIRED ecore-wl2) +PKG_CHECK_MODULES(SCREEN_CONNECTOR_PROVIDER_DEPS REQUIRED screen_connector_provider) +PKG_CHECK_MODULES(APPCORE_MULTIWINDOW_DEPS REQUIRED appcore-multiwindow) +PKG_CHECK_MODULES(AUL_DEP REQUIRED aul) +PKG_CHECK_MODULES(ELEMENTARY_DEP REQUIRED elementary) +PKG_CHECK_MODULES(CAPI_APP_COMMON_DEP REQUIRED capi-appfw-app-common) +PKG_CHECK_MODULES(GLIB_DEPS REQUIRED glib-2.0) +PKG_CHECK_MODULES(GOBJECT_DEPS REQUIRED gobject-2.0) +PKG_CHECK_MODULES(GMOCK_DEPS REQUIRED gmock) + +ADD_SUBDIRECTORY(src) +ADD_SUBDIRECTORY(test) + + + + -INCLUDE(FindPkgConfig) -pkg_check_modules(pkg_widget REQUIRED - aul - dlog - appcore-common - capi-appfw-app-common - elementary - ) -FOREACH(flag ${pkg_widget_CFLAGS}) - SET(EXTRA_CFLAGS_widget "${EXTRA_CFLAGS_widget} ${flag}") -ENDFOREACH(flag) - -ADD_LIBRARY(${APPCORE_WIDGET} SHARED ${SOURCES_efl}) -SET_TARGET_PROPERTIES(${APPCORE_WIDGET} PROPERTIES SOVERSION ${MAJORVER}) -SET_TARGET_PROPERTIES(${APPCORE_WIDGET} PROPERTIES VERSION ${FULLVER}) -SET_TARGET_PROPERTIES(${APPCORE_WIDGET} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_widget}) -TARGET_LINK_LIBRARIES(${APPCORE_WIDGET} ${pkg_widget_LDFLAGS} ${APPCORE_WIDGET_BASE} "-ldl -Wl,--no-undefined") - -CONFIGURE_FILE(${APPCORE_WIDGET}.pc.in ${APPCORE_WIDGET}.pc @ONLY) -INSTALL(TARGETS ${APPCORE_WIDGET} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPCORE_WIDGET}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) - -INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/appfw/ - FILES_MATCHING - PATTERN "*.h" - ) diff --git a/cmake/Modules/ApplyPkgConfig.cmake b/cmake/Modules/ApplyPkgConfig.cmake new file mode 100644 index 0000000..97679d7 --- /dev/null +++ b/cmake/Modules/ApplyPkgConfig.cmake @@ -0,0 +1,35 @@ +# Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +# +# This function applies external (out of source tree) dependencies +# to given target. Arguments are: +# TARGET - valid cmake target +# PRIVACY - dependency can be inherited by dependent targets or not: +# PUBLIC - this should be used by default, cause compile/link flags passing +# PRIVATE - do not passes any settings to dependent targets, +# may be usefull for static libraries from the inside of the project +# Argument ARGV2 and following are supposed to be names of checked pkg config +# packages. This function will use variables created by check_pkg_modules(). +# - ${DEP_NAME}_LIBRARIES +# - ${DEP_NAME}_INCLUDE_DIRS +# - ${DEP_NAME}_CFLAGS +# +FUNCTION(APPLY_PKG_CONFIG TARGET PRIVACY) + MATH(EXPR DEST_INDEX "${ARGC}-1") + FOREACH(I RANGE 2 ${DEST_INDEX}) + IF(NOT ${ARGV${I}}_FOUND) + MESSAGE(FATAL_ERROR "Not found dependency - ${ARGV${I}}_FOUND") + ENDIF(NOT ${ARGV${I}}_FOUND) + TARGET_LINK_LIBRARIES(${TARGET} ${PRIVACY} "${${ARGV${I}}_LIBRARIES}") + TARGET_INCLUDE_DIRECTORIES(${TARGET} ${PRIVACY} SYSTEM "${${ARGV${I}}_INCLUDE_DIRS}") + STRING(REPLACE ";" " " CFLAGS_STR "${${ARGV${I}}_CFLAGS}") + SET(CFLAGS_LIST ${CFLAGS_STR}) + SEPARATE_ARGUMENTS(CFLAGS_LIST) + FOREACH(OPTION ${CFLAGS_LIST}) + TARGET_COMPILE_OPTIONS(${TARGET} ${PRIVACY} ${OPTION}) + ENDFOREACH(OPTION) + SET_TARGET_PROPERTIES(${TARGET} PROPERTIES SKIP_BUILD_RPATH true) + ENDFOREACH(I RANGE 2 ${DEST_INDEX}) +ENDFUNCTION(APPLY_PKG_CONFIG TARGET PRIVACY) diff --git a/packaging/appcore-widget.spec b/packaging/appcore-widget.spec index 86af3a7..be7e811 100644 --- a/packaging/appcore-widget.spec +++ b/packaging/appcore-widget.spec @@ -15,8 +15,14 @@ BuildRequires: pkgconfig(capi-system-info) BuildRequires: pkgconfig(ecore-wl2) BuildRequires: pkgconfig(appcore-multiwindow) BuildRequires: pkgconfig(screen_connector_provider) +BuildRequires: pkgconfig(gmock) BuildRequires: cmake +%if 0%{?gcov:1} +BuildRequires: lcov +BuildRequires: zip +%endif + %description Widget base @@ -47,6 +53,13 @@ Requires: %{name} = %{version}-%{release} %description -n capi-appfw-widget-application-devel widget application (development files) +%package -n appcore_widget_unittests +Summary: GTest for appcore-widget +Group: Development/Libraries +%description -n appcore_widget_unittests +GTest for appcore-widget + + %if 0%{?gcov:1} %package gcov Summary: Widget application API(gcov) @@ -89,6 +102,16 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj mkdir -p %{buildroot}%{_libdir}/pkgconfig cp capi-appfw-widget-application.pc %{buildroot}%{_libdir}/pkgconfig +%check +export LD_LIBRARY_PATH=../../src/base:../../src/efl_base +ctest -V +%if 0%{?gcov:1} +lcov -c --ignore-errors graph --no-external -q -d . -o appcore-widget.info +genhtml appcore-widget.info -o appcore-widget.out +zip -r appcore-widget.zip appcore-widget.out +install -m 0644 appcore-widget.zip %{buildroot}%{_datadir}/gcov/ +%endif + %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -120,5 +143,5 @@ cp capi-appfw-widget-application.pc %{buildroot}%{_libdir}/pkgconfig %if 0%{?gcov:1} %files gcov -%{_datadir}/gcov/obj/* +%{_datadir}/gcov/* %endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..e6f55ae --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,2 @@ +ADD_SUBDIRECTORY(base) +ADD_SUBDIRECTORY(efl_base) \ No newline at end of file diff --git a/src/base/CMakeLists.txt b/src/base/CMakeLists.txt new file mode 100644 index 0000000..13314c5 --- /dev/null +++ b/src/base/CMakeLists.txt @@ -0,0 +1,23 @@ +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} WIDGET_BASE_SRCS) + +ADD_LIBRARY(${TARGET_WIDGET_BASE} SHARED ${WIDGET_BASE_SRCS}) +SET_TARGET_PROPERTIES(${TARGET_WIDGET_BASE} PROPERTIES SOVERSION ${MAJORVER}) +SET_TARGET_PROPERTIES(${TARGET_WIDGET_BASE} PROPERTIES VERSION ${FULLVER}) + +TARGET_INCLUDE_DIRECTORIES(${TARGET_WIDGET_BASE} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) +TARGET_INCLUDE_DIRECTORIES(${TARGET_WIDGET_BASE} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include/) + +APPLY_PKG_CONFIG(${TARGET_WIDGET_BASE} PUBLIC + DLOG_DEPS + APPCORE_COMMON_DEPS + WIDGET_SERVICE_DEPS + SYSTEM_INFO_DEPS + ECORE_WL2_DEPS + SCREEN_CONNECTOR_PROVIDER_DEPS + APPCORE_MULTIWINDOW_DEPS + CAPI_APP_COMMON_DEP +) + +CONFIGURE_FILE(../../appcore-widget-base.pc.in ../../appcore-widget-base.pc @ONLY) +INSTALL(TARGETS ${TARGET_WIDGET_BASE} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../appcore-widget-base.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) diff --git a/src/efl_base/CMakeLists.txt b/src/efl_base/CMakeLists.txt new file mode 100644 index 0000000..e9e7311 --- /dev/null +++ b/src/efl_base/CMakeLists.txt @@ -0,0 +1,26 @@ +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} WIDGET_APPLICATION_SRCS) + +ADD_LIBRARY(${TARGET_WIDGET_APPLICATION} SHARED ${WIDGET_APPLICATION_SRCS}) +SET_TARGET_PROPERTIES(${TARGET_WIDGET_APPLICATION} PROPERTIES SOVERSION ${MAJORVER}) +SET_TARGET_PROPERTIES(${TARGET_WIDGET_APPLICATION} PROPERTIES VERSION ${FULLVER}) +TARGET_LINK_LIBRARIES(${TARGET_WIDGET_APPLICATION} PRIVATE ${TARGET_WIDGET_BASE}) + +TARGET_INCLUDE_DIRECTORIES(${TARGET_WIDGET_APPLICATION} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) +TARGET_INCLUDE_DIRECTORIES(${TARGET_WIDGET_APPLICATION} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include/) + +APPLY_PKG_CONFIG(${TARGET_WIDGET_APPLICATION} PUBLIC + AUL_DEP + DLOG_DEPS + APPCORE_COMMON_DEPS + ELEMENTARY_DEP + WIDGET_SERVICE_DEPS + CAPI_APP_COMMON_DEP +) + +CONFIGURE_FILE(../../capi-appfw-widget-application.pc.in ../../capi-appfw-widget-application.pc @ONLY) +INSTALL(TARGETS ${TARGET_WIDGET_APPLICATION} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../capi-appfw-widget-application.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/appfw/ + FILES_MATCHING + PATTERN "*.h" + ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000..c90fac8 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1 @@ +ADD_SUBDIRECTORY(unit_tests) diff --git a/test/unit_tests/CMakeLists.txt b/test/unit_tests/CMakeLists.txt new file mode 100644 index 0000000..5bdc45d --- /dev/null +++ b/test/unit_tests/CMakeLists.txt @@ -0,0 +1,27 @@ +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ UNIT_TESTS_SRCS) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/mock/ UNIT_TESTS_SRCS) +ADD_EXECUTABLE(${TARGET_WIDGET_APPLICATION_UNIT_TEST} + ${UNIT_TESTS_SRCS} +) + +TARGET_INCLUDE_DIRECTORIES(${TARGET_WIDGET_APPLICATION_UNIT_TEST} PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/../" + "${CMAKE_CURRENT_SOURCE_DIR}/../../include" + "${CMAKE_CURRENT_SOURCE_DIR}/../../src" +) + +APPLY_PKG_CONFIG(${TARGET_WIDGET_APPLICATION_UNIT_TEST} PUBLIC + GLIB_DEPS + GMOCK_DEPS + BUNDLE_DEPS + GOBJECT_DEPS +) + +TARGET_LINK_LIBRARIES(${TARGET_WIDGET_APPLICATION_UNIT_TEST} PUBLIC ${TARGET_WIDGET_BASE} ${TARGET_WIDGET_APPLICATION}) +SET_TARGET_PROPERTIES(${TARGET_WIDGET_APPLICATION_UNIT_TEST} PROPERTIES COMPILE_FLAGS "-fPIE") +SET_TARGET_PROPERTIES(${TARGET_WIDGET_APPLICATION_UNIT_TEST} PROPERTIES LINK_FLAGS "-pie") + +ADD_TEST( + NAME ${TARGET_WIDGET_APPLICATION_UNIT_TEST} + COMMAND ${TARGET_WIDGET_APPLICATION_UNIT_TEST} +) diff --git a/test/unit_tests/main.cc b/test/unit_tests/main.cc new file mode 100644 index 0000000..5f340cd --- /dev/null +++ b/test/unit_tests/main.cc @@ -0,0 +1,25 @@ +// Copyright (c) 2020 Samsung Electronics Co., Ltd All Rights Reserved +// Use of this source code is governed by a apache 2.0 license that can be +// found in the LICENSE file. + +#include +#include + +int main(int argc, char** argv) { + int ret = -1; + try { + testing::InitGoogleTest(&argc, argv); + } catch(...) { + std::cout << "Exception occurred" << std::endl; + } + + try { + ret = RUN_ALL_TESTS(); + } catch (const ::testing::internal::GoogleTestFailureException& e) { + ret = -1; + std::cout << "GoogleTestFailureException was thrown:" << e.what() + << std::endl; + } + + return ret; +} diff --git a/test/unit_tests/mock/appcore_multiwindow_base_mock.cc b/test/unit_tests/mock/appcore_multiwindow_base_mock.cc new file mode 100644 index 0000000..f140a0d --- /dev/null +++ b/test/unit_tests/mock/appcore_multiwindow_base_mock.cc @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "unit_tests/mock/appcore_multiwindow_base_mock.h" + +#include + +#include "unit_tests/mock/mock_hook.h" +#include "unit_tests/mock/test_fixture.h" + +extern "C" int appcore_multiwindow_base_init( + appcore_multiwindow_base_ops ops, int argc, char **argv, void *data) { + return MOCK_HOOK_P4(MultiWindowBaseMock, appcore_multiwindow_base_init, + ops, argc, argv, data); +} + +extern "C" const char *appcore_multiwindow_base_instance_get_id( + appcore_multiwindow_base_instance_h context) { + return MOCK_HOOK_P1(MultiWindowBaseMock, + appcore_multiwindow_base_instance_get_id, context); +} + +extern "C" void *appcore_multiwindow_base_instance_get_extra( + appcore_multiwindow_base_instance_h context) { + return MOCK_HOOK_P1(MultiWindowBaseMock, + appcore_multiwindow_base_instance_get_extra, context); +} + +extern "C" const char* appcore_multiwindow_base_instance_get_class_id( + appcore_multiwindow_base_instance_h context) { + return MOCK_HOOK_P1(MultiWindowBaseMock, + appcore_multiwindow_base_instance_get_class_id, context); +} diff --git a/test/unit_tests/mock/appcore_multiwindow_base_mock.h b/test/unit_tests/mock/appcore_multiwindow_base_mock.h new file mode 100644 index 0000000..6aa400e --- /dev/null +++ b/test/unit_tests/mock/appcore_multiwindow_base_mock.h @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UNIT_TESTS_MOCK_APPCORE_MULTIWINDOW_BASE_MOCK_H_ +#define UNIT_TESTS_MOCK_APPCORE_MULTIWINDOW_BASE_MOCK_H_ + +#include +#include + +#include "mock/module_mock.h" + +class MultiWindowBaseMock : public virtual ModuleMock { + public: + virtual ~MultiWindowBaseMock() {} + + MOCK_METHOD4(appcore_multiwindow_base_init, + int(appcore_multiwindow_base_ops, int, char **, void *)); + MOCK_METHOD1(appcore_multiwindow_base_instance_get_id, + const char *(appcore_multiwindow_base_instance_h)); + MOCK_METHOD1(appcore_multiwindow_base_instance_get_extra, + void *(appcore_multiwindow_base_instance_h)); + MOCK_METHOD1(appcore_multiwindow_base_instance_get_class_id, + const char *(appcore_multiwindow_base_instance_h)); +}; + +#endif // UNIT_TESTS_MOCK_APPCORE_MULTIWINDOW_BASE_MOCK_H_ + diff --git a/test/unit_tests/mock/ecore_wl2_mock.cc b/test/unit_tests/mock/ecore_wl2_mock.cc new file mode 100644 index 0000000..11df066 --- /dev/null +++ b/test/unit_tests/mock/ecore_wl2_mock.cc @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "unit_tests/mock/ecore_wl2_mock.h" + +#include + +#include "unit_tests/mock/mock_hook.h" +#include "unit_tests/mock/test_fixture.h" + +extern "C" int ecore_wl2_init() { + return MOCK_HOOK_P0(EcoreWl2Mock, ecore_wl2_init); +} + +extern "C" Ecore_Wl2_Display* ecore_wl2_connected_display_get( + const char *display) { + return MOCK_HOOK_P1(EcoreWl2Mock, ecore_wl2_connected_display_get, display); +} + +extern "C" void ecore_wl2_window_iconified_set( + Ecore_Wl2_Window *win, Eina_Bool flag) { + return MOCK_HOOK_P2(EcoreWl2Mock, ecore_wl2_window_iconified_set, win, flag); +} + +extern "C" void ecore_wl2_window_class_set( + Ecore_Wl2_Window *win, const char *name) { + return MOCK_HOOK_P2(EcoreWl2Mock, ecore_wl2_window_class_set, win, name); +} + +extern "C" int ecore_wl2_window_id_get( + Ecore_Wl2_Window *win) { + return MOCK_HOOK_P1(EcoreWl2Mock, ecore_wl2_window_id_get, win); +} + +extern "C" void ecore_wl2_display_disconnect( + Ecore_Wl2_Display *display) { + return MOCK_HOOK_P1(EcoreWl2Mock, ecore_wl2_display_disconnect, display); +} + +extern "C" int ecore_wl2_shutdown() { + return MOCK_HOOK_P0(EcoreWl2Mock, ecore_wl2_shutdown); +} + +extern "C" Ecore_Wl2_Display *ecore_wl2_display_connect(const char *conn) { + return MOCK_HOOK_P1(EcoreWl2Mock, ecore_wl2_display_connect, conn); +} diff --git a/test/unit_tests/mock/ecore_wl2_mock.h b/test/unit_tests/mock/ecore_wl2_mock.h new file mode 100644 index 0000000..78e7704 --- /dev/null +++ b/test/unit_tests/mock/ecore_wl2_mock.h @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UNIT_TESTS_MOCK_ECORE_WL2_MOCK_H_ +#define UNIT_TESTS_MOCK_ECORE_WL2_MOCK_H_ + +#include +#include +#include + +#include "mock/module_mock.h" + +class EcoreWl2Mock : public virtual ModuleMock { + public: + virtual ~EcoreWl2Mock() {} + + MOCK_METHOD0(ecore_wl2_init, + int()); + MOCK_METHOD1(ecore_wl2_connected_display_get, + Ecore_Wl2_Display*(const char *)); + MOCK_METHOD2(ecore_wl2_window_iconified_set, + void(Ecore_Wl2_Window *, Eina_Bool)); + MOCK_METHOD2(ecore_wl2_window_class_set, + void(Ecore_Wl2_Window *, const char *)); + MOCK_METHOD1(ecore_wl2_window_id_get, + int(Ecore_Wl2_Window *)); + MOCK_METHOD1(ecore_wl2_display_disconnect, + void(Ecore_Wl2_Display *)); + MOCK_METHOD0(ecore_wl2_shutdown, + int()); + MOCK_METHOD1(ecore_wl2_display_connect, + Ecore_Wl2_Display *(const char *conn)); + +}; + +#endif // UNIT_TESTS_MOCK_ECORE_WL2_MOCK_H_ diff --git a/test/unit_tests/mock/gio_mock.cc b/test/unit_tests/mock/gio_mock.cc new file mode 100644 index 0000000..4e048fc --- /dev/null +++ b/test/unit_tests/mock/gio_mock.cc @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "unit_tests/mock/gio_mock.h" + +#include + +#include "unit_tests/mock/mock_hook.h" +#include "unit_tests/mock/test_fixture.h" + +extern "C" GDBusConnection* g_bus_get_sync(GBusType type, + GCancellable* cancellable, GError** error) { + return MOCK_HOOK_P3(GioMock, g_bus_get_sync, type, cancellable, error); +} + +extern "C" GDBusMessage* g_dbus_connection_send_message_with_reply_sync( + GDBusConnection* conn, GDBusMessage* msg, GDBusSendMessageFlags flags, + gint timeout, volatile guint32* out_serial, GCancellable* cancellable, + GError** error) { + return MOCK_HOOK_P7(GioMock, g_dbus_connection_send_message_with_reply_sync, + conn, msg, flags, timeout, out_serial, cancellable, error); +} + +extern "C" GDBusMessage* g_dbus_message_new_method_call(const gchar* arg0, + const gchar* arg1, const gchar* arg2, const gchar* arg3) { + return MOCK_HOOK_P4(GioMock, g_dbus_message_new_method_call, arg0, arg1, arg2, + arg3); +} + +extern "C" void g_dbus_message_set_body(GDBusMessage* arg0, GVariant* arg1) { + return MOCK_HOOK_P2(GioMock, g_dbus_message_set_body, arg0, arg1); +} + +extern "C" GVariant* g_dbus_message_get_body(GDBusMessage* arg0) { + return MOCK_HOOK_P1(GioMock, g_dbus_message_get_body, arg0); +} + +extern "C" gboolean g_dbus_connection_emit_signal(GDBusConnection* arg0, + const gchar* arg1, const gchar* arg2, const gchar* arg3, const gchar* arg4, + GVariant* arg5, GError** arg6) { + return MOCK_HOOK_P7(GioMock, g_dbus_connection_emit_signal, + arg0, arg1, arg2, arg3, arg4, arg5, arg6); +} + +extern "C" GDBusNodeInfo* g_dbus_node_info_new_for_xml( + const gchar* arg0, GError** arg1) { + return MOCK_HOOK_P2(GioMock, g_dbus_node_info_new_for_xml, arg0, arg1); +} + +extern "C" guint g_dbus_connection_register_object(GDBusConnection* arg0, + const gchar* arg1, GDBusInterfaceInfo* arg2, + const GDBusInterfaceVTable* arg3, gpointer arg4, + GDestroyNotify arg5, GError** arg6) { + return MOCK_HOOK_P7(GioMock, g_dbus_connection_register_object, + arg0, arg1, arg2, arg3, arg4, arg5, arg6); +} + +extern "C" guint g_bus_own_name_on_connection(GDBusConnection* arg0, + const gchar* arg1, GBusNameOwnerFlags arg2, + GBusNameAcquiredCallback arg3, GBusNameLostCallback arg4, + gpointer arg5, GDestroyNotify arg6) { + return MOCK_HOOK_P7(GioMock, g_bus_own_name_on_connection, + arg0, arg1, arg2, arg3, arg4, arg5, arg6); +} + +extern "C" guint g_dbus_connection_signal_subscribe(GDBusConnection* arg0, + const gchar* arg1, const gchar* arg2, const gchar* arg3, const gchar* arg4, + const gchar* arg5, GDBusSignalFlags arg6, GDBusSignalCallback arg7, + gpointer arg8, GDestroyNotify arg9) { + return MOCK_HOOK_P10(GioMock, g_dbus_connection_signal_subscribe, + arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9); +} + +extern "C" void g_dbus_connection_send_message_with_reply(GDBusConnection* arg0, + GDBusMessage* arg1, GDBusSendMessageFlags arg2, gint arg3, + volatile guint32* arg4, GCancellable* arg5, GAsyncReadyCallback arg6, + gpointer arg7) { + return MOCK_HOOK_P8(GioMock, g_dbus_connection_send_message_with_reply, + arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7); +} + +extern "C" GDBusMessage* g_dbus_connection_send_message_with_reply_finish( + GDBusConnection* arg0, GAsyncResult* arg1, GError** arg2) { + return MOCK_HOOK_P3(GioMock, g_dbus_connection_send_message_with_reply_finish, + arg0, arg1, arg2); +} diff --git a/test/unit_tests/mock/gio_mock.h b/test/unit_tests/mock/gio_mock.h new file mode 100755 index 0000000..a85f992 --- /dev/null +++ b/test/unit_tests/mock/gio_mock.h @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UNIT_TESTS_MOCK_GIO_MOCK_H_ +#define UNIT_TESTS_MOCK_GIO_MOCK_H_ + +#include +#include + +#include "mock/module_mock.h" + +class GioMock : public virtual ModuleMock { + public: + virtual ~GioMock() {} + + MOCK_METHOD3(g_bus_get_sync, + GDBusConnection*(GBusType, GCancellable*, GError**)); + MOCK_METHOD7(g_bus_own_name_on_connection, + guint(GDBusConnection*, const gchar*, GBusNameOwnerFlags, + GBusNameAcquiredCallback, GBusNameLostCallback, + gpointer, GDestroyNotify)); + + MOCK_METHOD4(g_dbus_message_new_method_call, + GDBusMessage*(const gchar*, const gchar*, const gchar*, const gchar*)); + MOCK_METHOD2(g_dbus_message_set_body, void(GDBusMessage*, GVariant*)); + MOCK_METHOD1(g_dbus_message_get_body, GVariant*(GDBusMessage*)); + + MOCK_METHOD7(g_dbus_connection_send_message_with_reply_sync, + GDBusMessage*(GDBusConnection*, GDBusMessage*, GDBusSendMessageFlags, + gint, volatile guint32*, GCancellable*, GError**)); + MOCK_METHOD7(g_dbus_connection_emit_signal, + gboolean(GDBusConnection*, const gchar*, const gchar*, const gchar*, + const gchar*, GVariant*, GError**)); + MOCK_METHOD7(g_dbus_connection_register_object, + guint(GDBusConnection*, const gchar*, GDBusInterfaceInfo*, + const GDBusInterfaceVTable*, gpointer, GDestroyNotify, GError**)); + MOCK_METHOD10(g_dbus_connection_signal_subscribe, + guint(GDBusConnection*, const gchar*, const gchar*, const gchar*, + const gchar*, const gchar*, GDBusSignalFlags, GDBusSignalCallback, + gpointer, GDestroyNotify)); + MOCK_METHOD8(g_dbus_connection_send_message_with_reply, + void(GDBusConnection*, GDBusMessage*, GDBusSendMessageFlags, gint, + volatile guint32*, GCancellable*, GAsyncReadyCallback, gpointer)); + MOCK_METHOD3(g_dbus_connection_send_message_with_reply_finish, + GDBusMessage*(GDBusConnection*, GAsyncResult*, GError**)); + + MOCK_METHOD2(g_dbus_node_info_new_for_xml, + GDBusNodeInfo*(const gchar*, GError**)); + + MOCK_METHOD2(g_dbus_method_invocation_return_value, + GDBusNodeInfo*(GDBusMethodInvocation*, GVariant*)); +}; + +#endif // UNIT_TESTS_MOCK_GIO_MOCK_H_ diff --git a/test/unit_tests/mock/mock_hook.h b/test/unit_tests/mock/mock_hook.h new file mode 100644 index 0000000..af27bba --- /dev/null +++ b/test/unit_tests/mock/mock_hook.h @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UNIT_TESTS_MOCK_MOCK_HOOK_H_ +#define UNIT_TESTS_MOCK_MOCK_HOOK_H_ + +#define MOCK_HOOK_P0(MOCK_CLASS, f) \ + TestFixture::GetMock().f() +#define MOCK_HOOK_P1(MOCK_CLASS, f, p1) \ + TestFixture::GetMock().f(p1) +#define MOCK_HOOK_P2(MOCK_CLASS, f, p1, p2) \ + TestFixture::GetMock().f(p1, p2) +#define MOCK_HOOK_P3(MOCK_CLASS, f, p1, p2, p3) \ + TestFixture::GetMock().f(p1, p2, p3) +#define MOCK_HOOK_P4(MOCK_CLASS, f, p1, p2, p3, p4) \ + TestFixture::GetMock().f(p1, p2, p3, p4) +#define MOCK_HOOK_P5(MOCK_CLASS, f, p1, p2, p3, p4, p5) \ + TestFixture::GetMock().f(p1, p2, p3, p4, p5) +#define MOCK_HOOK_P6(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6) \ + TestFixture::GetMock().f(p1, p2, p3, p4, p5, p6) +#define MOCK_HOOK_P7(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7) \ + TestFixture::GetMock().f(p1, p2, p3, p4, p5, p6, p7) +#define MOCK_HOOK_P8(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7, p8) \ + TestFixture::GetMock().f(p1, p2, p3, p4, p5, p6, p7, p8) +#define MOCK_HOOK_P10(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) \ + TestFixture::GetMock().f( \ + p1, p2, p3, p4, p5, p6, p7, p8, p9, p10) + +#endif // UNIT_TESTS_MOCK_MOCK_HOOK_H_ diff --git a/test/unit_tests/mock/module_mock.h b/test/unit_tests/mock/module_mock.h new file mode 100644 index 0000000..9b19d89 --- /dev/null +++ b/test/unit_tests/mock/module_mock.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UNIT_TESTS_MOCK_MODULE_MOCK_H_ +#define UNIT_TESTS_MOCK_MODULE_MOCK_H_ + +class ModuleMock { + public: + virtual ~ModuleMock() {} +}; + +#endif // UNIT_TESTS_MOCK_MODULE_MOCK_H_ diff --git a/test/unit_tests/mock/system_info_mock.cc b/test/unit_tests/mock/system_info_mock.cc new file mode 100644 index 0000000..ae07f8d --- /dev/null +++ b/test/unit_tests/mock/system_info_mock.cc @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "unit_tests/mock/system_info_mock.h" + +#include + +#include "unit_tests/mock/mock_hook.h" +#include "unit_tests/mock/test_fixture.h" + +extern "C" int system_info_get_platform_bool(const char *key, bool *value) { + return MOCK_HOOK_P2(SystemInfoMock, + system_info_get_platform_bool, key, value); +} diff --git a/test/unit_tests/mock/system_info_mock.h b/test/unit_tests/mock/system_info_mock.h new file mode 100644 index 0000000..83593ab --- /dev/null +++ b/test/unit_tests/mock/system_info_mock.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UNIT_TESTS_MOCK_SYSTEM_INFO_MOCK_H_ +#define UNIT_TESTS_MOCK_SYSTEM_INFO_MOCK_H_ + +#include + +#include "mock/module_mock.h" + +class SystemInfoMock : public virtual ModuleMock { + public: + virtual ~SystemInfoMock() {} + MOCK_METHOD2(system_info_get_platform_bool, + int (const char *, bool *)); +}; + +#endif // UNIT_TESTS_MOCK_SYSTEM_INFO_MOCK_H_ + diff --git a/test/unit_tests/mock/test_fixture.cc b/test/unit_tests/mock/test_fixture.cc new file mode 100644 index 0000000..cc5dd19 --- /dev/null +++ b/test/unit_tests/mock/test_fixture.cc @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "unit_tests/mock/test_fixture.h" + +#include + +std::unique_ptr TestFixture::mock_; diff --git a/test/unit_tests/mock/test_fixture.h b/test/unit_tests/mock/test_fixture.h new file mode 100644 index 0000000..3858e35 --- /dev/null +++ b/test/unit_tests/mock/test_fixture.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef UNIT_TESTS_MOCK_TEST_FIXTURE_H_ +#define UNIT_TESTS_MOCK_TEST_FIXTURE_H_ + +#include + +#include +#include +#include +#include + +#include "unit_tests/mock/module_mock.h" + +class TestFixture : public ::testing::Test { + public: + explicit TestFixture(std::unique_ptr&& mock) { + mock_ = std::move(mock); + } + virtual ~TestFixture() { + mock_.reset(); + } + + virtual void SetUp() {} + virtual void TearDown() {} + + template + static T& GetMock() { + auto ptr = dynamic_cast(mock_.get()); + if (!ptr) + throw std::invalid_argument("The test does not provide mock of \"" + + std::string(typeid(T).name()) + "\""); + return *ptr; + } + + static std::unique_ptr mock_; +}; + +#endif // UNIT_TESTS_MOCK_TEST_FIXTURE_H_ diff --git a/test/unit_tests/test_widget_app.cc b/test/unit_tests/test_widget_app.cc new file mode 100644 index 0000000..0460d13 --- /dev/null +++ b/test/unit_tests/test_widget_app.cc @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include + +#include +#include + +#include "widget_app.h" +#include "unit_tests/mock/gio_mock.h" +#include "unit_tests/mock/ecore_wl2_mock.h" +#include "unit_tests/mock/system_info_mock.h" +#include "unit_tests/mock/appcore_multiwindow_base_mock.h" +#include "unit_tests/mock/test_fixture.h" + +using ::testing::_; +using ::testing::DoAll; +using ::testing::Return; +using ::testing::SetArgPointee; +using ::testing::StrEq; + +class Mocks : public ::testing::NiceMock, + public ::testing::NiceMock, + public ::testing::NiceMock, + public ::testing::NiceMock {}; + +class WidgetAppTest : public TestFixture { + public: + WidgetAppTest() : TestFixture(std::make_unique()) {} + virtual ~WidgetAppTest() {} + + virtual void SetUp() { + } + + virtual void TearDown() { + } +}; + +widget_class_h __app_create_cb(void *user_data) { + return nullptr; +} + +void __app_terminate_cb(void *user_data) { +} + +TEST_F(WidgetAppTest, widget_app_main) { + tizen_base::Bundle b; + b.Add("__AUL_WIDGET_VIEWER__", "test"); + int ret = bundle_add_str(b.GetHandle(), "KEY", "VALUE"); + ASSERT_EQ(ret, BUNDLE_ERROR_NONE); + + char** argv = nullptr; + int argc = bundle_export_to_argv(b.GetHandle(), &argv); + ASSERT_EQ(get_last_result(), BUNDLE_ERROR_NONE); + ASSERT_NE(argv, nullptr); + ASSERT_NE(argc, 0); + + widget_app_lifecycle_callback_s callback; + callback.create = __app_create_cb; + callback.terminate = __app_terminate_cb; + + EXPECT_CALL(GetMock(), ecore_wl2_display_disconnect(_)). + Times(1); + + EXPECT_CALL(GetMock(), ecore_wl2_shutdown()). + Times(1); + + EXPECT_CALL(GetMock(), + system_info_get_platform_bool(_, _)). + WillOnce(DoAll( + SetArgPointee<1>(true), + Return(0))); + + EXPECT_CALL(GetMock(), + appcore_multiwindow_base_init(_, _, _, _)). + WillOnce(Return(0)); + + ret = widget_app_main(argc, argv, &callback, nullptr); + EXPECT_EQ(WIDGET_ERROR_NONE, ret); +}