Fix build break for unittest 84/223484/4
authorInkyun Kil <inkyun.kil@samsung.com>
Thu, 30 Jan 2020 07:34:56 +0000 (16:34 +0900)
committerInkyun Kil <inkyun.kil@samsung.com>
Sun, 8 Mar 2020 23:52:04 +0000 (08:52 +0900)
Change-Id: I6d88d45dd1d374e8b465f4ab3340fca8f9c532cf
Signed-off-by: Inkyun Kil <inkyun.kil@samsung.com>
unittest/CMakeLists.txt
unittest/alarm_manager_unittest.cpp
unittest/alarmlib_unittest.cpp

index 900a0be90ec00243aef4766362d72c14ba24c926..33e1e8f7eaf18fb5fd1212899ed8ca2059d5e41a 100755 (executable)
@@ -17,7 +17,8 @@ SET(GTEST_SERVER_SRCS ${CMAKE_SOURCE_DIR}/server/alarm-manager.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)
+       ${CMAKE_SOURCE_DIR}/server/alarm-manager-db.c
+       ${CMAKE_SOURCE_DIR}/server/alarm-manager-db-migration.c)
 
 AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/ GTEST_TEST_SRCS)
 AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/mock GTEST_TEST_SRCS)
index e59c1902cefb192ff610ff9f2f7d3425533641f1..64d5384a77153747d7f54d5229b550bb4b6dd68e 100644 (file)
@@ -23,11 +23,11 @@ _all * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved
 #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:
@@ -38,7 +38,7 @@ class AlarmServerTest : public ::testing::Test {
     }
 };
 
-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;
@@ -77,47 +77,47 @@ 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,
+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;
 
@@ -295,6 +295,8 @@ TEST_F(AlarmServerTest, alarm_manager_alarm_get_appsvc_info_n)
 
   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)
@@ -307,6 +309,8 @@ 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)
@@ -336,10 +340,12 @@ TEST_F(AlarmServerTest, alarm_manager_alarm_get_next_duetime_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)
index dc01df15b19224d2eba799ff7630c1a72c2c1e7d..9690a1477c12197ef27807a8f301b8ec01c6c86a 100755 (executable)
 
 #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)
 {
@@ -55,10 +57,19 @@ GDBusProxy* __g_dbus_proxy_new_sync_fake(GDBusConnection *con,
 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;
 
@@ -120,6 +131,30 @@ GVariant* __notification_ipc_make_gvariant_from_noti_fake(notification_h,
   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 {
@@ -223,6 +258,15 @@ TEST_F(AlarmLibTest, alarmmgr_add_alarm_appsvc_n)
   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);