#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"
+#include "glib_fake.h"
+#include "gio_fake.h"
+#include "aul_fake.h"
+#include "notification_fake.h"
+#include "pkgmgr_info_fake.h"
class AlarmServerTest : public ::testing::Test {
protected:
}
};
-int __aul_app_get_pkgid_bypid_for_uid_fake(int pid, char* pkgid, int size,
+static int __aul_app_get_pkgid_bypid_for_uid_fake(int pid, char* pkgid, int size,
uid_t uid)
{
return 0;
return NULL;
}
-int __pkgmgrinfo_pkginfo_get_usr_pkginfo_fake(const char *pkgid, uid_t uid,
+static 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(
+static int __pkgmgrinfo_pkginfo_get_api_version_fake(
pkgmgrinfo_pkginfo_h handle, char **version)
{
return 0;
}
-int __pkgmgrinfo_pkginfo_get_is_global_fake(
+static 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,
+static 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)
+static int __pkgmgrinfo_appinfo_get_component_type_fake(pkgmgrinfo_appinfo_h handle, char **type)
{
return 0;
}
-int __pkgmgrinfo_pkginfo_destroy_fake(pkgmgrinfo_pkginfo_h handle)
+static int __pkgmgrinfo_pkginfo_destroy_fake(pkgmgrinfo_pkginfo_h handle)
{
return 0;
}
-int __pkgmgrinfo_appinfo_destroy_fake(pkgmgrinfo_appinfo_h handle)
+static int __pkgmgrinfo_appinfo_destroy_fake(pkgmgrinfo_appinfo_h handle)
{
return 0;
}
-bundle *__bundle_decode_fake(const bundle_raw* raw, const int len)
+static bundle *__bundle_decode_fake(const bundle_raw* raw, const int len)
{
bundle *b;
ret = alarm_manager_alarm_get_appsvc_info(param, 5001, &b_data);
EXPECT_EQ(ERR_ALARM_INVALID_ID, ret);
+ if (b_data)
+ free(b_data);
}
TEST_F(AlarmServerTest, alarm_manager_alarm_get_noti_info_n)
ret = alarm_manager_alarm_get_noti_info(param, 5001, &b_data);
EXPECT_EQ(ERR_ALARM_INVALID_ID, ret);
+ if (b_data)
+ free(b_data);
}
TEST_F(AlarmServerTest, alarm_manager_alarm_get_info_n)
TEST_F(AlarmServerTest, alarm_manager_alarm_get_all_info_p)
{
int ret;
- char *db_path;
+ char *db_path = NULL;
ret = alarm_manager_alarm_get_all_info(5001, &db_path);
EXPECT_EQ(ALARMMGR_RESULT_SUCCESS, ret);
+ if (db_path)
+ free (db_path);
}
TEST_F(AlarmServerTest, alarm_manager_alarm_set_rtc_time_n)
#include "unittest.h"
#include "alarm.h"
-#include "mock/gio_fake.h"
-#include "mock/glib_fake.h"
-#include "mock/notification_fake.h"
+#include "aul_fake.h"
+#include "gio_fake.h"
+#include "glib_fake.h"
+#include "notification_fake.h"
+#include "pkgmgr_info_fake.h"
void __g_dbus_node_info_unref_fake(GDBusNodeInfo *info)
{
GDBusNodeInfo* __g_dbus_node_info_new_for_xml_fake(const gchar *xml, GError **error)
{
GDBusNodeInfo *info = (GDBusNodeInfo*)malloc(sizeof(GDBusNodeInfo));
+ if (!info)
+ return NULL;
+
+ GDBusInterfaceInfo *interface =
+ (GDBusInterfaceInfo*)malloc(sizeof(GDBusInterfaceInfo));
+ if (!interface) {
+ free(info);
+ return NULL;
+ }
info->ref_count = 10;
info->path = NULL;
- info->interfaces = (GDBusInterfaceInfo**)malloc(sizeof(GDBusInterfaceInfo));
+ info->interfaces = &interface;
info->nodes = NULL;
info->annotations = NULL;
return noti_gv;
}
+static int __aul_app_get_pkgid_bypid_for_uid_fake(int pid, char* pkgid, int size,
+ uid_t uid)
+{
+ return 0;
+}
+
+static int __pkgmgrinfo_pkginfo_get_usr_pkginfo_fake(const char *pkgid, uid_t uid,
+ pkgmgrinfo_pkginfo_h *handle)
+{
+ return 0;
+}
+
+static int __pkgmgrinfo_pkginfo_get_api_version_fake(
+ pkgmgrinfo_pkginfo_h handle, char **version)
+{
+ *version = strdup("3.0");
+ return 0;
+}
+
+static int __pkgmgrinfo_pkginfo_destroy_fake(pkgmgrinfo_pkginfo_h handle)
+{
+ return 0;
+}
+
class AlarmLibTest : public ::testing::Test {
protected:
void SetUp() override {
bundle *b;
g_dbus_proxy_call_sync_fake.custom_fake = __g_dbus_proxy_call_sync_fake_negative;
+ aul_app_get_pkgid_bypid_for_uid_fake.custom_fake = __aul_app_get_pkgid_bypid_for_uid_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_pkginfo_destroy_pkginfo_fake.custom_fake =
+ __pkgmgrinfo_pkginfo_destroy_fake;
+
b = bundle_create();
ASSERT_NE(b, nullptr);