summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInkyun Kil <inkyun.kil@samsung.com>2019-11-06 00:36:42 (GMT)
committerInkyun Kil <inkyun.kil@samsung.com>2019-11-14 00:30:35 (GMT)
commit82a79ce2bcd9c7c4212d1e26ea483304ce755800 (patch)
tree96132fe197e5ac96828c87a569292d30a44ba9e1
parent604058d2539209cf9d75dcdba6ea32a965bded90 (diff)
downloadalarm-manager-82a79ce2bcd9c7c4212d1e26ea483304ce755800.zip
alarm-manager-82a79ce2bcd9c7c4212d1e26ea483304ce755800.tar.gz
alarm-manager-82a79ce2bcd9c7c4212d1e26ea483304ce755800.tar.bz2
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com> Change-Id: I817be7d100eb5007b044fa1263a3ea5e1c488aac
-rw-r--r--CMakeLists.txt27
-rw-r--r--lib/alarm-lib.c2
-rw-r--r--packaging/alarm-manager.spec11
-rwxr-xr-xserver/alarm-manager.c3
-rwxr-xr-xunittest/CMakeLists.txt8
-rwxr-xr-xunittest/alarm_manager_unittest.cpp427
-rwxr-xr-xunittest/alarmlib_unittest.cpp466
-rwxr-xr-xunittest/mock/alarm_dbus.h93
-rw-r--r--unittest/mock/aul_fake.h54
-rw-r--r--unittest/mock/cynara_fake.h37
-rw-r--r--unittest/mock/gio_fake.h11
-rwxr-xr-xunittest/mock/glib_fake.h3
-rw-r--r--unittest/mock/mock.cc94
-rw-r--r--unittest/mock/pkgmgr_info_fake.h40
14 files changed, 737 insertions, 539 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 116490b..09ed2a6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,17 +2,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(alarm C CXX)
INCLUDE(FindPkgConfig)
-
-IF(BUILD_GTESTS)
- SET(EXTRA_CFLAGS "-Werror-implicit-function-declaration")
-ELSE(BUILD_GTESTS)
- SET(EXTRA_CFLAGS "-Werror-implicit-function-declaration -fvisibility=hidden")
-ENDIF(BUILD_GTESTS)
-
-IF(BUILD_GCOV)
- ADD_DEFINITIONS("-DTIZEN_TEST_GCOV")
-ENDIF(BUILD_GCOV)
-
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
@@ -38,6 +27,16 @@ IF(_APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG)
INSTALL(FILES ${CMAKE_SOURCE_DIR}/alarmmgr_log_dump.sh DESTINATION ${TZ_SYS_ETC}/dump.d/module.d/)
ENDIF(_APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG)
-#IF(BUILD_GTESTS)
-# ADD_SUBDIRECTORY(unittest)
-#ENDIF(BUILD_GTESTS)
+IF(BUILD_GTESTS)
+ SET(EXTRA_CFLAGS "-Werror-implicit-function-declaration")
+ELSE(BUILD_GTESTS)
+ SET(EXTRA_CFLAGS "-Werror-implicit-function-declaration -fvisibility=hidden")
+ENDIF(BUILD_GTESTS)
+
+IF(BUILD_GCOV)
+ ADD_DEFINITIONS("-DTIZEN_TEST_GCOV")
+ENDIF(BUILD_GCOV)
+
+IF(BUILD_GTESTS)
+ ADD_SUBDIRECTORY(unittest)
+ENDIF(BUILD_GTESTS)
diff --git a/lib/alarm-lib.c b/lib/alarm-lib.c
index 3b7190d..0ce96f2 100644
--- a/lib/alarm-lib.c
+++ b/lib/alarm-lib.c
@@ -912,7 +912,7 @@ EXPORT_API int alarmmgr_get_alarm_noti_info(alarm_id_t alarm_id, notification_h
if (ret < 0)
return ret;
- LOGD("[alarm-lib]:alarmmgr_get_alarm_appsvc_info() is called.");
+ LOGD("[alarm-lib]:alarmmgr_get_alarm_noti_info() is called.");
if (alarm_id <= 0) {
LOGE("alarm_id is Invalid[%d]", alarm_id);
diff --git a/packaging/alarm-manager.spec b/packaging/alarm-manager.spec
index 77f7fff..99ad86b 100644
--- a/packaging/alarm-manager.spec
+++ b/packaging/alarm-manager.spec
@@ -44,8 +44,6 @@ BuildRequires: lcov
BuildRequires: zip
%endif
-%define gtests 0
-
%if 0%{?gtests:1}
BuildRequires: pkgconfig(gmock)
%endif
@@ -162,6 +160,7 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
-D_APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG:BOOL=${_APPFW_FEATURE_ALARM_MANAGER_MODULE_LOG} \
-DALARM_CONF_DIR=%{_datadir}/alarm-manager \
-DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} \
+ -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} \
make %{?jobs:-j%jobs}
@@ -258,10 +257,10 @@ fi
%files -n alarm-config-service-restricted
%{_datadir}/alarm-manager/alarm-config-service-restricted
-#%if 0%{?gtests:1}
-#%files unittests
-#%{_bindir}/gtest*
-#%endif
+%if 0%{?gtests:1}
+%files unittests
+%{_bindir}/gtest*
+%endif
#################################################
# gcov
diff --git a/server/alarm-manager.c b/server/alarm-manager.c
index da17b39..8babbfa 100755
--- a/server/alarm-manager.c
+++ b/server/alarm-manager.c
@@ -187,7 +187,7 @@ gboolean __hash_table_remove_cb(gpointer key, gpointer value, gpointer user_data
static bool __get_cached_unique_name(int pid, char *unique_name, int size, bool *is_app, uid_t uid)
{
appid_cache_t *data;
- bool ret;
+ bool ret = false;
bool _is_app;
data = (appid_cache_t *)g_hash_table_lookup(caller_appid_cache_table, GINT_TO_POINTER(pid));
@@ -2566,7 +2566,6 @@ int alarm_manager_alarm_delete(GVariant *parameters, uid_t uid, pid_t pid)
if (!__alarm_delete(uid, alarm_id, &return_code)) {
LOGE("Unable to delete the alarm! alarm_id[%d], return_code[%d]", alarm_id, return_code);
strncpy(log_tag, "FAIL: DELETE", sizeof(log_tag) - 1);
- return_code = ERR_ALARM_SYSTEM_FAIL;
} else {
LOGD("alarm_id[%d] is removed.", alarm_id);
strncpy(log_tag, "DELETE", sizeof(log_tag) - 1);
diff --git a/unittest/CMakeLists.txt b/unittest/CMakeLists.txt
index 8e7cad9..91cc8d1 100755
--- a/unittest/CMakeLists.txt
+++ b/unittest/CMakeLists.txt
@@ -12,6 +12,12 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpie")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpie")
FILE(GLOB GTEST_TEST_SRCS *.cpp)
+SET(GTEST_SERVER_SRCS ${CMAKE_SOURCE_DIR}/server/alarm-manager.c
+ ${CMAKE_SOURCE_DIR}/server/alarm-manager-util.c
+ ${CMAKE_SOURCE_DIR}/server/alarm-manager-timer.c
+ ${CMAKE_SOURCE_DIR}/server/alarm-manager-schedule.c
+ ${CMAKE_SOURCE_DIR}/server/alarm-manager-dbus.c
+ ${CMAKE_SOURCE_DIR}/server/alarm-manager-db.c)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ GTEST_TEST_SRCS)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/mock GTEST_TEST_SRCS)
@@ -23,7 +29,7 @@ LINK_DIRECTORIES(${gtest_pkgs_LIBRARY_DIRS})
INCLUDE_DIRECTORIES(${svr_pkgs_INCLUDE_DIRS})
LINK_DIRECTORIES(${svr_pkgs_LIBRARY_DIRS})
-ADD_EXECUTABLE(${GTEST_TEST} ${GTEST_TEST_SRCS})
+ADD_EXECUTABLE(${GTEST_TEST} ${GTEST_TEST_SRCS} ${GTEST_SERVER_SRCS})
TARGET_LINK_LIBRARIES(${GTEST_TEST} ${gtest_pkgs_LIBRARIES} ${LIBRARY} ${svr_pkgs_LIBRARIES} alarm rt)
ADD_TEST(${GTEST_TEST} ${GTEST_TEST})
diff --git a/unittest/alarm_manager_unittest.cpp b/unittest/alarm_manager_unittest.cpp
new file mode 100755
index 0000000..62d3607
--- /dev/null
+++ b/unittest/alarm_manager_unittest.cpp
@@ -0,0 +1,427 @@
+/*
+_all * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <unistd.h>
+#include <stdio.h>
+
+#include <appsvc.h>
+
+#include "unittest.h"
+#include "alarm.h"
+#include "alarm-internal.h"
+#include "mock/gio_fake.h"
+#include "mock/glib_fake.h"
+#include "mock/aul_fake.h"
+#include "mock/notification_fake.h"
+#include "mock/pkgmgr_info_fake.h"
+
+class AlarmServerTest : public ::testing::Test {
+ protected:
+ void SetUp() override {
+ }
+
+ void TearDown() override {
+ }
+};
+
+int __aul_app_get_pkgid_bypid_for_uid_fake(int pid, char* pkgid, int size,
+ uid_t uid)
+{
+ return 0;
+}
+
+static GDBusConnection* __g_bus_get_sync_fake(GBusType type, GCancellable *cancel,
+ GError **error)
+{
+ GDBusConnection *con = (GDBusConnection*)g_object_new(G_TYPE_OBJECT, NULL);
+ return con;
+}
+
+static guint __g_dbus_connection_signal_subscribe_fake(GDBusConnection *con, const gchar* sender,
+ const gchar* interface, const gchar* member, const gchar* object,
+ const gchar* arg, GDBusSignalFlags flags, GDBusSignalCallback callback,
+ gpointer user_data, GDestroyNotify noti)
+{
+ return 1;
+}
+
+static GDBusNodeInfo* __g_dbus_node_info_new_for_xml_fake(const gchar* xml, GError **error)
+{
+ GDBusNodeInfo *info = (GDBusNodeInfo*)g_object_new(G_TYPE_OBJECT, NULL);
+ return info;
+}
+
+static guint __g_bus_own_name_on_connection_fake(GDBusConnection *con, const gchar* name,
+ GBusNameOwnerFlags flags, GBusNameAcquiredCallback bus_name_acquired,
+ GBusNameLostCallback lost, gpointer user_data, GDestroyNotify noti)
+{
+ return 1;
+}
+
+gpointer __g_hash_table_lookup_fake(GHashTable *table, gconstpointer p)
+{
+ return NULL;
+}
+
+int __pkgmgrinfo_pkginfo_get_usr_pkginfo_fake(const char *pkgid, uid_t uid,
+ pkgmgrinfo_pkginfo_h *handle)
+{
+ return 0;
+}
+
+int __pkgmgrinfo_pkginfo_get_api_version_fake(
+ pkgmgrinfo_pkginfo_h handle, char **version)
+{
+ return 0;
+}
+
+int __pkgmgrinfo_pkginfo_get_is_global_fake(
+ pkgmgrinfo_pkginfo_h handle, bool *is_global)
+{
+ *is_global = true;
+ return 0;
+}
+
+int __pkgmgrinfo_appinfo_get_usr_appinfo_fake(const char *pkgid, uid_t uid,
+ pkgmgrinfo_pkginfo_h *handle)
+{
+ return 0;
+}
+
+int __pkgmgrinfo_appinfo_get_component_type_fake(pkgmgrinfo_appinfo_h handle, char **type)
+{
+ return 0;
+}
+
+int __pkgmgrinfo_pkginfo_destroy_fake(pkgmgrinfo_pkginfo_h handle)
+{
+ return 0;
+}
+
+int __pkgmgrinfo_appinfo_destroy_fake(pkgmgrinfo_appinfo_h handle)
+{
+ return 0;
+}
+
+bundle *__bundle_decode_fake(const bundle_raw* raw, const int len)
+{
+ bundle *b;
+
+ b = bundle_create();
+ bundle_add_str(b, "__APP_SVC_PKG_NAME__", "org.tizen.alarm");
+
+ return b;
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_create_p)
+{
+ int ret;
+ int alarm_id;
+ GVariant *param = NULL;
+ gint64 reserved = 1;
+
+ g_hash_table_lookup_fake.custom_fake = __g_hash_table_lookup_fake;
+ g_bus_get_sync_fake.custom_fake = __g_bus_get_sync_fake;
+ g_dbus_connection_signal_subscribe_fake.custom_fake = __g_dbus_connection_signal_subscribe_fake;
+ g_dbus_node_info_new_for_xml_fake.custom_fake = __g_dbus_node_info_new_for_xml_fake;
+ g_bus_own_name_on_connection_fake.custom_fake = __g_bus_own_name_on_connection_fake;
+
+ _alarm_initialize();
+ param = g_variant_new("(ssiiiiiiiiiiiiixss)",
+ "app_service_name", "app_service_name_mod",
+ 2019, 11, 1, 12, 59, 59, 400, 2020, 12, 29, 3, 1, 1, reserved,
+ "reserved_service_name", "reserved_service_name_mod");
+
+ ret = alarm_manager_alarm_create(param, 5001, 1, &alarm_id);
+ EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_create_appsvc_p)
+{
+ int ret;
+ int alarm_id;
+ GVariant *param = NULL;
+ bundle *b = NULL;
+ bundle_raw *b_data = NULL;
+ int len = 0;
+ gint64 reserved = 1;
+
+ aul_app_get_pkgid_bypid_for_uid_fake.custom_fake = __aul_app_get_pkgid_bypid_for_uid_fake;
+ g_hash_table_lookup_fake.custom_fake = __g_hash_table_lookup_fake;
+
+ pkgmgrinfo_pkginfo_get_usr_pkginfo_fake.custom_fake =
+ __pkgmgrinfo_pkginfo_get_usr_pkginfo_fake;
+ pkgmgrinfo_pkginfo_get_api_version_fake.custom_fake =
+ __pkgmgrinfo_pkginfo_get_api_version_fake;
+
+ pkgmgrinfo_appinfo_get_usr_appinfo_fake.custom_fake =
+ __pkgmgrinfo_appinfo_get_usr_appinfo_fake;
+
+ pkgmgrinfo_appinfo_get_component_type_fake.custom_fake =
+ __pkgmgrinfo_appinfo_get_component_type_fake;
+ pkgmgrinfo_appinfo_destroy_appinfo_fake.custom_fake =
+ __pkgmgrinfo_appinfo_destroy_fake;
+
+ //bundle_decode_fake.custom_fake = __bundle_decode_fake;
+
+ b = bundle_create();
+ bundle_add_str(b, "__APP_SVC_PKG_NAME__", "org.tizen.alarm");
+ bundle_encode(b, &b_data, &len);
+
+ param = g_variant_new("(iiiiiiiiiixiixs)",
+ 2019, 11, 1, 12, 59, 59,
+ 2020, 12, 29,
+ 1, reserved, 1, 0, reserved,
+ (char *)b_data);
+ ret = alarm_manager_alarm_create_appsvc(param, 5001, 1, &alarm_id);
+ bundle_free(b);
+ if (b_data)
+ free(b_data);
+ EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_create_periodic_p)
+{
+ int ret;
+ int alarm_id;
+ GVariant *param = NULL;
+
+ param = g_variant_new("(ssiii)",
+ "app_service_name", "app_service_name_mod", 1, 0, 1);
+
+ ret = alarm_manager_alarm_create_periodic(param, 5001, 1, &alarm_id);
+ EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_create_noti_p)
+{
+ int ret;
+ int alarm_id;
+ GVariant *param = NULL;
+ gint64 reserved = 1;
+
+ param = g_variant_new("(iiiiiiiiiixiixs)",
+ 2019, 11, 1, 12, 59, 59,
+ 2020, 12, 29, 3,
+ 0, reserved, 1, 0, reserved,
+ "bundle");
+
+
+ ret = alarm_manager_alarm_create_noti(param, 5001, 1, &alarm_id);
+ EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_delete_p)
+{
+ int ret;
+ GVariant *param = NULL;
+
+ param = g_variant_new("(i)", 1);
+
+ ret = alarm_manager_alarm_delete(param, 5001, 1);
+ EXPECT_EQ(ERR_ALARM_INVALID_ID, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_delete_all_p)
+{
+ int ret;
+ GVariant *param = NULL;
+
+ ret = alarm_manager_alarm_delete_all(param, 5001, 1);
+ EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_update_n)
+{
+ int ret;
+ int alarm_id = 1;
+ GVariant *param = NULL;
+ gint64 reserved = 1;
+
+ param = g_variant_new("(iiiiiiiiiixiixi)",
+ alarm_id,
+ 2019, 11, 1, 12, 59, 59,
+ 2020, 12, 29, 0,
+ reserved, 0, 0, reserved, 0);
+
+ ret = alarm_manager_alarm_update(param, 5001, 1);
+ EXPECT_EQ(ERR_ALARM_INVALID_ID, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_get_number_of_ids_p)
+{
+ int ret;
+ int num_of_ids;
+
+ ret = alarm_manager_alarm_get_number_of_ids(5001, 1, &num_of_ids);
+ EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_get_list_of_ids_p)
+{
+ int ret;
+ int num_of_alarm;
+ GVariant *alarm_array = NULL;
+ GVariant *param = NULL;
+
+ param = g_variant_new("(i)", 10);
+
+ ret = alarm_manager_alarm_get_list_of_ids(param, 5001, 1, &alarm_array,
+ &num_of_alarm);
+ EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_get_appsvc_info_n)
+{
+ int ret;
+ gchar *b_data = NULL;
+ GVariant *param = NULL;
+
+ param = g_variant_new("(i)", 10);
+
+ ret = alarm_manager_alarm_get_appsvc_info(param, 5001, &b_data);
+ EXPECT_EQ(ERR_ALARM_INVALID_ID, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_get_noti_info_n)
+{
+ int ret;
+ gchar *b_data = NULL;
+ GVariant *param = NULL;
+
+ param = g_variant_new("(i)", 10);
+
+ ret = alarm_manager_alarm_get_noti_info(param, 5001, &b_data);
+ EXPECT_EQ(ERR_ALARM_INVALID_ID, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_get_info_n)
+{
+ int ret;
+ alarm_info_t info;
+ GVariant *param = NULL;
+
+ param = g_variant_new("(i)", 10);
+
+ ret = alarm_manager_alarm_get_info(param, 5001, &info);
+ EXPECT_EQ(ERR_ALARM_INVALID_ID, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_get_next_duetime_n)
+{
+ int ret;
+ time_t duetime;
+ GVariant *param = NULL;
+
+ param = g_variant_new("(i)", 10);
+
+ ret = alarm_manager_alarm_get_next_duetime(param, 5001, &duetime);
+ EXPECT_EQ(ERR_ALARM_INVALID_ID, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_get_all_info_p)
+{
+ int ret;
+ char *db_path;
+
+ ret = alarm_manager_alarm_get_all_info(5001, &db_path);
+ EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_set_rtc_time_n)
+{
+ int ret;
+ GVariant *param = NULL;
+
+ param = g_variant_new("(iiiiii)", 2019, 11, 1, 12, 12, 12);
+
+ ret = alarm_manager_alarm_set_rtc_time(param);
+ EXPECT_EQ(ERR_ALARM_SYSTEM_FAIL, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_set_time_n)
+{
+ int ret;
+ GVariant *param = NULL;
+
+ param = g_variant_new("(x)", 20190012);
+
+ ret = alarm_manager_alarm_set_time(param, 1);
+ EXPECT_EQ(ERR_ALARM_SYSTEM_FAIL, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_set_time_with_propagation_delay_n)
+{
+ int ret;
+ GVariant *param = NULL;
+
+ param = g_variant_new("(xxxx)", 20190012, 2949294, 292929, 29299292);
+
+ ret = alarm_manager_alarm_set_time_with_propagation_delay(param, 1);
+ EXPECT_EQ(ERR_ALARM_SYSTEM_FAIL, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_set_timezone_n)
+{
+ int ret;
+ GVariant *param = NULL;
+
+ param = g_variant_new("(s)", "/usr/share/zoneinfo/Asia/Seoul");
+
+ ret = alarm_manager_alarm_set_timezone(param);
+ EXPECT_EQ(ERR_ALARM_SYSTEM_FAIL, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_set_global_n)
+{
+ int ret;
+ GVariant *param = NULL;
+ GVariant *param2 = NULL;
+ gint64 reserved = 1;
+ int alarm_id;
+
+ g_hash_table_lookup_fake.custom_fake = __g_hash_table_lookup_fake;
+ pkgmgrinfo_pkginfo_get_usr_pkginfo_fake.custom_fake =
+ __pkgmgrinfo_pkginfo_get_usr_pkginfo_fake;
+ pkgmgrinfo_pkginfo_is_global_fake.custom_fake =
+ __pkgmgrinfo_pkginfo_get_is_global_fake;
+ pkgmgrinfo_pkginfo_destroy_pkginfo_fake.custom_fake =
+ __pkgmgrinfo_pkginfo_destroy_fake;
+
+ param = g_variant_new("(ssiiiiiiiiiiiiixss)",
+ "app_service_name", "app_service_name_mod",
+ 2019, 11, 1, 12, 59, 59, 400, 2020, 12, 29, 3, 1, 1, reserved,
+ "reserved_service_name", "reserved_service_name_mod");
+
+ ret = alarm_manager_alarm_create(param, 5001, 1, &alarm_id);
+ param2 = g_variant_new("(ib)", alarm_id, true);
+
+ ret = alarm_manager_alarm_set_global(param2, 5001);
+ EXPECT_EQ(ERR_ALARM_SYSTEM_FAIL, ret);
+}
+
+TEST_F(AlarmServerTest, alarm_manager_alarm_get_global_n)
+{
+ int ret;
+ GVariant *param = NULL;
+ gboolean global;
+
+ param = g_variant_new("(i)", 1);
+
+ ret = alarm_manager_alarm_get_global(param, &global);
+ EXPECT_EQ(ERR_ALARM_INVALID_ID, ret);
+}
diff --git a/unittest/alarmlib_unittest.cpp b/unittest/alarmlib_unittest.cpp
index c06890d..dc01df1 100755
--- a/unittest/alarmlib_unittest.cpp
+++ b/unittest/alarmlib_unittest.cpp
@@ -23,8 +23,7 @@
#include "unittest.h"
#include "alarm.h"
#include "mock/gio_fake.h"
-#include "mock/alarm_dbus.h"
-#include "mock/aul_fake.h"
+#include "mock/glib_fake.h"
#include "mock/notification_fake.h"
void __g_dbus_node_info_unref_fake(GDBusNodeInfo *info)
@@ -74,6 +73,12 @@ guint __g_dbus_connection_register_object_fake(GDBusConnection *con,
return 1;
}
+gboolean __g_dbus_connection_unregister_object_fake(GDBusConnection *con,
+ guint id)
+{
+ return true;
+}
+
guint __g_bus_own_name_on_connection_fake(GDBusConnection *con, const gchar *name,
GBusNameOwnerFlags flag, GBusNameAcquiredCallback acquired_cb,
GBusNameLostCallback lost_cb, gpointer user_data,
@@ -82,221 +87,27 @@ guint __g_bus_own_name_on_connection_fake(GDBusConnection *con, const gchar *nam
return 1;
}
-gboolean __alarm_manager_call_alarm_get_info_sync_fake(AlarmManager *alarm,
- gint alarm_id, gint *start_year, gint *start_month, gint *start_day, gint *start_hour,
- gint *start_min, gint *start_sec, gint *end_year, gint *end_month, gint *end_day,
- gint *mode_day_of_week, gint *mode_repeat, gint *alarm_type,
- gint *reserved_info, gint *return_code, GCancellable *cancel, GError **error)
-{
- return true;
-}
-
-//gboolean __alarm_manager_call_alarm_create_sync_fake(AlarmManager *alarm,
-// const gchar *arg_app_service_name, const gchar *arg_app_service_name_mod,
-// gint start_year, gint start_month,
-// gint start_day, gint start_hour, gint start_min, gint start_sec,
-// gint msec, gint end_year, gint end_month, gint end_day,
-// gint mode_day_of_week, gint mode_repeat, gint alarm_type,
-// gint reserved_info, const gchar *arg_alarm_info_reserved_service_name,
-// const gchar *arg_alarm_info_reserved_service_name_mod, gint *alarm_id,
-// gint *return_code, GCancellable *cancel, GError **error)
-//{
-// return true;
-//}
-
-gboolean __alarm_manager_call_alarm_create_appsvc_sync_fake(AlarmManager *alarm,
- gint start_year, gint start_month, gint start_day, gint start_hour,
- gint start_min, gint start_sec, gint end_year, gint end_month, gint end_day,
- gint mode_day_of_week, gint mode_ginterval, gint mode_repeat, gint alarm_type,
- gint reserved_info, const char *bundle, gint *alarm_id, gint *return_code,
- GCancellable *cancel, GError **error)
-{
- return true;
-}
-
-gboolean __alarm_manager_call_alarm_create_noti_sync_fake(AlarmManager *alarm,
- gint start_year, gint start_month, gint start_day, gint start_hour,
- gint start_min, gint start_sec, gint end_year, gint end_month, gint end_day,
- gint mode_day_of_week, gint mode_ginterval, gint mode_repeat, gint alarm_type,
- gint reserved_info, const char *bundle, gint *alarm_id, gint *return_code,
- GCancellable *cancel, GError **error)
-{
- return true;
-}
-
-gboolean __alarm_manager_call_alarm_get_appsvc_info_sync_fake(AlarmManager *alarm,
- gint alarm_id, gchar **b, gint *return_code, GCancellable *cancel,
- GError **error)
-{
- int datalen;
- bundle_raw *raw = NULL;
- bundle *bundle = bundle_create();
- bundle_add_str(bundle, "key", "val");
-
- bundle_encode(bundle, &raw, &datalen);
-
- *b = (gchar *)raw;
- *return_code = 0;
-
- bundle_free(bundle);
-
- return true;
-}
-
-gboolean __alarm_manager_call_alarm_get_noti_info_sync_fake(AlarmManager *alarm,
- gint alarm_id, gchar **b, gint *return_code, GCancellable *cancel,
- GError **error)
-{
- GVariant *noti_gv = NULL;
- char *noti_data;
- guchar *data;
- int datalen = 0;
- int noti_ret;
- notification_h noti;
-
- noti = notification_create(NOTIFICATION_TYPE_NOTI);
- if (!noti)
- return false;
-
- noti_ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE,
- "Test Title", "TITLE", NOTIFICATION_VARIABLE_TYPE_NONE);
- if (noti_ret != NOTIFICATION_ERROR_NONE)
- return false;
-
- noti_gv = notification_ipc_make_gvariant_from_noti(noti, true);
- if (!noti_gv)
- return false;
-
- datalen = g_variant_get_size(noti_gv);
- if (datalen < 0)
- return false;
-
- data = (guchar *)malloc(datalen);
- if (!data)
- return false;
-
- g_variant_store(noti_gv, data);
- noti_data = g_base64_encode((guchar *)data, datalen);
-
- *b = noti_data;
-
- return true;
-}
-
-gboolean __alarm_manager_call_alarm_set_rtc_time_sync_fake(AlarmManager *alarm,
- gint year, gint month, gint day, gint hour, gint min, gint sec, gint *return_code, GCancellable *cancel, GError **error)
-{
- return true;
-}
-
-gboolean __alarm_manager_call_alarm_delete_sync_fake(AlarmManager *alarm,
- gint alarm_id, gint *return_code, GCancellable *cancel,
- GError **error)
-{
- return true;
-}
-
-gboolean __alarm_manager_call_alarm_delete_all_sync_fake(AlarmManager *alarm,
- gint *return_code, GCancellable *cancel, GError **error)
-{
- return true;
-}
-
-gboolean __alarm_manager_call_alarm_get_number_of_ids_sync_fake(AlarmManager *alarm,
- gint *num, gint *return_code, GCancellable *cancel, GError **error)
-{
- return true;
-}
-
-gboolean __alarm_manager_call_alarm_get_list_of_ids_sync_fake(AlarmManager *alarm,
- gint id, GVariant **alarm_array, gint *num_of_ids, gint *return_code,
- GCancellable *cancel, GError **error)
-{
- int test[2] = {1, 1};
- GVariantBuilder *builder;
-
- builder = g_variant_builder_new(G_VARIANT_TYPE("ai"));
- g_variant_builder_add (builder, "i", test[0]);
- g_variant_builder_add (builder, "i", test[1]);
-
- *alarm_array = g_variant_new("ai", builder);
-
- return true;
-}
-
-gboolean __alarm_manager_call_alarm_get_next_duetime_sync_fake(AlarmManager *alarm,
- gint alarm_id, gint *duetime, gint *return_code, GCancellable *cancel,
+GVariant* __g_dbus_proxy_call_sync_fake_negative(GDBusProxy *proxy, const gchar* method,
+ GVariant *param, GDBusCallFlags flag, gint timeout, GCancellable *cancellable,
GError **error)
{
- return true;
-}
-
-gboolean __alarm_manager_call_alarm_create_periodic_sync_fake(AlarmManager *alarm,
- const gchar* service_name, const gchar *service_name_mod, gint interval,
- gint is_ref, gint method, gint *alarm_id, gint *return_code,
- GCancellable *cancel, GError **error)
-{
- return true;
-}
+ GQuark quark = g_quark_from_static_string("test");
+ *error = g_error_new(quark, G_DBUS_ERROR_ACCESS_DENIED, "Error");
-gboolean __alarm_manager_call_alarm_set_time_sync_fake(AlarmManager *alarm,
- gint new_time, gint *return_code, GCancellable *cancel, GError **error)
-{
- return true;
+ return NULL;
}
-void __alarm_manager_call_alarm_set_time_fake(AlarmManager *alarm,
- gint new_time, GCancellable *cancel, GAsyncReadyCallback cb, gpointer user_data)
+void __g_dbus_proxy_call_fake(GDBusProxy *proxy, const gchar* method,
+ GVariant *param, GDBusCallFlags flag, gint timeout, GCancellable *cancellable,
+ GAsyncReadyCallback cb, gpointer user_data)
{
return;
}
-gboolean __alarm_manager_call_alarm_set_timezone_sync_fake(AlarmManager *alarm,
- const gchar* tzpath, gint *return_code, GCancellable *cancel, GError **error)
+gsize __g_variant_get_size_fake(GVariant *var)
{
- return true;
-}
-
-gboolean __alarm_manager_call_alarm_set_time_with_propagation_delay_sync_fake(AlarmManager *alarm,
- guint new_sec, guint new_nsec, guint req_sec, guint req_nsec,
- gint *return_code, GCancellable *cancel, GError **error)
-{
- return true;
-}
-
-void __alarm_manager_call_alarm_set_time_with_propagation_delay_fake(AlarmManager *alarm,
- guint new_sec, guint new_nsec, guint req_sec, guint req_nsec,
- GCancellable *cancel, GAsyncReadyCallback, gpointer user_data)
-{
- return;
-}
-
-gboolean __alarm_manager_call_alarm_update_sync_fake(AlarmManager *alarm,
- gint id, gint start_year, gint start_month, gint start_day, gint start_hour,
- gint start_min, gint start_sec, gint end_year, gint end_month, gint end_day,
- gint mode_ginterval, gint mode_repeat, gint alarm_type, gint reserved_info,
- gint update_flag, gint *return_code, GCancellable *cancel, GError **error)
-{
- return true;
-}
-
-gboolean __alarm_manager_call_alarm_set_global_sync_fake(AlarmManager *alarm,
- gint id, gboolean global, gint *return_code, GCancellable *cancel, GError **error)
-{
- return true;
-}
-
-gboolean __alarm_manager_call_alarm_get_global_sync_fake(AlarmManager *alarm,
- gint id, gboolean *global, gint *return_code, GCancellable *cancel, GError **error)
-{
- return true;
-}
-
-int __aul_app_get_appid_bypid_fake(int pid, char *appid, int length)
-{
- sprintf(appid, "%s", "test");
-
- return 0;
+ int size = 1;
+ return (gsize)size;
}
GVariant* __notification_ipc_make_gvariant_from_noti_fake(notification_h,
@@ -317,9 +128,7 @@ class AlarmLibTest : public ::testing::Test {
g_bus_get_sync_fake.custom_fake = __g_bus_get_sync_fake;
g_dbus_proxy_new_sync_fake.custom_fake = __g_dbus_proxy_new_sync_fake;
g_dbus_node_info_unref_fake.custom_fake = __g_dbus_node_info_unref_fake;
-
}
-
void TearDown() override {
alarmmgr_free_alarm(alarm);
}
@@ -334,10 +143,25 @@ TEST_F(AlarmLibTest, alarmmgr_init_p)
g_dbus_node_info_new_for_xml_fake.custom_fake = __g_dbus_node_info_new_for_xml_fake;
g_dbus_connection_register_object_fake.custom_fake = __g_dbus_connection_register_object_fake;
+ g_dbus_connection_unregister_object_fake.custom_fake = __g_dbus_connection_unregister_object_fake;
g_bus_own_name_on_connection_fake.custom_fake = __g_bus_own_name_on_connection_fake;
ret = alarmmgr_init(testapp);
EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ alarmmgr_fini();
+}
+
+static int __handler(alarm_id_t alarm_id, void *user_param)
+{
+ return 0;
+}
+
+TEST_F(AlarmLibTest, alarmmgr_set_cb_p)
+{
+ int ret;
+
+ ret = alarmmgr_set_cb(__handler, NULL);
+ EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
}
TEST_F(AlarmLibTest, alarmmgr_set_get_time_p)
@@ -391,14 +215,14 @@ TEST_F(AlarmLibTest, alarmmgr_set_get_type_p)
EXPECT_EQ(ALARM_TYPE_VOLATILE, get_type);
}
-TEST_F(AlarmLibTest, alarmmgr_add_alarm_appsvc_p)
+TEST_F(AlarmLibTest, alarmmgr_add_alarm_appsvc_n)
{
int ret;
alarm_id_t alarm_id;
bundle *b;
- alarm_manager_call_alarm_create_appsvc_sync_fake.custom_fake = __alarm_manager_call_alarm_create_appsvc_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
b = bundle_create();
ASSERT_NE(b, nullptr);
@@ -411,65 +235,110 @@ TEST_F(AlarmLibTest, alarmmgr_add_alarm_appsvc_p)
ret = alarmmgr_add_alarm_appsvc(ALARM_TYPE_DEFAULT, 100, 0, (void *)b,
&alarm_id);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
-
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
bundle_free(b);
}
-TEST_F(AlarmLibTest, alarmmgr_get_alarm_appsvc_p)
+TEST_F(AlarmLibTest, alarmmgr_get_alarm_appsvc_n)
{
int ret;
alarm_id_t alarm_id = 10;
bundle *get_b;
- alarm_manager_call_alarm_get_appsvc_info_sync_fake.custom_fake = __alarm_manager_call_alarm_get_appsvc_info_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
get_b = (bundle *)alarmmgr_get_alarm_appsvc_info(alarm_id, &ret);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
bundle_free(get_b);
}
-TEST_F(AlarmLibTest, alarmmgr_add_alarm_noti_p)
+TEST_F(AlarmLibTest, alarmmgr_add_alarm_noti_n)
{
int ret;
alarm_id_t alarm_id;
notification_h noti = nullptr;
- alarm_manager_call_alarm_create_noti_sync_fake.custom_fake = __alarm_manager_call_alarm_create_noti_sync_fake;
+ g_variant_get_size_fake.custom_fake = __g_variant_get_size_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
notification_ipc_make_gvariant_from_noti_fake.custom_fake = __notification_ipc_make_gvariant_from_noti_fake;
ret = alarmmgr_add_alarm_noti(ALARM_TYPE_DEFAULT, 100, 0, noti,
&alarm_id);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
-TEST_F(AlarmLibTest, alarmmgr_get_alarm_noti_p)
+TEST_F(AlarmLibTest, alarmmgr_get_alarm_noti_n)
{
int ret;
notification_h get_noti;
- alarm_manager_call_alarm_get_noti_info_sync_fake.custom_fake = __alarm_manager_call_alarm_get_noti_info_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
ret = alarmmgr_get_alarm_noti_info(1, &get_noti);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
-TEST_F(AlarmLibTest, alarmmgr_set_rtc_time_p)
+TEST_F(AlarmLibTest, alarmmgr_set_rtc_time_n)
{
int ret;
alarm_date_t date = {2020, 4, 5, 10, 10, 0};
- alarm_manager_call_alarm_set_rtc_time_sync_fake.custom_fake = __alarm_manager_call_alarm_set_rtc_time_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
ret = alarmmgr_set_rtc_time(&date);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
+}
+
+TEST_F(AlarmLibTest, alarmmgr_add_alarm_with_localtime_n)
+{
+ int ret;
+ alarm_id_t alarm_id;
+ alarm_date_t test_time;
+ char testapp[256] = "org.tizen.alarmmgrtestapp";
+
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
+
+ test_time.year = 2022;
+ test_time.month = 1;
+ test_time.day = 1;
+
+ test_time.hour = 1;
+ test_time.min = 1;
+ test_time.sec = 5;
+
+ ret = alarmmgr_init(testapp);
+ EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+
+ ret = alarmmgr_set_time(alarm,test_time);
EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+
+ ret = alarmmgr_set_type(alarm, ALARM_TYPE_DEFAULT);
+ EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+
+ ret = alarmmgr_set_repeat_mode(alarm, ALARM_REPEAT_MODE_REPEAT, 1000);
+ EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+
+ ret = alarmmgr_add_alarm_with_localtime(alarm, testapp, &alarm_id);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
+ alarmmgr_fini();
+}
+
+TEST_F(AlarmLibTest, alarmmgr_get_info_n)
+{
+ int ret;
+ alarm_entry_t get_alarm;
+
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
+
+ ret = alarmmgr_get_info(1, &get_alarm);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
-TEST_F(AlarmLibTest, alarmmgr_add_alarm_appsvc_with_localtime_p)
+TEST_F(AlarmLibTest, alarmmgr_add_alarm_appsvc_with_localtime_n)
{
int ret;
alarm_id_t alarm_id;
@@ -478,7 +347,7 @@ TEST_F(AlarmLibTest, alarmmgr_add_alarm_appsvc_with_localtime_p)
alarm_date_t test_time;
- alarm_manager_call_alarm_create_appsvc_sync_fake.custom_fake = __alarm_manager_call_alarm_create_appsvc_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
b = bundle_create();
ASSERT_NE(b, nullptr);
@@ -505,86 +374,95 @@ TEST_F(AlarmLibTest, alarmmgr_add_alarm_appsvc_with_localtime_p)
ret = alarmmgr_add_alarm_appsvc_with_localtime(alarm, (void *)b,
&alarm_id);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
bundle_free(b);
}
-TEST_F(AlarmLibTest, alarmmgr_get_info_p)
-{
- int ret;
- alarm_entry_t get_alarm;
-
- alarm_manager_call_alarm_get_info_sync_fake.custom_fake = __alarm_manager_call_alarm_get_info_sync_fake;
-
- ret = alarmmgr_get_info(1, &get_alarm);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
-}
-
-TEST_F(AlarmLibTest, alarmmgr_add_alarm_noti_with_localtime_p)
+TEST_F(AlarmLibTest, alarmmgr_add_alarm_noti_with_localtime_n)
{
int ret;
alarm_id_t alarm_id;
notification_h noti = nullptr;
- alarm_manager_call_alarm_create_noti_sync_fake.custom_fake = __alarm_manager_call_alarm_create_noti_sync_fake;
+ notification_ipc_make_gvariant_from_noti_fake.custom_fake = __notification_ipc_make_gvariant_from_noti_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
- ret = alarmmgr_add_alarm_noti_with_localtime(alarm, noti, &alarm_id);
+ ret = alarmmgr_set_repeat_mode(alarm, ALARM_REPEAT_MODE_REPEAT, 1000);
EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+
+ ret = alarmmgr_add_alarm_noti_with_localtime(alarm, noti, &alarm_id);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
-//TODO
-/*
-TEST_F(AlarmLibTest, alarmmgr_add_alarm_p)
+TEST_F(AlarmLibTest, alarmmgr_add_alarm_n)
{
int ret;
alarm_id_t alarm_id;
- alarm_entry_t get_alarm;
- alarm_manager_call_alarm_create_sync_fake.custom_fake = __alarm_manager_call_alarm_create_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
+
+ ret = alarmmgr_set_repeat_mode(alarm, ALARM_REPEAT_MODE_REPEAT, 1000);
+ EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
ret = alarmmgr_add_alarm(ALARM_TYPE_VOLATILE, 100, 1000, "gtest-alarmmgr",
&alarm_id);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
-TEST_F(AlarmLibTest, alarmmgr_add_alarm_precision_p)
+TEST_F(AlarmLibTest, alarmmgr_add_alarm_precision_n)
{
int ret;
alarm_id_t alarm_id;
- alarm_entry_t get_alarm;
+
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
ret = alarmmgr_add_alarm_precision(ALARM_TYPE_VOLATILE, 100, 1000,
"gtest-alarmmgr", &alarm_id);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
-TEST(AlarmLibTest, alarmmgr_add_get_alarm_withcb_p)
+TEST_F(AlarmLibTest, alarmmgr_add_get_alarm_withcb_n)
{
+ int ret;
+ alarm_id_t alarm_id;
+
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
+
+ ret = alarmmgr_add_alarm_withcb(ALARM_TYPE_VOLATILE, 100, 1000,
+ __handler, NULL, &alarm_id);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
-TEST(AlarmLibTest, alarmmgr_add_get_alarm_withcb_precision_p)
+TEST_F(AlarmLibTest, alarmmgr_add_get_alarm_withcb_precision_n)
{
- }
-*/
+ int ret;
+ alarm_id_t alarm_id;
+
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
-TEST_F(AlarmLibTest, alarmmgr_remove_alarm_p)
+ ret = alarmmgr_add_alarm_withcb_precision(ALARM_TYPE_VOLATILE, 100, 1000,
+ __handler, NULL, &alarm_id);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
+}
+
+TEST_F(AlarmLibTest, alarmmgr_remove_alarm_n)
{
int ret;
- alarm_manager_call_alarm_delete_sync_fake.custom_fake = __alarm_manager_call_alarm_delete_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
ret = alarmmgr_remove_alarm(1);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
-TEST_F(AlarmLibTest, alarmmgr_remove_all_p)
+TEST_F(AlarmLibTest, alarmmgr_remove_all_n)
{
int ret;
- alarm_manager_call_alarm_delete_all_sync_fake.custom_fake = __alarm_manager_call_alarm_delete_all_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
ret = alarmmgr_remove_all();
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
int enum_fn(alarm_id_t alarm_id, void *user_param)
@@ -592,27 +470,25 @@ int enum_fn(alarm_id_t alarm_id, void *user_param)
return 0;
}
-TEST_F(AlarmLibTest, alarmmgr_enum_alarm_ids_p)
+TEST_F(AlarmLibTest, alarmmgr_enum_alarm_ids_n)
{
int ret;
- alarm_manager_call_alarm_get_number_of_ids_sync_fake.custom_fake = __alarm_manager_call_alarm_get_number_of_ids_sync_fake;
-
- alarm_manager_call_alarm_get_list_of_ids_sync_fake.custom_fake = __alarm_manager_call_alarm_get_list_of_ids_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
ret = alarmmgr_enum_alarm_ids(enum_fn, nullptr);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
-TEST_F(AlarmLibTest, alarmmgr_get_next_duetime_p)
+TEST_F(AlarmLibTest, alarmmgr_get_next_duetime_n)
{
int ret;
time_t next_time;
- alarm_manager_call_alarm_get_next_duetime_sync_fake.custom_fake = __alarm_manager_call_alarm_get_next_duetime_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
ret = alarmmgr_get_next_duetime(1, &next_time);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
int handler(alarm_id_t alarm_id, void *user_param)
@@ -620,46 +496,44 @@ int handler(alarm_id_t alarm_id, void *user_param)
return 0;
}
-TEST_F(AlarmLibTest, alarmmgr_add_periodic_alarm_withcb_p)
+TEST_F(AlarmLibTest, alarmmgr_add_periodic_alarm_withcb_n)
{
int ret;
alarm_id_t alarm_id;
- aul_app_get_appid_bypid_fake.custom_fake = __aul_app_get_appid_bypid_fake;
- alarm_manager_call_alarm_create_periodic_sync_fake.custom_fake = __alarm_manager_call_alarm_create_periodic_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
ret = alarmmgr_add_periodic_alarm_withcb(1000, CUT_OFF, handler, NULL,
&alarm_id);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
-TEST_F(AlarmLibTest, alarmmgr_add_reference_periodic_alarm_withcb_p)
+TEST_F(AlarmLibTest, alarmmgr_add_reference_periodic_alarm_withcb_n)
{
int ret;
alarm_id_t alarm_id;
- aul_app_get_appid_bypid_fake.custom_fake = __aul_app_get_appid_bypid_fake;
- alarm_manager_call_alarm_create_periodic_sync_fake.custom_fake = __alarm_manager_call_alarm_create_periodic_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
ret = alarmmgr_add_reference_periodic_alarm_withcb(1000, handler, NULL,
&alarm_id);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
-TEST_F(AlarmLibTest, alarmmgr_set_systime_p)
+TEST_F(AlarmLibTest, alarmmgr_set_systime_n)
{
int ret;
time_t current_time;
time(&current_time);
- alarm_manager_call_alarm_set_time_sync_fake.custom_fake = __alarm_manager_call_alarm_set_time_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
ret = alarmmgr_set_systime(current_time);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
-TEST_F(AlarmLibTest, alarmmgr_set_systime_with_propagation_delay_p)
+TEST_F(AlarmLibTest, alarmmgr_set_systime_with_propagation_delay_n)
{
int ret;
struct timespec newtime;
@@ -668,10 +542,10 @@ TEST_F(AlarmLibTest, alarmmgr_set_systime_with_propagation_delay_p)
clock_gettime(CLOCK_REALTIME, &newtime);
clock_gettime(CLOCK_REALTIME, &reqtime);
- alarm_manager_call_alarm_set_time_with_propagation_delay_sync_fake.custom_fake = __alarm_manager_call_alarm_set_time_with_propagation_delay_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
ret = alarmmgr_set_systime_with_propagation_delay(newtime, reqtime);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
int set_time_cb(int result, void *user_param)
@@ -684,7 +558,7 @@ TEST_F(AlarmLibTest, alarmmgr_set_systime_async_p)
int ret;
time_t current_time;
- alarm_manager_call_alarm_set_time_fake.custom_fake = __alarm_manager_call_alarm_set_time_fake;
+ g_dbus_proxy_call_fake.custom_fake = __g_dbus_proxy_call_fake;
time(&current_time);
@@ -698,7 +572,7 @@ TEST_F(AlarmLibTest, alarmmgr_set_systime_with_propagation_delay_async_p)
struct timespec newtime;
struct timespec reqtime;
- alarm_manager_call_alarm_set_time_with_propagation_delay_fake.custom_fake = __alarm_manager_call_alarm_set_time_with_propagation_delay_fake;
+ g_dbus_proxy_call_fake.custom_fake = __g_dbus_proxy_call_fake;
clock_gettime(CLOCK_REALTIME, &newtime);
clock_gettime(CLOCK_REALTIME, &reqtime);
@@ -711,44 +585,44 @@ TEST_F(AlarmLibTest, alarmmgr_set_systime_with_propagation_delay_async_p)
EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
}
-TEST_F(AlarmLibTest, alarmmgr_set_timezone_p)
+TEST_F(AlarmLibTest, alarmmgr_set_timezone_n)
{
int ret;
char zone[] = "/usr/share/zoneinfo/Asia/Seoul";
- alarm_manager_call_alarm_set_timezone_sync_fake.custom_fake = __alarm_manager_call_alarm_set_timezone_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
ret = alarmmgr_set_timezone(zone);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
-TEST_F(AlarmLibTest, alarmmgr_set_globla_p)
+TEST_F(AlarmLibTest, alarmmgr_set_global_n)
{
int ret;
- alarm_manager_call_alarm_set_global_sync_fake.custom_fake = __alarm_manager_call_alarm_set_global_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
ret = alarmmgr_set_global(1, true);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
-TEST_F(AlarmLibTest, alarmmgr_get_globla_p)
+TEST_F(AlarmLibTest, alarmmgr_get_global_n)
{
int ret;
bool global;
- alarm_manager_call_alarm_get_global_sync_fake.custom_fake = __alarm_manager_call_alarm_get_global_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
ret = alarmmgr_get_global(1, &global);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
-TEST_F(AlarmLibTest, alarmmgr_update_alarm_p)
+TEST_F(AlarmLibTest, alarmmgr_update_alarm_n)
{
int ret;
alarm_date_t test_time;
- alarm_manager_call_alarm_update_sync_fake.custom_fake = __alarm_manager_call_alarm_update_sync_fake;
+ g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
test_time.year = 2022;
test_time.month = 1;
@@ -762,5 +636,5 @@ TEST_F(AlarmLibTest, alarmmgr_update_alarm_p)
EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
ret = alarmmgr_update_alarm(1, alarm, ALARM_UPDATE_FLAG_TIME);
- EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ EXPECT_EQ(ERR_ALARM_NO_PERMISSION, ret);
}
diff --git a/unittest/mock/alarm_dbus.h b/unittest/mock/alarm_dbus.h
deleted file mode 100755
index b9c43d1..0000000
--- a/unittest/mock/alarm_dbus.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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_ALARM_DBUS_H_
-#define MOCK_ALARM_DBUS_H_
-
-#include <glib.h>
-
-#include "mock.h"
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_get_info_sync,
- AlarmManager*, gint, gint*, gint*, gint*, gint*, gint*, gint*, gint*,
- gint*, gint*, gint*, gint*, gint*, gint*, gint*, GCancellable*, GError**);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_create_appsvc_sync,
- AlarmManager*, gint, gint, gint, gint, gint, gint, gint, gint, gint, gint,
- gint, gint, gint, gint, const char*, gint*, gint*, GCancellable*, GError**);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_get_appsvc_info_sync,
- AlarmManager*, gint, gchar**, gint*, GCancellable*, GError**);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_create_noti_sync,
- AlarmManager*, gint, gint, gint, gint, gint, gint, gint, gint, gint, gint, gint,
- gint, gint, gint, const char*, gint*, gint*, GCancellable*, GError**);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_get_noti_info_sync,
- AlarmManager*, gint, gchar**, gint*, GCancellable*, GError**);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_set_rtc_time_sync,
- AlarmManager*, gint, gint, gint, gint, gint, gint, gint*, GCancellable*,
- GError**);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_delete_sync,
- AlarmManager*, gint, gint*, GCancellable*, GError**);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_delete_all_sync,
- AlarmManager*, gint*, GCancellable*, GError**);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_get_number_of_ids_sync,
- AlarmManager*, gint*, gint*, GCancellable*, GError**);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_get_list_of_ids_sync,
- AlarmManager*, gint, GVariant**, gint*, gint*, GCancellable*, GError**);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_get_next_duetime_sync,
- AlarmManager*, gint, gint*, gint*, GCancellable*, GError**);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_create_periodic_sync,
- AlarmManager*, const gchar*, const gchar*, gint, gint, gint, gint*,
- gint*, GCancellable*, GError**);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_set_time_sync,
- AlarmManager*, gint, gint*, GCancellable*, GError**);
-
-DECLARE_FAKE_VOID_FUNC(alarm_manager_call_alarm_set_time, AlarmManager*, gint,
- GCancellable*, GAsyncReadyCallback, gpointer);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_set_timezone_sync,
- AlarmManager*, const char*, gint*, GCancellable*, GError**);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean,
- alarm_manager_call_alarm_set_time_with_propagation_delay_sync,
- AlarmManager*, guint, guint, guint, guint, gint*, GCancellable*,
- GError**);
-
-DECLARE_FAKE_VOID_FUNC(alarm_manager_call_alarm_set_time_with_propagation_delay,
- AlarmManager*, guint, guint, guint, guint, GCancellable*,
- GAsyncReadyCallback, gpointer);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_update_sync,
- AlarmManager*, gint, gint, gint, gint, gint, gint, gint, gint, gint,
- gint, gint, gint, gint, gint, gint, gint*, GCancellable*, GError**);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_set_global_sync,
- AlarmManager*, gint, gboolean, gint*, GCancellable*, GError**);
-
-DECLARE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_get_global_sync,
- AlarmManager*, gint, gboolean*, gint*, GCancellable*, GError**);
-
-#endif //MOCK_ALARM_DBUS_H_
diff --git a/unittest/mock/aul_fake.h b/unittest/mock/aul_fake.h
index 9eff529..88393ab 100644
--- a/unittest/mock/aul_fake.h
+++ b/unittest/mock/aul_fake.h
@@ -1,26 +1,28 @@
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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_H_
-#define MOCK_AUL_H_
-
-#include <aul.h>
-
-#include "mock.h"
-
-DECLARE_FAKE_VALUE_FUNC(int, aul_app_get_appid_bypid, int, char*, int);
-
-#endif //MOCK_AUL_H_
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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_H_
+#define MOCK_AUL_H_
+
+#include <aul.h>
+
+#include "mock.h"
+
+DECLARE_FAKE_VALUE_FUNC(int, aul_app_get_appid_bypid, int, char*, int);
+DECLARE_FAKE_VALUE_FUNC(int, aul_app_get_pkgid_bypid_for_uid, int, char*, int,
+ uid_t);
+
+#endif //MOCK_AUL_H_
diff --git a/unittest/mock/cynara_fake.h b/unittest/mock/cynara_fake.h
deleted file mode 100644
index 309f07b..0000000
--- a/unittest/mock/cynara_fake.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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_CYNARA_H_
-#define MOCK_CYNARA_H_
-
-#include <cynara-session.h>
-#include <cynara-client.h>
-#include <cynara-creds-gdbus.h>
-
-#include "mock.h"
-
-DECLARE_FAKE_VALUE_FUNC(int, cynara_initialize, cynara**,
- const cynara_configuration*);
-DECLARE_FAKE_VALUE_FUNC(int, cynara_creds_gdbus_get_user, GDBusConnection*,
- const gchar*, enum cynara_user_creds, gchar **);
-DECLARE_FAKE_VALUE_FUNC(int, cynara_creds_gdbus_get_client, GDBusConnection*,
- const gchar*, enum cynara_client_creds, gchar **);
-DECLARE_FAKE_VALUE_FUNC(char*, cynara_session_from_pid, pid_t);
-DECLARE_FAKE_VALUE_FUNC(int, cynara_check, cynara*, const char*, const char*,
- const char*, const char*);
-
-
-#endif //MOCK_CYNARA_H_
diff --git a/unittest/mock/gio_fake.h b/unittest/mock/gio_fake.h
index 8181065..5192754 100644
--- a/unittest/mock/gio_fake.h
+++ b/unittest/mock/gio_fake.h
@@ -40,6 +40,9 @@ DECLARE_FAKE_VALUE_FUNC(guint, g_dbus_connection_register_object,
GDBusConnection*, const gchar*, GDBusInterfaceInfo*,
const GDBusInterfaceVTable*, gpointer, GDestroyNotify, GError**);
+DECLARE_FAKE_VALUE_FUNC(gboolean, g_dbus_connection_unregister_object,
+ GDBusConnection*, guint);
+
DECLARE_FAKE_VOID_FUNC(g_dbus_method_invocation_return_value,
GDBusMethodInvocation*, GVariant*);
@@ -66,7 +69,11 @@ DECLARE_FAKE_VALUE_FUNC(guint, g_dbus_connection_signal_subscribe,
const gchar*, GDBusSignalFlags, GDBusSignalCallback, gpointer,
GDestroyNotify);
-DECLARE_FAKE_VALUE_FUNC(gboolean, g_dbus_interface_skeleton_export,
- GDBusInterfaceSkeleton*, GDBusConnection*, const gchar*, GError**);
+DECLARE_FAKE_VALUE_FUNC(GVariant*, g_dbus_proxy_call_sync,
+ GDBusProxy*, const gchar*, GVariant*, GDBusCallFlags, gint,
+ GCancellable*, GError**);
+DECLARE_FAKE_VOID_FUNC(g_dbus_proxy_call,
+ GDBusProxy*, const gchar*, GVariant*, GDBusCallFlags, gint,
+ GCancellable*, GAsyncReadyCallback, gpointer);
#endif //MOCK_GIO_H_
diff --git a/unittest/mock/glib_fake.h b/unittest/mock/glib_fake.h
index 8b0d066..a46077a 100755
--- a/unittest/mock/glib_fake.h
+++ b/unittest/mock/glib_fake.h
@@ -21,12 +21,11 @@
#include "mock.h"
-DECLARE_FAKE_VOID_FUNC3_VARARG(g_variant_get, GVariant*, const gchar*, ...);
+DECLARE_FAKE_VALUE_FUNC(gsize, g_variant_get_size, GVariant*);
DECLARE_FAKE_VALUE_FUNC3_VARARG(gboolean, g_variant_iter_loop, GVariantIter*,
const gchar*, ...);
DECLARE_FAKE_VOID_FUNC(g_variant_iter_free, GVariantIter*);
DECLARE_FAKE_VOID_FUNC(g_variant_unref, GVariant*);
-DECLARE_FAKE_VALUE_FUNC2_VARARG(GVariant*, g_variant_new, const gchar*, ...);
DECLARE_FAKE_VALUE_FUNC(gpointer, g_hash_table_lookup, GHashTable*, gconstpointer);
DECLARE_FAKE_VALUE_FUNC(guint, g_hash_table_foreach_remove, GHashTable*,
GHRFunc, gpointer);
diff --git a/unittest/mock/mock.cc b/unittest/mock/mock.cc
index 817dce1..11aa6d1 100644
--- a/unittest/mock/mock.cc
+++ b/unittest/mock/mock.cc
@@ -14,30 +14,31 @@
* limitations under the License.
*/
-#include "alarm_dbus.h"
#include "aul_fake.h"
-#include "cynara_fake.h"
#include "gio_fake.h"
#include "glib_fake.h"
#include "mock.h"
#include "notification_fake.h"
+#include "pkgmgr_info_fake.h"
DEFINE_FFF_GLOBALS;
/* gio.h */
DEFINE_FAKE_VALUE_FUNC(GDBusConnection*, g_bus_get_sync,
- GBusType, GCancellable*, GError**);
+ GBusType, GCancellable*, GError**);
DEFINE_FAKE_VALUE_FUNC(GDBusProxy*, g_dbus_proxy_new_sync,
- GDBusConnection*, GDBusProxyFlags, GDBusInterfaceInfo*,
- const gchar*, const gchar*, const gchar*, GCancellable*, GError**);
+ GDBusConnection*, GDBusProxyFlags, GDBusInterfaceInfo*,
+ const gchar*, const gchar*, const gchar*, GCancellable*, GError**);
DEFINE_FAKE_VALUE_FUNC(GDBusNodeInfo*, g_dbus_node_info_new_for_xml,
- const gchar*, GError**);
+ const gchar*, GError**);
DEFINE_FAKE_VALUE_FUNC(guint, g_bus_own_name_on_connection, GDBusConnection*,
const gchar*, GBusNameOwnerFlags,GBusNameAcquiredCallback,
GBusNameLostCallback, gpointer, GDestroyNotify);
DEFINE_FAKE_VALUE_FUNC(guint, g_dbus_connection_register_object,
GDBusConnection*, const gchar*, GDBusInterfaceInfo*,
const GDBusInterfaceVTable*, gpointer, GDestroyNotify, GError**);
+DEFINE_FAKE_VALUE_FUNC(gboolean, g_dbus_connection_unregister_object,
+ GDBusConnection*, guint);
DEFINE_FAKE_VOID_FUNC(g_dbus_method_invocation_return_value,
GDBusMethodInvocation*, GVariant*);
DEFINE_FAKE_VOID_FUNC(g_bus_unown_name, guint);
@@ -48,73 +49,48 @@ DEFINE_FAKE_VALUE_FUNC(gboolean, g_dbus_connection_flush_sync,
GDBusConnection*, GCancellable*, GError**);
DEFINE_FAKE_VOID_FUNC(g_dbus_node_info_unref, GDBusNodeInfo*);
DEFINE_FAKE_VALUE_FUNC(guint, g_dbus_connection_signal_subscribe,
- GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*,
- const gchar*, GDBusSignalFlags, GDBusSignalCallback, gpointer,
- GDestroyNotify);
-DEFINE_FAKE_VALUE_FUNC(gboolean, g_dbus_interface_skeleton_export,
- GDBusInterfaceSkeleton*, GDBusConnection*, const gchar*, GError**);
-
-/* alarm_dbus.h */
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_get_info_sync,
- AlarmManager*, gint, gint*, gint*, gint*, gint*, gint*, gint*, gint*, gint*, gint*, gint*,
- gint*, gint*, gint*, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_create_appsvc_sync,
- AlarmManager*, gint, gint, gint, gint, gint, gint, gint, gint, gint, gint, gint,
- gint, gint, gint, const char*, gint*, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_get_appsvc_info_sync,
- AlarmManager*, gint, gchar**, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_create_noti_sync,
- AlarmManager*, gint, gint, gint, gint, gint, gint, gint, gint, gint, gint, gint,
- gint, gint, gint, const char*, gint*, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_get_noti_info_sync,
- AlarmManager*, gint, gchar**, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_set_rtc_time_sync, AlarmManager*, gint, gint, gint, gint, gint, gint, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_delete_sync, AlarmManager*, gint, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_delete_all_sync, AlarmManager*, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_get_number_of_ids_sync, AlarmManager*, gint*, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_get_list_of_ids_sync, AlarmManager*, gint, GVariant**, gint*, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_get_next_duetime_sync, AlarmManager*, gint, gint*, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_create_periodic_sync, AlarmManager*, const gchar*, const gchar*, gint, gint, gint, gint*, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_set_time_sync, AlarmManager*, gint, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VOID_FUNC(alarm_manager_call_alarm_set_time, AlarmManager*, gint, GCancellable*, GAsyncReadyCallback, gpointer);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_set_timezone_sync, AlarmManager*, const char*, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_set_time_with_propagation_delay_sync, AlarmManager*, guint, guint, guint, guint, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VOID_FUNC(alarm_manager_call_alarm_set_time_with_propagation_delay, AlarmManager*, guint, guint, guint, guint, GCancellable*, GAsyncReadyCallback, gpointer);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_update_sync, AlarmManager*, gint, gint, gint, gint, gint, gint, gint, gint, gint, gint, gint, gint, gint, gint, gint, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_set_global_sync, AlarmManager*, gint, gboolean, gint*, GCancellable*, GError**);
-DEFINE_FAKE_VALUE_FUNC(gboolean, alarm_manager_call_alarm_get_global_sync, AlarmManager*, gint, gboolean*, gint*, GCancellable*, GError**);
+ GDBusConnection*, const gchar*, const gchar*, const gchar*, const gchar*,
+ const gchar*, GDBusSignalFlags, GDBusSignalCallback, gpointer,
+ GDestroyNotify);
+DEFINE_FAKE_VALUE_FUNC(GVariant*, g_dbus_proxy_call_sync,
+ GDBusProxy*, const gchar*, GVariant*, GDBusCallFlags, gint,
+ GCancellable*, GError**);
+DEFINE_FAKE_VOID_FUNC(g_dbus_proxy_call,
+ GDBusProxy*, const gchar*, GVariant*, GDBusCallFlags, gint,
+ GCancellable*, GAsyncReadyCallback, gpointer);
/* glib_fake.h */
-DEFINE_FAKE_VALUE_FUNC(GVariant*, g_dbus_connection_call_sync, GDBusConnection*,
- const gchar*, const gchar*, const gchar*, const gchar*, GVariant*,
- const GVariantType*, GDBusCallFlags, gint, GCancellable*, GError**);
DEFINE_FAKE_VALUE_FUNC(const gchar*, g_dbus_method_invocation_get_sender, GDBusMethodInvocation*);
-DEFINE_FAKE_VOID_FUNC3_VARARG(g_variant_get, GVariant*, const gchar*, ...);
+DEFINE_FAKE_VALUE_FUNC(gsize, g_variant_get_size, GVariant*);
DEFINE_FAKE_VALUE_FUNC3_VARARG(gboolean, g_variant_iter_loop, GVariantIter*, const gchar*, ...);
DEFINE_FAKE_VOID_FUNC(g_variant_iter_free, GVariantIter*);
DEFINE_FAKE_VOID_FUNC(g_variant_unref, GVariant*);
-DEFINE_FAKE_VALUE_FUNC2_VARARG(GVariant*, g_variant_new, const gchar*, ...);
DEFINE_FAKE_VALUE_FUNC(gpointer, g_hash_table_lookup, GHashTable*, gconstpointer);
DEFINE_FAKE_VALUE_FUNC(guint, g_hash_table_foreach_remove, GHashTable*,
- GHRFunc, gpointer);
+ GHRFunc, gpointer);
DEFINE_FAKE_VALUE_FUNC(gboolean, g_hash_table_insert, GHashTable*,
- gpointer, gpointer);
+ gpointer, gpointer);
/* aul.h */
DEFINE_FAKE_VALUE_FUNC(int, aul_app_get_appid_bypid, int, char*, int);
+DEFINE_FAKE_VALUE_FUNC(int, aul_app_get_pkgid_bypid_for_uid, int, char*, int, uid_t);
/* notification.h */
DEFINE_FAKE_VALUE_FUNC(notification_h, notification_create, notification_type_e);
DEFINE_FAKE_VALUE_FUNC(GVariant*, notification_ipc_make_gvariant_from_noti, notification_h, bool);
-/* cynara_fake.h */
-DEFINE_FAKE_VALUE_FUNC(int, cynara_initialize, cynara**,
- const cynara_configuration*);
-DEFINE_FAKE_VALUE_FUNC(int, cynara_creds_gdbus_get_user, GDBusConnection*,
- const gchar*, enum cynara_user_creds, gchar **);
-DEFINE_FAKE_VALUE_FUNC(int, cynara_creds_gdbus_get_client, GDBusConnection*,
- const gchar*, enum cynara_client_creds, gchar **);
-DEFINE_FAKE_VALUE_FUNC(char*, cynara_session_from_pid, pid_t);
-DEFINE_FAKE_VALUE_FUNC(int, cynara_check, cynara*, const char*, const char*,
- const char*, const char*);
-
+/* pkgmgr_info_fake.h */
+DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_get_usr_pkginfo, const char *,
+ uid_t, pkgmgrinfo_pkginfo_h*);
+DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_get_api_version,
+ pkgmgrinfo_pkginfo_h, char **);
+DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_is_global,
+ pkgmgrinfo_pkginfo_h, bool *);
+DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_destroy_pkginfo,
+ pkgmgrinfo_pkginfo_h);
+DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_appinfo_get_usr_appinfo, const char *,
+ uid_t, pkgmgrinfo_appinfo_h*);
+DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_appinfo_get_component_type,
+ pkgmgrinfo_appinfo_h, char **);
+DEFINE_FAKE_VALUE_FUNC(int, pkgmgrinfo_appinfo_destroy_appinfo,
+ pkgmgrinfo_appinfo_h);
diff --git a/unittest/mock/pkgmgr_info_fake.h b/unittest/mock/pkgmgr_info_fake.h
new file mode 100644
index 0000000..4b739dd
--- /dev/null
+++ b/unittest/mock/pkgmgr_info_fake.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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_H_
+#define MOCK_PKGMGR_INFO_H_
+
+#include <pkgmgr-info.h>
+
+#include "mock.h"
+
+DECLARE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_get_usr_pkginfo, const char *,
+ uid_t, pkgmgrinfo_pkginfo_h*);
+DECLARE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_get_api_version,
+ pkgmgrinfo_pkginfo_h, char **);
+DECLARE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_is_global,
+ pkgmgrinfo_pkginfo_h, bool *);
+DECLARE_FAKE_VALUE_FUNC(int, pkgmgrinfo_pkginfo_destroy_pkginfo,
+ pkgmgrinfo_pkginfo_h);
+DECLARE_FAKE_VALUE_FUNC(int, pkgmgrinfo_appinfo_get_usr_appinfo, const char *,
+ uid_t, pkgmgrinfo_appinfo_h*);
+DECLARE_FAKE_VALUE_FUNC(int, pkgmgrinfo_appinfo_get_component_type,
+ pkgmgrinfo_appinfo_h, char **);
+DECLARE_FAKE_VALUE_FUNC(int, pkgmgrinfo_appinfo_destroy_appinfo,
+ pkgmgrinfo_appinfo_h);
+
+
+#endif //MOCK_PKGMGR_INFO_H_