From 4bda5be4e68ac38af1f07a36f40604e8c1555111 Mon Sep 17 00:00:00 2001 From: hyunho Date: Wed, 12 Aug 2020 13:58:12 +0900 Subject: [PATCH] Add gtests Change-Id: Iad0cb6978450d3456c404ba61cf9c9a4d0025395 Signed-off-by: hyunho --- CMakeLists.txt | 133 ++++++---------- cmake/Modules/ApplyPkgConfig.cmake | 35 +++++ mock/app_common_mock.cc | 26 ++++ mock/app_common_mock.h | 33 ++++ mock/appcore_multiwindow_base_mock.cc | 83 ++++++++++ mock/appcore_multiwindow_base_mock.h | 52 +++++++ mock/appcore_ui_base_mock.cc | 28 ++++ mock/appcore_ui_base_mock.h | 34 +++++ mock/aul_mock.cc | 32 ++++ mock/aul_mock.h | 35 +++++ mock/ecore_wl2_mock.cc | 95 ++++++++++++ mock/ecore_wl2_mock.h | 65 ++++++++ mock/elm_mock.cc | 45 ++++++ mock/elm_mock.h | 38 +++++ mock/gio_mock.cc | 99 ++++++++++++ mock/gio_mock.h | 67 +++++++++ mock/mock_hook.h | 42 ++++++ mock/module_mock.h | 25 +++ mock/system_info_mock.cc | 27 ++++ mock/system_info_mock.h | 31 ++++ mock/test_fixture.cc | 21 +++ mock/test_fixture.h | 53 +++++++ packaging/appcore-watch.spec | 19 ++- src/CMakeLists.txt | 2 + src/base/CMakeLists.txt | 33 ++++ src/efl_base/CMakeLists.txt | 26 ++++ test/CMakeLists.txt | 1 + test/unit_tests/CMakeLists.txt | 28 ++++ test/unit_tests/main.cc | 25 +++ test/unit_tests/test_watch_app.cc | 276 ++++++++++++++++++++++++++++++++++ 30 files changed, 1422 insertions(+), 87 deletions(-) create mode 100644 cmake/Modules/ApplyPkgConfig.cmake create mode 100644 mock/app_common_mock.cc create mode 100644 mock/app_common_mock.h create mode 100644 mock/appcore_multiwindow_base_mock.cc create mode 100644 mock/appcore_multiwindow_base_mock.h create mode 100644 mock/appcore_ui_base_mock.cc create mode 100644 mock/appcore_ui_base_mock.h create mode 100644 mock/aul_mock.cc create mode 100644 mock/aul_mock.h create mode 100644 mock/ecore_wl2_mock.cc create mode 100644 mock/ecore_wl2_mock.h create mode 100644 mock/elm_mock.cc create mode 100644 mock/elm_mock.h create mode 100644 mock/gio_mock.cc create mode 100755 mock/gio_mock.h create mode 100644 mock/mock_hook.h create mode 100644 mock/module_mock.h create mode 100644 mock/system_info_mock.cc create mode 100644 mock/system_info_mock.h create mode 100644 mock/test_fixture.cc create mode 100644 mock/test_fixture.h create mode 100644 src/CMakeLists.txt create mode 100644 src/base/CMakeLists.txt create mode 100644 src/efl_base/CMakeLists.txt create mode 100644 test/CMakeLists.txt create mode 100644 test/unit_tests/CMakeLists.txt create mode 100644 test/unit_tests/main.cc create mode 100644 test/unit_tests/test_watch_app.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index cabef15..395eb1b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,95 +1,58 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.6) -PROJECT(appcore-watch C) +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12) + +PROJECT(watch-application) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) -SET(EXEC_PREFIX "\${prefix}") -SET(LIBDIR "\${prefix}/lib") +SET(BINDIR "${CMAKE_INSTALL_PREFIX}/bin") +SET(LIBDIR ${LIB_INSTALL_DIR}) SET(INCLUDEDIR "\${prefix}/include") -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(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_WATCH_BASE "appcore-watch-base") +SET(TARGET_WATCH_APPLICATION "appcore-watch") -################################################################# -# Build appcore-watch-base Library -# ------------------------------ -SET(APPCORE_WATCH_BASE "appcore-watch-base") -SET(SOURCES_base src/base/watch_base_signal.c src/base/watch_base.c src/base/watch_base_time.c) +ENABLE_TESTING() +SET(TARGET_WATCH_APPLICATION_UNIT_TEST "appcore-watch-unit-test") INCLUDE(FindPkgConfig) -pkg_check_modules(pkg_watch_base REQUIRED - aul - dlog - alarm-service - capi-appfw-app-control - capi-appfw-app-common - vconf - ecore - ecore-wl2 - vconf-internal-keys - libtzplatform-config - capi-appfw-widget-application - icu-i18n - glib-2.0 - gio-2.0 - screen_connector_provider - appcore-common - appcore-ui - pkgmgr-info - capi-system-info - ) -FOREACH(flag ${pkg_watch_base_CFLAGS}) - SET(EXTRA_CFLAGS_watch_base "${EXTRA_CFLAGS_watch_base} ${flag}") -ENDFOREACH(flag) - -ADD_LIBRARY(${APPCORE_WATCH_BASE} SHARED ${SOURCES_base}) -SET_TARGET_PROPERTIES(${APPCORE_WATCH_BASE} PROPERTIES SOVERSION ${MAJORVER}) -SET_TARGET_PROPERTIES(${APPCORE_WATCH_BASE} PROPERTIES VERSION ${FULLVER}) -SET_TARGET_PROPERTIES(${APPCORE_WATCH_BASE} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_watch_base}) -TARGET_LINK_LIBRARIES(${APPCORE_WATCH_BASE} ${pkg_watch_base_LDFLAGS} "-ldl -Wl,--no-undefined") - -CONFIGURE_FILE(${APPCORE_WATCH_BASE}.pc.in ${APPCORE_WATCH_BASE}.pc @ONLY) - -INSTALL(TARGETS ${APPCORE_WATCH_BASE} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPCORE_WATCH_BASE}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) - -################################################################# -# Build appcore-watch Library -# ------------------------------ -SET(APPCORE_WATCH "appcore-watch") -SET(SOURCES_efl src/efl_base/watch_app_main.c) - -INCLUDE(FindPkgConfig) -pkg_check_modules(pkg_watch REQUIRED - dlog - capi-appfw-app-control - capi-appfw-app-common - elementary - ecore-wl2 - screen_connector_provider - ) -FOREACH(flag ${pkg_watch_CFLAGS}) - SET(EXTRA_CFLAGS_watch "${EXTRA_CFLAGS_watch} ${flag}") -ENDFOREACH(flag) - -ADD_LIBRARY(${APPCORE_WATCH} SHARED ${SOURCES_efl}) -SET_TARGET_PROPERTIES(${APPCORE_WATCH} PROPERTIES SOVERSION ${MAJORVER}) -SET_TARGET_PROPERTIES(${APPCORE_WATCH} PROPERTIES VERSION ${FULLVER}) -SET_TARGET_PROPERTIES(${APPCORE_WATCH} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_watch}) -TARGET_LINK_LIBRARIES(${APPCORE_WATCH} ${pkg_watch_LDFLAGS} ${APPCORE_WATCH_BASE} "-ldl -Wl,--no-undefined") - -CONFIGURE_FILE(${APPCORE_WATCH}.pc.in ${APPCORE_WATCH}.pc @ONLY) - -INSTALL(TARGETS ${APPCORE_WATCH} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPCORE_WATCH}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) - -INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/appcore-watch/ - FILES_MATCHING - PATTERN "*.h" - ) \ No newline at end of file +INCLUDE(ApplyPkgConfig) + +ADD_DEFINITIONS("-DPROJECT_TAG=\"TIZEN_APPCORE_WATCH\"") + +## 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(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_DEPS REQUIRED aul) +PKG_CHECK_MODULES(ELEMENTARY_DEPS REQUIRED elementary) +PKG_CHECK_MODULES(CAPI_APP_COMMON_DEPS 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) +PKG_CHECK_MODULES(ALARM_SERVICE_DEPS REQUIRED alarm-service) +PKG_CHECK_MODULES(APP_CONTROL_DEPS REQUIRED capi-appfw-app-control) +PKG_CHECK_MODULES(APP_COMMON_DEPS REQUIRED capi-appfw-app-common) +PKG_CHECK_MODULES(VCONF_DEPS REQUIRED vconf) +PKG_CHECK_MODULES(ECORE_DEPS REQUIRED ecore) +PKG_CHECK_MODULES(ECORE_WL2_DEPS REQUIRED ecore-wl2) +PKG_CHECK_MODULES(VCONF_INTERNAL_KEYS_DEPS REQUIRED vconf-internal-keys) +PKG_CHECK_MODULES(TZ_PLATFORM_CONFIG_DEPS REQUIRED libtzplatform-config) +PKG_CHECK_MODULES(ICU_I18N_DEPS REQUIRED icu-i18n) +PKG_CHECK_MODULES(GIO_DEPS REQUIRED gio-2.0) +PKG_CHECK_MODULES(APPCORE_UI_DEPS REQUIRED appcore-ui) +PKG_CHECK_MODULES(PKGMGR_INFO_DEPS REQUIRED pkgmgr-info) + +ADD_SUBDIRECTORY(src) +ADD_SUBDIRECTORY(test) 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/mock/app_common_mock.cc b/mock/app_common_mock.cc new file mode 100644 index 0000000..c7e4744 --- /dev/null +++ b/mock/app_common_mock.cc @@ -0,0 +1,26 @@ +/* + * 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 "app_common_mock.h" + +#include + +#include "mock_hook.h" +#include "test_fixture.h" + +extern "C" int app_get_id(char **id) { + return MOCK_HOOK_P1(AppCommonMock, app_get_id, id); +} diff --git a/mock/app_common_mock.h b/mock/app_common_mock.h new file mode 100644 index 0000000..1d1676f --- /dev/null +++ b/mock/app_common_mock.h @@ -0,0 +1,33 @@ +/* + * 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_APP_COMMON_MOCK_H_ +#define UNIT_TESTS_MOCK_APP_COMMON_MOCK_H_ + +#include +#include + +#include "module_mock.h" + +class AppCommonMock : public virtual ModuleMock { + public: + virtual ~AppCommonMock() {} + + MOCK_METHOD1(app_get_id, int (char **id)); +}; + +#endif // UNIT_TESTS_MOCK_APP_COMMON_MOCK_H_ + diff --git a/mock/appcore_multiwindow_base_mock.cc b/mock/appcore_multiwindow_base_mock.cc new file mode 100644 index 0000000..fb13fa5 --- /dev/null +++ b/mock/appcore_multiwindow_base_mock.cc @@ -0,0 +1,83 @@ +/* + * 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 "appcore_multiwindow_base_mock.h" + +#include + +#include "mock_hook.h" +#include "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); +} + +extern "C" void appcore_multiwindow_base_class_add( + appcore_multiwindow_base_class cls) { + return MOCK_HOOK_P1(MultiWindowBaseMock, + appcore_multiwindow_base_class_add, cls); +} + +extern "C" void appcore_multiwindow_base_instance_drop( + appcore_multiwindow_base_instance_h context) { + return MOCK_HOOK_P1(MultiWindowBaseMock, + appcore_multiwindow_base_instance_drop, context); +} + +extern "C" appcore_multiwindow_base_instance_h + appcore_multiwindow_base_instance_find(const char *id) { + return MOCK_HOOK_P1(MultiWindowBaseMock, + appcore_multiwindow_base_instance_find, id); +} + +extern "C" const appcore_multiwindow_base_class * + appcore_multiwindow_base_instance_get_class( + appcore_multiwindow_base_instance_h context) { + return MOCK_HOOK_P1(MultiWindowBaseMock, + appcore_multiwindow_base_instance_get_class, context); +} + +extern "C" void appcore_multiwindow_base_instance_exit( + appcore_multiwindow_base_instance_h context) { + return MOCK_HOOK_P1(MultiWindowBaseMock, + appcore_multiwindow_base_instance_exit, context); +} + +extern "C" void appcore_multiwindow_base_instance_pause( + appcore_multiwindow_base_instance_h context) { + return MOCK_HOOK_P1(MultiWindowBaseMock, + appcore_multiwindow_base_instance_pause, context); +} diff --git a/mock/appcore_multiwindow_base_mock.h b/mock/appcore_multiwindow_base_mock.h new file mode 100644 index 0000000..ab7b2b6 --- /dev/null +++ b/mock/appcore_multiwindow_base_mock.h @@ -0,0 +1,52 @@ +/* + * 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 "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)); + MOCK_METHOD1(appcore_multiwindow_base_class_add, + void(appcore_multiwindow_base_class)); + MOCK_METHOD1(appcore_multiwindow_base_instance_drop, + void(appcore_multiwindow_base_instance_h)); + MOCK_METHOD1(appcore_multiwindow_base_instance_find, + appcore_multiwindow_base_instance_h(const char *)); + MOCK_METHOD1(appcore_multiwindow_base_instance_get_class, + const appcore_multiwindow_base_class *(appcore_multiwindow_base_instance_h)); + MOCK_METHOD1(appcore_multiwindow_base_instance_exit, + void(appcore_multiwindow_base_instance_h)); + MOCK_METHOD1(appcore_multiwindow_base_instance_pause, + void(appcore_multiwindow_base_instance_h)); +}; + +#endif // UNIT_TESTS_MOCK_APPCORE_MULTIWINDOW_BASE_MOCK_H_ + diff --git a/mock/appcore_ui_base_mock.cc b/mock/appcore_ui_base_mock.cc new file mode 100644 index 0000000..59e774f --- /dev/null +++ b/mock/appcore_ui_base_mock.cc @@ -0,0 +1,28 @@ +/* + * 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 "appcore_ui_base_mock.h" + +#include + +#include "mock_hook.h" +#include "test_fixture.h" + +extern "C" int appcore_ui_base_init(appcore_ui_base_ops ops, int argc, + char **argv, void *data, unsigned int hint) { + return MOCK_HOOK_P5(AppCoreUIBaseMock, appcore_ui_base_init, + ops, argc, argv, data, hint); +} diff --git a/mock/appcore_ui_base_mock.h b/mock/appcore_ui_base_mock.h new file mode 100644 index 0000000..0c47b93 --- /dev/null +++ b/mock/appcore_ui_base_mock.h @@ -0,0 +1,34 @@ +/* + * 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_APP_CORE_UI_MOCK_H_ +#define UNIT_TESTS_MOCK_APP_CORE_UI_MOCK_H_ + +#include +#include + +#include "module_mock.h" + +class AppCoreUIBaseMock : public virtual ModuleMock { + public: + virtual ~AppCoreUIBaseMock() {} + + MOCK_METHOD5(appcore_ui_base_init, int (appcore_ui_base_ops, int, char **, + void *, unsigned int)); +}; + +#endif // UNIT_TESTS_MOCK_APP_CORE_UI_MOCK_H_ + diff --git a/mock/aul_mock.cc b/mock/aul_mock.cc new file mode 100644 index 0000000..0344ad7 --- /dev/null +++ b/mock/aul_mock.cc @@ -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. + */ + +#include "aul_mock.h" + +#include "mock_hook.h" +#include "test_fixture.h" + +extern "C" int aul_app_get_pkgid_bypid(int pid, char *pkgid, int len) { + return MOCK_HOOK_P3(AulMock, aul_app_get_pkgid_bypid, pid, pkgid, len); +} + +extern "C" int aul_app_com_send(const char *endpoint, bundle *envelope) { + return MOCK_HOOK_P2(AulMock, aul_app_com_send, endpoint, envelope); +} + +extern "C" int aul_app_get_appid_bypid(int pid, char *appid, int len) { + return MOCK_HOOK_P3(AulMock, aul_app_get_appid_bypid, pid, appid, len); +} diff --git a/mock/aul_mock.h b/mock/aul_mock.h new file mode 100644 index 0000000..31d3696 --- /dev/null +++ b/mock/aul_mock.h @@ -0,0 +1,35 @@ +/* + * 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_AUL_MOCK_H_ +#define UNIT_TESTS_MOCK_AUL_MOCK_H_ + +#include +#include + +#include "module_mock.h" + +class AulMock : public virtual ModuleMock { + public: + virtual ~AulMock() {} + + MOCK_METHOD3(aul_app_get_pkgid_bypid, int (int , char *, int)); + MOCK_METHOD2(aul_app_com_send, int (const char *, bundle *)); + MOCK_METHOD3(aul_app_get_appid_bypid, int (int , char *, int)); +}; + +#endif // UNIT_TESTS_MOCK_AUL_MOCK_H_ + diff --git a/mock/ecore_wl2_mock.cc b/mock/ecore_wl2_mock.cc new file mode 100644 index 0000000..f721a97 --- /dev/null +++ b/mock/ecore_wl2_mock.cc @@ -0,0 +1,95 @@ +/* + * 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 "ecore_wl2_mock.h" + +#include + +#include "mock_hook.h" +#include "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); +} + +extern "C" Ecore_Wl2_Window *ecore_evas_wayland2_window_get(const Ecore_Evas *ee) { + return MOCK_HOOK_P1(EcoreWl2Mock, ecore_evas_wayland2_window_get, ee); +} + +extern "C" Ecore_Evas *ecore_evas_ecore_evas_get(const Evas *e) { + return MOCK_HOOK_P1(EcoreWl2Mock, ecore_evas_ecore_evas_get, e); +} + +extern "C" Evas *evas_object_evas_get(const Eo *eo_obj) { + return MOCK_HOOK_P1(EcoreWl2Mock, evas_object_evas_get, eo_obj); +} + +extern "C" void evas_object_del(Evas_Object *obj) { + return MOCK_HOOK_P1(EcoreWl2Mock, evas_object_del, obj); +} + +extern "C" struct wl_surface *ecore_wl2_window_surface_get(Ecore_Wl2_Window *window) { + return MOCK_HOOK_P1(EcoreWl2Mock, ecore_wl2_window_surface_get, window); +} + +extern "C" void evas_object_data_set(Evas_Object *eo_obj, const char *key, + const void *data) { + return MOCK_HOOK_P3(EcoreWl2Mock, evas_object_data_set, eo_obj, key, data); +} + +extern "C" void evas_object_event_callback_add(Evas_Object *eo_obj, + Evas_Callback_Type type, Evas_Object_Event_Cb func, const void *data) { + return MOCK_HOOK_P4(EcoreWl2Mock, evas_object_event_callback_add, + eo_obj, type, func, data); +} + +extern "C" Ecore_Timer *ecore_timer_add(double in, + Ecore_Task_Cb func, const void *data) { + return MOCK_HOOK_P3(EcoreWl2Mock, ecore_timer_add, in, func, data); +} diff --git a/mock/ecore_wl2_mock.h b/mock/ecore_wl2_mock.h new file mode 100644 index 0000000..8d52836 --- /dev/null +++ b/mock/ecore_wl2_mock.h @@ -0,0 +1,65 @@ +/* + * 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 + +#include "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 *)); + MOCK_METHOD1(ecore_evas_wayland2_window_get, + Ecore_Wl2_Window *(const Ecore_Evas *)); + MOCK_METHOD1(ecore_evas_ecore_evas_get, + Ecore_Evas *(const Evas *)); + MOCK_METHOD1(evas_object_evas_get, + Evas *(const Eo *)); + MOCK_METHOD1(evas_object_del, + void (Evas_Object *)); + MOCK_METHOD1(ecore_wl2_window_surface_get, + struct wl_surface *(Ecore_Wl2_Window *)); + MOCK_METHOD3(evas_object_data_set, + void (Evas_Object *, const char *, const void *)); + MOCK_METHOD4(evas_object_event_callback_add, void (Evas_Object *, + Evas_Callback_Type, Evas_Object_Event_Cb, const void *)); + MOCK_METHOD3(ecore_timer_add, + Ecore_Timer *(double, Ecore_Task_Cb, const void *)); +}; + +#endif // UNIT_TESTS_MOCK_ECORE_WL2_MOCK_H_ diff --git a/mock/elm_mock.cc b/mock/elm_mock.cc new file mode 100644 index 0000000..93c8a1b --- /dev/null +++ b/mock/elm_mock.cc @@ -0,0 +1,45 @@ +/* + * 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 "elm_mock.h" + +#include + +#include "mock_hook.h" +#include "test_fixture.h" + +extern "C" Evas_Object * elm_win_add(Evas_Object *parent, + const char *name, Elm_Win_Type type) { + return MOCK_HOOK_P3(ElmMock, elm_win_add, parent, name, type); +} + +extern "C" void elm_win_wm_rotation_preferred_rotation_set( + Evas_Object *obj, int rotation) { + return MOCK_HOOK_P2( + ElmMock, elm_win_wm_rotation_preferred_rotation_set, obj, rotation); +} + +extern "C" void elm_win_wm_rotation_available_rotations_set(Elm_Win *obj, + const int *rotations, unsigned int count) { + return MOCK_HOOK_P3( + ElmMock, elm_win_wm_rotation_available_rotations_set, + obj, rotations, count); +} + +extern "C" int elm_win_aux_hint_add(Evas_Object *obj, + const char *hint, const char *val) { + return MOCK_HOOK_P3(ElmMock, elm_win_aux_hint_add, obj, hint, val); +} diff --git a/mock/elm_mock.h b/mock/elm_mock.h new file mode 100644 index 0000000..4abd4a5 --- /dev/null +++ b/mock/elm_mock.h @@ -0,0 +1,38 @@ +/* + * 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_ELM_MOCK_H_ +#define UNIT_TESTS_MOCK_ELM_MOCK_H_ + +#include +#include + +#include "module_mock.h" + +class ElmMock : public virtual ModuleMock { + public: + virtual ~ElmMock() {} + MOCK_METHOD3(elm_win_add, + Evas_Object *(Evas_Object *, const char *, Elm_Win_Type)); + MOCK_METHOD2(elm_win_wm_rotation_preferred_rotation_set, + void (Evas_Object *, int)); + MOCK_METHOD3(elm_win_wm_rotation_available_rotations_set, + void (Elm_Win *, const int *, unsigned int)); + MOCK_METHOD3(elm_win_aux_hint_add, + int (Evas_Object *, const char *, const char *)); +}; + +#endif // UNIT_TESTS_MOCK_ELM_MOCK_H_ diff --git a/mock/gio_mock.cc b/mock/gio_mock.cc new file mode 100644 index 0000000..4b64e69 --- /dev/null +++ b/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 "gio_mock.h" + +#include + +#include "mock_hook.h" +#include "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/mock/gio_mock.h b/mock/gio_mock.h new file mode 100755 index 0000000..d9c5f39 --- /dev/null +++ b/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 "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/mock/mock_hook.h b/mock/mock_hook.h new file mode 100644 index 0000000..af27bba --- /dev/null +++ b/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/mock/module_mock.h b/mock/module_mock.h new file mode 100644 index 0000000..9b19d89 --- /dev/null +++ b/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/mock/system_info_mock.cc b/mock/system_info_mock.cc new file mode 100644 index 0000000..37be469 --- /dev/null +++ b/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 "system_info_mock.h" + +#include + +#include "mock_hook.h" +#include "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/mock/system_info_mock.h b/mock/system_info_mock.h new file mode 100644 index 0000000..aaa3d0d --- /dev/null +++ b/mock/system_info_mock.h @@ -0,0 +1,31 @@ +/* + * 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 "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/mock/test_fixture.cc b/mock/test_fixture.cc new file mode 100644 index 0000000..27f5666 --- /dev/null +++ b/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 "test_fixture.h" + +#include + +std::unique_ptr TestFixture::mock_; diff --git a/mock/test_fixture.h b/mock/test_fixture.h new file mode 100644 index 0000000..1ea3b8f --- /dev/null +++ b/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 "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/packaging/appcore-watch.spec b/packaging/appcore-watch.spec index d5583b3..bafa43c 100644 --- a/packaging/appcore-watch.spec +++ b/packaging/appcore-watch.spec @@ -25,9 +25,15 @@ BuildRequires: pkgconfig(gio-2.0) BuildRequires: pkgconfig(screen_connector_provider) BuildRequires: pkgconfig(pkgmgr-info) BuildRequires: pkgconfig(capi-system-info) +BuildRequires: pkgconfig(gmock) BuildRequires: cmake Recommends: amd-mod-watch +%if 0%{?gcov:1} +BuildRequires: lcov +BuildRequires: zip +%endif + %description Watch application @@ -111,6 +117,15 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj mkdir -p %{buildroot}%{_libdir}/pkgconfig cp capi-appfw-watch-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-watch.info +genhtml appcore-watch.info -o appcore-watch.out +zip -r appcore-watch.zip appcore-watch.out +install -m 0644 appcore-watch.zip %{buildroot}%{_datadir}/gcov/ +%endif %post -p /sbin/ldconfig @@ -150,5 +165,5 @@ cp capi-appfw-watch-application.pc %{buildroot}%{_libdir}/pkgconfig %if 0%{?gcov:1} %files gcov -%{_datadir}/gcov/obj/* -%endif +%{_datadir}/gcov/* +%endif \ No newline at end of file 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..7c81c69 --- /dev/null +++ b/src/base/CMakeLists.txt @@ -0,0 +1,33 @@ +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} WATCH_BASE_SRCS) + +ADD_LIBRARY(${TARGET_WATCH_BASE} SHARED ${WATCH_BASE_SRCS}) +SET_TARGET_PROPERTIES(${TARGET_WATCH_BASE} PROPERTIES SOVERSION ${MAJORVER}) +SET_TARGET_PROPERTIES(${TARGET_WATCH_BASE} PROPERTIES VERSION ${FULLVER}) + +TARGET_INCLUDE_DIRECTORIES(${TARGET_WATCH_BASE} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) +TARGET_INCLUDE_DIRECTORIES(${TARGET_WATCH_BASE} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include/) + +APPLY_PKG_CONFIG(${TARGET_WATCH_BASE} PUBLIC + AUL_DEPS + DLOG_DEPS + ALARM_SERVICE_DEPS + APP_CONTROL_DEPS + APP_COMMON_DEPS + VCONF_DEPS + ECORE_DEPS + ECORE_WL2_DEPS + VCONF_INTERNAL_KEYS_DEPS + TZ_PLATFORM_CONFIG_DEPS + ICU_I18N_DEPS + GLIB_DEPS + GIO_DEPS + SCREEN_CONNECTOR_PROVIDER_DEPS + APPCORE_COMMON_DEPS + APPCORE_UI_DEPS + PKGMGR_INFO_DEPS + SYSTEM_INFO_DEPS +) + +CONFIGURE_FILE(../../appcore-watch-base.pc.in ../../appcore-watch-base.pc @ONLY) +INSTALL(TARGETS ${TARGET_WATCH_BASE} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../appcore-watch-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..94e23a2 --- /dev/null +++ b/src/efl_base/CMakeLists.txt @@ -0,0 +1,26 @@ +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} WATCH_APPLICATION_SRCS) + +ADD_LIBRARY(${TARGET_WATCH_APPLICATION} SHARED ${WATCH_APPLICATION_SRCS}) +SET_TARGET_PROPERTIES(${TARGET_WATCH_APPLICATION} PROPERTIES SOVERSION ${MAJORVER}) +SET_TARGET_PROPERTIES(${TARGET_WATCH_APPLICATION} PROPERTIES VERSION ${FULLVER}) +TARGET_LINK_LIBRARIES(${TARGET_WATCH_APPLICATION} PRIVATE ${TARGET_WATCH_BASE}) + +TARGET_INCLUDE_DIRECTORIES(${TARGET_WATCH_APPLICATION} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../) +TARGET_INCLUDE_DIRECTORIES(${TARGET_WATCH_APPLICATION} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../include/) + +APPLY_PKG_CONFIG(${TARGET_WATCH_APPLICATION} PUBLIC + DLOG_DEPS + APP_CONTROL_DEPS + APP_COMMON_DEPS + ELEMENTARY_DEPS + ECORE_WL2_DEPS + SCREEN_CONNECTOR_PROVIDER_DEPS +) + +CONFIGURE_FILE(../../appcore-watch.pc.in ../../appcore-watch.pc @ONLY) +INSTALL(TARGETS ${TARGET_WATCH_APPLICATION} DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/../../appcore-watch.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include/appcore-watch/ + 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..0821456 --- /dev/null +++ b/test/unit_tests/CMakeLists.txt @@ -0,0 +1,28 @@ +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ UNIT_TESTS_SRCS) +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../mock/ UNIT_TESTS_SRCS) +ADD_EXECUTABLE(${TARGET_WATCH_APPLICATION_UNIT_TEST} + ${UNIT_TESTS_SRCS} +) + +TARGET_INCLUDE_DIRECTORIES(${TARGET_WATCH_APPLICATION_UNIT_TEST} PUBLIC + "${CMAKE_CURRENT_SOURCE_DIR}/../" + "${CMAKE_CURRENT_SOURCE_DIR}/../../include" + "${CMAKE_CURRENT_SOURCE_DIR}/../../src" + "${CMAKE_CURRENT_SOURCE_DIR}/../../mock" +) + +APPLY_PKG_CONFIG(${TARGET_WATCH_APPLICATION_UNIT_TEST} PUBLIC + GLIB_DEPS + GMOCK_DEPS + BUNDLE_DEPS + GOBJECT_DEPS +) + +TARGET_LINK_LIBRARIES(${TARGET_WATCH_APPLICATION_UNIT_TEST} PUBLIC ${TARGET_WATCH_BASE} ${TARGET_WATCH_APPLICATION}) +SET_TARGET_PROPERTIES(${TARGET_WATCH_APPLICATION_UNIT_TEST} PROPERTIES COMPILE_FLAGS "-fPIE") +SET_TARGET_PROPERTIES(${TARGET_WATCH_APPLICATION_UNIT_TEST} PROPERTIES LINK_FLAGS "-pie") + +ADD_TEST( + NAME ${TARGET_WATCH_APPLICATION_UNIT_TEST} + COMMAND ${TARGET_WATCH_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/test_watch_app.cc b/test/unit_tests/test_watch_app.cc new file mode 100644 index 0000000..43394e2 --- /dev/null +++ b/test/unit_tests/test_watch_app.cc @@ -0,0 +1,276 @@ +/* + * 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 "watch_app.h" +#include "watch_app_internal.h" +#include "watch_app_extension.h" +#include "watch_app_efl.h" +#include "ecore_wl2_mock.h" +#include "system_info_mock.h" +#include "elm_mock.h" +#include "aul_mock.h" +#include "appcore_ui_base_mock.h" +#include "test_fixture.h" +#include "app_common_mock.h" + +using ::testing::_; +using ::testing::DoAll; +using ::testing::Return; +using ::testing::SetArgPointee; +using ::testing::Invoke; + +class Mocks : public ::testing::NiceMock, + public ::testing::NiceMock, + public ::testing::NiceMock, + public ::testing::NiceMock, + public ::testing::NiceMock, + public ::testing::NiceMock {}; + +class WatchAppTest : public TestFixture { + public: + WatchAppTest() : TestFixture(std::make_unique()) {} + virtual ~WatchAppTest() {} + + virtual void SetUp() { + } + + virtual void TearDown() { + } +}; + +bool __app_create_cb(int width, int height, void *user_data) { + return true; +} + +void __app_control_cb(app_control_h app_control, void *user_data) { +} + +void __app_pause_cb(void *user_data) { +} + +void __app_resume_cb(void *user_data) { +} + +void __app_terminate_cb(void *user_data) { +} + +void __app_time_tick_cb(watch_time_h watch_time, void *user_data) { +} + +void __app_ambient_tick_cb(watch_time_h watch_time, void *user_data) { +} + +void __app_ambient_changed_cb(bool ambient_mode, void *user_data) { +} + +TEST_F(WatchAppTest, watch_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); + + watch_app_lifecycle_callback_s callback; + callback.create = __app_create_cb; + callback.app_control = __app_control_cb; + callback.pause = __app_pause_cb; + callback.resume = __app_resume_cb; + callback.terminate = __app_terminate_cb; + callback.time_tick = __app_time_tick_cb; + callback.ambient_tick = __app_ambient_tick_cb; + callback.ambient_changed = __app_ambient_changed_cb; + + EXPECT_CALL(GetMock(), + system_info_get_platform_bool(_, _)). + WillOnce(DoAll( + SetArgPointee<1>(true), + Return(0))); + + EXPECT_CALL(GetMock(), + appcore_ui_base_init(_, _, _, _, _)). + WillOnce(Return(0)); + + ret = watch_app_main(argc, argv, &callback, nullptr); + EXPECT_EQ(APP_ERROR_NONE, ret); +} + +void __app_event_cb(app_event_info_h event_info, void *user_data) { +} + +TEST_F(WatchAppTest, watch_app_add_event_handler) { + app_event_handler_h handler; + int ret = watch_app_add_event_handler(&handler, + APP_EVENT_LOW_MEMORY, __app_event_cb, nullptr); + EXPECT_EQ(APP_ERROR_NONE, ret); +} + +TEST_F(WatchAppTest, watch_app_remove_event_handler) { + app_event_handler_h handler; + int ret = watch_app_add_event_handler(&handler, + APP_EVENT_LOW_MEMORY, __app_event_cb, nullptr); + EXPECT_EQ(APP_ERROR_NONE, ret); + + ret = watch_app_remove_event_handler(handler); + EXPECT_EQ(APP_ERROR_NONE, ret); +} + +TEST_F(WatchAppTest, watch_app_exit) { + watch_app_exit(); +} + +TEST_F(WatchAppTest, watch_app_set_time_tick_frequency) { + int ret = watch_app_set_time_tick_frequency(1, + WATCH_APP_TIME_TICKS_PER_SECOND); + EXPECT_EQ(APP_ERROR_NONE, ret); +} + +TEST_F(WatchAppTest, watch_app_get_time_tick_frequency) { + int ticks; + watch_app_time_tick_resolution_e type; + int ret = watch_app_get_time_tick_frequency(&ticks, &type); + EXPECT_EQ(APP_ERROR_NONE, ret); +} + +TEST_F(WatchAppTest, watch_app_set_ambient_tick_type) { + int ret = watch_app_set_ambient_tick_type( + WATCH_APP_AMBIENT_TICK_EVERY_MINUTE); + EXPECT_EQ(APP_ERROR_NONE, ret); +} + +TEST_F(WatchAppTest, watch_app_get_ambient_tick_type) { + watch_app_ambient_tick_type_e type; + int ret = watch_app_get_ambient_tick_type(&type); + EXPECT_EQ(APP_ERROR_NONE, ret); +} + +TEST_F(WatchAppTest, watch_time_get_current_time) { + watch_time_h time; + int ret = watch_time_get_current_time(&time); + EXPECT_EQ(APP_ERROR_NONE, ret); +} + +TEST_F(WatchAppTest, watch_time_delete) { + watch_time_h time; + int ret = watch_time_get_current_time(&time); + EXPECT_EQ(APP_ERROR_NONE, ret); + ret = watch_time_delete(time); + EXPECT_EQ(APP_ERROR_NONE, ret); +} + +TEST_F(WatchAppTest, watch_time_info) { + watch_time_h time; + int ret = watch_time_get_current_time(&time); + EXPECT_EQ(APP_ERROR_NONE, ret); + + int year, month, day, day_of_week, hour, hour24, minute, second, millisecond; + struct tm utc_time; + time_t utc_timestamp; + char* time_zone_id; + bool status; + bool daylight; + + ret = watch_time_get_year(time, &year); + EXPECT_EQ(APP_ERROR_NONE, ret); + ret = watch_time_get_month(time, &month); + EXPECT_EQ(APP_ERROR_NONE, ret); + ret = watch_time_get_day(time, &day); + EXPECT_EQ(APP_ERROR_NONE, ret); + ret = watch_time_get_day_of_week(time, &day_of_week); + EXPECT_EQ(APP_ERROR_NONE, ret); + ret = watch_time_get_hour(time, &hour); + EXPECT_EQ(APP_ERROR_NONE, ret); + ret = watch_time_get_hour24(time, &hour24); + EXPECT_EQ(APP_ERROR_NONE, ret); + ret = watch_time_get_minute(time, &minute); + EXPECT_EQ(APP_ERROR_NONE, ret); + ret = watch_time_get_second(time, &second); + EXPECT_EQ(APP_ERROR_NONE, ret); + ret = watch_time_get_millisecond(time, &millisecond); + EXPECT_EQ(APP_ERROR_NONE, ret); + ret = watch_time_get_utc_time(time, &utc_time); + EXPECT_EQ(APP_ERROR_NONE, ret); + ret = watch_time_get_utc_timestamp(time, &utc_timestamp); + EXPECT_EQ(APP_ERROR_NONE, ret); + ret = watch_time_get_time_zone(time, &time_zone_id); + EXPECT_EQ(APP_ERROR_INVALID_PARAMETER, ret); + ret = watch_time_get_dst_status(time, &status); + EXPECT_EQ(APP_ERROR_NONE, ret); + ret = watch_time_get_daylight_time_status(time, &daylight); + EXPECT_EQ(APP_ERROR_NONE, ret); +} + +TEST_F(WatchAppTest, watch_app_ambient_get_extra_negative) { + bundle* extra; + int ret = watch_app_ambient_get_extra(&extra); + EXPECT_EQ(APP_ERROR_INVALID_CONTEXT, ret); +} + +int __aul_app_get_appid_bypid(int pid, char *appid, int len) { + snprintf(appid, 10, "%s", "test"); + return 0; +} + +TEST_F(WatchAppTest, watch_app_ambient_notify_event) { + EXPECT_CALL(GetMock(), + aul_app_get_appid_bypid(_, _, _)) + .WillOnce(Invoke(__aul_app_get_appid_bypid)); + EXPECT_CALL(GetMock(), aul_app_com_send(_, _)).WillOnce(Return(0)); + + tizen_base::Bundle data; + int ret = watch_app_ambient_notify_event( + WATCH_APP_AMBIENT_EVENT_PREPARE, data.GetHandle()); + EXPECT_EQ(APP_ERROR_NONE, ret); +} + +TEST_F(WatchAppTest, widget_app_get_elm_win) { + EXPECT_CALL(GetMock(), + elm_win_add(_, _, _)). + WillOnce(Return((Evas_Object *)calloc(1, sizeof(char)))); + + EXPECT_CALL(GetMock(), + ecore_evas_wayland2_window_get(_)). + WillOnce(Return((Ecore_Wl2_Window *)calloc(1, sizeof(char)))); + + EXPECT_CALL(GetMock(), + ecore_wl2_window_surface_get(_)). + WillOnce(Return(nullptr)); + + EXPECT_CALL(GetMock(), + evas_object_event_callback_add(_, _, _, _)). + Times(1); + + EXPECT_CALL(GetMock(), + evas_object_data_set(_, _, _)). + Times(1); + + Evas_Object* win; + int ret = watch_app_get_elm_win(&win); + EXPECT_EQ(APP_ERROR_NONE, ret); +} -- 2.7.4