-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)
--- /dev/null
+# 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)
--- /dev/null
+/*
+ * 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 <gio/gio.h>
+
+#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);
+}
--- /dev/null
+/*
+ * 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 <gmock/gmock.h>
+#include <appcore_multiwindow_base.h>
+
+#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_
+
--- /dev/null
+/*
+ * 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 <gio/gio.h>
+
+#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);
+}
--- /dev/null
+/*
+ * 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 <gmock/gmock.h>
+#include <appcore_multiwindow_base.h>
+
+#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_
+
--- /dev/null
+/*
+ * 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 <gio/gio.h>
+
+#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);
+}
--- /dev/null
+/*
+ * 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 <gmock/gmock.h>
+#include <appcore_ui_base.h>
+
+#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_
+
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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 <gmock/gmock.h>
+#include <appcore_multiwindow_base.h>
+
+#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_
+
--- /dev/null
+/*
+ * 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 <gio/gio.h>
+
+#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);
+}
--- /dev/null
+/*
+ * 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 <gmock/gmock.h>
+#include <Eina.h>
+#include <Ecore_Wl2.h>
+#include <Elementary.h>
+
+#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_
--- /dev/null
+/*
+ * 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 <gio/gio.h>
+
+#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);
+}
--- /dev/null
+/*
+ * 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 <gmock/gmock.h>
+#include <Elementary.h>
+
+#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_
--- /dev/null
+/*
+ * 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 <gio/gio.h>
+
+#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);
+}
--- /dev/null
+/*
+ * 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 <gio/gio.h>
+#include <gmock/gmock.h>
+
+#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_
--- /dev/null
+/*
+ * 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<MOCK_CLASS>().f()
+#define MOCK_HOOK_P1(MOCK_CLASS, f, p1) \
+ TestFixture::GetMock<MOCK_CLASS>().f(p1)
+#define MOCK_HOOK_P2(MOCK_CLASS, f, p1, p2) \
+ TestFixture::GetMock<MOCK_CLASS>().f(p1, p2)
+#define MOCK_HOOK_P3(MOCK_CLASS, f, p1, p2, p3) \
+ TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3)
+#define MOCK_HOOK_P4(MOCK_CLASS, f, p1, p2, p3, p4) \
+ TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4)
+#define MOCK_HOOK_P5(MOCK_CLASS, f, p1, p2, p3, p4, p5) \
+ TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5)
+#define MOCK_HOOK_P6(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6) \
+ TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5, p6)
+#define MOCK_HOOK_P7(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7) \
+ TestFixture::GetMock<MOCK_CLASS>().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<MOCK_CLASS>().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<MOCK_CLASS>().f( \
+ p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)
+
+#endif // UNIT_TESTS_MOCK_MOCK_HOOK_H_
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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 <gio/gio.h>
+
+#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);
+}
--- /dev/null
+/*
+ * 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 <gmock/gmock.h>
+
+#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_
--- /dev/null
+/*
+ * 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 <memory>
+
+std::unique_ptr<ModuleMock> TestFixture::mock_;
--- /dev/null
+/*
+ * 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 <gtest/gtest.h>
+
+#include <memory>
+#include <stdexcept>
+#include <string>
+#include <utility>
+
+#include "module_mock.h"
+
+class TestFixture : public ::testing::Test {
+ public:
+ explicit TestFixture(std::unique_ptr<ModuleMock>&& mock) {
+ mock_ = std::move(mock);
+ }
+ virtual ~TestFixture() {
+ mock_.reset();
+ }
+
+ virtual void SetUp() {}
+ virtual void TearDown() {}
+
+ template <typename T>
+ static T& GetMock() {
+ auto ptr = dynamic_cast<T*>(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<ModuleMock> mock_;
+};
+
+#endif // UNIT_TESTS_MOCK_TEST_FIXTURE_H_
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
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
%if 0%{?gcov:1}
%files gcov
-%{_datadir}/gcov/obj/*
-%endif
+%{_datadir}/gcov/*
+%endif
\ No newline at end of file
--- /dev/null
+ADD_SUBDIRECTORY(base)
+ADD_SUBDIRECTORY(efl_base)
\ No newline at end of file
--- /dev/null
+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)
--- /dev/null
+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"
+ )
--- /dev/null
+ADD_SUBDIRECTORY(unit_tests)
--- /dev/null
+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}
+)
--- /dev/null
+// 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 <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+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;
+}
--- /dev/null
+/*
+ * 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 <stdlib.h>
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+#include <bundle_cpp.h>
+#include <bundle_internal.h>
+
+#include <iostream>
+#include <memory>
+
+#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<ElmMock>,
+ public ::testing::NiceMock<AppCommonMock>,
+ public ::testing::NiceMock<AulMock>,
+ public ::testing::NiceMock<SystemInfoMock>,
+ public ::testing::NiceMock<AppCoreUIBaseMock>,
+ public ::testing::NiceMock<EcoreWl2Mock> {};
+
+class WatchAppTest : public TestFixture {
+ public:
+ WatchAppTest() : TestFixture(std::make_unique<Mocks>()) {}
+ 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<SystemInfoMock>(),
+ system_info_get_platform_bool(_, _)).
+ WillOnce(DoAll(
+ SetArgPointee<1>(true),
+ Return(0)));
+
+ EXPECT_CALL(GetMock<AppCoreUIBaseMock>(),
+ 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<AulMock>(),
+ aul_app_get_appid_bypid(_, _, _))
+ .WillOnce(Invoke(__aul_app_get_appid_bypid));
+ EXPECT_CALL(GetMock<AulMock>(), 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<ElmMock>(),
+ elm_win_add(_, _, _)).
+ WillOnce(Return((Evas_Object *)calloc(1, sizeof(char))));
+
+ EXPECT_CALL(GetMock<EcoreWl2Mock>(),
+ ecore_evas_wayland2_window_get(_)).
+ WillOnce(Return((Ecore_Wl2_Window *)calloc(1, sizeof(char))));
+
+ EXPECT_CALL(GetMock<EcoreWl2Mock>(),
+ ecore_wl2_window_surface_get(_)).
+ WillOnce(Return(nullptr));
+
+ EXPECT_CALL(GetMock<EcoreWl2Mock>(),
+ evas_object_event_callback_add(_, _, _, _)).
+ Times(1);
+
+ EXPECT_CALL(GetMock<EcoreWl2Mock>(),
+ evas_object_data_set(_, _, _)).
+ Times(1);
+
+ Evas_Object* win;
+ int ret = watch_app_get_elm_win(&win);
+ EXPECT_EQ(APP_ERROR_NONE, ret);
+}