SET(VERSION_MAJOR 1)
SET(VERSION "${VERSION_MAJOR}.0.0")
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED
- dlog
- aul
- vconf
- sqlite3
- glib-2.0
- gio-2.0
- gio-unix-2.0
- bundle
- pkgmgr
- notification
- notification-ex
- badge
- libsmack
- shortcut
- pkgmgr-info
- libsystemd
- capi-appfw-app-manager
- alarm-service
- libtzplatform-config
- security-manager
-)
+ADD_SUBDIRECTORY(src)
-FOREACH(flag ${pkgs_CFLAGS})
- SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -Werror -Winline")
-
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++11")
-SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
-SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
-
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
-
-AUX_SOURCE_DIRECTORY(src SOURCES)
-ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES})
-
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS} -fPIE")
-SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-pie")
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
-
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
CONFIGURE_FILE(data-provider-master.conf.in data-provider-master.conf @ONLY)
CONFIGURE_FILE(org.tizen.data-provider-master.service.in org.tizen.data_provider_service.service @ONLY)
--- /dev/null
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED
+ dlog
+ aul
+ vconf
+ sqlite3
+ glib-2.0
+ gio-2.0
+ gio-unix-2.0
+ bundle
+ pkgmgr
+ notification
+ notification-ex
+ badge
+ libsmack
+ shortcut
+ pkgmgr-info
+ libsystemd
+ capi-appfw-app-manager
+ alarm-service
+ libtzplatform-config
+ security-manager
+)
+
+FOREACH(flag ${pkgs_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -Werror -Winline")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++14")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../include)
+
+AUX_SOURCE_DIRECTORY(../src SOURCES)
+ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES})
+
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS} -fPIE")
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-pie")
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2023 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_appid_bypid_for_uid(int arg0, char* arg1, int arg2,
+ uid_t arg3) {
+ return MOCK_HOOK_P4(AulMock, aul_app_get_appid_bypid_for_uid, arg0, arg1,
+ arg2, arg3);
+}
+
+extern "C" int aul_app_get_appid_bypid(int pid, char* appid, int size) {
+ return MOCK_HOOK_P3(AulMock, aul_app_get_appid_bypid, pid, appid, size);
+}
--- /dev/null
+/*
+ * Copyright (c) 2023 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 MOCK_AUL_MOCK_H_
+#define MOCK_AUL_MOCK_H_
+
+#include <aul.h>
+#include <aul_svc.h>
+#include <gmock/gmock.h>
+
+#include "module_mock.h"
+
+class AulMock : public virtual ModuleMock {
+ public:
+ virtual ~AulMock() {}
+
+ MOCK_METHOD4(aul_app_get_appid_bypid_for_uid, int (int, char*, int, uid_t));
+ MOCK_METHOD3(aul_app_get_appid_bypid, int (int, char*, int));
+};
+
+#endif // MOCK_AUL_MOCK_H_
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2023 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 "badge_mock.h"
+#include "mock_hook.h"
+#include "test_fixture.h"
+
+extern "C" int badge_db_init(void) {
+ return MOCK_HOOK_P0(BadgeMock, badge_db_init);
+}
+
+extern "C" int badge_db_is_existing(const char* arg0, bool* arg1, uid_t arg2) {
+ return MOCK_HOOK_P3(BadgeMock, badge_db_is_existing, arg0, arg1, arg2);
+}
+
+extern "C" int badge_db_get_list(GList** arg0, uid_t arg1) {
+ return MOCK_HOOK_P2(BadgeMock, badge_db_get_list, arg0, arg1);
+}
+
+extern "C" int badge_db_insert(const char* arg0, const char* arg1,
+ const char* arg2, uid_t arg3) {
+ return MOCK_HOOK_P4(BadgeMock, badge_db_insert, arg0, arg1, arg2, arg3);
+}
+
+extern "C" int badge_db_delete(const char* arg0, const char* arg1,
+ uid_t arg2, pid_t arg3) {
+ return MOCK_HOOK_P4(BadgeMock, badge_db_delete, arg0, arg1, arg2, arg3);
+}
+
+extern "C" int badge_db_set_count(const char* arg0, const char* arg1,
+ unsigned int arg2, uid_t arg3, pid_t arg4) {
+ return MOCK_HOOK_P5(BadgeMock, badge_db_set_count, arg0, arg1, arg2, arg3, arg4);
+}
+
+extern "C" int badge_db_get_count(const char* arg0, unsigned int* arg1,
+ uid_t arg2) {
+ return MOCK_HOOK_P3(BadgeMock, badge_db_get_count, arg0, arg1, arg2);
+}
+
+extern "C" int badge_db_set_display_option(const char* arg0, unsigned int arg1,
+ uid_t arg2) {
+ return MOCK_HOOK_P3(BadgeMock, badge_db_set_display_option, arg0, arg1, arg2);
+}
+
+extern "C" int badge_db_get_display_option(const char* arg0, unsigned int* arg1,
+ uid_t arg2) {
+ return MOCK_HOOK_P3(BadgeMock, badge_db_get_display_option, arg0, arg1, arg2);
+}
+
+extern "C" int badge_db_get_allow_to_display_by_appid(char* arg0, int* arg1,
+ uid_t arg2) {
+ return MOCK_HOOK_P3(BadgeMock, badge_db_get_allow_to_display_by_appid, arg0,
+ arg1, arg2);
+}
+
+extern "C" int badge_db_update_setting(char* arg0, char* arg1, int arg2,
+ uid_t arg3) {
+ return MOCK_HOOK_P4(BadgeMock, badge_db_update_setting, arg0, arg1, arg2, arg3);
+}
+
+extern "C" int badge_setting_get_appid(badge_setting_h arg0, char** arg1) {
+ return MOCK_HOOK_P2(BadgeMock, badge_setting_get_appid, arg0, arg1);
+}
+
+extern "C" int badge_db_get_setting_by_appid(const char* arg0,
+ badge_setting_h* arg1, uid_t arg2) {
+ return MOCK_HOOK_P3(BadgeMock, badge_db_get_setting_by_appid, arg0, arg1, arg2);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2023 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 MOCK_BADGE_MOCK_H_
+#define MOCK_BADGE_MOCK_H_
+
+#include <badge.h>
+#include <badge_db.h>
+#include <badge_setting.h>
+#include <badge_setting_service.h>
+#include <gmock/gmock.h>
+
+#include "module_mock.h"
+
+class BadgeMock : public virtual ModuleMock {
+ public:
+ virtual ~BadgeMock() {}
+
+ MOCK_METHOD0(badge_db_init, int (void));
+ MOCK_METHOD3(badge_db_is_existing, int (const char*, bool*, uid_t));
+ MOCK_METHOD2(badge_db_get_list, int (GList**, uid_t));
+ MOCK_METHOD4(badge_db_insert, int (const char*, const char*, const char*,
+ uid_t));
+ MOCK_METHOD4(badge_db_delete, int (const char*, const char*, uid_t, pid_t));
+ MOCK_METHOD5(badge_db_set_count, int (const char*, const char*, unsigned int,
+ uid_t, pid_t));
+ MOCK_METHOD3(badge_db_get_count, int (const char*, unsigned int*, uid_t));
+ MOCK_METHOD3(badge_db_set_display_option, int (const char*, unsigned int,
+ uid_t));
+ MOCK_METHOD3(badge_db_get_display_option, int (const char*, unsigned int*,
+ uid_t));
+ MOCK_METHOD3(badge_db_get_allow_to_display_by_appid, int (char*, int*,
+ uid_t));
+ MOCK_METHOD4(badge_db_update_setting, int (char*, char*, int, uid_t));
+ MOCK_METHOD2(badge_setting_get_appid, int (badge_setting_h, char**));
+ MOCK_METHOD3(badge_db_get_setting_by_appid, int (const char*,
+ badge_setting_h*, uid_t));
+
+};
+
+#endif // MOCK_BADGE_MOCK_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" void g_dbus_node_info_unref(GDBusNodeInfo* arg0) {
+ return MOCK_HOOK_P1(GioMock, g_dbus_node_info_unref, arg0);
}
extern "C" GDBusMessage* g_dbus_message_new_method_call(const gchar* arg0,
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* arg1,
+ const gchar* arg2, const gchar* arg3, const gchar* arg4, const gchar* arg5,
+ GVariant* arg6, GError** arg7) {
+ return MOCK_HOOK_P7(GioMock, g_dbus_connection_emit_signal, arg1, arg2,
+ arg3, arg4, arg5, arg6, arg7);
}
extern "C" guint g_dbus_connection_signal_subscribe(GDBusConnection* arg0,
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" void g_dbus_connection_signal_unsubscribe(
+ GDBusConnection* arg0, guint arg1) {
+ return MOCK_HOOK_P2(GioMock, g_dbus_connection_signal_unsubscribe,
+ arg0, arg1);
}
-extern "C" guint g_bus_watch_name_on_connection(
- GDBusConnection* arg0, const gchar* arg1, GBusNameWatcherFlags arg2,
- GBusNameAppearedCallback arg3, GBusNameVanishedCallback arg4,
- gpointer arg5, GDestroyNotify arg6) {
- return MOCK_HOOK_P7(GioMock, g_bus_watch_name_on_connection,
+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" GVariant* g_dbus_message_get_body(GDBusMessage* arg0) {
+ return MOCK_HOOK_P1(GioMock, g_dbus_message_get_body, arg0);
+}
+
+extern "C" void g_dbus_method_invocation_return_value(
+ GDBusMethodInvocation* arg0, GVariant* arg1) {
+ MOCK_HOOK_P2(GioMock, g_dbus_method_invocation_return_value, arg0, arg1);
+}
+
+extern "C" guint g_bus_watch_name_on_connection(GDBusConnection* arg0,
+ const gchar* arg1, GBusNameWatcherFlags arg2, GBusNameAppearedCallback arg3,
+ GBusNameVanishedCallback arg4, gpointer arg5, GDestroyNotify arg6) {
+ return MOCK_HOOK_P7(GioMock, g_bus_watch_name_on_connection, 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" 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_bus_own_name(GBusType arg0, const gchar* arg1,
+ GBusNameOwnerFlags arg2, GBusAcquiredCallback arg3,
+ GBusNameAcquiredCallback arg4, GBusNameLostCallback arg5, gpointer arg6,
+ GDestroyNotify arg7) {
+ return MOCK_HOOK_P8(GioMock, g_bus_own_name, arg0, arg1, arg2, arg3, arg4,
+ arg5, arg6, arg7);
+}
+
extern "C" void g_bus_unwatch_name(guint arg0) {
return MOCK_HOOK_P1(GioMock, g_bus_unwatch_name, arg0);
}
-extern "C" void g_dbus_connection_signal_unsubscribe(
- GDBusConnection* arg0, guint arg1) {
- return MOCK_HOOK_P2(GioMock, g_dbus_connection_signal_unsubscribe,
- arg0, arg1);
+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" const gchar* g_dbus_connection_get_unique_name(GDBusConnection* connection) {
- return MOCK_HOOK_P1(GioMock, g_dbus_connection_get_unique_name, connection);
+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" gboolean g_source_remove(guint tag) {
- return MOCK_HOOK_P1(GioMock, g_source_remove, tag);
+extern "C" guint g_bus_watch_name(GBusType arg0, const gchar* arg1,
+ GBusNameWatcherFlags arg2, GBusNameAppearedCallback arg3,
+ GBusNameVanishedCallback arg4, gpointer arg5, GDestroyNotify arg6) {
+ return MOCK_HOOK_P7(GioMock, g_bus_watch_name, arg0, arg1, arg2, arg3, arg4,
+ arg5, arg6);
+}
+
+extern "C" void g_object_unref(gpointer arg0) {
+ return MOCK_HOOK_P1(GioMock, g_object_unref, arg0);
+}
+
+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);
}
public:
virtual ~GioMock() {}
- MOCK_METHOD3(g_bus_get_sync,
- GDBusConnection*(GBusType, GCancellable*, GError**));
+ MOCK_METHOD1(g_dbus_node_info_unref, void (GDBusNodeInfo*));
+
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_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_METHOD7(g_bus_watch_name_on_connection,
- guint(GDBusConnection*, const gchar*, GBusNameWatcherFlags,
- GBusNameAppearedCallback, GBusNameVanishedCallback, gpointer,
- GDestroyNotify));
- MOCK_METHOD1(g_bus_unwatch_name, void(guint));
+
MOCK_METHOD2(g_dbus_connection_signal_unsubscribe,
- void(GDBusConnection*, guint));
- MOCK_METHOD1(g_dbus_connection_get_unique_name, const gchar*(GDBusConnection*));
- MOCK_METHOD1(g_source_remove, gboolean(guint));
+ void(GDBusConnection*, guint));
+
+ MOCK_METHOD7(g_dbus_connection_send_message_with_reply_sync,
+ GDBusMessage*(GDBusConnection*, GDBusMessage*, GDBusSendMessageFlags,
+ gint, volatile guint32*, GCancellable*, GError**));
+
+ MOCK_METHOD1(g_dbus_message_get_body, GVariant*(GDBusMessage*));
+
+ MOCK_METHOD2(g_dbus_method_invocation_return_value,
+ void (GDBusMethodInvocation*, GVariant*));
+
+ MOCK_METHOD7(g_bus_watch_name_on_connection, guint(GDBusConnection*,
+ const gchar*, GBusNameWatcherFlags, GBusNameAppearedCallback,
+ GBusNameVanishedCallback, gpointer, GDestroyNotify));
+
+ MOCK_METHOD7(g_bus_own_name_on_connection,
+ guint(GDBusConnection*, const gchar*, GBusNameOwnerFlags,
+ GBusNameAcquiredCallback, GBusNameLostCallback,
+ gpointer, GDestroyNotify));
+
+ MOCK_METHOD2(g_dbus_node_info_new_for_xml, GDBusNodeInfo* (const gchar*,
+ GError**));
+
+ MOCK_METHOD8(g_bus_own_name,
+ guint(GBusType, const gchar*,
+ GBusNameOwnerFlags, GBusAcquiredCallback, GBusNameAcquiredCallback,
+ GBusNameLostCallback, gpointer, GDestroyNotify));
+
+ MOCK_METHOD1(g_bus_unwatch_name, void(guint));
+
+ MOCK_METHOD2(g_dbus_message_set_body, void(GDBusMessage*, GVariant*));
+
+ MOCK_METHOD7(g_dbus_connection_register_object, guint (GDBusConnection*,
+ const gchar*, GDBusInterfaceInfo*, const GDBusInterfaceVTable*, gpointer,
+ GDestroyNotify, GError**));
+
+ MOCK_METHOD7(g_bus_watch_name, guint(GBusType, const gchar*,
+ GBusNameWatcherFlags, GBusNameAppearedCallback,
+ GBusNameVanishedCallback, gpointer, GDestroyNotify));
+
+ MOCK_METHOD1(g_object_unref, void(gpointer));
+
+ MOCK_METHOD3(g_bus_get_sync,
+ GDBusConnection*(GBusType, GCancellable*, GError**));
+
};
-#endif // MOCK_GIO_MOCK_H_
+#endif // MOCK_GIO_MOCK_H_
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2023 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 <notification_noti.h>
+
+#include "notification_mock.h"
+#include "mock_hook.h"
+#include "test_fixture.h"
+
+extern "C" notification_h notification_create(notification_type_e arg0) {
+ return MOCK_HOOK_P1(NotificationMock, notification_create, arg0);
+}
+
+extern "C" int notification_free(notification_h arg0) {
+ return MOCK_HOOK_P1(NotificationMock, notification_free, arg0);
+}
+
+extern "C" int notification_get_id(notification_h arg0, int* arg1, int* arg2) {
+ return MOCK_HOOK_P3(NotificationMock, notification_get_id, arg0, arg1, arg2);
+}
+
+extern "C" int notification_noti_check_tag(notification_h arg0) {
+ return MOCK_HOOK_P1(NotificationMock, notification_noti_check_tag, arg0);
+}
+
+extern "C" int notification_noti_update(notification_h arg0) {
+ return MOCK_HOOK_P1(NotificationMock, notification_noti_update, arg0);
+}
+
+extern "C" int notification_noti_delete_by_priv_id_get_changes(
+ const char* arg0, int arg1, int* arg2, uid_t arg3) {
+ return MOCK_HOOK_P4(NotificationMock,
+ notification_noti_delete_by_priv_id_get_changes, arg0, arg1, arg2, arg3);
+}
+
+extern "C" int notification_noti_delete_by_display_applist(
+ int arg0, int* arg1, notification_deleted_list_info_s** arg2, uid_t arg3) {
+ return MOCK_HOOK_P4(NotificationMock,
+ notification_noti_delete_by_display_applist, arg0, arg1, arg2, arg3);
+}
+
+extern "C" int notification_noti_delete_all(notification_type_e arg0,
+ const char* arg1, int* arg2, int** arg3, uid_t arg4) {
+ return MOCK_HOOK_P5(NotificationMock,
+ notification_noti_delete_all, arg0, arg1, arg2, arg3, arg4);
+}
+
+extern "C" int notification_noti_get_count(
+ notification_type_e arg0, const char* arg1, int arg2, int arg3, int* arg4,
+ uid_t arg5) {
+ return MOCK_HOOK_P6(NotificationMock,
+ notification_noti_get_count, arg0, arg1, arg2, arg3, arg4, arg5);
+}
+
+extern "C" int notification_noti_get_all_count(
+ notification_type_e arg0, int* arg1, uid_t arg2) {
+ return MOCK_HOOK_P3(NotificationMock, notification_noti_get_all_count, arg0,
+ arg1, arg2);
+}
+
+extern "C" int notification_noti_get_by_tag(
+ notification_h arg0, char* arg1, char* arg2, uid_t arg3) {
+ return MOCK_HOOK_P4(NotificationMock, notification_noti_get_by_tag, arg0,
+ arg1, arg2, arg3);
+}
+
+extern "C" int notification_noti_get_by_priv_id(
+ notification_h arg0, int arg1) {
+ return MOCK_HOOK_P2(NotificationMock, notification_noti_get_by_priv_id, arg0,
+ arg1);
+}
+
+extern "C" int notification_get_event_flag(notification_h arg0,
+ bool* arg1) {
+ return MOCK_HOOK_P2(NotificationMock, notification_get_event_flag,
+ arg0, arg1);
+}
+
+extern "C" int notification_noti_get_detail_list(const char* arg0, int arg1,
+ int arg2, int arg3, notification_list_h* arg4, uid_t arg5) {
+ return MOCK_HOOK_P6(NotificationMock, notification_noti_get_detail_list,
+ arg0, arg1, arg2, arg3, arg4, arg5);
+}
+
+extern "C" int notification_noti_add_template(notification_h arg0,
+ char* arg1) {
+ return MOCK_HOOK_P2(NotificationMock, notification_noti_add_template,
+ arg0, arg1);
+}
+
+extern "C" int notification_noti_get_package_template(notification_h arg0,
+ char* arg1, char* arg2) {
+ return MOCK_HOOK_P3(NotificationMock, notification_noti_get_package_template,
+ arg0, arg1, arg2);
+}
+
+extern "C" int notification_get_uid(notification_h arg0, uid_t* arg1) {
+ return MOCK_HOOK_P2(NotificationMock, notification_get_uid, arg0, arg1);
+}
+
+extern "C" int notification_set_uid(notification_h arg0, uid_t arg1) {
+ return MOCK_HOOK_P2(NotificationMock, notification_set_uid, arg0, arg1);
+}
+
+extern "C" int notification_ipc_make_noti_from_gvariant(notification_h arg0,
+ GVariant* arg1) {
+ return MOCK_HOOK_P2(NotificationMock, notification_ipc_make_noti_from_gvariant,
+ arg0, arg1);
+}
+
+extern "C" GVariant* notification_ipc_make_gvariant_from_noti(notification_h arg0,
+ bool arg1) {
+ return MOCK_HOOK_P2(NotificationMock, notification_ipc_make_gvariant_from_noti,
+ arg0, arg1);
+}
+
+extern "C" int notification_db_init(void) {
+ return MOCK_HOOK_P0(NotificationMock, notification_db_init);
+}
+
+extern "C" int notification_init_default_viewer(void) {
+ return MOCK_HOOK_P0(NotificationMock, notification_init_default_viewer);
+}
+
+extern "C" int notification_system_setting_init_system_setting_table(
+ uid_t arg0) {
+ return MOCK_HOOK_P1(NotificationMock,
+ notification_system_setting_init_system_setting_table, arg0);
+}
+
+extern "C" int notification_system_setting_get_dnd_schedule_enabled_uid(
+ uid_t** arg0, int* arg1) {
+ return MOCK_HOOK_P2(NotificationMock,
+ notification_system_setting_get_dnd_schedule_enabled_uid, arg0, arg1);
+}
+
+extern "C" int notification_setting_db_update(const char* arg0, const char* arg1,
+ int arg2, int arg3, int arg4, int arg5, int arg6, uid_t arg7) {
+ return MOCK_HOOK_P8(NotificationMock,
+ notification_setting_db_update, arg0, arg1, arg2, arg3, arg4, arg5, arg6,
+ arg7);
+}
+
+extern "C" int noti_system_setting_get_do_not_disturb(int* arg0, uid_t arg1) {
+ return MOCK_HOOK_P2(NotificationMock,
+ noti_system_setting_get_do_not_disturb, arg0, arg1);
+}
+
+extern "C" int notification_setting_db_update_system_setting(int arg0, int arg1,
+ int arg2, int arg3, int arg4, int arg5, int arg6, int arg7, int arg8,
+ uid_t arg9) {
+ return MOCK_HOOK_P10(NotificationMock,
+ notification_setting_db_update_system_setting, arg0, arg1, arg2, arg3,
+ arg4, arg5, arg6, arg7, arg8, arg9);
+}
+
+extern "C" int noti_setting_get_setting_array(notification_setting_h* arg0, int* arg1,
+ uid_t arg2) {
+ return MOCK_HOOK_P3(NotificationMock,
+ noti_setting_get_setting_array, arg0, arg1, arg2);
+}
+
+extern "C" int noti_setting_service_get_setting_by_app_id(const char* arg0,
+ notification_setting_h* arg1, uid_t arg2) {
+ return MOCK_HOOK_P3(NotificationMock,
+ noti_setting_service_get_setting_by_app_id, arg0, arg1, arg2);
+}
+
+extern "C" int noti_system_setting_load_system_setting(
+ notification_system_setting_h* arg0, uid_t arg1) {
+ return MOCK_HOOK_P2(NotificationMock,
+ noti_system_setting_load_system_setting, arg0, arg1);
+}
+
+extern "C" bool notification_validate_private_sharing(notification_h arg0) {
+ return MOCK_HOOK_P1(NotificationMock,
+ notification_validate_private_sharing, arg0);
+}
+
+extern "C" int notification_set_private_sharing(notification_h arg0, uid_t arg1) {
+ return MOCK_HOOK_P2(NotificationMock, notification_set_private_sharing,
+ arg0, arg1);
+}
+
+extern "C" int notification_launch_default_viewer(int arg0,
+ notification_op_type_e arg1, uid_t arg2) {
+ return MOCK_HOOK_P3(NotificationMock, notification_launch_default_viewer,
+ arg0, arg1, arg2);
+}
+
+extern "C" int notification_get_pkgname(notification_h arg0, char** arg1) {
+ return MOCK_HOOK_P2(NotificationMock, notification_get_pkgname, arg0, arg1);
+}
+
+extern "C" int notification_get_text(notification_h arg0,
+ notification_text_type_e arg1, char** arg2) {
+ return MOCK_HOOK_P3(NotificationMock, notification_get_text, arg0, arg1, arg2);
+}
+
+extern "C" int notification_get_tag(notification_h arg0, const char** arg1) {
+ return MOCK_HOOK_P2(NotificationMock, notification_get_tag, arg0, arg1);
+}
+
+extern "C" int notification_get_dnd_and_allow_to_notify(const char* arg0,
+ int* arg1, int* arg2, int* arg3, uid_t arg4) {
+ return MOCK_HOOK_P5(NotificationMock, notification_get_dnd_and_allow_to_notify,
+ arg0, arg1, arg2, arg3, arg4);
+}
+
+extern "C" GVariant* notification_ipc_make_gvariant_from_system_setting(
+ struct notification_system_setting* arg0) {
+ return MOCK_HOOK_P1(NotificationMock, notification_ipc_make_gvariant_from_system_setting,
+ arg0);
+}
+
+extern "C" int notification_system_setting_load_dnd_allow_exception(
+ dnd_allow_exception_h* arg0, int* arg1, uid_t arg2) {
+ return MOCK_HOOK_P3(NotificationMock,
+ notification_system_setting_load_dnd_allow_exception, arg0, arg1, arg2);
+}
+
+extern "C" int notification_system_setting_update_dnd_allow_exception(
+ int arg0, int arg1, uid_t arg2) {
+ return MOCK_HOOK_P3(NotificationMock,
+ notification_system_setting_update_dnd_allow_exception, arg0, arg1, arg2);
+}
+
+extern "C" int notification_set_indirect_request(
+ notification_h arg0, pid_t arg1, uid_t arg2) {
+ return MOCK_HOOK_P3(NotificationMock,
+ notification_set_indirect_request, arg0, arg1, arg2);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2023 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 MOCK_NOTIFICATION_MOCK_H_
+#define MOCK_NOTIFICATION_MOCK_H_
+
+#include <gmock/gmock.h>
+
+#include "module_mock.h"
+
+#include <notification_noti.h>
+
+#include <notification_type.h>
+#include <notification.h>
+#include <notification_viewer.h>
+#include <notification_setting_internal.h>
+#include <notification_setting.h>
+#include <notification_setting_service.h>
+
+class NotificationMock : public virtual ModuleMock {
+ public:
+ virtual ~NotificationMock() {}
+
+ MOCK_METHOD1(notification_create, notification_h (notification_type_e));
+ MOCK_METHOD1(notification_free, int (notification_h));
+ MOCK_METHOD3(notification_get_id, int (notification_h, int*, int*));
+ MOCK_METHOD1(notification_noti_check_tag, int (notification_h));
+ MOCK_METHOD1(notification_noti_update, int (notification_h));
+ MOCK_METHOD4(notification_noti_delete_by_priv_id_get_changes,
+ int (const char*, int, int*, uid_t));
+ MOCK_METHOD4(notification_noti_delete_by_display_applist,
+ int (int, int*, notification_deleted_list_info_s**, uid_t));
+ MOCK_METHOD5(notification_noti_delete_all,
+ int (notification_type_e, const char*, int*, int**, uid_t));
+ MOCK_METHOD6(notification_noti_get_count,
+ int (notification_type_e, const char*, int, int, int*, uid_t));
+ MOCK_METHOD3(notification_noti_get_all_count,
+ int (notification_type_e, int*, uid_t));
+ MOCK_METHOD4(notification_noti_get_by_tag,
+ int (notification_h, char*, char*, uid_t));
+ MOCK_METHOD2(notification_noti_get_by_priv_id,
+ int (notification_h, int));
+ MOCK_METHOD6(notification_noti_get_detail_list,
+ int (const char*, int, int, int, notification_list_h*, uid_t));
+ MOCK_METHOD2(notification_noti_add_template,
+ int (notification_h, char*));
+ MOCK_METHOD3(notification_noti_get_package_template,
+ int (notification_h, char*, char*));
+ MOCK_METHOD2(notification_get_event_flag, int (notification_h, bool*));
+ MOCK_METHOD2(notification_get_uid, int (notification_h, uid_t*));
+ MOCK_METHOD2(notification_set_uid, int (notification_h, uid_t));
+ MOCK_METHOD2(notification_ipc_make_noti_from_gvariant,
+ int (notification_h, GVariant*));
+ MOCK_METHOD2(notification_ipc_make_gvariant_from_noti,
+ GVariant* (notification_h, bool));
+ MOCK_METHOD0(notification_db_init, int (void));
+ MOCK_METHOD0(notification_init_default_viewer, int (void));
+ MOCK_METHOD1(notification_system_setting_init_system_setting_table, int (uid_t));
+ MOCK_METHOD2(notification_system_setting_get_dnd_schedule_enabled_uid,
+ int (uid_t**, int*));
+ MOCK_METHOD8(notification_setting_db_update,
+ int (const char*, const char*, int, int, int, int, int, uid_t));
+ MOCK_METHOD2(noti_system_setting_get_do_not_disturb, int (int*, uid_t));
+ MOCK_METHOD10(notification_setting_db_update_system_setting, int (int, int, int,
+ int, int, int, int, int, int, uid_t));
+ MOCK_METHOD3(noti_setting_get_setting_array, int (notification_setting_h*,
+ int*, uid_t));
+ MOCK_METHOD3(noti_setting_service_get_setting_by_app_id, int (const char*,
+ notification_setting_h*, uid_t));
+ MOCK_METHOD2(noti_system_setting_load_system_setting, int (
+ notification_system_setting_h*, uid_t));
+ MOCK_METHOD1(notification_validate_private_sharing, bool (notification_h));
+ MOCK_METHOD2(notification_set_private_sharing, int (notification_h, uid_t));
+ MOCK_METHOD3(notification_launch_default_viewer, int (int,
+ notification_op_type_e, uid_t));
+ MOCK_METHOD2(notification_get_pkgname, int (notification_h, char**));
+ MOCK_METHOD3(notification_get_text, int (notification_h,
+ notification_text_type_e, char**));
+ MOCK_METHOD2(notification_get_tag, int (notification_h, const char**));
+ MOCK_METHOD5(notification_get_dnd_and_allow_to_notify, int (const char*, int*,
+ int*, int*, uid_t));
+ MOCK_METHOD1(notification_ipc_make_gvariant_from_system_setting, GVariant*
+ (struct notification_system_setting*));
+ MOCK_METHOD3(notification_system_setting_load_dnd_allow_exception, int
+ (dnd_allow_exception_h*, int*, uid_t));
+ MOCK_METHOD3(notification_system_setting_update_dnd_allow_exception, int
+ (int, int, uid_t));
+ MOCK_METHOD3(notification_set_indirect_request, int (notification_h, pid_t,
+ uid_t));
+};
+
+#endif // MOCK_NOTIFICATION_MOCK_H_
--- /dev/null
+/*
+ * Copyright (c) 2023 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 "pkgmgr_info_mock.h"
+#include "mock_hook.h"
+#include "test_fixture.h"
+
+extern "C" int pkgmgrinfo_appinfo_destroy_appinfo(
+ pkgmgrinfo_appinfo_h arg0) {
+ return MOCK_HOOK_P1(PkgmgrInfoMock, pkgmgrinfo_appinfo_destroy_appinfo,
+ arg0);
+}
+
+extern "C" int pkgmgr_client_free(pkgmgr_client* arg0) {
+ return MOCK_HOOK_P1(PkgmgrInfoMock, pkgmgr_client_free, arg0);
+}
+
+extern "C" int pkgmgrinfo_appinfo_get_usr_appinfo(const char* arg0, uid_t arg1,
+ pkgmgrinfo_appinfo_h* arg2) {
+ return MOCK_HOOK_P3(PkgmgrInfoMock, pkgmgrinfo_appinfo_get_usr_appinfo, arg0,
+ arg1, arg2);
+}
+
+extern "C" int pkgmgrinfo_appinfo_get_pkgid(pkgmgrinfo_pkginfo_h arg0,
+ char** arg1) {
+ return MOCK_HOOK_P2(PkgmgrInfoMock, pkgmgrinfo_appinfo_get_pkgid, arg0,
+ arg1);
+}
+
+extern "C" int pkgmgrinfo_pkginfo_get_usr_pkginfo(const char* arg0, uid_t arg1,
+ pkgmgrinfo_pkginfo_h* arg2) {
+ return MOCK_HOOK_P3(PkgmgrInfoMock, pkgmgrinfo_pkginfo_get_usr_pkginfo, arg0,
+ arg1, arg2);
+}
+
+extern "C" int pkgmgrinfo_pkginfo_destroy_pkginfo(pkgmgrinfo_pkginfo_h arg0) {
+ return MOCK_HOOK_P1(PkgmgrInfoMock, pkgmgrinfo_pkginfo_destroy_pkginfo,
+ arg0);
+}
+
+extern "C" pkgmgr_client* pkgmgr_client_new(pkgmgr_client_type arg0) {
+ return MOCK_HOOK_P1(PkgmgrInfoMock, pkgmgr_client_new, arg0);
+}
+
+extern "C" int pkgmgr_client_listen_status(pkgmgr_client* arg0,
+ pkgmgr_handler arg1, void* arg2) {
+ return MOCK_HOOK_P3(PkgmgrInfoMock, pkgmgr_client_listen_status, arg0, arg1,
+ arg2);
+}
+
--- /dev/null
+/*
+ * Copyright (c) 2023 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 MOCK_PKGMGR_INFO_MOCK_H_
+#define MOCK_PKGMGR_INFO_MOCK_H_
+
+#include <pkgmgr-info.h>
+#include <package-manager.h>
+#include <gmock/gmock.h>
+
+#include "module_mock.h"
+
+class PkgmgrInfoMock : public virtual ModuleMock {
+ public:
+ virtual ~PkgmgrInfoMock() {}
+
+ MOCK_METHOD1(pkgmgrinfo_appinfo_destroy_appinfo,
+ int (pkgmgrinfo_appinfo_h));
+ MOCK_METHOD1(pkgmgr_client_free, int (pkgmgr_client*));
+ MOCK_METHOD3(pkgmgrinfo_appinfo_get_usr_appinfo,
+ int (const char *, uid_t, pkgmgrinfo_appinfo_h*));
+ MOCK_METHOD2(pkgmgrinfo_appinfo_get_pkgid,
+ int (pkgmgrinfo_pkginfo_h, char **));
+ MOCK_METHOD3(pkgmgrinfo_pkginfo_get_usr_pkginfo,
+ int (const char *, uid_t, pkgmgrinfo_pkginfo_h*));
+ MOCK_METHOD1(pkgmgrinfo_pkginfo_destroy_pkginfo,
+ int (pkgmgrinfo_pkginfo_h));
+ MOCK_METHOD1(pkgmgr_client_new, pkgmgr_client* (pkgmgr_client_type));
+ MOCK_METHOD3(pkgmgr_client_listen_status, int (pkgmgr_client*,
+ pkgmgr_handler, void*));
+};
+
+#endif // MOCK_PKMGR_INFO_MOCK_H_
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2023 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 "shortcut_mock.h"
+#include "mock_hook.h"
+#include "test_fixture.h"
+
+extern "C" int shortcut_db_init(void) {
+ return MOCK_HOOK_P0(ShortcutMock, shortcut_db_init);
+}
+
+extern "C" int shortcut_db_get_list(const char* arg0, GList** arg1) {
+ return MOCK_HOOK_P2(ShortcutMock, shortcut_db_get_list, arg0, arg1);
+}
--- /dev/null
+/*
+ * Copyright (c) 2023 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 MOCK_SHORTCUT_MOCK_H_
+#define MOCK_SHORTCUT_MOCK_H_
+
+#include <shortcut.h>
+#include <shortcut_db.h>
+#include <badge_setting.h>
+#include <badge_setting_service.h>
+#include <gmock/gmock.h>
+
+#include "module_mock.h"
+
+class ShortcutMock : public virtual ModuleMock {
+ public:
+ virtual ~ShortcutMock() {}
+
+ MOCK_METHOD0(shortcut_db_init, int (void));
+ MOCK_METHOD2(shortcut_db_get_list, int (const char*, GList**));
+};
+
+#endif // MOCK_SHORTCUT_MOCK_H_
--- /dev/null
+/*
+ * Copyright (c) 2023 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 "tzplatform_config_mock.h"
+
+#include "mock_hook.h"
+#include "test_fixture.h"
+
+extern "C" uid_t tzplatform_getuid(enum tzplatform_variable arg0) {
+ return MOCK_HOOK_P1(TzplatformConfigMock, tzplatform_getuid, arg0);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2023 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 MOCK_TZPLATFORM_CONFIG_MOCK_H_
+#define MOCK_TZPLATFORM_CONFIG_MOCK_H_
+
+#include <tzplatform_config.h>
+#include <gmock/gmock.h>
+
+#include "module_mock.h"
+
+class TzplatformConfigMock : public virtual ModuleMock {
+ public:
+ virtual ~TzplatformConfigMock() {}
+
+ MOCK_METHOD1(tzplatform_getuid, uid_t (enum tzplatform_variable));
+};
+
+#endif // MOCK_TZPLATFORM_CONFIG_MOCK_H_
\ No newline at end of file
PKG_CHECK_MODULES(data-provider-master-unittests REQUIRED\r
gmock\r
dlog\r
- bundle\r
+ aul\r
+ vconf\r
+ sqlite3\r
glib-2.0\r
gio-2.0\r
- sqlite3\r
- aul\r
+ gio-unix-2.0\r
+ bundle\r
+ pkgmgr\r
+ notification\r
+ notification-ex\r
+ badge\r
+ libsmack\r
+ shortcut\r
+ pkgmgr-info\r
+ libsystemd\r
+ capi-appfw-app-manager\r
+ alarm-service\r
+ libtzplatform-config\r
+ security-manager\r
)\r
\r
FOREACH(flag ${data-provider-master-unittests_CFLAGS})\r
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")\r
ENDFOREACH(flag)\r
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror")\r
\r
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++14")\r
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++17")\r
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")\r
SET(CMAKE_CXX_FLAGS_RELEASE "-O2")\r
\r
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../..)\r
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../include)\r
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../src)\r
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../mock)\r
\r
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src TEST_SOURCES)\r
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../mock MOCK_SOURCES)\r
-# AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../../src LIB_SOURCES)\r
+SET(DPM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../../src/badge_service.c\r
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../src/notification_ex_service.cc\r
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../src/notification_service.c\r
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../src/pkgmgr.c\r
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../src/shortcut_service.c\r
+ ${CMAKE_CURRENT_SOURCE_DIR}/../../src/service_common.c)\r
\r
ADD_EXECUTABLE(${PROJECT_NAME}\r
${TEST_SOURCES}\r
- ${LIB_SOURCES}\r
+ ${DPM_SOURCES}\r
${MOCK_SOURCES}\r
)\r
\r
* limitations under the License.
*/
-#include <stdlib.h>
#include <gtest/gtest.h>
-#include <stdio.h>
-#include <glib.h>
-#include <memory>
+#include "include/service_common.h"
+#include "include/badge_service.h"
+#include "tests/mock/badge_mock.h"
+#include "tests/mock/gio_mock.h"
+#include "tests/mock/tzplatform_config_mock.h"
+#include "tests/mock/test_fixture.h"
-#include "service_common.h"
-#include "badge_service.h"
-#include "gio_mock.h"
-#include "test_fixture.h"
-
-// using namespace tizen_base;
using ::testing::_;
using ::testing::DoAll;
using ::testing::Return;
using ::testing::SetArgPointee;
-class Mocks : public ::testing::NiceMock<GioMock> {};
+namespace {
+
+class Mocks : public ::testing::NiceMock<BadgeMock>,
+ public ::testing::NiceMock<GioMock>,
+ public ::testing::NiceMock<TzplatformConfigMock> {};
+
+} //namespace
class BadgeServiceTest : public TestFixture {
public:
virtual ~BadgeServiceTest() {}
virtual void SetUp() {
+ EXPECT_CALL(GetMock<TzplatformConfigMock>(), tzplatform_getuid(_))
+ .WillRepeatedly(Return(6001));
}
virtual void TearDown() {
};
TEST_F(BadgeServiceTest, badge_service_init) {
- int ret;
- ret = BADGE_ERROR_NONE;
+ GDBusNodeInfo* info = reinterpret_cast<GDBusNodeInfo*>(
+ malloc(sizeof(GDBusNodeInfo)));
+ info->interfaces = reinterpret_cast<GDBusInterfaceInfo**>(
+ malloc(sizeof(GDBusInterfaceInfo*)));
+ GDBusConnection* conn = reinterpret_cast<GDBusConnection*>(calloc(1, 4));
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_init())
+ .WillOnce(Return(0));
+ EXPECT_CALL(GetMock<GioMock>(), g_bus_own_name(_, _, _, _, _, _, _, _))
+ .WillOnce(Return(1));
+ EXPECT_CALL(GetMock<GioMock>(), g_bus_get_sync(_, _, _))
+ .WillOnce(Return(conn));
+ EXPECT_CALL(GetMock<GioMock>(), g_dbus_node_info_new_for_xml(_, _))
+ .WillOnce(Return(info));
+ EXPECT_CALL(GetMock<GioMock>(), g_dbus_node_info_unref(_))
+ .WillOnce(Return());
+ EXPECT_CALL(GetMock<GioMock>(), g_dbus_connection_register_object(_, _, _, _, _, _, _))
+ .WillOnce(Return(1));
+
+ int ret = badge_service_init();
+ EXPECT_EQ(ret, BADGE_ERROR_NONE);
+
+ free(info->interfaces);
+ free(info);
+ free(conn);
+}
+
+TEST_F(BadgeServiceTest, badge_service_fini) {
+ int ret = badge_service_fini();
+ EXPECT_EQ(ret, BADGE_ERROR_NONE);
+}
+
+TEST_F(BadgeServiceTest, badge_get_badge_existing) {
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_is_existing(_, _, _))
+ .WillOnce(Return(0));
+ GVariant* param = g_variant_new("(si)", "pkgname", 5001);
+ GVariant* reply;
+ int ret = badge_get_badge_existing(param, &reply, 5001);
+ EXPECT_EQ(ret, BADGE_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(BadgeServiceTest, badge_get_badge_list) {
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_list(_, _))
+ .WillOnce(Return(0));
+ GVariant* param = g_variant_new("(i)", 5001);
+ GVariant* reply;
+ int ret = badge_get_badge_list(param, &reply, 5001);
+ EXPECT_EQ(ret, BADGE_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+
+}
+
+TEST_F(BadgeServiceTest, badge_insert) {
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_insert(_, _, _, _))
+ .WillOnce(Return(0));
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_allow_to_display_by_appid(_, _,
+ _)).WillOnce(Return(0));
+ GVariant* param = g_variant_new("(sssi)", "pkgname", "writable", "call", 5001);
+ GVariant* reply;
+ int ret = badge_insert(param, &reply, 5001);
EXPECT_EQ(ret, BADGE_ERROR_NONE);
+ g_object_unref(param);
+ g_object_unref(reply);
}
+
+TEST_F(BadgeServiceTest, badge_delete) {
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_delete(_, _, _, _))
+ .WillOnce(Return(0));
+ GVariant* param = g_variant_new("(ssi)", "pkgname", "caller", 5001);
+ GVariant* reply;
+ int ret = badge_delete(param, &reply, 5001, 10);
+ EXPECT_EQ(ret, BADGE_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(BadgeServiceTest, badge_set_badge_count) {
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_set_count(_, _, _, _, _))
+ .WillOnce(Return(0));
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_allow_to_display_by_appid(_, _,
+ _)).WillOnce(Return(0));
+ GVariant* param = g_variant_new("(ssii)", "pkgname", "caller", 10, 5001);
+ GVariant* reply;
+ int ret = badge_set_badge_count(param, &reply, 5001, 10);
+ EXPECT_EQ(ret, BADGE_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(BadgeServiceTest, badge_get_badge_count) {
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_count(_, _, _))
+ .WillOnce(Return(0));
+ GVariant* param = g_variant_new("(si)", "pkgname", 5001);
+ GVariant* reply;
+ int ret = badge_get_badge_count(param, &reply, 5001);
+ EXPECT_EQ(ret, BADGE_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(BadgeServiceTest, badge_set_display_option) {
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_set_display_option(_, _, _))
+ .WillOnce(Return(0));
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_allow_to_display_by_appid(_, _,
+ _)).WillOnce(Return(0));
+ GVariant* param = g_variant_new("(ssii)", "pkgname", "caller", 1, 5001);
+ GVariant* reply;
+ int ret = badge_set_display_option(param, &reply, 5001);
+ EXPECT_EQ(ret, BADGE_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(BadgeServiceTest, badge_get_display_option) {
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_display_option(_, _, _))
+ .WillOnce(Return(0));
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_allow_to_display_by_appid(_, _,
+ _)).WillOnce(Return(0));
+ GVariant* param = g_variant_new("(si)", "pkgname", 5001);
+ GVariant* reply;
+ int ret = badge_get_display_option(param, &reply, "sender", 5001);
+ EXPECT_EQ(ret, BADGE_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(BadgeServiceTest, badge_update_badge_setting) {
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_update_setting(_, _, _, _))
+ .WillOnce(Return(0));
+ GVariant* param = g_variant_new("(ssii)", "pkgname", "caller", 1, 5001);
+ GVariant* reply;
+ int ret = badge_update_badge_setting(param, &reply, 5001);
+ EXPECT_EQ(ret, BADGE_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(BadgeServiceTest, badge_get_setting_by_appid) {
+ struct badge_setting* setting =
+ reinterpret_cast<struct badge_setting*>(malloc(sizeof(struct badge_setting)));
+ setting->pkgname = strdup("pkgname");
+ setting->appid = strdup("appid");
+ setting->allow_to_display = 1;
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_setting_by_appid(_, _, _))
+ .WillOnce(DoAll(SetArgPointee<1>(setting), Return(0)));
+ GVariant* param = g_variant_new("(si)", "appid", 5001);
+ GVariant* reply;
+ int ret = badge_get_setting_by_appid(param, &reply, 5001);
+ EXPECT_EQ(ret, BADGE_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(BadgeServiceTest, badge_init_display) {
+ EXPECT_CALL(GetMock<BadgeMock>(), badge_db_get_list(_, _))
+ .WillOnce(Return(0));
+ GVariant* param = g_variant_new("(i)", 5001);
+ GVariant* reply;
+ int ret = badge_init_display(param, &reply, 5001);
+ EXPECT_EQ(ret, BADGE_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2023 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 <gtest/gtest.h>
+
+#include "tests/mock/aul_mock.h"
+#include "tests/mock/gio_mock.h"
+#include "tests/mock/notification_mock.h"
+#include "tests/mock/test_fixture.h"
+
+#include "include/service_common.h"
+#include "include/notification_ex_service.h"
+
+using ::testing::_;
+using ::testing::Invoke;
+using ::testing::Return;
+
+namespace {
+
+class Mocks : public ::testing::NiceMock<AulMock>,
+ public ::testing::NiceMock<GioMock>,
+ public ::testing::NiceMock<NotificationMock> {};
+
+} //namespace
+
+class NotificationEXServiceTest : public TestFixture {
+ public:
+ NotificationEXServiceTest() : TestFixture(std::make_unique<Mocks>()) {}
+ virtual ~NotificationEXServiceTest() {}
+
+ virtual void SetUp() {
+ }
+
+ virtual void TearDown() {
+ }
+};
+
+TEST_F(NotificationEXServiceTest, notification_ex_service) {
+ GDBusConnection* conn = reinterpret_cast<GDBusConnection*>(calloc(1, 4));
+ GDBusMessage* msg = static_cast<GDBusMessage*>(g_object_new(G_TYPE_OBJECT, NULL));
+ GDBusMessage* msg2 = static_cast<GDBusMessage*>(g_object_new(G_TYPE_OBJECT, NULL));
+ g_dbus_message_set_body(msg2, g_variant_new("(i)", 1));
+ EXPECT_CALL(GetMock<GioMock>(), g_bus_own_name_on_connection(_, _, _, _, _,
+ _, _)).WillOnce(Return(1));
+ EXPECT_CALL(GetMock<GioMock>(), g_bus_get_sync(_, _, _))
+ .WillOnce(Return(conn));
+ EXPECT_CALL(GetMock<AulMock>(), aul_app_get_appid_bypid(_, _, _))
+ .WillRepeatedly(Invoke([](int pid, char* appid, int size) {
+ snprintf(appid, size, "%s", "org.tizen.helloworld");
+ return AUL_R_OK;
+ }));
+ EXPECT_CALL(GetMock<GioMock>(),
+ g_dbus_message_new_method_call(_, _, _, _))
+ .WillRepeatedly(Return(msg));
+ EXPECT_CALL(GetMock<GioMock>(),
+ g_dbus_connection_send_message_with_reply_sync(
+ _, _, _, _, _, _, _))
+ .WillRepeatedly(Return(msg2));
+ EXPECT_CALL(GetMock<GioMock>(), g_dbus_message_get_body(_))
+ .WillRepeatedly(Return(g_variant_new("(i)", 1)));
+
+ int ret = notification_ex_service_init(0);
+ EXPECT_EQ(ret, 0);
+ GDBusConnection* inst_conn = notification_ex_service_get_gdbus_connection();
+ EXPECT_EQ(conn, inst_conn);
+ ret = notification_ex_service_fini();
+ EXPECT_EQ(ret, 0);
+
+ free(conn);
+}
--- /dev/null
+/*
+ * Copyright (c) 2023 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 <gtest/gtest.h>
+
+#include "tests/mock/aul_mock.h"
+#include "tests/mock/notification_mock.h"
+#include "tests/mock/gio_mock.h"
+#include "tests/mock/tzplatform_config_mock.h"
+#include "tests/mock/test_fixture.h"
+
+#include "include/service_common.h"
+#include "include/notification_service.h"
+
+using ::testing::_;
+using ::testing::DoAll;
+using ::testing::Return;
+using ::testing::SetArgPointee;
+
+namespace {
+
+class Mocks : public ::testing::NiceMock<AulMock>,
+ public ::testing::NiceMock<NotificationMock>,
+ public ::testing::NiceMock<GioMock>,
+ public ::testing::NiceMock<TzplatformConfigMock> {};
+
+} //namespace
+
+class NotificationServiceTest : public TestFixture {
+ public:
+ NotificationServiceTest() : TestFixture(std::make_unique<Mocks>()) {}
+ virtual ~NotificationServiceTest() {}
+
+ virtual void SetUp() {
+ EXPECT_CALL(GetMock<TzplatformConfigMock>(), tzplatform_getuid(_))
+ .WillRepeatedly(Return(6001));
+ }
+
+ virtual void TearDown() {
+ }
+};
+
+TEST_F(NotificationServiceTest, notification_service_init) {
+ GDBusNodeInfo* info = reinterpret_cast<GDBusNodeInfo*>(
+ malloc(sizeof(GDBusNodeInfo)));
+ info->interfaces = reinterpret_cast<GDBusInterfaceInfo**>(
+ malloc(sizeof(GDBusInterfaceInfo*)));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_db_init())
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_init_default_viewer())
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_system_setting_init_system_setting_table(_))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_system_setting_get_dnd_schedule_enabled_uid(_, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<GioMock>(), g_bus_own_name(_, _, _, _, _, _, _, _))
+ .WillOnce(Return(1));
+ EXPECT_CALL(GetMock<GioMock>(), g_dbus_node_info_new_for_xml(_, _))
+ .WillOnce(Return(info));
+ EXPECT_CALL(GetMock<GioMock>(), g_dbus_node_info_unref(_))
+ .WillOnce(Return());
+ EXPECT_CALL(GetMock<GioMock>(), g_dbus_connection_register_object(_, _, _, _, _, _, _))
+ .WillOnce(Return(1));
+
+ int ret = notification_service_init(0);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ free(info->interfaces);
+ free(info);
+}
+
+TEST_F(NotificationServiceTest, notification_service_fini) {
+ int ret = notification_service_fini();
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
+
+TEST_F(NotificationServiceTest, notification_add_noti) {
+ notification_h info = reinterpret_cast<notification_h>(
+ malloc(sizeof(notification_h)));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_create(_))
+ .WillOnce(Return(info));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_free(_))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_get_uid(_, _))
+ .WillOnce(DoAll(SetArgPointee<1>(5001), Return(NOTIFICATION_ERROR_NONE)));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_noti_check_tag(_))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_get_event_flag(_, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_ipc_make_noti_from_gvariant(_, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+
+ GVariant* body = g_variant_new("(i)", 0);
+ GVariant* param = g_variant_new("(v)", body);
+ GVariant* reply;
+ int ret = notification_add_noti(param, &reply, "sender", 100, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+}
+
+TEST_F(NotificationServiceTest, notification_update_noti) {
+ notification_h info = reinterpret_cast<notification_h>(
+ malloc(sizeof(notification_h)));
+ GVariant* body = g_variant_new("(i)", 0);
+ GVariant* param = g_variant_new("(v)", body);
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_create(_))
+ .WillOnce(Return(info));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_free(_))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_noti_update(_))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_ipc_make_gvariant_from_noti(_, _))
+ .WillOnce(Return(body));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_get_uid(_, _))
+ .WillOnce(DoAll(SetArgPointee<1>(5001), Return(NOTIFICATION_ERROR_NONE)));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_ipc_make_noti_from_gvariant(_, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_validate_private_sharing(_))
+ .WillOnce(Return(true));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_launch_default_viewer(_, _, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_get_pkgname(_, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_get_tag(_, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_get_text(_, _, _))
+ .WillRepeatedly(Return(NOTIFICATION_ERROR_NONE));
+
+ GVariant* reply;
+ int ret = notification_update_noti(param, &reply, 100, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+}
+
+TEST_F(NotificationServiceTest, notification_refresh_noti) {
+ GVariant* param = g_variant_new("(i)", 5001);
+ GVariant* reply;
+ int ret = notification_refresh_noti(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+}
+
+TEST_F(NotificationServiceTest, notification_del_noti_single) {
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_noti_delete_by_priv_id_get_changes(_, _, _, _))
+ .WillOnce(DoAll(SetArgPointee<2>(0), Return(NOTIFICATION_ERROR_NONE)));
+ GVariant* param = g_variant_new("(sii)", "appid", 10, 5001);
+ GVariant* reply;
+ int ret = notification_del_noti_single(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+}
+
+TEST_F(NotificationServiceTest, notification_del_noti_by_display_applist) {
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_noti_delete_by_display_applist(_, _, _, _))
+ .WillOnce(DoAll(SetArgPointee<1>(0), Return(NOTIFICATION_ERROR_NONE)));
+ GVariant* param = g_variant_new("(ii)", 10, 5001);
+ GVariant* reply;
+ int ret = notification_del_noti_by_display_applist(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+}
+
+TEST_F(NotificationServiceTest, notification_get_noti_count) {
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_noti_get_count(_, _, _, _, _, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ GVariant* param = g_variant_new("(isiii)", 1, "appid", 1, 1, 5001);
+ GVariant* reply;
+ int ret = notification_get_noti_count(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+}
+
+TEST_F(NotificationServiceTest, notification_get_noti_all_count) {
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_noti_get_all_count(_, _, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ GVariant* param = g_variant_new("(ii)", 1, 5001);
+ GVariant* reply;
+ int ret = notification_get_noti_all_count(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+}
+
+TEST_F(NotificationServiceTest, notification_update_noti_setting) {
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_setting_db_update(_, _, _, _, _, _, _, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ GVariant* param = g_variant_new("(ssiiiiii)", "pkgname", "appid", 0, 0, 0, 0,
+ 1, 5001);
+ GVariant* reply;
+ int ret = notification_update_noti_setting(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+}
+
+TEST_F(NotificationServiceTest, notification_update_noti_sys_setting) {
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ noti_system_setting_get_do_not_disturb(_, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_setting_db_update_system_setting(_, _, _, _, _, _, _, _, _, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ GVariant* param = g_variant_new("(iiiiiiiiii)", 2, 0, 0, 0, 0, 0,
+ 0, 0, 0, 5001);
+ GVariant* reply;
+ int ret = notification_update_noti_sys_setting(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+}
+
+TEST_F(NotificationServiceTest, notification_load_noti_by_tag) {
+ notification_h info = reinterpret_cast<notification_h>(
+ malloc(sizeof(notification_h)));
+ GVariant* body = g_variant_new("(i)", 0);
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_create(_))
+ .WillOnce(Return(info));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_noti_get_by_tag(_, _, _, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_ipc_make_gvariant_from_noti(_, _))
+ .WillOnce(Return(body));
+ GVariant* param = g_variant_new("(ssi)", "appid", "tag", 5001);
+ GVariant* reply;
+ int ret = notification_load_noti_by_tag(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(body);
+}
+
+TEST_F(NotificationServiceTest, notification_load_noti_by_priv_id) {
+ notification_h info = reinterpret_cast<notification_h>(
+ malloc(sizeof(notification_h)));
+ GVariant* body = g_variant_new("(i)", 0);
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_create(_))
+ .WillOnce(Return(info));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_noti_get_by_priv_id(_, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_ipc_make_gvariant_from_noti(_, _))
+ .WillOnce(Return(body));
+ GVariant* param = g_variant_new("(sii)", "appid", 0, 5001);
+ GVariant* reply;
+ int ret = notification_load_noti_by_priv_id(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(body);
+}
+
+TEST_F(NotificationServiceTest, notification_load_detail_list) {
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_noti_get_detail_list(_, _, _, _, _, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ GVariant* param = g_variant_new("(siiii)", "appid", 0, 0, 0, 5001);
+ GVariant* reply;
+ int ret = notification_load_detail_list(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+}
+
+TEST_F(NotificationServiceTest, notification_get_setting_array) {
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ noti_setting_get_setting_array(_, _, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ GVariant* param = g_variant_new("(i)", 5001);
+ GVariant* reply;
+ int ret = notification_get_setting_array(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+}
+
+TEST_F(NotificationServiceTest, notification_load_system_setting) {
+ GVariant* param = g_variant_new("(i)", 5001);
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ noti_system_setting_load_system_setting(_, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_ipc_make_gvariant_from_system_setting(_))
+ .WillOnce(Return(param));
+ GVariant* reply;
+ int ret = notification_load_system_setting(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+}
+
+TEST_F(NotificationServiceTest, notification_add_noti_template) {
+ notification_h info = reinterpret_cast<notification_h>(
+ malloc(sizeof(notification_h)));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_create(_))
+ .WillOnce(Return(info));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_noti_add_template(_, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ GVariant* reply = g_variant_new("(i)", 10);;
+ GVariant* body = g_variant_new("(v)", reply);
+ GVariant* param = g_variant_new("(vs)", body, "template");
+ int ret = notification_add_noti_template(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+}
+
+TEST_F(NotificationServiceTest, notification_get_noti_template) {
+ notification_h info = reinterpret_cast<notification_h>(
+ malloc(sizeof(notification_h)));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_create(_))
+ .WillOnce(Return(info));
+ EXPECT_CALL(GetMock<AulMock>(),
+ aul_app_get_appid_bypid_for_uid(_, _, _, _))
+ .WillOnce(Return(AUL_R_OK));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_noti_get_package_template(_, _, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ GVariant* param = g_variant_new("(s)", "template");
+ GVariant* reply = g_variant_new("(si)", "appid", 5001);;
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_ipc_make_gvariant_from_noti(_, _))
+ .WillOnce(Return(reply));
+ int ret = notification_get_noti_template(param, &reply, 10, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(NotificationServiceTest, notification_get_noti_package_template) {
+ notification_h info = reinterpret_cast<notification_h>(
+ malloc(sizeof(notification_h)));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_create(_))
+ .WillOnce(Return(info));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_noti_get_package_template(_, _, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ GVariant* param = g_variant_new("(ss)", "appid", "template");
+ GVariant* reply = g_variant_new("(si)", "appid", 5001);;
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_ipc_make_gvariant_from_noti(_, _))
+ .WillOnce(Return(reply));
+ int ret = notification_get_noti_package_template(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(NotificationServiceTest, notification_get_block_state) {
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_get_dnd_and_allow_to_notify(_, _, _, _, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ GVariant* param = g_variant_new("(si)", "appid", 5001);
+ GVariant* reply;
+ int ret = notification_get_block_state(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(NotificationServiceTest, notification_load_dnd_allow_exception) {
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_system_setting_load_dnd_allow_exception(_, _, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ GVariant* param = g_variant_new("(i)", 5001);
+ GVariant* reply;
+ int ret = notification_load_dnd_allow_exception(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(NotificationServiceTest, notification_update_dnd_allow_exception) {
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_system_setting_update_dnd_allow_exception(_, _, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ GVariant* param = g_variant_new("(iii)", 1, 5001, 5001);
+ GVariant* reply;
+ int ret = notification_update_dnd_allow_exception(param, &reply, 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(NotificationServiceTest, notification_send_noti_event) {
+ notification_h info = reinterpret_cast<notification_h>(
+ malloc(sizeof(notification_h)));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_create(_))
+ .WillOnce(Return(info));
+ GVariant* reply = g_variant_new("(i)", 10);
+ GVariant* reply2;
+ GVariant* body = g_variant_new("(v)", reply);
+ GVariant* param2 = g_variant_new("(i)", 10);
+ GVariant* param = g_variant_new("(vi)", body, 10);
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_get_id(_, _, _))
+ .WillOnce(DoAll(SetArgPointee<2>(10), Return(NOTIFICATION_ERROR_NONE)));
+ EXPECT_CALL(GetMock<GioMock>(),
+ g_dbus_connection_emit_signal(_, _, _, _, _, _, _))
+ .WillOnce(Return(TRUE));
+ EXPECT_CALL(GetMock<GioMock>(),
+ g_bus_watch_name(_, _, _, _, _, _, _))
+ .WillOnce(Return(1));
+ int ret = notification_reset_event_receiver(param2, &reply2, "sender");
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+ ret = notification_send_noti_event(param, &reply);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+ g_object_unref(param2);
+ g_object_unref(reply2);
+}
+
+TEST_F(NotificationServiceTest, notification_send_noti_event_by_priv_id) {
+ notification_h info = reinterpret_cast<notification_h>(
+ malloc(sizeof(notification_h)));
+ EXPECT_CALL(GetMock<GioMock>(),
+ g_dbus_connection_emit_signal(_, _, _, _, _, _, _))
+ .WillOnce(Return(TRUE));
+ EXPECT_CALL(GetMock<GioMock>(),
+ g_bus_watch_name(_, _, _, _, _, _, _))
+ .WillOnce(Return(1));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_create(_))
+ .WillOnce(Return(info));
+ GVariant* param2 = g_variant_new("(i)", 20);
+ GVariant* reply2;
+ int ret = notification_reset_event_receiver(param2, &reply2, "sender");
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ GVariant* reply = g_variant_new("(i)", 10);
+ GVariant* param = g_variant_new("(ii)", 20, 1);
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_get_event_flag(_, _))
+ .WillOnce(DoAll(SetArgPointee<1>(true), Return(NOTIFICATION_ERROR_NONE)));
+ EXPECT_CALL(GetMock<NotificationMock>(), notification_noti_get_by_priv_id(_, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_ipc_make_gvariant_from_noti(_, _))
+ .WillOnce(Return(reply));
+
+ ret = notification_send_noti_event_by_priv_id(param, &reply);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+ g_object_unref(param2);
+ g_object_unref(reply2);
+}
+
+TEST_F(NotificationServiceTest, notification_reset_event_receiver) {
+ GVariant* param = g_variant_new("(i)", 1);
+ GVariant* reply;
+ int ret = notification_reset_event_receiver(param, &reply, "sender");
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(NotificationServiceTest, notification_check_event_receiver) {
+ GVariant* param = g_variant_new("(i)", 1);
+ GVariant* reply;
+ int ret = notification_reset_event_receiver(param, &reply, "sender");
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+ ret = notification_check_event_receiver(param, &reply);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(NotificationServiceTest, notification_delete_noti_by_app_id) {
+ EXPECT_CALL(GetMock<NotificationMock>(),
+ notification_noti_delete_all(_, _, _, _, _))
+ .WillOnce(Return(NOTIFICATION_ERROR_NONE));
+ int ret = notification_delete_noti_by_app_id("appid", 5001);
+ EXPECT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2023 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 <gtest/gtest.h>
+
+#include "tests/mock/aul_mock.h"
+#include "tests/mock/gio_mock.h"
+#include "tests/mock/test_fixture.h"
+
+#include "include/service_common.h"
+
+using ::testing::_;
+using ::testing::Invoke;
+using ::testing::Return;
+
+namespace {
+
+class Mocks : public ::testing::NiceMock<AulMock>,
+ public ::testing::NiceMock<GioMock> {};
+
+} //namespace
+
+class ServiceCommonServiceTest : public TestFixture {
+ public:
+ ServiceCommonServiceTest() : TestFixture(std::make_unique<Mocks>()) {}
+ virtual ~ServiceCommonServiceTest() {}
+
+ virtual void SetUp() {
+ }
+
+ virtual void TearDown() {
+ }
+
+};
+
+TEST_F(ServiceCommonServiceTest, get_sender_uid) {
+ GDBusMessage* msg = static_cast<GDBusMessage*>(g_object_new(G_TYPE_OBJECT, NULL));
+ GDBusMessage* msg2 = static_cast<GDBusMessage*>(g_object_new(G_TYPE_OBJECT, NULL));
+ EXPECT_CALL(GetMock<GioMock>(),
+ g_dbus_message_new_method_call(_, _, _, _))
+ .WillRepeatedly(Return(msg));
+ EXPECT_CALL(GetMock<GioMock>(),
+ g_dbus_connection_send_message_with_reply_sync(
+ _, _, _, _, _, _, _))
+ .WillRepeatedly(Return(msg2));
+ EXPECT_CALL(GetMock<GioMock>(), g_dbus_message_get_body(_))
+ .WillRepeatedly(Return(g_variant_new("(u)", 11)));
+
+ uid_t uid = get_sender_uid("sender");
+ EXPECT_EQ(uid, 11);
+}
+
+TEST_F(ServiceCommonServiceTest, get_sender_pid) {
+ GDBusMessage* msg = static_cast<GDBusMessage*>(g_object_new(G_TYPE_OBJECT, NULL));
+ GDBusMessage* msg2 = static_cast<GDBusMessage*>(g_object_new(G_TYPE_OBJECT, NULL));
+ EXPECT_CALL(GetMock<GioMock>(),
+ g_dbus_message_new_method_call(_, _, _, _))
+ .WillRepeatedly(Return(msg));
+ EXPECT_CALL(GetMock<GioMock>(),
+ g_dbus_connection_send_message_with_reply_sync(
+ _, _, _, _, _, _, _))
+ .WillRepeatedly(Return(msg2));
+ EXPECT_CALL(GetMock<GioMock>(), g_dbus_message_get_body(_))
+ .WillRepeatedly(Return(g_variant_new("(u)", 11)));
+
+ pid_t pid = get_sender_pid("sender");
+ EXPECT_EQ(pid, 11);
+}
+
+TEST_F(ServiceCommonServiceTest, service_register) {
+ GVariant* param = g_variant_new("(i)", 5001);
+ GVariant* reply;
+ GHashTable* hash = g_hash_table_new(g_direct_hash, g_direct_equal);
+ EXPECT_CALL(GetMock<GioMock>(),
+ g_bus_watch_name_on_connection(
+ _, _, _, _, _, _, _))
+ .WillRepeatedly(Return(1));
+
+ int ret = service_register(param, &reply, "sender", nullptr, nullptr, &hash,
+ 5001);
+ EXPECT_EQ(ret, SERVICE_COMMON_ERROR_NONE);
+}
+
+TEST_F(ServiceCommonServiceTest, delete_monitoring_list) {
+ GHashTable* hash = g_hash_table_new(g_direct_hash, g_direct_equal);
+ GList* list = nullptr;
+ list = g_list_append(list, strdup("sender"));
+ g_hash_table_insert(hash, GUINT_TO_POINTER(5001), list);
+
+ int ret = delete_monitoring_list(&hash, "sender", 5001);
+ EXPECT_EQ(ret, SERVICE_COMMON_ERROR_NONE);
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2023 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 <gtest/gtest.h>
+
+#include "include/service_common.h"
+#include "include/shortcut_service.h"
+#include "tests/mock/shortcut_mock.h"
+#include "tests/mock/gio_mock.h"
+#include "tests/mock/test_fixture.h"
+
+using ::testing::_;
+using ::testing::DoAll;
+using ::testing::Return;
+using ::testing::SetArgPointee;
+
+namespace {
+
+class Mocks : public ::testing::NiceMock<ShortcutMock>,
+ public ::testing::NiceMock<GioMock> {};
+
+} //namespace
+
+class ShortcutServiceTest : public TestFixture {
+ public:
+ ShortcutServiceTest() : TestFixture(std::make_unique<Mocks>()) {}
+ virtual ~ShortcutServiceTest() {}
+
+ virtual void SetUp() {
+ }
+
+ virtual void TearDown() {
+ }
+};
+
+TEST_F(ShortcutServiceTest, shortcut_service_init) {
+ GDBusNodeInfo* info = reinterpret_cast<GDBusNodeInfo*>(
+ malloc(sizeof(GDBusNodeInfo)));
+ info->interfaces = reinterpret_cast<GDBusInterfaceInfo**>(
+ malloc(sizeof(GDBusInterfaceInfo*)));
+ EXPECT_CALL(GetMock<ShortcutMock>(), shortcut_db_init())
+ .WillOnce(Return(0));
+ EXPECT_CALL(GetMock<GioMock>(), g_bus_own_name(_, _, _, _, _, _, _, _))
+ .WillOnce(Return(1));
+ EXPECT_CALL(GetMock<GioMock>(), g_dbus_node_info_new_for_xml(_, _))
+ .WillOnce(Return(info));
+ EXPECT_CALL(GetMock<GioMock>(), g_dbus_node_info_unref(_))
+ .WillOnce(Return());
+ EXPECT_CALL(GetMock<GioMock>(), g_dbus_connection_register_object(_, _, _, _, _, _, _))
+ .WillOnce(Return(1));
+
+ int ret = shortcut_service_init();
+ EXPECT_EQ(ret, SHORTCUT_ERROR_NONE);
+
+ free(info->interfaces);
+ free(info);
+}
+
+TEST_F(ShortcutServiceTest, shortcut_get_shortcut_service_list) {
+ GVariantBuilder* b = g_variant_builder_new(G_VARIANT_TYPE("a{sv}"));
+ g_variant_builder_add(b, "{sv}", "package_name", g_variant_new_string("name"));
+ GVariant* body = g_variant_builder_end(b);
+ GVariant* param = g_variant_new("(v)", body);
+
+ GVariant* reply;
+ int ret = shortcut_get_shortcut_service_list(param, &reply, 5001);
+ EXPECT_EQ(ret, SHORTCUT_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+}
+
+TEST_F(ShortcutServiceTest, shortcut_send_return_value) {
+ EXPECT_CALL(GetMock<GioMock>(), g_dbus_method_invocation_return_value(_, _))
+ .WillOnce(Return());
+ GDBusMethodInvocation* invoc = reinterpret_cast<GDBusMethodInvocation*>(
+ malloc(sizeof(GDBusMethodInvocation*)));
+ GVariant* param = g_variant_new("(sis)", "request_id", 10, "appid");
+ GVariant* param2 = g_variant_new("(is)", 1, "request_id");
+ GVariant* reply;
+
+ shortcut_add(param, invoc, 5001);
+ shortcut_add_widget(param, invoc, 5001);
+ shortcut_remove(param, invoc, 5001);
+
+ int ret = shortcut_send_return_value(param2, &reply);
+ EXPECT_EQ(ret, SHORTCUT_ERROR_NONE);
+
+ g_object_unref(param);
+ g_object_unref(reply);
+ free(invoc);
+}
+
+TEST_F(ShortcutServiceTest, shortcut_service_fini) {
+ int ret = shortcut_service_fini();
+ EXPECT_EQ(ret, SHORTCUT_ERROR_NONE);
+}