Improve coverage and add notification unittest 20/297620/19
authorSukhyungKang <shine.kang@samsung.com>
Tue, 22 Aug 2023 01:51:31 +0000 (10:51 +0900)
committerSukhyungKang <shine.kang@samsung.com>
Wed, 27 Sep 2023 01:09:20 +0000 (10:09 +0900)
Change-Id: I045b5f72d2d20f024b35cc1e3d51bff5fa7008d8
Signed-off-by: SukhyungKang <shine.kang@samsung.com>
119 files changed:
CMakeLists.txt
notification-ex/abstract_item.h
notification-ex/chat_message_item.cc
notification-ex/common.cc
notification-ex/db_manager.cc
notification-ex/db_manager.h
notification-ex/dbus_connection_manager.cc
notification-ex/dbus_connection_manager.h
notification-ex/dbus_event_listener.cc
notification-ex/dbus_event_listener_implementation.h
notification-ex/dbus_sender.cc
notification-ex/dbus_sender_implementation.h
notification-ex/event_info.cc
notification-ex/event_listener_interface.h
notification-ex/event_observer_interface.h
notification-ex/event_sender_interface.h
notification-ex/ex_util.cc
notification-ex/exception.h
notification-ex/ievent_info.h
notification-ex/ievent_info_internal.h
notification-ex/iitem_info.h
notification-ex/iitem_info_internal.h
notification-ex/image_item.cc
notification-ex/manager.cc
notification-ex/manager.h
notification-ex/multi_language.cc
notification-ex/multi_language.h
notification-ex/multi_language_implementation.h
notification-ex/null_item.cc
notification-ex/reporter.cc
notification-ex/reporter.h
notification-ex/shared_file.cc
notification-ex/shared_file.h
notification-ex/socket_handler.h
notification-ex/stub.cc
notification/src/notification_internal.c
notification/src/notification_ipc.c
notification/src/notification_ipc_socket.c
notification/src/notification_setting.c
notification/src/notification_setting_service.c
notification/src/notification_shared_file.c
notification/src/notification_status.c
notification/src/notification_viewer.c
packaging/notification.spec
tests/CMakeLists.txt
tests/mock/app_common_mock.cc
tests/mock/app_common_mock.h [deleted file]
tests/mock/app_common_mock.hh [new file with mode: 0644]
tests/mock/aul_mock.cc [new file with mode: 0644]
tests/mock/aul_mock.hh [new file with mode: 0644]
tests/mock/glib_mock.cc
tests/mock/glib_mock.h [deleted file]
tests/mock/glib_mock.hh [new file with mode: 0644]
tests/mock/mock_hook.h [deleted file]
tests/mock/mock_hook.hh [new file with mode: 0644]
tests/mock/module_mock.h [deleted file]
tests/mock/module_mock.hh [new file with mode: 0644]
tests/mock/package_manager_mock.cc [new file with mode: 0644]
tests/mock/package_manager_mock.hh [new file with mode: 0644]
tests/mock/security_manager_mock.cc
tests/mock/security_manager_mock.h [deleted file]
tests/mock/security_manager_mock.hh [new file with mode: 0644]
tests/mock/smack_mock.cc
tests/mock/smack_mock.h [deleted file]
tests/mock/smack_mock.hh [new file with mode: 0644]
tests/mock/socket_mock.cc [new file with mode: 0644]
tests/mock/socket_mock.hh [new file with mode: 0644]
tests/mock/sqlite_mock.cc [new file with mode: 0644]
tests/mock/sqlite_mock.hh [new file with mode: 0644]
tests/mock/test_fixture.cc
tests/mock/test_fixture.h [deleted file]
tests/mock/test_fixture.hh [new file with mode: 0644]
tests/mock/tzplatform_config_mock.cc
tests/mock/tzplatform_config_mock.h [deleted file]
tests/mock/tzplatform_config_mock.hh [new file with mode: 0644]
tests/noti_ex_unittest/CMakeLists.txt [new file with mode: 0644]
tests/noti_ex_unittest/src/test_main.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_abstract_item.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_app_control_action.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_button_item.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_chat_message_item.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_checkbox_item.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_entry_item.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_event_info.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_group_item.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_icon_item.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_image_item.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_input_selector_item.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_progress_item.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_shared_file.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_text_item.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_time_item.cc [new file with mode: 0644]
tests/noti_ex_unittest/src/test_noti_ex_visibility_action.cc [new file with mode: 0644]
tests/noti_unittest/CMakeLists.txt [new file with mode: 0644]
tests/noti_unittest/src/test_main.cc [new file with mode: 0644]
tests/noti_unittest/src/test_notification.cc [new file with mode: 0644]
tests/noti_unittest/src/test_notification_db.cc [new file with mode: 0644]
tests/noti_unittest/src/test_notification_list.cc [new file with mode: 0644]
tests/noti_unittest/src/test_notification_noti.cc [new file with mode: 0644]
tests/noti_unittest/src/test_notification_ongoing.cc [new file with mode: 0644]
tests/noti_unittest/src/test_notification_setting.cc [new file with mode: 0644]
tests/unittest/CMakeLists.txt [deleted file]
tests/unittest/src/test_main.cc [deleted file]
tests/unittest/src/test_noti_ex_abstract_item.cc [deleted file]
tests/unittest/src/test_noti_ex_app_control_action.cc [deleted file]
tests/unittest/src/test_noti_ex_button_item.cc [deleted file]
tests/unittest/src/test_noti_ex_chat_message_item.cc [deleted file]
tests/unittest/src/test_noti_ex_checkbox_item.cc [deleted file]
tests/unittest/src/test_noti_ex_entry_item.cc [deleted file]
tests/unittest/src/test_noti_ex_event_info.cc [deleted file]
tests/unittest/src/test_noti_ex_group_item.cc [deleted file]
tests/unittest/src/test_noti_ex_icon_item.cc [deleted file]
tests/unittest/src/test_noti_ex_image_item.cc [deleted file]
tests/unittest/src/test_noti_ex_input_selector_item.cc [deleted file]
tests/unittest/src/test_noti_ex_progress_item.cc [deleted file]
tests/unittest/src/test_noti_ex_shared_file.cc [deleted file]
tests/unittest/src/test_noti_ex_text_item.cc [deleted file]
tests/unittest/src/test_noti_ex_time_item.cc [deleted file]
tests/unittest/src/test_noti_ex_visibility_action.cc [deleted file]

index b69932caf40c7199b14322b1a6be706e534b3126..0c0fea1cf882a1bbaa7864e7920df725cff1a6fe 100644 (file)
@@ -5,5 +5,10 @@ ADD_SUBDIRECTORY(notification-ex)
 ADD_SUBDIRECTORY(tests)
 
 ENABLE_TESTING()
-SET(NOTIFICATION_UNIT_TESTS notification-ex_unittests)
-ADD_TEST(NAME ${NOTIFICATION_UNIT_TESTS} COMMAND ${NOTIFICATION_UNIT_TESTS})
\ No newline at end of file
+SET(NOTIFICATION_EX_UNIT_TESTS notification-ex-unittests)
+ADD_TEST(NAME ${NOTIFICATION_EX_UNIT_TESTS} COMMAND ${NOTIFICATION_EX_UNIT_TESTS})
+ADD_DEPENDENCIES(${NOTIFICATION_EX_UNIT_TESTS} notification-ex)
+
+SET(NOTIFICATION_UNIT_TESTS notification-unittests)
+ADD_TEST(NAME ${NOTIFICATION_UNIT_TESTS} COMMAND ${NOTIFICATION_UNIT_TESTS})
+ADD_DEPENDENCIES(${NOTIFICATION_UNIT_TESTS} notification)
index c4e912d0ed96993ec75cf53807856ad699402268..29102943b6f3b25f825f9a758fcd47f20703c075 100644 (file)
@@ -37,6 +37,7 @@
 namespace notification {
 namespace item {
 
+/* LCOV_EXCL_START */
 /**
  * @brief The class for ReceiverGroup.
  * @details The class to define receiver group of notification.
@@ -1092,6 +1093,7 @@ class EXPORT_API AbstractItem {
   void UpdateSoundPrivatePath();
   void UpdateVibrationPrivatePath();
 };  // class AbstractItem
+/* LCOV_EXCL_STOP */
 
 }  // namespace item
 }  // namespace notification
index c5ceb8722d5f5742c74bd921f9c3b46acc508859..9a4ff7344c53a6735810994a685284519f3b38c5 100644 (file)
@@ -134,6 +134,7 @@ AbstractItem& ChatMessageItem::FindByID(std::string id) {
   return FactoryManager::GetInst().GetNullItem();
 }
 
+/* LCOV_EXCL_START */
 AbstractItem& ChatMessageItem::FindByMainType(MainType type) {
   if (GetMainType() == type)
     return *this;
@@ -171,6 +172,7 @@ std::list<std::string> ChatMessageItem::GetSharedPath() const {
 
   return ret;
 }
+/* LCOV_EXCL_STOP */
 
 TextItem& ChatMessageItem::GetNameItem() const {
   if (impl_->name_ == nullptr)
index 1ab82d9136db7c120913dcdb81c78e46b933b405..3634cd358df9e3a7cd03ccd3873b823000f9cc5f 100644 (file)
@@ -27,6 +27,7 @@
 
 namespace notification {
 
+/* LCOV_EXCL_START */
 static const GDBusErrorEntry dbus_error_entries[] = {
   {ERROR_INVALID_PARAMETER, "org.freedesktop.Notification-ex.Error.INVALID_PARAMETER"},
   {ERROR_OUT_OF_MEMORY,     "org.freedesktop.Notification-ex.Error.OUT_OF_MEMORY"},
@@ -55,5 +56,6 @@ GQuark noti_ex_error_quark(void) {
         dbus_error_entries, G_N_ELEMENTS(dbus_error_entries));
   return (GQuark)quark_volatile;
 }
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
index 12cb3e330b2260fa386e85f99bfcafae182ee45c..59f8bb64604e6305986535c71f59334cc4a2f2b0 100644 (file)
@@ -73,6 +73,7 @@ namespace notification {
 DBManager::DBManager() = default;
 DBManager::~DBManager() = default;
 
+/* LCOV_EXCL_START */
 sqlite3* DBManager::OpenDB() {
   int ret;
   sqlite3* db;
@@ -105,10 +106,8 @@ int DBManager::ExecuteQuery(sqlite3* db, const char* query, int* num_changes) {
 
   ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, nullptr);
   if (ret != SQLITE_OK) {
-    /* LCOV_EXCL_START */
     LOGE("Sqlite3 err[%d][%s]", ret, sqlite3_errmsg(db));
     return ERROR_FROM_DB;
-    /* LCOV_EXCL_STOP */
   }
 
   ret = sqlite3_step(stmt);
@@ -117,10 +116,8 @@ int DBManager::ExecuteQuery(sqlite3* db, const char* query, int* num_changes) {
     *num_changes = sqlite3_changes(db);
     ret = ERROR_NONE;
   } else {
-    /* LCOV_EXCL_START */
     LOGE("Sqlite err[%d][%s]", ret, sqlite3_errmsg(db));
     ret = ERROR_FROM_DB;
-    /* LCOV_EXCL_STOP */
   }
 
   sqlite3_finalize(stmt);
@@ -154,10 +151,8 @@ int DBManager::GetSequence(sqlite3* db, int64_t* seq) {
       " FROM noti_ex_list";
   ret = sqlite3_prepare_v2(db, query.c_str(), query.size(), &stmt, nullptr);
   if (ret != SQLITE_OK) {
-    /* LCOV_EXCL_START */
     LOGE("Sqlite3 err[%d][%s]", ret, sqlite3_errmsg(db));
     return ERROR_FROM_DB;
-    /* LCOV_EXCL_STOP */
   }
 
   ret = sqlite3_step(stmt);
@@ -169,10 +164,8 @@ int DBManager::GetSequence(sqlite3* db, int64_t* seq) {
       *seq = sqlite3_column_int64(stmt, 1) + 1;
     ret = ERROR_NONE;
   } else {
-    /* LCOV_EXCL_START */
     LOGE("Sqlite err [%d][%s]", ret, sqlite3_errmsg(db));
     ret = ERROR_FROM_DB;
-    /* LCOV_EXCL_STOP */
   }
 
   sqlite3_finalize(stmt);
@@ -307,10 +300,8 @@ void DBManager::CheckLimit(shared_ptr<item::AbstractItem> addedItem, sqlite3* db
 
   ret = sqlite3_prepare_v2(db, query, -1, &stmt, nullptr);
   if (ret != SQLITE_OK) {
-    /* LCOV_EXCL_START */
     LOGE("sqlite3_prepare_v2 Failed [%d][%s]", ret, sqlite3_errmsg(db));
     goto out;
-    /* LCOV_EXCL_STOP */
   }
 
   count -= NOTI_LIMIT;
@@ -327,10 +318,8 @@ void DBManager::CheckLimit(shared_ptr<item::AbstractItem> addedItem, sqlite3* db
 
   ret = sqlite3_prepare_v2(db, query, -1, &delete_stmt, nullptr);
   if (ret != SQLITE_OK) {
-    /* LCOV_EXCL_START */
     LOGE("sqlite3_prepare_v2 Failed [%d][%s]", ret, sqlite3_errmsg(db));
     goto out;
-    /* LCOV_EXCL_STOP */
   }
 
   while (sqlite3_step(stmt) == SQLITE_ROW && count > 0) {
@@ -876,4 +865,6 @@ string DBManager::GetPkgId(const string& app_id, uid_t uid) {
   }
   return pkgid;
 }
+/* LCOV_EXCL_STOP */
+
 }  // namespace notification
index 55d15f6535478bad2952a8b9b0fe770ed6bb7dab..a611a810cf5a39834e482a443fd3d71912ce6235 100644 (file)
@@ -32,6 +32,7 @@
 
 namespace notification {
 
+/* LCOV_EXCL_START */
 class EXPORT_API DBManager {
  public:
   static int InitializeDB();
@@ -65,6 +66,8 @@ class EXPORT_API DBManager {
   static int UpdateReceiverList(std::shared_ptr<item::AbstractItem> updatedItem,  sqlite3* db);
   static std::list<std::shared_ptr<item::AbstractItem>> ExecuteGetList(char* query);
 };
+/* LCOV_EXCL_STOP */
+
 }  // namespace notification
 
 #endif  // NOTIFICATION_EX_DB_MANAGER_H_
index 633fa411f36aee5a0380362a45bc18e9cf7bcc57..83b2f4493e0c3be778090491a329d62fc48612ed 100644 (file)
@@ -34,6 +34,7 @@
 using namespace std;
 namespace notification {
 
+/* LCOV_EXCL_START */
 DBusConnectionManager::DBusConnectionManager() = default;
 DBusConnectionManager::~DBusConnectionManager() = default;
 
@@ -118,5 +119,6 @@ int DBusConnectionManager::Init() {
   }
   return ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
index 1f967585da161bb83ff0c24fc4ea6e84abf3fe4b..85a0589545b3f175c8b3a6cf05b4a1ec675cd0cd 100644 (file)
@@ -27,6 +27,7 @@
 
 namespace notification {
 
+/* LCOV_EXCL_START */
 class EXPORT_API DBusConnectionManager {
  public:
   static DBusConnectionManager& GetInst();
@@ -44,6 +45,7 @@ class EXPORT_API DBusConnectionManager {
   GDBusConnection* connection_ = nullptr;
   bool is_DPM_ = false;
 };
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
 
index b61568a5c913096188c7b5b0c58a7b52d7ff4f65..30f79b483ba02d310db241506158e917c2367b9c 100644 (file)
@@ -49,6 +49,7 @@ using namespace tizen_base;
 
 namespace notification {
 
+/* LCOV_EXCL_START */
 DBusEventListener::DBusEventListener(string path)
     : impl_(new Impl(this, path)) {
   LOGW("Created (%s)", path.c_str());
@@ -521,5 +522,6 @@ list<Bundle> DBusEventListener::NotifyObserver(const IEventInfo& info) {
 int DBusEventListener::NotifyNumberRequest(const IEventInfo& info) {
   return impl_->observer_->OnRequestNumber(info);
 }
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
index 0bc70e9ff1e574fd443571ec1f4e556d271461b9..d7a9720d64d718868eaada3c1690a0584aee48d4 100644 (file)
@@ -25,6 +25,7 @@
 
 namespace notification {
 
+/* LCOV_EXCL_START */
 class DBusEventListener::Impl {
  public:
   virtual ~Impl();
@@ -77,6 +78,7 @@ class DBusEventListener::Impl {
   std::string path_;
   DBusEventListener* parent_;
 };
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
 #endif  // NOTIFICATION_EX_DBUS_EVENT_LISTENER_IMPLEMENTATION_H_
index 89ea543eb26afcbfb633a4efb1eba936adcd4813..9d9318e05f63d62e88ef83bd0e32098230e904ce 100644 (file)
@@ -44,6 +44,7 @@ using namespace std;
 using namespace tizen_base;
 namespace notification {
 
+/* LCOV_EXCL_START */
 DBusSender::DBusSender(string path) : impl_(new Impl(this, path)) {
   LOGW("Created (%s)", path.c_str());
 }
@@ -361,5 +362,6 @@ int DBusSender::RequestReturnValue(const IEventInfo& info) {
   Bundle serialized = info.Serialize();
   return impl_->MethodCall(appid, method_name, serialized);
 }
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
index f701fa84c207c32838942eaef95c3da0502033fe..063d4f2f3857ddd013933dadca801fd5eac58b22 100644 (file)
@@ -28,6 +28,7 @@
 
 namespace notification {
 
+/* LCOV_EXCL_START */
 class DBusSender::Impl {
  public:
   virtual ~Impl();
@@ -51,6 +52,7 @@ class DBusSender::Impl {
   std::string path_;
   DBusSender* parent_;
 };
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
 #endif  // NOTIFICATION_EX_DBUS_SENDER_IMPLEMENTATION_H_
\ No newline at end of file
index 547abeb462c85d1694288be16a89c0fc2ca8c962..244698be0cc7040ab768ea62468d4e1db119c847 100644 (file)
@@ -159,9 +159,11 @@ void EventInfo::SetValidatedUid(uid_t uid) {
   impl_->validated_uid_ = uid;
 }
 
+/* LCOV_EXCL_START */
 int EventInfo::GetRequestId() const {
   return impl_->request_id_;
 }
+/* LCOV_EXCL_STOP */
 
 NotificationError EventInfo::GetError() const {
   return impl_->error_;
index 9813a71488994155e9736fbb2ec9e3ccec443a2e..a27ee212909b59f4ad124c259d6bc7d5a8c7d9f7 100644 (file)
@@ -28,6 +28,7 @@
 
 namespace notification {
 
+/* LCOV_EXCL_START */
 class EXPORT_API IEventListener {
  public:
   virtual ~IEventListener() = default;
@@ -38,6 +39,7 @@ class EXPORT_API IEventListener {
   virtual std::list<tizen_base::Bundle> NotifyObserver(const IEventInfo& info) = 0;
   virtual int NotifyNumberRequest(const IEventInfo& info) = 0;
 };
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
 
index bad3a23183fc5174c63799e3ef98c5d136af8c10..71d16b3c53d57cbfba0e3850bac5a36b85f97780 100644 (file)
@@ -29,6 +29,7 @@
 
 namespace notification {
 
+/* LCOV_EXCL_START */
 class EXPORT_API IEventObserver {
  public:
   virtual ~IEventObserver() = default;
@@ -37,6 +38,7 @@ class EXPORT_API IEventObserver {
   virtual std::list<tizen_base::Bundle> OnRequest(const IEventInfo& info) = 0;
   virtual int OnRequestNumber(const IEventInfo& info) = 0;
 };
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
 
index ad1cd72fb3431ea3d6af192e6cb51bcea0c15b8c..0af9d23aa3577c6bc0f4cb0eacf2461732e01b8f 100644 (file)
@@ -30,6 +30,7 @@
 
 namespace notification {
 
+/* LCOV_EXCL_START */
 class EXPORT_API IEventSender {
  public:
   virtual ~IEventSender() = default;
@@ -42,6 +43,7 @@ class EXPORT_API IEventSender {
   virtual std::list<tizen_base::Bundle> Request(const IEventInfo& info) = 0;
   virtual int RequestReturnValue(const IEventInfo& info) = 0;
 };
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
 
index 19943ca25e1ff7dc84ecd1c4b274d545b24594bc..068bdf0bd7a291c8782c917315981d0be908fa3d 100644 (file)
@@ -37,6 +37,7 @@
 
 using namespace std;
 
+/* LCOV_EXCL_START */
 namespace {
 constexpr int MAX_PACKAGE_STR_SIZE = 512;
 constexpr int MAX_CACHE_SIZE = 100;
@@ -296,7 +297,7 @@ int ConvertDBusError(int error) {
 
   return ERROR_IO_ERROR;
 }
-
+/* LCOV_EXCL_STOP */
 
 }  // namespace util
 }  // namespace notification
index aca1041511b3891df2d775839b69483750d05041..4ca36e65ddbaa295413c56890f93d5ae22c61e2f 100644 (file)
@@ -34,6 +34,7 @@
 
 namespace notification {
 
+/* LCOV_EXCL_START */
 class Exception : public std::exception {
  public:
   explicit Exception(int error_code, std::string file = __FILE__,
@@ -79,6 +80,7 @@ class Exception : public std::exception {
     }
   }
 };  // class Exception
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
 
index 33986ef3fb3bae48abb8100c9adc2de38306d492..22f09d34a426e11f43cfa2f341f7de50aef4cd15 100644 (file)
@@ -27,6 +27,7 @@ namespace notification {
 #define EXPORT_API __attribute__((visibility("default")))
 #endif
 
+/* LCOV_EXCL_START */
 class EXPORT_API IEventInfo {
  public:
   enum EventType {
@@ -49,6 +50,7 @@ class EXPORT_API IEventInfo {
   virtual int GetRequestId() const = 0;
   virtual tizen_base::Bundle Serialize() const = 0;
 };
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
 #endif  // NOTIFICATION_EX_IEVENT_INFO_H_
index c3599745e0512f94b336ea7426afcde303cd21a1..327b6f39f16aeb71ebb87932208574a3bee5080f 100644 (file)
@@ -22,6 +22,7 @@
 
 namespace notification {
 
+/* LCOV_EXCL_START */
 class IEventInfoInternal : public IEventInfo {
  public:
   virtual ~IEventInfoInternal() = default;
@@ -35,6 +36,7 @@ class IEventInfoInternal : public IEventInfo {
   virtual void SetError(NotificationError error) = 0;
   virtual void SetEventType(int type) = 0;
 };
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
 #endif  // NOTIFICATION_EX_IEVENT_INFO_INTERNAL_H_
index bbe605e51b0e0e3ca854b28e69eab57665f88bff..4e10928c020dca3c8bf8f9408eecf924f3115a0f 100644 (file)
@@ -22,6 +22,7 @@
 namespace notification {
 namespace item {
 
+/* LCOV_EXCL_START */
 /**
  * @brief The interface class for ItemInfo
  * @since_tizen 5.5
@@ -69,6 +70,7 @@ class EXPORT_API IItemInfo {
    */
   virtual time_t GetTime() const = 0;
 };
+/* LCOV_EXCL_STOP */
 
 }  // namespace item
 }  // namespace notification
index 2f79e366165edbc332d85e1e0095beda7f446255..f95beec67fe0d5b1e44fbbedf3a52ebe7d39ad97 100644 (file)
@@ -29,6 +29,7 @@
 namespace notification {
 namespace item {
 
+/* LCOV_EXCL_START */
 class EXPORT_API IItemInfoInternal : public IItemInfo {
  public:
   virtual ~IItemInfoInternal() = default;
@@ -43,6 +44,7 @@ class EXPORT_API IItemInfoInternal : public IItemInfo {
   virtual void SetTime(time_t time) = 0;
   virtual bool CanReceive(std::string receiver_group) const = 0;
 };
+/* LCOV_EXCL_STOP */
 
 }  // namespace item
 }  // namespace notification
index ee8087ced395798ab0af0f18d13fa44f29616649..01a5c9e4ef2c44f361ec2a51c7afa820d982d350 100644 (file)
@@ -100,6 +100,7 @@ std::list<std::string> ImageItem::GetSharedPath() const {
   return ret;
 }
 
+/* LCOV_EXCL_START */
 void ImageItem::SetSharedPath() {
   if (!impl_->priv_image_path_.empty())
     impl_->image_path_ = impl_->priv_image_path_;
@@ -117,6 +118,7 @@ std::list<std::map<std::string, std::string>> ImageItem::GetPathMapList() const
 
   return path_map_list;
 }
+/* LCOV_EXCL_STOP */
 
 void ImageItem::UpdatePrivatePath() {
   std::string path;
index 36cf0002954c7d21e59123d4ed7bd1a5db3d0544..3c483fa99a690aada9569182439d6f3bbd1cac1d 100644 (file)
@@ -45,6 +45,7 @@ using namespace tizen_base;
 using namespace notification::item;
 namespace notification {
 
+/* LCOV_EXCL_START */
 Manager::Manager(unique_ptr<IEventSender> sender,
     unique_ptr<IEventListener> listener, string receiver_group)
   : impl_(new Impl(this, move(sender), move(listener), receiver_group)) {
@@ -284,5 +285,6 @@ int Manager::OnRequestNumberEvent(const IEventInfo& info) {
 string Manager::GetPath() {
   return NOTIFICATION_EX_MANAGER_OBJECT_PATH;
 }
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
index 5134deef3f3d7b2587888a0e9bb6b3b89c64799b..6a921632dfb9e6e3fbf7396d38dcb0b8b491728c 100644 (file)
@@ -33,6 +33,7 @@
 
 namespace notification {
 
+/* LCOV_EXCL_START */
 class EXPORT_API Manager : public IEventObserver {
  public:
   Manager(std::unique_ptr<IEventSender> sender,
@@ -70,6 +71,7 @@ class EXPORT_API Manager : public IEventObserver {
   class Impl;
   std::unique_ptr<Impl> impl_;
 };
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
 
index cb0bf6def6dca6f43853b568797e6462aaf4fdbb..4d08a9bd243fcd213d85c8687ff3569b8c8786e6 100644 (file)
@@ -42,6 +42,7 @@ using namespace tizen_base;
 namespace notification {
 namespace item {
 
+/* LCOV_EXCL_START */
 MultiLanguage::MultiLanguage(string msgid, string format,
       vector<string> args)
     : impl_(new Impl(msgid, format, args, this)) {
@@ -130,6 +131,7 @@ void MultiLanguage::UpdateString(string domain, string locale_directory) {
 string MultiLanguage::GetTranslatedString() {
   return impl_->translated_;
 }
+/* LCOV_EXCL_STOP */
 
 }  // namespace item
 }  // namespace notification
\ No newline at end of file
index 0916a1fe83625a4c2b7bcc94cd68f5c5ac6625d9..0f242b4746a01f611242a4952951fae438ede857 100644 (file)
@@ -30,6 +30,7 @@
 namespace notification {
 namespace item {
 
+/* LCOV_EXCL_START */
 /**
  * @brief The class for MultiLanguage type notification.
  * @details The class to make the notification with multi language.
@@ -51,6 +52,7 @@ class EXPORT_API MultiLanguage {
   class Impl;
   std::unique_ptr<Impl> impl_;
 };  // class MultiLanguage
+/* LCOV_EXCL_STOP */
 
 }  // namespace item
 }  // namespace notification
index ddacbc39ef45b8414d694d7ca73f2d0d7b69febe..7c556d1ac36c15aa935036773efd338358b52849 100644 (file)
@@ -28,6 +28,7 @@
 namespace notification {
 namespace item {
 
+/* LCOV_EXCL_START */
 class MultiLanguage::Impl {
  public:
   virtual ~Impl();
@@ -48,6 +49,7 @@ class MultiLanguage::Impl {
   std::string locale_directory_;
   MultiLanguage* parent_;
 };
+/* LCOV_EXCL_STOP */
 
 }  // namespace item
 }  // namespace notification
index f85cf15077ef85caaa6ee705b720c87c8f3cfc19..131565dc08eee56db4f92fb2503fc995c8f1340c 100644 (file)
@@ -32,6 +32,7 @@ using namespace tizen_base;
 namespace notification {
 namespace item {
 
+/* LCOV_EXCL_START */
 NullItem::NullItem(shared_ptr<AbstractAction> action)
     : AbstractItem(action) {
 }
@@ -65,6 +66,7 @@ bool NullItem::IsItemTypeExist(int type) {
     return true;
   return false;
 }
+/* LCOV_EXCL_STOP */
 
 }  // namespace item
 }  // namespace notification
index d100aac9b0e9a0c564e998de9947662bc8108312..5dbe2e5c146ac5d86ac51153dae17fad2393c2e8 100644 (file)
@@ -43,6 +43,7 @@ using namespace tizen_base;
 using namespace notification::item;
 namespace notification {
 
+/* LCOV_EXCL_START */
 Reporter::Reporter(
     unique_ptr<IEventSender> sender, unique_ptr<IEventListener> listener)
   : impl_(new Impl(this, move(sender), move(listener))) {
@@ -256,5 +257,6 @@ string Reporter::GetPath() {
 
 void Reporter::OnRegister(const IEventInfo& info) {
 }
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
index 36e6840b0a654a7e764b8abb2cbb89e994fc70db..e8c849a0ec590ed72b754ddd5f64b2520acf0bde 100644 (file)
@@ -34,6 +34,7 @@
 
 namespace notification {
 
+/* LCOV_EXCL_START */
 class EXPORT_API Reporter : public IEventObserver {
  public:
   Reporter(std::unique_ptr<IEventSender> sender,
@@ -71,6 +72,7 @@ class EXPORT_API Reporter : public IEventObserver {
   class Impl;
   std::unique_ptr<Impl> impl_;
 };
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
 
index 665abd363ab7fcb9cd64c776049036ea0eb9b8e3..41228ee4330e1282c86087a95de4141464bf4c4d 100644 (file)
@@ -83,6 +83,7 @@ const char* SharedFile::GetLastIndex(const char* path, const char* search) {
   return nullptr;
 }
 
+/* LCOV_EXCL_START */
 bool SharedFile::MakeDir(const char* path) {
   if (access(path, R_OK) == 0)
     return true;
@@ -574,6 +575,7 @@ int SharedFile::CopyPrivateFile(shared_ptr<item::AbstractItem> item) {
 
   return ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
 }  // namespace item
 }  // namespace notification
index f0ee5d6819c6d73891a94e3a9d5ebc11f4a09d13..da2fc5206cc346fbead4ecddefbbb5625d98f076 100644 (file)
@@ -34,6 +34,7 @@
 namespace notification {
 namespace item {
 
+/* LCOV_EXCL_START */
 class EXPORT_API SharedFile {
  public:
   SharedFile();
@@ -82,6 +83,7 @@ class EXPORT_API SharedFile {
   std::list<SharingData> sharing_data_list_;
   std::list<SharingTarget> sharing_target_list_;
 };  // class SharedFile
+/* LCOV_EXCL_STOP */
 
 }  // namespace item
 }  // namespace notification
index aa9747f697a188345f9160ed7e6cd76488ec27f0..951ddfa7f56b5f35597b90a17c9af44aa452ac1b 100644 (file)
@@ -21,6 +21,7 @@
 
 namespace notification {
 
+/* LCOV_EXCL_START */
 class SocketHandler {
  public:
   SocketHandler(int fd):fd_(fd){}
@@ -36,6 +37,7 @@ class SocketHandler {
  private:
   int fd_ = -1;
 };
+/* LCOV_EXCL_STOP */
 
 }  // namespace notification
 #endif  // NOTIFICATION_EX_SOCKET_HANDLER_H_
\ No newline at end of file
index cd6b60a20a6ba65e0b003eac853e2a512f40890f..c9f08f5c3fae3cf367f3ceff35fdd5b8f8945468 100644 (file)
@@ -61,6 +61,7 @@ using namespace notification;
 
 namespace {
 
+/* LCOV_EXCL_START */
 class Handle {
  public:
   explicit Handle(item::AbstractItem* ref) : ref_(ref) { }
@@ -276,9 +277,11 @@ class ReporterStub : public Reporter {
  private:
   unique_ptr<ReporterCallbackInfo> cb_;
 };
+/* LCOV_EXCL_STOP */
 
 }  // namespace
 
+/* LCOV_EXCL_START */
 void __noti_ex_free_str_array(char** val, int length) {
   int i;
   for (i = 0; i < length ; i++)
@@ -3778,3 +3781,4 @@ extern "C" EXPORT_API int noti_ex_item_icon_get_icon_path(noti_ex_item_h handle,
 
   return NOTI_EX_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
index 8c2e35938dc41e138a2526cb0f3cdb0c4a5db055..3a7fff9ce6f845a7ed7acada2ac08893bd0d9022 100644 (file)
@@ -68,6 +68,7 @@ struct _notification_event_cb_info {
 static GHashTable *_noti_cb_hash = NULL;
 static GList *__noti_event_cb_list = NULL;
 
+/* LCOV_EXCL_START */
 void notification_reset_event_handler_list(void)
 {
        GList *iter;
@@ -85,7 +86,6 @@ void notification_reset_event_handler_list(void)
        }
 }
 
-/* LCOV_EXCL_START */
 static void __free_changed_cb_info(gpointer data)
 {
        notification_cb_info_s *noti_cb_info = (notification_cb_info_s *)data;
@@ -95,6 +95,7 @@ static void __free_changed_cb_info(gpointer data)
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 void notification_call_changed_cb_for_uid(notification_op *op_list, int op_num, uid_t uid)
 {
        notification_type_e type = NOTIFICATION_TYPE_NOTI;
@@ -167,6 +168,7 @@ void notification_call_event_handler_cb(notification_h noti, int event_type)
        info = g_list_nth_data(find_list, 0);
        info->cb(noti, event_type, info->userdata);
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 void notification_delete_event_handler_cb(int priv_id)
@@ -195,6 +197,7 @@ void notification_delete_event_handler_cb(int priv_id)
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_add_deferred_task(
                void (*deferred_task_cb)(void *data), void *user_data)
 {
@@ -212,7 +215,9 @@ EXPORT_API int notification_del_deferred_task(
 
        return notification_ipc_del_deffered_task(deferred_task_cb);
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_resister_changed_cb_for_uid(
                void (*changed_cb)(void *data, notification_type_e type),
                void *user_data, uid_t uid)
@@ -228,10 +233,8 @@ EXPORT_API int notification_resister_changed_cb_for_uid(
 
        noti_cb_info_new = (notification_cb_info_s *)malloc(sizeof(notification_cb_info_s));
        if (noti_cb_info_new == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc memory");
                return NOTIFICATION_ERROR_OUT_OF_MEMORY;
-               /* LCOV_EXCL_STOP */
        }
 
        noti_cb_info_new->cb_type = NOTIFICATION_CB_NORMAL;
@@ -255,7 +258,9 @@ EXPORT_API int notification_resister_changed_cb_for_uid(
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_resister_changed_cb(
                void (*changed_cb)(void *data, notification_type_e type),
                void *user_data)
@@ -431,6 +436,7 @@ EXPORT_API int notification_update_content(notification_h noti,
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
 /* notification_set_icon will be removed */
 /* LCOV_EXCL_START */
@@ -459,6 +465,7 @@ EXPORT_API int notification_get_icon(notification_h noti,
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_translate_localized_text(notification_h noti)
 {
        int ret = NOTIFICATION_ERROR_NONE;
@@ -502,6 +509,7 @@ EXPORT_API int notification_translate_localized_text(notification_h noti)
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 EXPORT_API int notification_set_title(notification_h noti,
@@ -815,6 +823,7 @@ EXPORT_API int notification_set_pkgname(notification_h noti,
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_set_app_id(notification_h noti,
                const char *app_id)
 {
@@ -831,6 +840,7 @@ EXPORT_API int notification_set_app_id(notification_h noti,
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 int notification_delete_all_by_type_for_uid(const char *app_id,
@@ -998,6 +1008,7 @@ EXPORT_API int notification_get_id(notification_h noti,
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_set_priv_id(notification_h noti, int priv_id)
 {
        if (noti == NULL || priv_id <= 0)
@@ -1007,6 +1018,7 @@ EXPORT_API int notification_set_priv_id(notification_h noti, int priv_id)
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 notification_h notification_load_for_uid(char *app_id,
@@ -1124,6 +1136,7 @@ EXPORT_API int notification_get_execute_option(notification_h noti,
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_insert_for_uid(notification_h noti,
                int *priv_id, uid_t uid)
 {
@@ -1177,7 +1190,9 @@ EXPORT_API int notification_update_async(notification_h noti,
 {
        return notification_update_async_for_uid(noti, result_cb, user_data, getuid());
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_register_detailed_changed_cb_for_uid(
                void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
                void *user_data, uid_t uid)
@@ -1193,10 +1208,8 @@ EXPORT_API int notification_register_detailed_changed_cb_for_uid(
 
        noti_cb_info_new = (notification_cb_info_s *)malloc(sizeof(notification_cb_info_s));
        if (noti_cb_info_new == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc memory");
                return NOTIFICATION_ERROR_OUT_OF_MEMORY;
-               /* LCOV_EXCL_STOP */
        }
 
        noti_cb_info_new->cb_type = NOTIFICATION_CB_DETAILED;
@@ -1220,7 +1233,9 @@ EXPORT_API int notification_register_detailed_changed_cb_for_uid(
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_register_detailed_changed_cb(
                void (*detailed_changed_cb)(void *data, notification_type_e type, notification_op *op_list, int num_op),
                void *user_data)
@@ -1293,6 +1308,7 @@ EXPORT_API int notification_unregister_detailed_changed_cb(
 {
        return notification_unregister_detailed_changed_cb_for_uid(detailed_changed_cb, user_data, getuid());
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 EXPORT_API int notification_is_service_ready(void)
@@ -1301,6 +1317,7 @@ EXPORT_API int notification_is_service_ready(void)
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_set_uid(notification_h noti,
                uid_t uid)
 {
@@ -1372,6 +1389,7 @@ static GList *__copy_private_file(notification_h noti)
 
        return file_list;
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 static void __remove_private_file(gpointer data, gpointer user_data)
@@ -1387,6 +1405,7 @@ static void __remove_private_file(gpointer data, gpointer user_data)
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_post_for_uid(notification_h noti, uid_t uid)
 {
        int ret = 0;
@@ -1459,7 +1478,9 @@ EXPORT_API int notification_delete_all_for_uid(notification_type_e type, uid_t u
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API notification_h notification_load_by_tag_for_uid(const char *tag, uid_t uid)
 {
        int ret;
@@ -1474,22 +1495,18 @@ EXPORT_API notification_h notification_load_by_tag_for_uid(const char *tag, uid_
 
        caller_app_id = notification_get_app_id_by_pid(getpid());
        if (!caller_app_id) {
-               /* LCOV_EXCL_START */
                ERR("Failed to get a package name");
                set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
                return NULL;
-               /* LCOV_EXCL_STOP */
        }
 
        noti = (notification_h)calloc(1, sizeof(struct _notification));
        if (noti == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc a new notification");
                set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
                free(caller_app_id);
 
                return NULL;
-               /* LCOV_EXCL_STOP */
        }
 
        ret = notification_ipc_request_load_noti_by_tag(noti, caller_app_id, (char *)tag, uid);
@@ -1503,7 +1520,9 @@ EXPORT_API notification_h notification_load_by_tag_for_uid(const char *tag, uid_
 
        return noti;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API notification_h notification_create_from_package_template(const char *app_id, const char *template_name)
 {
        int ret;
@@ -1517,11 +1536,9 @@ EXPORT_API notification_h notification_create_from_package_template(const char *
 
        noti = (notification_h)calloc(1, sizeof(struct _notification));
        if (noti == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc memory");
                set_last_result(NOTIFICATION_ERROR_OUT_OF_MEMORY);
                return NULL;
-               /* LCOV_EXCL_STOP */
        }
 
        ret = notification_ipc_request_create_from_package_template(noti, app_id, template_name);
@@ -1533,7 +1550,9 @@ EXPORT_API notification_h notification_create_from_package_template(const char *
 
        return noti;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_set_default_button(notification_h noti, notification_button_index_e index)
 {
        if (noti == NULL)
@@ -1654,7 +1673,9 @@ EXPORT_API int notification_get_text_input_max_length(notification_h noti, int *
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_post_with_event_cb_for_uid(notification_h noti, event_handler_cb cb,
                                                        void *userdata, uid_t uid)
 {
@@ -1690,10 +1711,8 @@ EXPORT_API int notification_post_with_event_cb_for_uid(notification_h noti, even
        } else {
                info = (notification_event_cb_info_s *)malloc(sizeof(notification_event_cb_info_s));
                if (info == NULL) {
-                       /* LCOV_EXCL_START */
                        ERR("Failed to alloc memory");
                        return NOTIFICATION_ERROR_OUT_OF_MEMORY;
-                       /* LCOV_EXCL_STOP */
                }
                info->priv_id = priv_id;
                info->cb = cb;
@@ -1703,7 +1722,9 @@ EXPORT_API int notification_post_with_event_cb_for_uid(notification_h noti, even
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_post_with_event_cb(notification_h noti, event_handler_cb cb, void *userdata)
 {
        return notification_post_with_event_cb_for_uid(noti, cb, userdata, getuid());
@@ -1860,9 +1881,12 @@ EXPORT_API int notification_get_extension_data(notification_h noti, const char *
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
 #define KEY_LEN 40
 #define EXTENSION_EVENT_KEY "_NOTIFICATION_EXTENSION_EVENT_"
+
+/* LCOV_EXCL_START */
 EXPORT_API int notification_set_extension_event_handler(notification_h noti,
                                        notification_event_type_extension_e event,
                                        app_control_h event_handler)
@@ -1898,29 +1922,23 @@ EXPORT_API int notification_set_extension_event_handler(notification_h noti,
 
        err = app_control_export_as_bundle(event_handler, &app_control_bundle);
        if (err != APP_CONTROL_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to export app_control to bundle [%d]", err);
                ret = NOTIFICATION_ERROR_IO_ERROR;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        err = bundle_encode(app_control_bundle, &b_raw, &len);
        if (err != BUNDLE_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to encode bundle [%d]", err);
                ret = NOTIFICATION_ERROR_IO_ERROR;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        err = bundle_add_str(noti->args, key, (const char *)b_raw);
        if (err != BUNDLE_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to add str to bundle [%d]", err);
                ret = NOTIFICATION_ERROR_IO_ERROR;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
 out:
@@ -1931,7 +1949,9 @@ out:
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_get_extension_event_handler(notification_h noti,
                                        notification_event_type_extension_e event,
                                        app_control_h *event_handler)
@@ -1964,29 +1984,23 @@ EXPORT_API int notification_get_extension_event_handler(notification_h noti,
 
        app_control_bundle = _create_bundle_from_bundle_raw((bundle_raw *)ret_str);
        if (app_control_bundle == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to create bundle");
                return NOTIFICATION_ERROR_IO_ERROR;
-               /* LCOV_EXCL_STOP */
        }
 
        err = app_control_create(&ret_app_control);
        if (err != APP_CONTROL_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to create app control [%d]", err);
                ret = NOTIFICATION_ERROR_IO_ERROR;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        err = app_control_import_from_bundle(ret_app_control, app_control_bundle);
        if (err != APP_CONTROL_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to import app control from bundle [%d]", err);
                app_control_destroy(ret_app_control);
                ret = NOTIFICATION_ERROR_IO_ERROR;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        *event_handler = ret_app_control;
@@ -1997,7 +2011,9 @@ out:
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_get_all_count_for_uid(notification_type_e type, int *count, uid_t uid)
 {
        int ret;
@@ -2191,3 +2207,4 @@ EXPORT_API int notification_get_check_box_checked(notification_h noti,
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
index c97dcd9c8189ae29c0dcd309498c0086f9d7c040..07f215f40777944db6dc8d983ed8a8a325692f98 100644 (file)
@@ -200,6 +200,7 @@ int notification_ipc_is_master_ready(void)
 /*
  * store tasks when daemon stopped
  */
+ /* LCOV_EXCL_START */
 int notification_ipc_add_deffered_task(
                void (*deferred_task_cb)(void *data),
                void *user_data)
@@ -272,6 +273,7 @@ int notification_ipc_del_deffered_task(
 
        return NOTIFICATION_ERROR_INVALID_PARAMETER;
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 static void _do_deffered_task(void)
@@ -504,6 +506,7 @@ static void _delete_multiple_notify(GVariant *parameters)
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static void _delete_by_display_applist_notify(GVariant *parameters)
 {
        int *buf;
@@ -545,6 +548,7 @@ static void _delete_by_display_applist_notify(GVariant *parameters)
        free(noti_op);
        free(buf);
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 static void _change_dnd_notify(GVariant *parameters)
@@ -589,6 +593,7 @@ static void _handle_noti_notify(GDBusConnection *connection,
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static void _send_event(GVariant *parameters)
 {
        int ret;
@@ -599,10 +604,8 @@ static void _send_event(GVariant *parameters)
 
        noti = notification_create(NOTIFICATION_TYPE_NOTI);
        if (noti == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to create notification handle");
                return;
-               /* LCOV_EXCL_STOP */
        }
 
        g_variant_get(parameters, "(vi)", &coupled_body, &event_type);
@@ -612,16 +615,15 @@ static void _send_event(GVariant *parameters)
        g_variant_unref(coupled_body);
        g_variant_unref(body);
        if (ret != NOTIFICATION_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to make notification handle from gvariant");
                notification_free(noti);
                return;
-               /* LCOV_EXCL_STOP */
        }
 
        notification_call_event_handler_cb(noti, event_type);
        notification_free(noti);
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 static void _delete_event(GVariant *parameters)
@@ -633,6 +635,7 @@ static void _delete_event(GVariant *parameters)
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static void _handle_noti_event_handler_notify(GDBusConnection *connection,
                const gchar     *sender_name,
                const gchar     *object_path,
@@ -649,7 +652,9 @@ static void _handle_noti_event_handler_notify(GDBusConnection *connection,
        else if (g_strcmp0(signal_name, "delete_noti") == 0)
                _delete_event(parameters);
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static int _dbus_event_handler_signal_init(void)
 {
        int id;
@@ -669,10 +674,8 @@ static int _dbus_event_handler_signal_init(void)
 
                DBG("subscribe id[%d]", id);
                if (id == 0) {
-                       /* LCOV_EXCL_START */
                        ret = NOTIFICATION_ERROR_IO_ERROR;
                        ERR("Failed to subscribe connection signal");
-                       /* LCOV_EXCL_STOP */
                } else {
                        event_monitor_id = id;
                }
@@ -681,6 +684,7 @@ static int _dbus_event_handler_signal_init(void)
        return ret;
 }
 
+/* LCOV_EXCL_START */
 static int _dbus_signal_init(void)
 {
        int id;
@@ -700,10 +704,8 @@ static int _dbus_signal_init(void)
 
                DBG("subscribe id : %d", id);
                if (id == 0) {
-                       /* LCOV_EXCL_START */
                        ret = NOTIFICATION_ERROR_IO_ERROR;
                        ERR("Failed to register dbus_interface");
-                       /* LCOV_EXCL_STOP */
                } else {
                        monitor_id = id;
                        ret = NOTIFICATION_ERROR_NONE;
@@ -712,6 +714,7 @@ static int _dbus_signal_init(void)
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
 static GDBusMessage *__get_new_msg(GVariant *body, const char *cmd)
 {
@@ -830,6 +833,7 @@ static int _send_sync_noti(GVariant *body, GDBusMessage **reply, char *cmd)
        return ret;
 }
 
+/* LCOV_EXCL_START */
 static void _send_message_with_reply_async_cb(GDBusConnection *connection,
                GAsyncResult *res,
                gpointer user_data)
@@ -842,10 +846,8 @@ static void _send_message_with_reply_async_cb(GDBusConnection *connection,
        result_cb_item *cb_item = (result_cb_item *)user_data;
 
        if (cb_item == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to get a callback item");
                return;
-               /* LCOV_EXCL_START */
        }
 
        reply = g_dbus_connection_send_message_with_reply_finish(
@@ -854,16 +856,13 @@ static void _send_message_with_reply_async_cb(GDBusConnection *connection,
                        &err);
 
        if (!reply) {
-               /* LCOV_EXCL_START */
                if (err != NULL) {
                        ERR("No reply[%s]", err->message);
                        g_error_free(err);
                }
                result = NOTIFICATION_ERROR_SERVICE_NOT_READY;
-               /* LCOV_EXCL_STOP */
 
        } else if (g_dbus_message_to_gerror(reply, &err)) {
-               /* LCOV_EXCL_START */
                if (err->code == G_DBUS_ERROR_ACCESS_DENIED)
                        result = NOTIFICATION_ERROR_PERMISSION_DENIED;
                else
@@ -871,7 +870,6 @@ static void _send_message_with_reply_async_cb(GDBusConnection *connection,
 
                ERR("Failed to send message[%s]", err->message);
                g_error_free(err);
-               /* LCOV_EXCL_STOP */
        }
 
        INFO("Async message callback result[%d]", result);
@@ -890,7 +888,9 @@ static void _send_message_with_reply_async_cb(GDBusConnection *connection,
                g_object_unref(reply);
        free(cb_item);
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static int _send_async_noti(GVariant *body, result_cb_item *cb_item, char *cmd)
 {
        GDBusMessage *msg;
@@ -901,10 +901,8 @@ static int _send_async_noti(GVariant *body, result_cb_item *cb_item, char *cmd)
                        PROVIDER_NOTI_INTERFACE_NAME,
                        cmd);
        if (!msg) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc new method call");
                return NOTIFICATION_ERROR_OUT_OF_MEMORY;
-               /* LCOV_EXCL_STOP */
        }
 
        if (g_variant_is_floating(body))
@@ -929,6 +927,8 @@ static int _send_async_noti(GVariant *body, result_cb_item *cb_item, char *cmd)
        DBG("Success to send async message");
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
+
 
 int notification_ipc_request_insert(notification_h noti, int *priv_id)
 {
@@ -1026,6 +1026,7 @@ int notification_ipc_request_update(notification_h noti)
        return result;
 }
 
+/* LCOV_EXCL_START */
 int notification_ipc_request_update_async(notification_h noti,
                void (*result_cb)(int priv_id, int result, void *data), void *user_data)
 {
@@ -1035,10 +1036,8 @@ int notification_ipc_request_update_async(notification_h noti,
 
        result = _dbus_init();
        if (result != NOTIFICATION_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to init dbus connection[%d]", result);
                return result;
-               /* LCOV_EXCL_STOP */
        }
 
        cb_item = calloc(1, sizeof(result_cb_item));
@@ -1050,28 +1049,26 @@ int notification_ipc_request_update_async(notification_h noti,
 
        body = notification_ipc_make_gvariant_from_noti(noti, false);
        if (body == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to make gvariant from notification handle");
                free(cb_item);
                return NOTIFICATION_ERROR_OUT_OF_MEMORY;
-               /* LCOV_EXCL_STOP */
        }
 
        result = _send_async_noti(body, cb_item, "update_noti");
        DBG("Update async result[%d]", result);
 
        if (result != NOTIFICATION_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                free(cb_item);
                cb_item = NULL;
-               /* LCOV_EXCL_STOP */
        }
 
        g_variant_unref(body);
 
        return result;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 int notification_ipc_request_refresh(uid_t uid)
 {
        int result;
@@ -1080,10 +1077,8 @@ int notification_ipc_request_refresh(uid_t uid)
 
        result = _dbus_init();
        if (result != NOTIFICATION_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to init dbus connection[%d]", result);
                return result;
-               /* LCOV_EXCL_STOP */
        }
 
        body = g_variant_new("(i)", uid);
@@ -1095,6 +1090,7 @@ int notification_ipc_request_refresh(uid_t uid)
        DBG("result[%d]", result);
        return result;
 }
+/* LCOV_EXCL_STOP */
 
 int notification_ipc_request_delete_single(notification_type_e type, char *app_id, int priv_id, uid_t uid)
 {
@@ -1162,6 +1158,7 @@ int notification_ipc_request_delete_multiple(notification_type_e type, char *app
        return result;
 }
 
+/* LCOV_EXCL_START */
 int notification_ipc_request_delete_by_display_applist(int display_applist, uid_t uid)
 {
        int result;
@@ -1191,6 +1188,7 @@ int notification_ipc_request_delete_by_display_applist(int display_applist, uid_
        DBG("result[%d]", result);
        return result;
 }
+/* LCOV_EXCL_STOP */
 
 int notification_ipc_request_load_noti_by_tag(notification_h noti, const char *app_id, const char *tag, uid_t uid)
 {
@@ -1470,6 +1468,7 @@ int notification_ipc_request_load_noti_detail_list(const char *app_id,
        return result;
 }
 
+/* LCOV_EXCL_START */
 int notification_ipc_request_get_setting_array(
                notification_setting_h *setting_array,
                int *count,
@@ -1487,10 +1486,8 @@ int notification_ipc_request_get_setting_array(
 
        result = _dbus_init();
        if (result != NOTIFICATION_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to init dbus connection[%d]", result);
                return result;
-               /* LCOV_EXCL_STOP */
        }
 
        result = _send_sync_noti(g_variant_new("(i)", uid), &reply, "get_setting_array");
@@ -1502,12 +1499,10 @@ int notification_ipc_request_get_setting_array(
                DBG("get setting arr cnt: %d", setting_cnt);
                result_setting_array = (struct notification_setting *)malloc(sizeof(struct notification_setting) * setting_cnt);
                if (result_setting_array == NULL) {
-                       /* LCOV_EXCL_START */
                        ERR("malloc failed");
                        g_object_unref(reply);
                        g_variant_iter_free(iter);
                        return NOTIFICATION_ERROR_OUT_OF_MEMORY;
-                       /* LCOV_EXCL_STOP */
                }
 
                setting_idx = 0;
@@ -1528,7 +1523,9 @@ int notification_ipc_request_get_setting_array(
        DBG("result[%d]", result);
        return result;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 int notification_ipc_request_get_setting_by_app_id(
                const char *app_id, notification_setting_h *setting, uid_t uid)
 {
@@ -1554,12 +1551,10 @@ int notification_ipc_request_get_setting_by_app_id(
 
                result_setting = (struct notification_setting *)malloc(sizeof(struct notification_setting));
                if (result_setting == NULL) {
-                       /* LCOV_EXCL_START */
                        ERR("malloc failed");
                        g_object_unref(reply);
                        g_variant_unref(body);
                        return NOTIFICATION_ERROR_OUT_OF_MEMORY;
-                       /* LCOV_EXCL_STOP */
                }
                notification_ipc_make_setting_from_gvariant(result_setting, setting_body);
 
@@ -1573,7 +1568,9 @@ int notification_ipc_request_get_setting_by_app_id(
        DBG("result[%d]", result);
        return result;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 int notification_ipc_request_load_system_setting(notification_system_setting_h *setting, uid_t uid)
 {
        int result;
@@ -1588,10 +1585,8 @@ int notification_ipc_request_load_system_setting(notification_system_setting_h *
 
        result = _dbus_init();
        if (result != NOTIFICATION_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to init dbus connection[%d]", result);
                return result;
-               /* LCOV_EXCL_STOP */
        }
 
        result = _send_sync_noti(g_variant_new("(i)", uid), &reply, "load_system_setting");
@@ -1601,11 +1596,9 @@ int notification_ipc_request_load_system_setting(notification_system_setting_h *
 
                result_setting = (struct notification_system_setting *)calloc(1, sizeof(struct notification_system_setting));
                if (result_setting == NULL) {
-                       /* LCOV_EXCL_START */
                        ERR("malloc failed");
                        result = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                        goto out;
-                       /* LCOV_EXCL_STOP */
                }
 
                notification_ipc_make_system_setting_from_gvariant(result_setting, setting_body);
@@ -1623,12 +1616,10 @@ int notification_ipc_request_load_system_setting(notification_system_setting_h *
                        while (g_variant_iter_loop(iter, "(v)", &iter_body)) {
                                dnd_allow_exception = (dnd_allow_exception_h)calloc(1, sizeof(struct notification_system_setting_dnd_allow_exception));
                                if (dnd_allow_exception == NULL) {
-                                       /* LCOV_EXCL_START */
                                        ERR("Out of memory");
                                        result = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                                        g_variant_unref(iter_body);
                                        goto out;
-                                       /* LCOV_EXCL_STOP */
                                }
 
                                notification_ipc_make_dnd_allow_exception_from_gvariant(dnd_allow_exception, iter_body);
@@ -1652,6 +1643,7 @@ out:
        DBG("result[%d]", result);
        return result;
 }
+/* LCOV_EXCL_START */
 
 int notification_ipc_update_setting(notification_setting_h setting, uid_t uid)
 {
@@ -1686,6 +1678,7 @@ int notification_ipc_update_setting(notification_setting_h setting, uid_t uid)
        return result;
 }
 
+/* LCOV_EXCL_START */
 int notification_ipc_update_system_setting(notification_system_setting_h system_setting, uid_t uid)
 {
        int result;
@@ -1696,10 +1689,8 @@ int notification_ipc_update_system_setting(notification_system_setting_h system_
 
        result = _dbus_init();
        if (result != NOTIFICATION_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to init dbus connection[%d]", result);
                return result;
-               /* LCOV_EXCL_STOP */
        }
 
        body = g_variant_new("(iiiiiiiiii)",
@@ -1735,6 +1726,7 @@ int notification_ipc_update_system_setting(notification_system_setting_h system_
        DBG("result[%d]", result);
        return result;
 }
+/* LCOV_EXCL_STOP */
 
 int notification_ipc_request_save_as_template(notification_h noti, const char *template_name)
 {
@@ -1801,6 +1793,7 @@ int notification_ipc_request_create_from_template(notification_h noti, const cha
        return result;
 }
 
+/* LCOV_EXCL_START */
 int notification_ipc_request_create_from_package_template(notification_h noti, const char *app_id, const char *template_name)
 {
        int result;
@@ -1811,10 +1804,8 @@ int notification_ipc_request_create_from_package_template(notification_h noti, c
 
        result = _dbus_init();
        if (result != NOTIFICATION_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to init dbus connection[%d]", result);
                return result;
-               /* LCOV_EXCL_STOP */
        }
 
        body = g_variant_new("(ss)", app_id, template_name);
@@ -1836,6 +1827,7 @@ int notification_ipc_request_create_from_package_template(notification_h noti, c
 
        return result;
 }
+/* LCOV_EXCL_STOP */
 
 int notification_ipc_get_noti_block_state(const char *app_id, int *do_not_disturb,
                                          int *do_not_disturb_except, int *allow_to_notify,
@@ -1883,6 +1875,7 @@ int notification_ipc_get_noti_block_state(const char *app_id, int *do_not_distur
        return ret;
 }
 
+/* LCOV_EXCL_START */
 int notification_ipc_request_get_all_count(notification_type_e type, int *count, uid_t uid)
 {
        int ret;
@@ -1972,6 +1965,7 @@ int notification_ipc_check_event_receiver(int priv_id, bool *available)
        DBG("result[%d]", ret);
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 void notification_ipc_reset_event_handler(int priv_id)
@@ -2440,6 +2434,7 @@ EXPORT_API int notification_ipc_make_noti_from_gvariant(notification_h noti,
        return NOTIFICATION_ERROR_NONE;
 }
 
+/* LCOV_EXCL_START */
 EXPORT_API GVariant *notification_ipc_make_gvariant_from_system_setting(struct notification_system_setting *noti_setting)
 {
        GVariant *body = NULL;
@@ -2627,6 +2622,7 @@ static int _ipc_monitor_register(uid_t uid)
 {
        return  _send_service_register(uid);
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 static void _on_name_appeared(GDBusConnection *connection,
@@ -2658,32 +2654,27 @@ static void _on_name_vanished(GDBusConnection *connection,
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 int notification_ipc_monitor_init(uid_t uid)
 {
        int ret;
 
        ret = _dbus_init();
        if (ret != NOTIFICATION_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to init dbus connection[%d]", ret);
                return ret;
-               /* LCOV_EXCL_STOP */
        }
 
        ret = _dbus_signal_init();
        if (ret != NOTIFICATION_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to init signal[%d]", ret);
                return ret;
-               /* LCOV_EXCL_STOP */
        }
 
        ret = _ipc_monitor_register(uid);
        if (ret != NOTIFICATION_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to register service[%d]", ret);
                return ret;
-               /* LCOV_EXCL_STOP */
        }
 
        if (provider_monitor_id == 0) {
@@ -2696,18 +2687,18 @@ int notification_ipc_monitor_init(uid_t uid)
                                GINT_TO_POINTER((int)uid),
                                NULL);
                if (provider_monitor_id == 0) {
-                       /* LCOV_EXCL_START */
                        g_dbus_connection_signal_unsubscribe(_gdbus_conn, monitor_id);
                        monitor_id = 0;
                        ERR("Failed to watch name");
                        return NOTIFICATION_ERROR_IO_ERROR;
-                       /* LCOV_EXCL_STOP */
                }
        }
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static int _ipc_monitor_deregister(void)
 {
        if (provider_monitor_id) {
@@ -2727,6 +2718,7 @@ int notification_ipc_monitor_fini(void)
 {
        return  _ipc_monitor_deregister();
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 void notification_ipc_event_monitor_fini(void)
index 54090ac9d94352d4ba587aff4aac00f8af1c8412..ae9cceb73bf49e988db187c50e1dc0ec8b11ac21 100644 (file)
@@ -69,12 +69,14 @@ EXPORT_API int notification_ipc_socket_get_read_buf_size(int fd, unsigned int *s
        return __get_socket_buffer_size(fd, size, SO_RCVBUF);
 }
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_ipc_socket_get_write_buf_size(int fd, unsigned int *size)
 {
        return __get_socket_buffer_size(fd, size, SO_SNDBUF);
 }
+/* LCOV_EXCL_STOP */
 
-
+/* LCOV_EXCL_START */
 EXPORT_API int notification_ipc_socket_write(int fd, const char *buffer, unsigned int nbytes)
 {
        int retry_cnt = 0;
@@ -86,7 +88,6 @@ EXPORT_API int notification_ipc_socket_write(int fd, const char *buffer, unsigne
                errno = 0;
                nb = write(fd, buffer, left);
                if (nb == -1) {
-                       /* LCOV_EXCL_START */
                        if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) {
                                ERR("continue..");
                                retry_cnt++;
@@ -95,7 +96,6 @@ EXPORT_API int notification_ipc_socket_write(int fd, const char *buffer, unsigne
                        }
                        ERR("error fd [%d] errno [%d]", fd, errno);
                        return NOTIFICATION_ERROR_IO_ERROR;
-                       /* LCOV_EXCL_STOP */
                }
 
                left -= nb;
@@ -110,31 +110,30 @@ EXPORT_API int notification_ipc_socket_write(int fd, const char *buffer, unsigne
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_ipc_socket_write_string(int fd, const char *buffer, unsigned int string_len)
 {
        int ret;
 
        ret = notification_ipc_socket_write(fd, (char *)&string_len, sizeof(string_len));
        if (ret != NOTIFICATION_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("write string_len fail");
                return ret;
-               /* LCOV_EXCL_STOP */
        }
 
        if (string_len > 0) {
                ret = notification_ipc_socket_write(fd, buffer, string_len);
                if (ret != NOTIFICATION_ERROR_NONE) {
-                       /* LCOV_EXCL_START */
                        ERR("write string fail");
                        return ret;
-                       /* LCOV_EXCL_STOP */
                }
        }
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
 EXPORT_API int notification_ipc_socket_read(int fd, char *buffer, unsigned int nbytes)
 {
index 6be851f66e136388aa528f837e57ed39907459bc..652706a5762ce2a10617ab0589c38c678aa61ba2 100644 (file)
@@ -49,6 +49,7 @@ struct _noti_dnd_cb_info {
 
 static GHashTable *_noti_dnd_cb_hash = NULL;
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_setting_get_setting_array_for_uid(notification_setting_h *setting_array, int *count, uid_t uid)
 {
        if (setting_array == NULL || count == NULL) {
@@ -73,6 +74,7 @@ EXPORT_API int notification_setting_get_setting_by_appid_for_uid(const char *app
 
        return notification_ipc_request_get_setting_by_app_id(app_id, setting, uid);
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 EXPORT_API int notification_setting_get_setting_by_package_name(const char *package_name, notification_setting_h *setting)
@@ -99,6 +101,7 @@ EXPORT_API int notification_setting_get_setting(notification_setting_h *setting)
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_setting_get_package_name(notification_setting_h setting, char **value)
 {
        if (setting == NULL || value == NULL) {
@@ -107,17 +110,17 @@ EXPORT_API int notification_setting_get_package_name(notification_setting_h sett
        }
 
        if (setting->package_name == NULL) {
-               /* LCOV_EXCL_START */
                ERR("setting->package_name is null");
                return NOTIFICATION_ERROR_NOT_EXIST_ID;
-               /* LCOV_EXCL_STOP */
        }
 
        *value = SAFE_STRDUP(setting->package_name);
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_setting_get_appid(notification_setting_h setting, char **app_id)
 {
        if (setting == NULL || app_id == NULL) {
@@ -126,17 +129,17 @@ EXPORT_API int notification_setting_get_appid(notification_setting_h setting, ch
        }
 
        if (setting->app_id == NULL) {
-               /* LCOV_EXCL_START */
                ERR("setting->app_id is null");
                return NOTIFICATION_ERROR_NOT_EXIST_ID;
-               /* LCOV_EXCL_STOP */
        }
 
        *app_id = SAFE_STRDUP(setting->app_id);
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_setting_get_allow_to_notify(notification_setting_h setting, bool *value)
 {
        if (setting == NULL || value == NULL) {
@@ -184,6 +187,7 @@ EXPORT_API int notification_setting_set_do_not_disturb_except(notification_setti
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
 EXPORT_API int notification_setting_get_visibility_class(notification_setting_h setting, int *value)
 {
@@ -209,6 +213,7 @@ EXPORT_API int notification_setting_set_visibility_class(notification_setting_h
        return NOTIFICATION_ERROR_NONE;
 }
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_setting_get_pop_up_notification(notification_setting_h setting, bool *value)
 {
        if (setting == NULL || value == NULL) {
@@ -266,6 +271,7 @@ EXPORT_API int notification_setting_get_app_disabled(notification_setting_h sett
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
 EXPORT_API int notification_setting_update_setting_for_uid(notification_setting_h setting, uid_t uid)
 {
@@ -299,6 +305,7 @@ EXPORT_API int notification_setting_free_notification(notification_setting_h set
        return NOTIFICATION_ERROR_NONE;
 }
 
+/* LCOV_EXCL_START */
 static bool _is_package_in_setting_table(sqlite3 *db, const char *package_name,
                        const char *app_id, uid_t uid)
 {
@@ -319,20 +326,16 @@ static bool _is_package_in_setting_table(sqlite3 *db, const char *package_name,
                                        uid, package_name);
 
        if (query == NULL) {
-               /* LCOV_EXCL_START */
                ERR("fail to alloc query");
                return false;
-               /* LCOV_EXCL_STOP */
        }
 
        sql_ret = sqlite3_prepare_v2(db, query, -1, &stmt, NULL);
        if (sql_ret != SQLITE_OK) {
-               /* LCOV_EXCL_START */
                ERR("sqlite3_prepare_v2 failed [%d][%s]", sql_ret,
                                sqlite3_errmsg(db));
                err = false;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        sql_ret = sqlite3_step(stmt);
@@ -344,12 +347,10 @@ static bool _is_package_in_setting_table(sqlite3 *db, const char *package_name,
        }
 
        if (sql_ret != SQLITE_OK && sql_ret != SQLITE_ROW) {
-               /* LCOV_EXCL_START */
                ERR("sqlite3_step failed [%d][%s]", sql_ret,
                                sqlite3_errmsg(db));
                err = false;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
 out:
@@ -361,7 +362,9 @@ out:
 
        return err;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static int _foreach_app_info_callback(const pkgmgrinfo_appinfo_h handle,
                                void *user_data)
 {
@@ -375,21 +378,17 @@ static int _foreach_app_info_callback(const pkgmgrinfo_appinfo_h handle,
 
        ret = pkgmgrinfo_appinfo_get_appid(handle, &app_id);
        if (ret != PACKAGE_MANAGER_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to get appid from pkgmgrinfo [%d]",
                                ret);
                err = false;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        ret = pkgmgrinfo_appinfo_get_pkgname(handle, &package_name);
        if (ret != PACKAGE_MANAGER_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to get pkgname from pkgmgrinfo[%d]",
                                ret);
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        if (_is_package_in_setting_table(db, package_name, app_id, info->uid) == true) {
@@ -403,11 +402,9 @@ static int _foreach_app_info_callback(const pkgmgrinfo_appinfo_h handle,
                                NOTIFICATION_SETTING_DB_TABLE,
                                info->uid, package_name, app_id);
        if (query == NULL) {
-               /* LCOV_EXCL_START */
                ERR("fail to alloc query");
                err = false;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        ret = notification_db_exec(db, query, NULL);
@@ -423,7 +420,9 @@ out:
 
        return err;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static int _install_and_update_package(const char *package_name, uid_t uid)
 {
        sqlite3 *db;
@@ -438,31 +437,25 @@ static int _install_and_update_package(const char *package_name, uid_t uid)
 
        pkgmgr_ret = pkgmgrinfo_appinfo_filter_create(&handle);
        if (pkgmgr_ret != PMINFO_R_OK) {
-               /* LCOV_EXCL_START */
                ERR("Failed to create appinfo_filter[%d]", pkgmgr_ret);
                err = NOTIFICATION_ERROR_FROM_DB;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        pkgmgr_ret = pkgmgrinfo_appinfo_filter_add_string(handle,
                        PMINFO_APPINFO_PROP_PRIVILEGE, NOTIFICATION_PRIVILEGE);
        if (pkgmgr_ret != PMINFO_R_OK) {
-               /* LCOV_EXCL_START */
                ERR("Failed to add string to appinfo_filter[%d]", pkgmgr_ret);
                err = NOTIFICATION_ERROR_FROM_DB;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        pkgmgr_ret = pkgmgrinfo_appinfo_filter_add_string(handle,
                        PMINFO_APPINFO_PROP_APP_PACKAGE, package_name);
        if (pkgmgr_ret != PMINFO_R_OK) {
-               /* LCOV_EXCL_START */
                ERR("Failed to add string to appinfo_filter[%d]", pkgmgr_ret);
                err = NOTIFICATION_ERROR_FROM_DB;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        info.db = db;
@@ -470,11 +463,9 @@ static int _install_and_update_package(const char *package_name, uid_t uid)
        pkgmgr_ret = pkgmgrinfo_appinfo_usr_filter_foreach_appinfo(handle,
                        _foreach_app_info_callback, &info, uid);
        if (pkgmgr_ret != PMINFO_R_OK) {
-               /* LCOV_EXCL_START */
                ERR("Failed to iterate appinfo[%d]", pkgmgr_ret);
                err = NOTIFICATION_ERROR_FROM_DB;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
 out:
@@ -486,7 +477,9 @@ out:
 
        return err;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static int _delete_package_from_setting_db(const char *package_name, uid_t uid)
 {
        sqlite3 *db = NULL;
@@ -510,11 +503,9 @@ static int _delete_package_from_setting_db(const char *package_name, uid_t uid)
                                NOTIFICATION_SETTING_DB_TABLE, uid,
                                package_name);
        if (query == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc query");
                err = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        err = notification_db_exec(db, query, NULL);
@@ -528,6 +519,7 @@ out:
 
        return err;
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 EXPORT_API int notification_setting_refresh_setting_table(uid_t uid)
@@ -580,6 +572,7 @@ out:
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_setting_insert_package_for_uid(const char *package_name, uid_t uid)
 {
        return _install_and_update_package(package_name, uid);
@@ -888,6 +881,7 @@ static gint _noti_dnd_cb_compare(gconstpointer a, gconstpointer b)
 
        return 1;
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 void notification_call_dnd_changed_cb_for_uid(int do_not_disturb, uid_t uid)
@@ -915,6 +909,7 @@ void notification_call_dnd_changed_cb_for_uid(int do_not_disturb, uid_t uid)
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_register_system_setting_dnd_changed_cb_for_uid(dnd_changed_cb callback, void *user_data, uid_t uid)
 {
        GList *noti_dnd_list = NULL;
@@ -925,10 +920,8 @@ EXPORT_API int notification_register_system_setting_dnd_changed_cb_for_uid(dnd_c
                return NOTIFICATION_ERROR_INVALID_PARAMETER;
 
        if (notification_ipc_monitor_init(uid) != NOTIFICATION_ERROR_NONE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to init monitor");
                return NOTIFICATION_ERROR_IO_ERROR;
-               /* LCOV_EXCL_STOP */
        }
 
        if (_noti_dnd_cb_hash == NULL)
@@ -960,7 +953,9 @@ EXPORT_API int notification_register_system_setting_dnd_changed_cb_for_uid(dnd_c
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_register_system_setting_dnd_changed_cb(dnd_changed_cb callback, void *user_data)
 {
        return notification_register_system_setting_dnd_changed_cb_for_uid(callback, user_data, getuid());
@@ -1006,11 +1001,14 @@ EXPORT_API int notification_unregister_system_setting_dnd_changed_cb_for_uid(dnd
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_unregister_system_setting_dnd_changed_cb(dnd_changed_cb callback)
 {
        return notification_unregister_system_setting_dnd_changed_cb_for_uid(callback, getuid());
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 static bool _is_uid_in_system_setting_table(sqlite3 *db, uid_t uid)
index f757e2e80d860cee0df7bd3c499cd244bb8d1bd6..a09fb2d32ad6793a6e1ad1844b42d0a1134f2332 100644 (file)
 #include <notification_setting_service.h>
 #include "notification_db_query.h"
 
+/* LCOV_EXCL_START */
 static int _get_table_field_data_int(char **table, int *buf, int index)
 {
        if (table == NULL || buf == NULL || index < 0) {
-               /* LCOV_EXCL_START */
                ERR("table[%p], buf[%p], index[%d]", table, buf, index);
                return false;
-               /* LCOV_EXCL_STOP */
        }
 
        if (table[index] != NULL) {
@@ -47,10 +46,8 @@ static int _get_table_field_data_int(char **table, int *buf, int index)
                return true;
        }
 
-       /* LCOV_EXCL_START */
        *buf = 0;
        return false;
-       /* LCOV_EXCL_STOP */
 }
 
 static int _get_table_field_data_string(char **table, char **buf, int ucs2, int index)
@@ -60,10 +57,8 @@ static int _get_table_field_data_string(char **table, char **buf, int ucs2, int
        char *pTemp;
 
        if (table == NULL || buf == NULL || index < 0) {
-               /* LCOV_EXCL_START */
                ERR("table[%p], buf[%p], index[%d]", table, buf, index);
                return false;
-               /* LCOV_EXCL_STOP */
        }
 
        pTemp = table[index];
@@ -118,21 +113,17 @@ int noti_setting_service_get_setting_by_app_id(const char *app_id, notification_
                        NOTIFICATION_SETTING_DB_ATTRIBUTES, NOTIFICATION_SETTING_DB_TABLE,
                        app_id, uid);
        if (query == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc query");
                ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        sql_ret = sqlite3_get_table(db, query, &query_result, &row_count, &column_count, NULL);
        if (sql_ret != SQLITE_OK && sql_ret != -1) {
-               /* LCOV_EXCL_START */
                ERR("sqlite3_get_table failed [%d][%s]", sql_ret,
                                query);
                ret = NOTIFICATION_ERROR_FROM_DB;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        if (!row_count) {
@@ -147,11 +138,9 @@ int noti_setting_service_get_setting_by_app_id(const char *app_id, notification_
 
        result_setting_array = (struct notification_setting *)malloc(sizeof(struct notification_setting) * row_count);
        if (result_setting_array == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc memory");
                ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        col_index = column_count;
@@ -208,21 +197,17 @@ int noti_setting_get_setting_array(notification_setting_h *setting_array, int *c
                                "app_id ", NOTIFICATION_SETTING_DB_ATTRIBUTES,
                                NOTIFICATION_SETTING_DB_TABLE, uid, 0);
        if (query == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc query"); /* LCOV_EXCL_LINE */
                ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        sql_ret = sqlite3_get_table(db, query, &query_result, &row_count, &column_count, NULL);
        if (sql_ret != SQLITE_OK && sql_ret != -1) {
-               /* LCOV_EXCL_START */
                ERR("Failed to get db table [%d][%s]",
                        sql_ret, query); /* LCOV_EXCL_LINE */
                ret = NOTIFICATION_ERROR_FROM_DB;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        if (!row_count) {
@@ -235,11 +220,9 @@ int noti_setting_get_setting_array(notification_setting_h *setting_array, int *c
 
        result_setting_array = (struct notification_setting *)malloc(sizeof(struct notification_setting) * row_count);
        if (result_setting_array == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc memory"); /* LCOV_EXCL_LINE */
                ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        col_index = column_count;
@@ -298,36 +281,29 @@ int noti_system_setting_load_system_setting(notification_system_setting_h *syste
                        NOTIFICATION_SYSTEM_SETTING_DB_ATTRIBUTES,
                        NOTIFICATION_SYSTEM_SETTING_DB_TABLE, uid);
        if (query == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc query");
                ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        sql_ret = sqlite3_get_table(db, query, &query_result, &row_count, &column_count, NULL);
        if (sql_ret != SQLITE_OK && sql_ret != -1) {
-               /* LCOV_EXCL_START */
                ERR("Failed to get db table [%d][%s]", sql_ret, query);
                ret = NOTIFICATION_ERROR_FROM_DB;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        DBG("row_count [%d] column_count [%d]", row_count, column_count);
 
        result_system_setting = (struct notification_system_setting *)malloc(sizeof(struct notification_system_setting));
        if (result_system_setting == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc memory");
                ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        /* no system setting record. allow everyting */
        if (!row_count) {
-               /* LCOV_EXCL_START */
                DBG("No setting found");
                result_system_setting->do_not_disturb = 0;
                result_system_setting->visibility_class = 0;
@@ -339,9 +315,7 @@ int noti_system_setting_load_system_setting(notification_system_setting_h *syste
                result_system_setting->dnd_end_min = 0;
                result_system_setting->lock_screen_content_level = 0;
                result_system_setting->dnd_allow_exceptions = NULL;
-               /* LCOV_EXCL_STOP */
        } else {
-               /* LCOV_EXCL_START */
                col_index = column_count;
                _get_table_field_data_int(query_result, (int *)&(result_system_setting->do_not_disturb), col_index++);
                _get_table_field_data_int(query_result, &(result_system_setting->visibility_class), col_index++);
@@ -353,7 +327,6 @@ int noti_system_setting_load_system_setting(notification_system_setting_h *syste
                _get_table_field_data_int(query_result, &(result_system_setting->dnd_end_min), col_index++);
                _get_table_field_data_int(query_result, (int *)&(result_system_setting->lock_screen_content_level), col_index++);
                result_system_setting->dnd_allow_exceptions = NULL;
-               /* LCOV_EXCL_STOP */
        }
 
        *system_setting = result_system_setting;
@@ -399,10 +372,8 @@ int notification_setting_db_update(const char *package_name, const char *app_id,
                        pop_up_notification, lock_screen_content_level, app_id,
                        package_name, uid);
        if (query == NULL) {
-               /* LCOV_EXCL_START */
                ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        ret = notification_db_exec(db, query, NULL);
@@ -442,10 +413,8 @@ int notification_setting_db_update_system_setting(int do_not_disturb, int visibi
                        dnd_start_min, dnd_end_hour, dnd_end_min,
                        lock_screen_content_level);
        if (query == NULL) {
-               /* LCOV_EXCL_START */
                ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        ret = notification_db_exec(db, query, &num_changes);
@@ -464,6 +433,7 @@ out:
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 EXPORT_API
@@ -567,6 +537,7 @@ out:
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API
 int notification_get_dnd_and_allow_to_notify(const char *app_id,
                                        int *do_not_disturb,
@@ -598,31 +569,25 @@ int notification_get_dnd_and_allow_to_notify(const char *app_id,
                                NOTIFICATION_SETTING_DB_TABLE, app_id,
                                uid, tzplatform_getuid(TZ_SYS_GLOBALAPP_USER));
        if (query_setting == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc memory");
                ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        query_system_setting = sqlite3_mprintf("SELECT do_not_disturb FROM %s "
                                        "WHERE uid = %d",
                                        NOTIFICATION_SYSTEM_SETTING_DB_TABLE, uid);
        if (query_system_setting == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc memory");
                ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        sql_ret = sqlite3_get_table(db, query_setting, &query_setting_result, &row_count, &col_count, NULL);
        if (sql_ret != SQLITE_OK && sql_ret != -1) {
-               /* LCOV_EXCL_START */
                ERR("Failed to get DB table [%d][%s]", sql_ret, query_setting);
                ret = NOTIFICATION_ERROR_FROM_DB;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        if (row_count == 0) {
@@ -637,11 +602,9 @@ int notification_get_dnd_and_allow_to_notify(const char *app_id,
 
        sql_ret = sqlite3_get_table(db, query_system_setting, &query_system_setting_result, &row_count, &col_count, NULL);
        if (sql_ret != SQLITE_OK && sql_ret != -1) {
-               /* LCOV_EXCL_START */
                ERR("Failed to get DB table [%d][%s]", sql_ret, query_setting);
                ret = NOTIFICATION_ERROR_FROM_DB;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        if (row_count == 0) {
@@ -697,20 +660,16 @@ EXPORT_API int notification_system_setting_load_dnd_allow_exception(dnd_allow_ex
        query = sqlite3_mprintf("SELECT type, value FROM %s WHERE uid = %d",
                        NOTIFICATION_DND_ALLOW_EXCEPTION, uid);
        if (query == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc memory");
                ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        sql_ret = sqlite3_get_table(db, query, &query_result, &row_count, &column_count, NULL);
        if (sql_ret != SQLITE_OK && sql_ret != -1) {
-               /* LCOV_EXCL_START */
                ERR("Failed to get DB table [%d][%s]", sql_ret, query); /* LCOV_EXCL_LINE */
                ret = NOTIFICATION_ERROR_FROM_DB;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        if (!row_count) {
@@ -765,11 +724,9 @@ int notification_system_setting_update_dnd_allow_exception(int type, int value,
                                NOTIFICATION_DND_ALLOW_EXCEPTION,
                                uid, type, value);
        if (query == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc memory");
                ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        ret = notification_db_exec(db, query, &num_changes);
@@ -807,28 +764,22 @@ int noti_system_setting_get_do_not_disturb(int *do_not_disturb, uid_t uid)
        query = sqlite3_mprintf("SELECT do_not_disturb FROM %s WHERE uid = %d",
                                NOTIFICATION_SYSTEM_SETTING_DB_TABLE, uid);
        if (query == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to alloc memory");
                ret = NOTIFICATION_ERROR_OUT_OF_MEMORY;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        ret = sqlite3_get_table(db, query, &query_result, &row_count, &col_count, NULL);
        if (ret != SQLITE_OK && ret != -1) {
-               /* LCOV_EXCL_START */
                ERR("Failed to get DB table [%d][%s]", ret, query);
                ret = NOTIFICATION_ERROR_FROM_DB;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        col_index = col_count;
        if (row_count == 0) {
-               /* LCOV_EXCL_START */
                ERR("No system setting found");
                ret = NOTIFICATION_ERROR_INVALID_PARAMETER;
-               /* LCOV_EXCL_STOP */
        } else {
                if (_get_table_field_data_int(query_result, (int *)do_not_disturb, col_index++) == false)
                        ret = NOTIFICATION_ERROR_FROM_DB;
@@ -846,6 +797,7 @@ out:
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 EXPORT_API
index 2f5d88672d6fddf12d1f56b4ec3f655c404cae52..bfd4265058be7b85e72c80e5d6ce11e998c1f476 100644 (file)
@@ -84,6 +84,7 @@ typedef struct target_app_info {
        char *dbus_sender_name;
 } target_app_info_s;
 
+/* LCOV_EXCL_START */
 static const char *__last_index_of(const char *path, const char *search);
 static bool __make_sharing_dir(const char *dir)
 {
@@ -98,20 +99,20 @@ static bool __make_sharing_dir(const char *dir)
                return false;
 
        if (g_file_make_directory(noti_dir, NULL, &g_err) == false) {
-               /* LCOV_EXCL_START */
                if (g_err) {
                        ERR("Failed to make sharing dir[%s]", g_err->message);
                        g_error_free(g_err);
                }
                g_object_unref(noti_dir);
                return false;
-               /* LCOV_EXCL_STOP */
        }
 
        g_object_unref(noti_dir);
        return true;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static char *__get_data_path_by_pkg_id(const char *pkg_id,
                                        const char *file_path, uid_t uid)
 {
@@ -181,6 +182,7 @@ static const char *__last_index_of(const char *path, const char *search)
 
        return NULL;
 }
+/* LCOV_EXCL_STOP */
 
 /* Check path that include res directory */
 /* LCOV_EXCL_START */
@@ -200,6 +202,7 @@ static bool __is_private_file(const char *smack_label, const char *pkg_id)
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static bool __is_RO_file(const char *smack_label)
 {
 #define CHECK_LABEL "::RO"
@@ -213,8 +216,10 @@ static bool __is_RO_file(const char *smack_label)
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
 /* file copy from /res to /data */
+/* LCOV_EXCL_START */
 int notification_copy_private_file(const char *src_path,
                                        const char *dst_path)
 {
@@ -226,11 +231,9 @@ int notification_copy_private_file(const char *src_path,
 
        dst = g_file_new_for_path(dst_path);
        if (dst == NULL) {
-               /* LCOV_EXCL_START */
                ERR("dst path is wrong [%s]", dst_path);
                ret = NOTIFICATION_ERROR_IO_ERROR;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        if (g_file_query_exists(dst, NULL) == true) {
@@ -241,16 +244,13 @@ int notification_copy_private_file(const char *src_path,
 
        src = g_file_new_for_path(src_path);
        if (src == NULL) {
-               /* LCOV_EXCL_START */
                ERR("src path is wrong [%s]", src_path);
                ret = NOTIFICATION_ERROR_IO_ERROR;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        if (!g_file_copy(src, dst, G_FILE_COPY_NOFOLLOW_SYMLINKS, NULL, NULL,
                        NULL, &g_err)) {
-               /* LCOV_EXCL_START */
                if (g_err) {
                        ERR("Copying file from [%s] to [%s] is failed [%s]",
                                src_path, dst_path, g_err->message);
@@ -258,7 +258,6 @@ int notification_copy_private_file(const char *src_path,
                }
                ret = NOTIFICATION_ERROR_IO_ERROR;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        ut.modtime = time(NULL);
@@ -273,7 +272,9 @@ out:
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static void __free_file_info(gpointer data)
 {
        sharing_file_info_s *info = (sharing_file_info_s *)data;
@@ -286,6 +287,7 @@ static void __free_file_info(gpointer data)
                free(info);
        }
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 static void __free_req_info(gpointer data)
@@ -307,6 +309,7 @@ static void __free_req_info(gpointer data)
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static char **__convert_list_to_array(GList *list, int *length)
 {
        int len, i;
@@ -341,6 +344,7 @@ static gint __comp_str(gconstpointer a, gconstpointer b)
 
        return strcmp(new_file, file);
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 static gint __comp_file_info(gconstpointer a, gconstpointer b)
@@ -368,6 +372,7 @@ static gint __comp_dst_path(gconstpointer a, gconstpointer b)
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static sharing_file_info_s *__dup_file_info(sharing_file_info_s *src)
 {
        sharing_file_info_s *file_info;
@@ -920,7 +925,9 @@ out:
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 int __set_sharing_for_new_file(sharing_req_data_s *req_data,
                                GList *new_file_list, bool is_overlapping)
 {
@@ -946,21 +953,17 @@ int __set_sharing_for_new_file(sharing_req_data_s *req_data,
        ret = security_manager_private_sharing_req_set_owner_appid(handle,
                                        req_data->app_id);
        if (ret != SECURITY_MANAGER_SUCCESS) {
-               /* LCOV_EXCL_START */
                ERR("Failed to set owner appid[%s][%d]", req_data->app_id, ret);
                ret = NOTIFICATION_ERROR_IO_ERROR;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        ret = security_manager_private_sharing_req_add_paths(handle,
                                                (const char **)path_array, len);
        if (ret != SECURITY_MANAGER_SUCCESS) {
-               /* LCOV_EXCL_START */
                ERR("Failed to add paths [%d]", ret);
                ret = NOTIFICATION_ERROR_IO_ERROR;
                goto out;
-               /* LCOV_EXCL_STOP */
        }
 
        if (is_overlapping == true) {
@@ -969,21 +972,17 @@ int __set_sharing_for_new_file(sharing_req_data_s *req_data,
                        ret = security_manager_private_sharing_req_set_target_appid(
                                                        handle, (const char *)iter->data);
                        if (ret != SECURITY_MANAGER_SUCCESS) {
-                               /* LCOV_EXCL_START */
                                ERR("Failed to set target appid [%s]",
                                        (const char *)iter->data);
                                ret = NOTIFICATION_ERROR_IO_ERROR;
                                goto out;
-                               /* LCOV_EXCL_STOP */
                        }
 
                        ret = security_manager_private_sharing_drop(handle);
                        if (ret != SECURITY_MANAGER_SUCCESS) {
-                               /* LCOV_EXCL_START */
                                ERR("Failed to drop [%d]", ret);
                                ret = NOTIFICATION_ERROR_IO_ERROR;
                                goto out;
-                               /* LCOV_EXCL_STOP */
                        }
                }
        }
@@ -993,21 +992,17 @@ int __set_sharing_for_new_file(sharing_req_data_s *req_data,
                ret = security_manager_private_sharing_req_set_target_appid(handle,
                                                        (const char *)iter->data);
                if (ret != SECURITY_MANAGER_SUCCESS) {
-                       /* LCOV_EXCL_START */
                        ERR("Failed to set target appid [%s]",
                                (const char *)iter->data);
                        ret = NOTIFICATION_ERROR_IO_ERROR;
                        goto out;
-                       /* LCOV_EXCL_STOP */
                }
 
                ret = security_manager_private_sharing_apply(handle);
                if (ret != SECURITY_MANAGER_SUCCESS) {
-                       /* LCOV_EXCL_START */
                        ERR("Failed to apply PS [%d]", ret);
                        ret = NOTIFICATION_ERROR_IO_ERROR;
                        goto out;
-                       /* LCOV_EXCL_STOP */
                }
        }
 
@@ -1020,7 +1015,9 @@ out:
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API int notification_set_private_sharing(notification_h noti,
                                                uid_t uid)
 {
@@ -1297,3 +1294,4 @@ EXPORT_API void notification_remove_private_sharing(
        }
 
 }
+/* LCOV_EXCL_STOP */
index cb69bbc6bf397ee8cae6a563162b01b14041ea67..7d3746402bda9fd312f101e3312cb18f0722cc0c 100644 (file)
@@ -44,6 +44,7 @@ struct _message_cb_data {
 
 static struct _message_cb_data md;
 
+/* LCOV_EXCL_START */
 static void __notification_status_message_dbus_callback(GDBusConnection *connection,
                                        const gchar *sender_name,
                                        const gchar *object_path,
@@ -56,22 +57,20 @@ static void __notification_status_message_dbus_callback(GDBusConnection *connect
 
        g_variant_get(parameters, "(&s)", &message);
        if (strlen(message) <= 0) {
-               /* LCOV_EXCL_START */
                ERR("message is NULL");
                return;
-               /* LCOV_EXCL_STOP */
        }
 
        if (!md.callback) {
-               /* LCOV_EXCL_START */
                ERR("No callback");
                return;
-               /* LCOV_EXCL_STOP */
        }
 
        md.callback(message, md.data);
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API
 int notification_status_monitor_message_cb_set(notification_status_message_cb callback, void *user_data)
 {
@@ -83,12 +82,10 @@ int notification_status_monitor_message_cb_set(notification_status_message_cb ca
        if (md.conn == NULL) {
                md.conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
                if (md.conn == NULL) {
-                       /* LCOV_EXCL_START */
                        ERR("Failed to connect to the D-BUS Daemon[%s]",
                                                error->message);
                        g_error_free(error);
                        return NOTIFICATION_ERROR_FROM_DBUS;
-                       /* LCOV_EXCL_STOP */
                }
        }
 
@@ -104,11 +101,9 @@ int notification_status_monitor_message_cb_set(notification_status_message_cb ca
                                        NULL,
                                        NULL);
                if (md.message_id == 0) {
-                       /* LCOV_EXCL_START */
                        ERR("Failed to subscribe signal");
                        g_object_unref(md.conn);
                        return NOTIFICATION_ERROR_FROM_DBUS;
-                       /* LCOV_EXCL_STOP */
                }
        }
 
@@ -117,7 +112,9 @@ int notification_status_monitor_message_cb_set(notification_status_message_cb ca
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API
 int notification_status_monitor_message_cb_unset(void)
 {
@@ -136,7 +133,9 @@ int notification_status_monitor_message_cb_unset(void)
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 EXPORT_API
 int notification_status_message_post(const char *message)
 {
@@ -152,12 +151,10 @@ int notification_status_message_post(const char *message)
 
        conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
        if (conn == NULL) {
-               /* LCOV_EXCL_START */
                ERR("Failed to connect to the D-BUS Daemon[%s]",
                                        err->message);
                ret = NOTIFICATION_ERROR_FROM_DBUS;
                goto end;
-               /* LCOV_EXCL_STOP */
        }
 
        param = g_variant_new("(s)", message);
@@ -169,21 +166,17 @@ int notification_status_message_post(const char *message)
                                        MEMBER_NAME,
                                        param,
                                        &err) == FALSE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to emit signal[%s]",
                                        err->message);
                ret = NOTIFICATION_ERROR_FROM_DBUS;
                goto end;
-               /* LCOV_EXCL_STOP */
        }
 
        if (g_dbus_connection_flush_sync(conn, NULL, &err) == FALSE) {
-               /* LCOV_EXCL_START */
                ERR("Failed to flush connection sync[%s]",
                                        err->message);
                ret = NOTIFICATION_ERROR_FROM_DBUS;
                goto end;
-               /* LCOV_EXCL_STOP */
        }
 
 end:
@@ -195,3 +188,4 @@ end:
 
        return ret;
 }
+/* LCOV_EXCL_STOP */
index 69ef54bf77998cd0d8d8ba8bd4116d81c06b00c5..3d7e07b13f1d94445503625334e53dd0266fcbab 100644 (file)
@@ -69,6 +69,7 @@ EXPORT_API int notification_init_default_viewer()
 }
 /* LCOV_EXCL_STOP */
 
+/* LCOV_EXCL_START */
 static int __pop_delayed_noti() {
        delayed_noti_info_s *noti = g_list_nth_data(_delayed_noti_list, 0);
 
@@ -139,6 +140,7 @@ static int __push_delayed_noti(bundle *noti_info, uid_t uid) {
 
        return NOTIFICATION_ERROR_NONE;
 }
+/* LCOV_EXCL_STOP */
 
 /* LCOV_EXCL_START */
 EXPORT_API int notification_launch_default_viewer(int priv_id,
index 17ee72c042d4d1c301efc733841e3815ffec454c..5f9e31020e073c6c963ecf1f1490a1b78080aa70 100644 (file)
@@ -76,10 +76,10 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
 %check
 ctest -V
 %if 0%{?gcov:1}
-lcov -c --ignore-errors graph --no-external -q -d . -o notification-ex.info
-genhtml notification-ex.info -o notification-ex.out
-zip -r notification-ex.zip notification-ex.out
-install -m 0644 notification-ex.zip %{buildroot}%{_datadir}/gcov/obj/notification-ex.zip
+lcov -c --ignore-errors graph --no-external -q -d . -o notification.info
+genhtml notification.info -o notification.out
+zip -r notification.zip notification.out
+install -m 0644 notification.zip %{buildroot}%{_datadir}/gcov/obj/notification.zip
 %endif
 
 %install
@@ -101,7 +101,7 @@ setup() {
 
 test_main() {
     echo "test_main start"
-    /usr/bin/notification-ex_unittests
+    /usr/bin/<NAME>-unittests
 }
 
 teardown() {
@@ -119,6 +119,11 @@ EOF
 
 mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name}
 install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}/
+sed -i -e 's/<NAME>/notification/g' %{buildroot}%{_bindir}/tizen-unittests/%{name}/run-unittest.sh
+
+mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name}-ex
+install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}-ex/
+sed -i -e 's/<NAME>/notification-ex/g' %{buildroot}%{_bindir}/tizen-unittests/%{name}-ex/run-unittest.sh
 
 mkdir -p %{buildroot}%{upgrade_script_path}
 cp -f scripts/505.notification_upgrade.sh %{buildroot}%{upgrade_script_path}
@@ -205,19 +210,33 @@ Header & package configuration files to support development of the notification.
 %attr(0644,root,root) %{_libdir}/libnotification-ex.so
 
 #################################################
-# notification-ex_unittests
+# notification-ex-unittests
 #################################################
-%package -n notification-ex_unittests
+%package -n notification-ex-unittests
 Summary:    GTest for notification-ex
 Group:      Development/Libraries
 
-%description -n notification-ex_unittests
+%description -n notification-ex-unittests
 GTest for notification-ex
 
-%files -n notification-ex_unittests
-%{_bindir}/notification-ex_unittests
+%files -n notification-ex-unittests
+%{_bindir}/notification-ex-unittests
 %{_bindir}/tizen-unittests/%{name}/run-unittest.sh
 
+#################################################
+# notification-unittests
+#################################################
+%package -n notification-unittests
+Summary:    GTest for notification
+Group:      Development/Libraries
+
+%description -n notification-unittests
+GTest for notification
+
+%files -n notification-unittests
+%{_bindir}/notification-unittests
+%{_bindir}/tizen-unittests/%{name}-ex/run-unittest.sh
+
 %if 0%{?gcov:1}
 %files gcov
 %{_datadir}/gcov/obj/*
index 907a64da829d3ad8ce5352ce38e9b8b02614f4d6..5e5460b859d3ef4bddfbc2f3734fd1f625602b8d 100644 (file)
@@ -1,2 +1,2 @@
-ADD_SUBDIRECTORY(unittest)
-ADD_DEPENDENCIES(notification-ex_unittests notification-ex)
+ADD_SUBDIRECTORY(noti_unittest)
+ADD_SUBDIRECTORY(noti_ex_unittest)
index 2a4918093af1565d78289782dc89018c5197f4c1..ef5ba696c45e730451902af7b54e1204a61982cb 100644 (file)
  * limitations under the License.
  */
 
-#include "app_common_mock.h"
+#include "app_common_mock.hh"
 
-#include "mock_hook.h"
-#include "test_fixture.h"
+#include "mock_hook.hh"
+#include "test_fixture.hh"
 
 extern "C" int app_get_name(char** arg1) {
   return MOCK_HOOK_P1(AppCommonMock, app_get_name, arg1);
diff --git a/tests/mock/app_common_mock.h b/tests/mock/app_common_mock.h
deleted file mode 100644 (file)
index 18bcbc8..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef UNIT_TESTS_MOCK_APP_COMMON_MOCK_H_
-#define UNIT_TESTS_MOCK_APP_COMMON_MOCK_H_
-
-#include <gmock/gmock.h>
-#include <app_common.h>
-
-#include "module_mock.h"
-
-class AppCommonMock : public virtual ModuleMock {
- public:
-  AppCommonMock() {
-    using ::testing::_;
-    using ::testing::Return;
-    using ::testing::Invoke;
-  }
-
-  MOCK_METHOD1(app_get_name, int (char**));
-};
-
-#endif  // UNIT_TESTS_MOCK_APP_COMMON_MOCK_H_
\ No newline at end of file
diff --git a/tests/mock/app_common_mock.hh b/tests/mock/app_common_mock.hh
new file mode 100644 (file)
index 0000000..c1b85bc
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TESTS_MOCK_APP_COMMON_MOCK_H_
+#define UNIT_TESTS_MOCK_APP_COMMON_MOCK_H_
+
+#include <gmock/gmock.h>
+#include <app_common.h>
+
+#include "module_mock.hh"
+
+class AppCommonMock : public virtual ModuleMock {
+ public:
+  AppCommonMock() {
+    using ::testing::_;
+    using ::testing::Return;
+    using ::testing::Invoke;
+  }
+
+  MOCK_METHOD1(app_get_name, int (char**));
+};
+
+#endif  // UNIT_TESTS_MOCK_APP_COMMON_MOCK_H_
\ No newline at end of file
diff --git a/tests/mock/aul_mock.cc b/tests/mock/aul_mock.cc
new file mode 100644 (file)
index 0000000..7c6efbc
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2022 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.hh"
+
+#include "mock_hook.hh"
+#include "test_fixture.hh"
+
+extern "C" int aul_app_get_appid_bypid(int pid, char* appid, int len) {
+  return MOCK_HOOK_P3(AulMock, aul_app_get_appid_bypid, pid, appid, len);
+}
+
+extern "C" int aul_app_get_pkgid_bypid(int pid, char* pkgid, int len) {
+  return MOCK_HOOK_P3(AulMock, aul_app_get_pkgid_bypid, pid, pkgid, len);
+}
diff --git a/tests/mock/aul_mock.hh b/tests/mock/aul_mock.hh
new file mode 100644 (file)
index 0000000..2c3ea83
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TESTS_MOCK_AUL_MOCK_H_
+#define UNIT_TESTS_MOCK_AUL_MOCK_H_
+
+#include <gmock/gmock.h>
+#include <aul.h>
+#include <aul_app_event.h>
+#include <aul_app_group.h>
+#include <aul_app_manager.h>
+#include <aul_svc.h>
+#include <aul_window.h>
+
+#include "module_mock.hh"
+
+class AulMock : public virtual ModuleMock {
+ public:
+  virtual ~AulMock() {}
+
+  MOCK_METHOD3(aul_app_get_appid_bypid, int(int, char*, int));
+  MOCK_METHOD3(aul_app_get_pkgid_bypid, int(int, char*, int));
+};
+
+#endif  // UNIT_TESTS_MOCK_AUL_MOCK_H_
index 15569ac7c6ae3a7650bc6ec26f643e80c7251980..2e990407c94621d2573e92e179dfeb9c89a4224b 100644 (file)
  * limitations under the License.
  */
 
-#include "glib_mock.h"
+#include "glib_mock.hh"
 
-#include "mock_hook.h"
-#include "test_fixture.h"
+#include "mock_hook.hh"
+#include "test_fixture.hh"
+
+extern "C" uid_t getuid() {
+  return 5001;
+}
 
 extern "C" GFile* g_file_new_for_path(const char* arg1) {
   return MOCK_HOOK_P1(GlibMock, g_file_new_for_path, arg1);
@@ -35,3 +39,65 @@ extern "C" gboolean g_file_make_directory(GFile* arg1, GCancellable* arg2,
 extern "C" int access(const char* arg1, int arg2) {
   return MOCK_HOOK_P2(GlibMock, access, arg1, arg2);
 }
+
+extern "C" ssize_t read(int fd, void *buf, size_t count) {
+  return MOCK_HOOK_P3(GlibMock, read, fd, buf, count);
+}
+
+extern "C" GDBusConnection* g_bus_get_sync(GBusType type,
+    GCancellable* cancellable, GError** error) {
+  return MOCK_HOOK_P3(GlibMock, 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(GlibMock, 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(GlibMock, g_dbus_message_get_body, arg0);
+}
+
+extern "C" GList* g_list_append (GList* list, gpointer data) {
+  return MOCK_HOOK_P2(GlibMock, g_list_append, list, data);
+}
+
+extern "C" guint g_dbus_connection_signal_subscribe(GDBusConnection* arg0,
+    const gchar* arg1, const gchar* arg2, const gchar* arg3, const gchar* arg4,
+    const gchar* arg5, GDBusSignalFlags arg6, GDBusSignalCallback arg7,
+    gpointer arg8, GDestroyNotify arg9) {
+  return MOCK_HOOK_P10(GlibMock, g_dbus_connection_signal_subscribe,
+      arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
+}
+
+extern "C" gboolean g_dbus_connection_emit_signal(GDBusConnection* arg0,
+    const gchar* arg1, const gchar* arg2, const gchar* arg3, const gchar* arg4,
+    GVariant* arg5, GError** arg6) {
+  return MOCK_HOOK_P7(GlibMock, g_dbus_connection_emit_signal,
+      arg0, arg1, arg2, arg3, arg4, arg5, arg6);
+}
+
+extern "C" gboolean g_dbus_connection_flush_sync(GDBusConnection* arg0,
+    GCancellable* arg1, GError** arg2) {
+  return MOCK_HOOK_P3(GlibMock, g_dbus_connection_flush_sync, arg0, arg1, arg2);
+}
+
+extern "C" const gchar* g_dbus_connection_get_unique_name(GDBusConnection* connection) {
+  return MOCK_HOOK_P1(GlibMock, g_dbus_connection_get_unique_name, connection);
+}
+
+extern "C" guint g_bus_watch_name (GBusType bus_type, const gchar* name, GBusNameWatcherFlags flags,
+    GBusNameAppearedCallback name_appeared_handler, GBusNameVanishedCallback name_vanished_handler,
+    gpointer user_data, GDestroyNotify user_data_free_func) {
+  return MOCK_HOOK_P7(GlibMock, g_bus_watch_name, bus_type, name, flags, name_appeared_handler,
+      name_vanished_handler, user_data, user_data_free_func);
+}
+
+extern "C" GDBusMessage* g_dbus_message_new_method_call(const gchar* arg0,
+    const gchar* arg1, const gchar* arg2, const gchar* arg3) {
+  return MOCK_HOOK_P4(GlibMock, g_dbus_message_new_method_call, arg0, arg1, arg2,
+      arg3);
+}
diff --git a/tests/mock/glib_mock.h b/tests/mock/glib_mock.h
deleted file mode 100644 (file)
index 03688ad..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef UNIT_TESTS_MOCK_GLIB_MOCK_H_
-#define UNIT_TESTS_MOCK_GLIB_MOCK_H_
-
-#include <gio/gio.h>
-#include <glib.h>
-#include <gmock/gmock.h>
-
-#include "module_mock.h"
-
-class GlibMock : public virtual ModuleMock {
- public:
-  GlibMock() {
-    using ::testing::_;
-    using ::testing::Return;
-    using ::testing::Invoke;
-  }
-
-  MOCK_METHOD1(g_file_new_for_path, GFile* (const char*));
-  MOCK_METHOD2(g_file_query_exists, gboolean (GFile*, GCancellable*));
-  MOCK_METHOD3(g_file_make_directory, gboolean (GFile*, GCancellable*, GError**));
-
-  MOCK_METHOD2(access, int (const char*, int));
-};
-
-#endif  // UNIT_TESTS_MOCK_GLIB_MOCK_H_
diff --git a/tests/mock/glib_mock.hh b/tests/mock/glib_mock.hh
new file mode 100644 (file)
index 0000000..06331fd
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TESTS_MOCK_GLIB_MOCK_H_
+#define UNIT_TESTS_MOCK_GLIB_MOCK_H_
+
+#include <gio/gio.h>
+#include <glib.h>
+#include <gmock/gmock.h>
+
+#include "module_mock.hh"
+
+class GlibMock : public virtual ModuleMock {
+ public:
+  GlibMock() {
+    using ::testing::_;
+    using ::testing::Return;
+    using ::testing::Invoke;
+  }
+
+  MOCK_METHOD0(getuid, uid_t());
+  MOCK_METHOD1(g_file_new_for_path, GFile* (const char*));
+  MOCK_METHOD2(g_file_query_exists, gboolean (GFile*, GCancellable*));
+  MOCK_METHOD3(g_file_make_directory, gboolean (GFile*, GCancellable*, GError**));
+
+  MOCK_METHOD2(access, int (const char*, int));
+  MOCK_METHOD3(read, size_t(int , void*, size_t));
+
+  MOCK_METHOD3(g_bus_get_sync, GDBusConnection*(GBusType, GCancellable*, GError**));
+
+  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_list_append, GList*(GList*, gpointer));
+  MOCK_METHOD10(g_dbus_connection_signal_subscribe,
+      guint(GDBusConnection*, const gchar*, const gchar*, const gchar*,
+      const gchar*, const gchar*, GDBusSignalFlags, GDBusSignalCallback,
+      gpointer, GDestroyNotify));
+  MOCK_METHOD7(g_dbus_connection_emit_signal,
+      gboolean(GDBusConnection*, const gchar*, const gchar*, const gchar*,
+          const gchar*, GVariant*, GError**));
+  MOCK_METHOD3(g_dbus_connection_flush_sync,
+      gboolean(GDBusConnection*, GCancellable*, GError**));
+  MOCK_METHOD1(g_dbus_connection_get_unique_name, const gchar*(GDBusConnection*));
+  MOCK_METHOD7(g_bus_watch_name, guint(GBusType, const gchar*, GBusNameWatcherFlags,
+      GBusNameAppearedCallback, GBusNameVanishedCallback, gpointer, GDestroyNotify));
+  MOCK_METHOD4(g_dbus_message_new_method_call,
+      GDBusMessage*(const gchar*, const gchar*, const gchar*, const gchar*));
+};
+
+#endif  // UNIT_TESTS_MOCK_GLIB_MOCK_H_
diff --git a/tests/mock/mock_hook.h b/tests/mock/mock_hook.h
deleted file mode 100644 (file)
index 29b0932..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef UNIT_TESTS_MOCK_MOCK_HOOK_H_
-#define UNIT_TESTS_MOCK_MOCK_HOOK_H_
-
-#define MOCK_HOOK_P0(MOCK_CLASS, f)                                            \
-    TestFixture::GetMock<MOCK_CLASS>().f()
-#define MOCK_HOOK_P1(MOCK_CLASS, f, p1)                                        \
-    TestFixture::GetMock<MOCK_CLASS>().f(p1)
-#define MOCK_HOOK_P2(MOCK_CLASS, f, p1, p2)                                    \
-    TestFixture::GetMock<MOCK_CLASS>().f(p1, p2)
-#define MOCK_HOOK_P3(MOCK_CLASS, f, p1, p2, p3)                                \
-    TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3)
-#define MOCK_HOOK_P4(MOCK_CLASS, f, p1, p2, p3, p4)                            \
-    TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4)
-#define MOCK_HOOK_P5(MOCK_CLASS, f, p1, p2, p3, p4, p5)                        \
-    TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5)
-#define MOCK_HOOK_P6(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6)                    \
-    TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5, p6)
-#define MOCK_HOOK_P7(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7)                \
-    TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5, p6, p7)
-#define MOCK_HOOK_P8(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7, p8)            \
-    TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5, p6, p7, p8)
-#define MOCK_HOOK_P10(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)  \
-    TestFixture::GetMock<MOCK_CLASS>().f(                                      \
-        p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)
-#define MOCK_HOOK_P11(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)  \
-    TestFixture::GetMock<MOCK_CLASS>().f(                                      \
-        p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)
-
-#endif  // UNIT_TESTS_MOCK_MOCK_HOOK_H_
diff --git a/tests/mock/mock_hook.hh b/tests/mock/mock_hook.hh
new file mode 100644 (file)
index 0000000..29b0932
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TESTS_MOCK_MOCK_HOOK_H_
+#define UNIT_TESTS_MOCK_MOCK_HOOK_H_
+
+#define MOCK_HOOK_P0(MOCK_CLASS, f)                                            \
+    TestFixture::GetMock<MOCK_CLASS>().f()
+#define MOCK_HOOK_P1(MOCK_CLASS, f, p1)                                        \
+    TestFixture::GetMock<MOCK_CLASS>().f(p1)
+#define MOCK_HOOK_P2(MOCK_CLASS, f, p1, p2)                                    \
+    TestFixture::GetMock<MOCK_CLASS>().f(p1, p2)
+#define MOCK_HOOK_P3(MOCK_CLASS, f, p1, p2, p3)                                \
+    TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3)
+#define MOCK_HOOK_P4(MOCK_CLASS, f, p1, p2, p3, p4)                            \
+    TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4)
+#define MOCK_HOOK_P5(MOCK_CLASS, f, p1, p2, p3, p4, p5)                        \
+    TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5)
+#define MOCK_HOOK_P6(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6)                    \
+    TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5, p6)
+#define MOCK_HOOK_P7(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7)                \
+    TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5, p6, p7)
+#define MOCK_HOOK_P8(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7, p8)            \
+    TestFixture::GetMock<MOCK_CLASS>().f(p1, p2, p3, p4, p5, p6, p7, p8)
+#define MOCK_HOOK_P10(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)  \
+    TestFixture::GetMock<MOCK_CLASS>().f(                                      \
+        p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)
+#define MOCK_HOOK_P11(MOCK_CLASS, f, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)  \
+    TestFixture::GetMock<MOCK_CLASS>().f(                                      \
+        p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11)
+
+#endif  // UNIT_TESTS_MOCK_MOCK_HOOK_H_
diff --git a/tests/mock/module_mock.h b/tests/mock/module_mock.h
deleted file mode 100644 (file)
index 9b19d89..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef UNIT_TESTS_MOCK_MODULE_MOCK_H_
-#define UNIT_TESTS_MOCK_MODULE_MOCK_H_
-
-class ModuleMock {
- public:
-  virtual ~ModuleMock() {}
-};
-
-#endif  // UNIT_TESTS_MOCK_MODULE_MOCK_H_
diff --git a/tests/mock/module_mock.hh b/tests/mock/module_mock.hh
new file mode 100644 (file)
index 0000000..9b19d89
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TESTS_MOCK_MODULE_MOCK_H_
+#define UNIT_TESTS_MOCK_MODULE_MOCK_H_
+
+class ModuleMock {
+ public:
+  virtual ~ModuleMock() {}
+};
+
+#endif  // UNIT_TESTS_MOCK_MODULE_MOCK_H_
diff --git a/tests/mock/package_manager_mock.cc b/tests/mock/package_manager_mock.cc
new file mode 100644 (file)
index 0000000..e6e5e98
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2022 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 "package_manager_mock.hh"
+
+#include "mock_hook.hh"
+#include "test_fixture.hh"
+
+extern "C" int package_info_create(const char *package, package_info_h *package_info) {
+  return MOCK_HOOK_P2(PackageManagerMock, package_info_create, package, package_info);
+}
+
+extern "C" int package_info_get_root_path(package_info_h package_info, char **path) {
+  return MOCK_HOOK_P2(PackageManagerMock, package_info_get_root_path, package_info, path);
+}
+
+extern "C" int pkgmgrinfo_appinfo_get_usr_appinfo(const char *appid,
+    uid_t uid, pkgmgrinfo_appinfo_h *handle) {
+  return MOCK_HOOK_P3(PackageManagerMock, pkgmgrinfo_appinfo_get_usr_appinfo, appid, uid, handle);
+}
+
+extern "C" int pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char **label) {
+  return MOCK_HOOK_P2(PackageManagerMock, pkgmgrinfo_appinfo_get_label, handle, label);
+}
diff --git a/tests/mock/package_manager_mock.hh b/tests/mock/package_manager_mock.hh
new file mode 100644 (file)
index 0000000..8cca951
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TESTS_MOCK_PACKAGE_MANAGER_MOCK_H_
+#define UNIT_TESTS_MOCK_PACKAGE_MANAGER_MOCK_H_
+
+#include <gmock/gmock.h>
+#include <package_manager.h>
+#include <pkgmgr-info.h>
+#include <pkgmgrinfo_basic.h>
+
+#include "module_mock.hh"
+
+class PackageManagerMock : public virtual ModuleMock {
+ public:
+  virtual ~PackageManagerMock() {}
+
+  MOCK_METHOD2(package_info_create, int(const char*, package_info_h*));
+  MOCK_METHOD2(package_info_get_root_path, int(package_info_h, char**));
+  MOCK_METHOD3(pkgmgrinfo_appinfo_get_usr_appinfo, int(const char*, uid_t, pkgmgrinfo_appinfo_h*));
+  MOCK_METHOD2(pkgmgrinfo_appinfo_get_label, int(pkgmgrinfo_appinfo_h, char**));
+};
+
+#endif  // UNIT_TESTS_MOCK_PACKAGE_MANAGER_MOCK_H_
index 85710d68aae9b0c7006d92d74137b8a2b02c0268..67c2dadf7f1e1344685927c49c9f54669e5c511e 100644 (file)
  * limitations under the License.
  */
 
-#include "security_manager_mock.h"
+#include "security_manager_mock.hh"
 
-#include "mock_hook.h"
-#include "test_fixture.h"
+#include "mock_hook.hh"
+#include "test_fixture.hh"
 
 extern "C" int security_manager_private_sharing_req_new(private_sharing_req** arg1) {
   return MOCK_HOOK_P1(SecurityManagerMock, security_manager_private_sharing_req_new, arg1);
diff --git a/tests/mock/security_manager_mock.h b/tests/mock/security_manager_mock.h
deleted file mode 100644 (file)
index c5424fd..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef UNIT_TESTS_MOCK_SECURITY_MANAGER_MOCK_H_
-#define UNIT_TESTS_MOCK_SECURITY_MANAGER_MOCK_H_
-
-#include <security-manager.h>
-#include <gmock/gmock.h>
-
-#include "module_mock.h"
-
-class SecurityManagerMock : public virtual ModuleMock {
- public:
-  SecurityManagerMock() {
-    using ::testing::_;
-    using ::testing::Return;
-    using ::testing::Invoke;
-  }
-
-  MOCK_METHOD1(security_manager_private_sharing_req_new, int (private_sharing_req**));
-  MOCK_METHOD1(security_manager_private_sharing_apply, int (const private_sharing_req*));
-  MOCK_METHOD1(security_manager_private_sharing_drop, int (const private_sharing_req*));
-  MOCK_METHOD2(security_manager_private_sharing_req_set_target_appid,
-      int (private_sharing_req*, const char*));
-  MOCK_METHOD3(security_manager_private_sharing_req_add_paths,
-      int (private_sharing_req*, const char**, size_t));
-
-};
-
-#endif  // UNIT_TESTS_MOCK_SECURITY_MANAGER_MOCK_H_
diff --git a/tests/mock/security_manager_mock.hh b/tests/mock/security_manager_mock.hh
new file mode 100644 (file)
index 0000000..cc35956
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TESTS_MOCK_SECURITY_MANAGER_MOCK_H_
+#define UNIT_TESTS_MOCK_SECURITY_MANAGER_MOCK_H_
+
+#include <security-manager.h>
+#include <gmock/gmock.h>
+
+#include "module_mock.hh"
+
+class SecurityManagerMock : public virtual ModuleMock {
+ public:
+  SecurityManagerMock() {
+    using ::testing::_;
+    using ::testing::Return;
+    using ::testing::Invoke;
+  }
+
+  MOCK_METHOD1(security_manager_private_sharing_req_new, int (private_sharing_req**));
+  MOCK_METHOD1(security_manager_private_sharing_apply, int (const private_sharing_req*));
+  MOCK_METHOD1(security_manager_private_sharing_drop, int (const private_sharing_req*));
+  MOCK_METHOD2(security_manager_private_sharing_req_set_target_appid,
+      int (private_sharing_req*, const char*));
+  MOCK_METHOD3(security_manager_private_sharing_req_add_paths,
+      int (private_sharing_req*, const char**, size_t));
+
+};
+
+#endif  // UNIT_TESTS_MOCK_SECURITY_MANAGER_MOCK_H_
index 4b8388dac208867e57c36c8c9f8ee47d2874743a..28aae23c823f8e5f4d69358b46111b02d06154c7 100644 (file)
  * limitations under the License.
  */
 
-#include "smack_mock.h"
+#include "smack_mock.hh"
 
-#include "mock_hook.h"
-#include "test_fixture.h"
+#include "mock_hook.hh"
+#include "test_fixture.hh"
 
 extern "C" ssize_t smack_new_label_from_path(const char* arg1,
     const char* arg2, int arg3, char** arg4) {
diff --git a/tests/mock/smack_mock.h b/tests/mock/smack_mock.h
deleted file mode 100644 (file)
index 2517c16..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef UNIT_TESTS_MOCK_SMACK_MOCK_H_
-#define UNIT_TESTS_MOCK_SMACK_MOCK_H_
-
-#include <gmock/gmock.h>
-#include <sys/smack.h>
-
-#include "module_mock.h"
-
-class SmackMock : public virtual ModuleMock {
- public:
-  SmackMock() {
-    using ::testing::_;
-    using ::testing::Return;
-    using ::testing::Invoke;
-  }
-
-  MOCK_METHOD4(smack_new_label_from_path, ssize_t (const char*,
-    const char*, int, char**));
-};
-
-#endif  // UNIT_TESTS_MOCK_SMACK_MOCK_H_
\ No newline at end of file
diff --git a/tests/mock/smack_mock.hh b/tests/mock/smack_mock.hh
new file mode 100644 (file)
index 0000000..4ebdf44
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TESTS_MOCK_SMACK_MOCK_H_
+#define UNIT_TESTS_MOCK_SMACK_MOCK_H_
+
+#include <gmock/gmock.h>
+#include <sys/smack.h>
+
+#include "module_mock.hh"
+
+class SmackMock : public virtual ModuleMock {
+ public:
+  SmackMock() {
+    using ::testing::_;
+    using ::testing::Return;
+    using ::testing::Invoke;
+  }
+
+  MOCK_METHOD4(smack_new_label_from_path, ssize_t (const char*,
+    const char*, int, char**));
+};
+
+#endif  // UNIT_TESTS_MOCK_SMACK_MOCK_H_
\ No newline at end of file
diff --git a/tests/mock/socket_mock.cc b/tests/mock/socket_mock.cc
new file mode 100644 (file)
index 0000000..ea5c46c
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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 "socket_mock.hh"
+
+#include "mock_hook.hh"
+#include "test_fixture.hh"
+
+extern "C" int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen) {
+  return MOCK_HOOK_P5(SocketMock, getsockopt, sockfd, level, optname, optval, optlen);
+}
diff --git a/tests/mock/socket_mock.hh b/tests/mock/socket_mock.hh
new file mode 100644 (file)
index 0000000..9bbbb40
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * 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 UNIT_TESTS_MOCK_SOCKET_MOCK_H_
+#define UNIT_TESTS_MOCK_SOCKET_MOCK_H_
+
+#include <gmock/gmock.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include "module_mock.hh"
+
+class SocketMock : public virtual ModuleMock {
+ public:
+  virtual ~SocketMock() {}
+
+  MOCK_METHOD5(getsockopt, int(int, int, int, void*, socklen_t*));
+};
+
+#endif  // UNIT_TESTS_MOCK_SOCKET_MOCK_H_
diff --git a/tests/mock/sqlite_mock.cc b/tests/mock/sqlite_mock.cc
new file mode 100644 (file)
index 0000000..b031493
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2022 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 "sqlite_mock.hh"
+
+#include "mock_hook.hh"
+#include "test_fixture.hh"
+
+typedef int(*execcb)(void*, int, char**, char**);
+typedef void(*bindcb)(void*);
+
+extern "C" int sqlite3_open_v2(const char* arg0,
+    sqlite3** arg1, int arg2, const char* arg3) {
+  return MOCK_HOOK_P4(SqliteMock, sqlite3_open_v2, arg0, arg1, arg2, arg3);
+}
+
+extern "C" int sqlite3_close(sqlite3* arg0) {
+  return MOCK_HOOK_P1(SqliteMock, sqlite3_close, arg0);
+}
+
+extern "C" int sqlite3_changes(sqlite3* arg0) {
+  return MOCK_HOOK_P1(SqliteMock, sqlite3_changes, arg0);
+}
+
+extern "C" int sqlite3_exec(sqlite3* arg0, const char* arg1,
+    execcb arg2, void* arg3, char** arg4) {
+  return MOCK_HOOK_P5(SqliteMock, sqlite3_exec, arg0, arg1, arg2, arg3, arg4);
+}
+
+extern "C" int sqlite3_prepare_v2(sqlite3* arg0, const char* arg1,
+    int arg2, sqlite3_stmt** arg3, const char** arg4) {
+  return MOCK_HOOK_P5(SqliteMock, sqlite3_prepare_v2, arg0, arg1, arg2, arg3, arg4);
+}
+
+extern "C" int sqlite3_step(sqlite3_stmt* arg0) {
+  return MOCK_HOOK_P1(SqliteMock, sqlite3_step, arg0);
+}
+
+extern "C" const unsigned char* sqlite3_column_text(sqlite3_stmt* arg0, int arg1) {
+  return MOCK_HOOK_P2(SqliteMock, sqlite3_column_text, arg0, arg1);
+}
+
+extern "C" int sqlite3_get_table(sqlite3 *db, const char *zSql, char ***pazResult,
+    int *pnRow, int *pnColumn, char **pzErrmsg) {
+  return MOCK_HOOK_P6(SqliteMock, sqlite3_get_table, db, zSql, pazResult, pnRow, pnColumn, pzErrmsg);
+}
+
+extern "C" int sqlite3_bind_int(sqlite3_stmt* arg0, int arg1, int arg2) {
+  return MOCK_HOOK_P3(SqliteMock, sqlite3_bind_int, arg0, arg1, arg2);
+}
+
+extern "C" int sqlite3_bind_double(sqlite3_stmt* arg0, int arg1, double arg2) {
+  return MOCK_HOOK_P3(SqliteMock, sqlite3_bind_double, arg0, arg1, arg2);
+}
+
+extern "C" int sqlite3_bind_text(sqlite3_stmt* arg0, int arg1, const char* arg2, int arg3, bindcb arg4) {
+  return MOCK_HOOK_P5(SqliteMock, sqlite3_bind_text, arg0, arg1, arg2, arg3, arg4);
+}
+
+extern "C" int sqlite3_finalize(sqlite3_stmt* arg0) {
+  return MOCK_HOOK_P1(SqliteMock, sqlite3_finalize, arg0);
+}
+
+extern "C" void sqlite3_free(void* arg0) {
+  return MOCK_HOOK_P1(SqliteMock, sqlite3_free, arg0);
+}
+
+extern "C" int sqlite3_column_int(sqlite3_stmt* stmt, int iCol) {
+  return MOCK_HOOK_P2(SqliteMock, sqlite3_column_int, stmt, iCol);
+}
+
+extern "C" double sqlite3_column_double(sqlite3_stmt* stmt, int iCol) {
+  return MOCK_HOOK_P2(SqliteMock, sqlite3_column_double, stmt, iCol);
+}
diff --git a/tests/mock/sqlite_mock.hh b/tests/mock/sqlite_mock.hh
new file mode 100644 (file)
index 0000000..0c9cfb5
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TESTS_MOCK_SQLITE_MOCK_H_
+#define UNIT_TESTS_MOCK_SQLITE_MOCK_H_
+
+#include <gmock/gmock.h>
+#include <sqlite3.h>
+
+#include "module_mock.hh"
+
+class SqliteMock : public virtual ModuleMock {
+ public:
+  virtual ~SqliteMock() {}
+
+  MOCK_METHOD1(sqlite3_close, int(sqlite3*));
+  MOCK_METHOD1(sqlite3_changes, int(sqlite3*));
+  MOCK_METHOD4(sqlite3_open_v2, int(const char*, sqlite3**, int, const char*));
+  MOCK_METHOD5(sqlite3_exec, int(sqlite3*, const char*,
+      int(*)(void*, int, char**, char**), void*, char**));
+  MOCK_METHOD5(sqlite3_prepare_v2, int(sqlite3*, const char*,
+      int, sqlite3_stmt**, const char**));
+  MOCK_METHOD1(sqlite3_step, int(sqlite3_stmt*));
+  MOCK_METHOD2(sqlite3_column_text, const unsigned char*(sqlite3_stmt*, int));
+  MOCK_METHOD6(sqlite3_get_table, int(sqlite3*, const char*, char***, int* , int*, char**));
+  MOCK_METHOD3(sqlite3_bind_int, int(sqlite3_stmt*, int, int));
+  MOCK_METHOD3(sqlite3_bind_double, int(sqlite3_stmt*, int, double));
+  MOCK_METHOD5(sqlite3_bind_text, int(sqlite3_stmt*, int, const char*, int, void(*)(void*)));
+  MOCK_METHOD1(sqlite3_finalize, int(sqlite3_stmt*));
+  MOCK_METHOD1(sqlite3_free, void(void*));
+  MOCK_METHOD2(sqlite3_column_int, int(sqlite3_stmt*, int));
+  MOCK_METHOD2(sqlite3_column_double, double(sqlite3_stmt*, int));
+};
+
+#endif  // UNIT_TESTS_MOCK_SQLITE_MOCK_H_
index 27f566616c9fcf6a9202a80e6d16569ad2d127e1..50f39e99370bf23870e073a3c8386ec0fde1420f 100644 (file)
@@ -14,7 +14,7 @@
  * limitations under the License.
  */
 
-#include "test_fixture.h"
+#include "test_fixture.hh"
 
 #include <memory>
 
diff --git a/tests/mock/test_fixture.h b/tests/mock/test_fixture.h
deleted file mode 100644 (file)
index 1ea3b8f..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef UNIT_TESTS_MOCK_TEST_FIXTURE_H_
-#define UNIT_TESTS_MOCK_TEST_FIXTURE_H_
-
-#include <gtest/gtest.h>
-
-#include <memory>
-#include <stdexcept>
-#include <string>
-#include <utility>
-
-#include "module_mock.h"
-
-class TestFixture : public ::testing::Test {
- public:
-  explicit TestFixture(std::unique_ptr<ModuleMock>&& mock) {
-    mock_ = std::move(mock);
-  }
-  virtual ~TestFixture() {
-    mock_.reset();
-  }
-
-  virtual void SetUp() {}
-  virtual void TearDown() {}
-
-  template <typename T>
-  static T& GetMock() {
-    auto ptr = dynamic_cast<T*>(mock_.get());
-    if (!ptr)
-      throw std::invalid_argument("The test does not provide mock of \"" +
-          std::string(typeid(T).name()) + "\"");
-    return *ptr;
-  }
-
-  static std::unique_ptr<ModuleMock> mock_;
-};
-
-#endif  // UNIT_TESTS_MOCK_TEST_FIXTURE_H_
diff --git a/tests/mock/test_fixture.hh b/tests/mock/test_fixture.hh
new file mode 100644 (file)
index 0000000..0bf58d1
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TESTS_MOCK_TEST_FIXTURE_H_
+#define UNIT_TESTS_MOCK_TEST_FIXTURE_H_
+
+#include <gtest/gtest.h>
+
+#include <memory>
+#include <stdexcept>
+#include <string>
+#include <utility>
+
+#include "module_mock.hh"
+
+class TestFixture : public ::testing::Test {
+ public:
+  explicit TestFixture(std::unique_ptr<ModuleMock>&& mock) {
+    mock_ = std::move(mock);
+  }
+  virtual ~TestFixture() {
+    mock_.reset();
+  }
+
+  virtual void SetUp() {}
+  virtual void TearDown() {}
+
+  template <typename T>
+  static T& GetMock() {
+    auto ptr = dynamic_cast<T*>(mock_.get());
+    if (!ptr)
+      throw std::invalid_argument("The test does not provide mock of \"" +
+          std::string(typeid(T).name()) + "\"");
+    return *ptr;
+  }
+
+  static std::unique_ptr<ModuleMock> mock_;
+};
+
+#endif  // UNIT_TESTS_MOCK_TEST_FIXTURE_H_
index e6b3cbdf20181a68af0b751d2d4b6cc4e5e6370e..60946548783545c4a4a007b40df9403c1ba4114d 100644 (file)
  * limitations under the License.
  */
 
-#include "tzplatform_config_mock.h"
+#include "tzplatform_config_mock.hh"
 
-#include "mock_hook.h"
-#include "test_fixture.h"
+#include "mock_hook.hh"
+#include "test_fixture.hh"
 
 extern "C" const char* tzplatform_getenv(enum tzplatform_variable arg1) {
   return MOCK_HOOK_P1(TzplatformConfigMock, tzplatform_getenv, arg1);
diff --git a/tests/mock/tzplatform_config_mock.h b/tests/mock/tzplatform_config_mock.h
deleted file mode 100644 (file)
index b6c75e4..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2022 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef UNIT_TESTS_MOCK_TZPLATFORM_CONFIG_MOCK_H_
-#define UNIT_TESTS_MOCK_TZPLATFORM_CONFIG_MOCK_H_
-
-#include <tzplatform_config.h>
-#include <gmock/gmock.h>
-
-#include "module_mock.h"
-
-class TzplatformConfigMock : public virtual ModuleMock {
- public:
-  TzplatformConfigMock() {
-    using ::testing::_;
-    using ::testing::Return;
-    using ::testing::Invoke;
-  }
-
-  MOCK_METHOD1(tzplatform_getenv, const char* (enum tzplatform_variable));
-};
-
-#endif  // UNIT_TESTS_MOCK_TZPLATFORM_CONFIG_MOCK_H_
\ No newline at end of file
diff --git a/tests/mock/tzplatform_config_mock.hh b/tests/mock/tzplatform_config_mock.hh
new file mode 100644 (file)
index 0000000..43d1ac1
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef UNIT_TESTS_MOCK_TZPLATFORM_CONFIG_MOCK_H_
+#define UNIT_TESTS_MOCK_TZPLATFORM_CONFIG_MOCK_H_
+
+#include <tzplatform_config.h>
+#include <gmock/gmock.h>
+
+#include "module_mock.hh"
+
+class TzplatformConfigMock : public virtual ModuleMock {
+ public:
+  TzplatformConfigMock() {
+    using ::testing::_;
+    using ::testing::Return;
+    using ::testing::Invoke;
+  }
+
+  MOCK_METHOD1(tzplatform_getenv, const char* (enum tzplatform_variable));
+};
+
+#endif  // UNIT_TESTS_MOCK_TZPLATFORM_CONFIG_MOCK_H_
\ No newline at end of file
diff --git a/tests/noti_ex_unittest/CMakeLists.txt b/tests/noti_ex_unittest/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5ff9faa
--- /dev/null
@@ -0,0 +1,50 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+PROJECT(notification-ex-unittests CXX)
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(notification-ex-unittests REQUIRED
+    dlog
+    gmock
+    capi-appfw-app-control
+    glib-2.0
+    gio-2.0
+    gio-unix-2.0
+    aul
+    security-manager
+    libtzplatform-config
+)
+
+FOREACH(flag ${notification-ex-unittests_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+INCLUDE_DIRECTORIES(
+    ${CMAKE_SOURCE_DIR}/
+    ${CMAKE_SOURCE_DIR}/notification-ex/
+    ${CMAKE_SOURCE_DIR}/notification-ex/api
+    ${CMAKE_CURRENT_SOURCE_DIR}/../
+    ${CMAKE_CURRENT_SOURCE_DIR}/../mock
+)
+
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../mock MOCK_SOURCES)
+AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/notification-ex NOTIFICATION_EX_SOURCES)
+ADD_EXECUTABLE(${PROJECT_NAME}
+    ${SOURCES}
+    ${NOTIFICATION_EX_SOURCES}
+    ${MOCK_SOURCES}
+)
+
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${notification-ex-unittests_LDFLAGS}
+    ${pkgs_LDFLAGS}
+    ${pkgs_LIBRARIES}
+    gmock
+    notification-ex
+)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
diff --git a/tests/noti_ex_unittest/src/test_main.cc b/tests/noti_ex_unittest/src/test_main.cc
new file mode 100644 (file)
index 0000000..ad7ec6c
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+int main(int argc, char** argv) {
+  int ret = -1;
+
+  try {
+    testing::InitGoogleTest(&argc, argv);
+  } catch(...) {
+    std::cout << "Exception occurred" << std::endl;
+  }
+
+  try {
+    ret = RUN_ALL_TESTS();
+  } catch (const ::testing::internal::GoogleTestFailureException& e) {
+    ret = -1;
+    std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl;
+  }
+
+  return ret;
+}
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_abstract_item.cc b/tests/noti_ex_unittest/src/test_noti_ex_abstract_item.cc
new file mode 100644 (file)
index 0000000..3d1549a
--- /dev/null
@@ -0,0 +1,349 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+#include <app_control.h>
+#include <app_common.h>
+
+#include "notification-ex/item_inflator.h"
+#include "notification-ex/app_control_action.h"
+#include "notification-ex/item_info_internal.h"
+#include "notification-ex/iitem_factory.h"
+#include "notification-ex/factory_manager.h"
+#include "notification-ex/default_item_factory.h"
+#include "notification-ex/group_item.h"
+#include "notification-ex/button_item.h"
+
+#include "mock/test_fixture.hh"
+#include "mock/smack_mock.hh"
+#include "mock/app_common_mock.hh"
+#include "mock/aul_mock.hh"
+
+#define MY_ITEM_TYPE AbstractItem::Type::Custom + 1
+
+using namespace notification;
+using namespace tizen_base;
+using namespace notification::item;
+
+using ::testing::_;
+using ::testing::Invoke;
+
+namespace {
+class TestItem : public AbstractItem {
+  public:
+   TestItem(std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}))
+     : AbstractItem(action) {
+   }
+   TestItem(std::string id, std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}))
+     : AbstractItem(id, action) {
+   }
+   virtual ~TestItem() {}
+
+  Bundle Serialize() const override {
+    Bundle b;
+    b = AbstractItem::Serialize();
+    return b;
+  }
+  void Deserialize(Bundle b) override {
+    AbstractItem::Deserialize(b);
+  }
+  AbstractItem& FindByID(std::string id) override {
+    return *this;
+  }
+  bool IsItemTypeExist(int type) {
+  if (GetType() == type)
+      return true;
+    return false;
+  }
+  int GetType() const override {
+    return MY_ITEM_TYPE;
+  }
+};
+
+class MyFactory : public IItemFactory {
+ public:
+  MyFactory() {}
+  virtual ~MyFactory() {}
+
+  std::unique_ptr<AbstractItem> CreateItem(int type) override {
+    if (type == MY_ITEM_TYPE)
+      return std::unique_ptr<AbstractItem>(new TestItem(""));
+
+    return nullptr;
+  }
+};
+
+class Mocks :
+    virtual public ::testing::NiceMock<AulMock>,
+    virtual public ::testing::NiceMock<SmackMock>,
+    virtual public ::testing::NiceMock<AppCommonMock> {};
+} // namespace
+
+class AbstractItemTest : public TestFixture {
+ public:
+  AbstractItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
+
+  virtual void SetUp() {
+    FactoryManager::GetInst().RegisterFactory(std::unique_ptr<IItemFactory>(new MyFactory()));
+  }
+  virtual void TearDown() {
+    FactoryManager::GetInst().RegisterFactory(std::unique_ptr<IItemFactory>(new DefaultItemFactory()));
+  }
+};
+
+TEST_F(AbstractItemTest, SerializeDeserialize) {
+  /* Serialize */
+  app_control_h app_control, app_control_1;
+  char* app_id = NULL;
+  time_t current_time;
+  Bundle extension_b;
+
+  app_control_create(&app_control);
+  app_control_set_app_id(app_control, "new_appid");
+  std::shared_ptr<AppControlAction> action = std::make_shared<AppControlAction>(app_control);
+  app_control_destroy(app_control);
+
+  app_control_create(&app_control_1);
+  app_control_set_app_id(app_control_1, "new_appid_1");
+  std::shared_ptr<AppControlAction> action_1 = std::make_shared<AppControlAction>(app_control_1);
+  app_control_destroy(app_control_1);
+
+  TestItem item("test_id", action);
+
+  std::shared_ptr<Color> color = std::make_shared<Color>(50, 100,150,200);
+  std::shared_ptr<Padding> padding = std::make_shared<Padding>(10, 20, 30, 40);
+  std::shared_ptr<Geometry> geometry = std::make_shared<Geometry>(110, 120, 130, 140);
+  std::shared_ptr<Color> bg_color = std::make_shared<Color>(71, 72, 73, 74);
+
+  item.SetStyle(std::make_shared<Style>(color, padding, geometry, bg_color, "bg path"));
+  item.SetVisible(false);
+  item.SetEnable(false);
+  item.AddReceiver("receiver_1");
+  item.AddReceiver("receiver_2");
+  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->AddHideViewer("hide_1");
+  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->AddHideViewer("hide_2");
+  item.SetPolicy(AbstractItem::Policy::OnBootClear);
+  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetVersion(3);
+  item.GetInfo()->SetHideTime(5);
+  item.GetInfo()->SetDeleteTime(9);
+  item.SetChannel("channel99");
+  item.SetSoundPath("soundpath");
+  item.SetVibrationPath("vibrationpath");
+  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetUid(3);
+  item.SetSenderAppId("sender");
+  item.SetTag("tag");
+
+  time(&current_time);
+  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetTime(current_time);
+
+  std::shared_ptr<Color> color2 = std::make_shared<Color>(150, 160, 170, 180);
+  std::shared_ptr<LEDInfo> led = std::make_shared<LEDInfo>(color2);
+  led->SetOnPeriod(10);
+  led->SetOffPeriod(20);
+
+  item.SetLEDInfo(led);
+  item.SetOnGoingState(true);
+
+  extension_b.Add("test_key", "test_value");
+  item.SetExtensionData("extension_key", extension_b);
+
+  /* Deserialize */
+  Bundle b = item.Serialize();
+
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  TestItem* gen_test = static_cast<TestItem*>(gen_item.get());
+
+  ASSERT_EQ(gen_test->GetId(), "test_id");
+  ASSERT_EQ(gen_test->GetType(), MY_ITEM_TYPE);
+  ASSERT_EQ(std::static_pointer_cast<IItemInfoInternal>(gen_test->GetInfo())->GetUid(), 3);
+  ASSERT_EQ(gen_test->GetEnable(), false);
+  ASSERT_EQ(gen_test->GetVisible(),false);
+  ASSERT_EQ(gen_test->GetPolicy(), AbstractItem::Policy::OnBootClear);
+  ASSERT_EQ(std::static_pointer_cast<IItemInfoInternal>(gen_test->GetInfo())->GetVersion(), 3);
+  ASSERT_EQ(gen_test->GetInfo()->GetHideTime(), 5);
+  ASSERT_EQ(gen_test->GetInfo()->GetDeleteTime(), 9);
+  ASSERT_EQ(gen_test->GetChannel(), "channel99");
+  ASSERT_EQ(gen_test->GetSoundPath(), "soundpath");
+  ASSERT_EQ(gen_test->GetVibrationPath(), "vibrationpath");
+  ASSERT_EQ(gen_test->GetSenderAppId(), "sender");
+  ASSERT_EQ(gen_test->GetTag(), "tag");
+  ASSERT_EQ(gen_test->GetInfo()->GetTime(), current_time);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetLeft(), 10);
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetTop(), 20);
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetRight(), 30);
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetBottom(), 40);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetAVal(), 50);
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetRVal(), 100);
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetGVal(), 150);
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetBVal(), 200);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetX(), 110);
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetY(), 120);
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetWidth(), 130);
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetHeight(), 140);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetAVal(), 71);
+  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetRVal(), 72);
+  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetGVal(), 73);
+  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetBVal(), 74);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundImage(), "bg path");
+
+  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetAVal(), 150);
+  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetRVal(), 160);
+  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetGVal(), 170);
+  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetBVal(), 180);
+  ASSERT_EQ(gen_test->GetLEDInfo()->GetOnPeriod(), 10);
+  ASSERT_EQ(gen_test->GetLEDInfo()->GetOffPeriod(), 20);
+
+  std::list<std::string> receiver1 = item.GetReceiverList();
+  std::list<std::string> receiver2 = gen_test->GetReceiverList();
+
+  ASSERT_EQ(receiver1.size(), receiver2.size());
+
+  for (unsigned int i = 0; i < receiver1.size(); i++) {
+    ASSERT_EQ(receiver1.front(), receiver2.front());
+    receiver1.pop_front();
+    receiver2.pop_front();
+  }
+
+  std::list<std::string> hide1 =
+      std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->GetHideViewerList();
+  std::list<std::string> hide2 =
+      std::static_pointer_cast<IItemInfoInternal>(gen_test->GetInfo())->GetHideViewerList();
+
+  ASSERT_EQ(hide1.size(), hide2.size());
+
+  for (unsigned int i = 0; i < hide1.size(); i++) {
+    ASSERT_EQ(hide1.front(), hide2.front());
+    hide1.pop_front();
+    hide2.pop_front();
+  }
+
+  ASSERT_EQ(gen_test->GetAction()->GetType(), AbstractAction::Type::AppControl);
+
+  std::shared_ptr<AppControlAction> ac =
+      std::static_pointer_cast<AppControlAction>(gen_test->GetAction());
+  app_control_get_app_id(ac->GetAppControl(), &app_id);
+
+  ASSERT_STREQ(app_id, "new_appid");
+
+  item.SetAction(action_1);
+
+  b = item.Serialize();
+  gen_item = ItemInflator::Create(b);
+  gen_test = static_cast<TestItem*>(gen_item.get());
+
+  ac = std::static_pointer_cast<AppControlAction>(gen_test->GetAction());
+  app_control_get_app_id(ac->GetAppControl(), &app_id);
+
+  ASSERT_STREQ(app_id, "new_appid_1");
+  ASSERT_EQ(gen_test->GetOnGoingState(), true);
+
+  Bundle extension_b2 = gen_test->GetExtensionData("extension_key");
+  ASSERT_EQ(extension_b2.GetString("test_key"), "test_value");
+}
+
+TEST_F(AbstractItemTest, SerializeDeserialize2) {
+  /* Serialize */
+  TestItem item("test_id");
+
+  std::shared_ptr<Color> color = std::make_shared<Color>(50, 100,150,200);
+  std::shared_ptr<Padding> padding = std::make_shared<Padding>(10, 20, 30, 40);
+  std::shared_ptr<Geometry> geometry = std::make_shared<Geometry>(110, 120, 130, 140);
+
+  item.SetStyle(std::make_shared<Style>(color, padding, geometry, nullptr, ""));
+
+  /* Deserialize */
+  Bundle b = item.Serialize();
+
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  TestItem* gen_test = static_cast<TestItem*>(gen_item.get());
+
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetLeft(), 10);
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetTop(), 20);
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetRight(), 30);
+  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetBottom(), 40);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetAVal(), 50);
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetRVal(), 100);
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetGVal(), 150);
+  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetBVal(), 200);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetX(), 110);
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetY(), 120);
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetWidth(), 130);
+  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetHeight(), 140);
+
+  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor(), nullptr);
+  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundImage(), "");
+}
+
+TEST_F(AbstractItemTest, ItemInfoCanReceive) {
+  TestItem item("test_id");
+
+  item.AddReceiver(ReceiverGroup::Panel);
+  item.AddReceiver(ReceiverGroup::LockScreen);
+
+  ASSERT_TRUE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::Panel));
+  ASSERT_TRUE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::LockScreen));
+  ASSERT_FALSE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::Popup));
+}
+
+TEST_F(AbstractItemTest, SetGetOnGoingState) {
+  TestItem item("test_id");
+
+  ASSERT_EQ(item.GetOnGoingState(), false);
+
+  item.SetOnGoingState(true);
+
+  ASSERT_EQ(item.GetOnGoingState(), true);
+}
+
+int __fake_app_get_name(char** app_name) {
+  *app_name = strdup("unittest_appname");
+  return 0;
+}
+
+TEST_F(AbstractItemTest, SetGetFindMainType) {
+  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
+      .WillRepeatedly(Invoke(__fake_app_get_name));
+
+  auto root = std::make_shared<GroupItem>("test_group");
+  auto item = std::make_shared<ButtonItem>("test_id", "title");
+  root->AddChild(item);
+
+  bool ret = root->SetMainType("test_id", AbstractItem::MainButton);
+  EXPECT_TRUE(ret);
+  EXPECT_EQ(item->GetMainType(), AbstractItem::MainButton);
+  auto& i = root->FindByMainType(AbstractItem::MainButton);
+  EXPECT_EQ(i.GetId(), "test_id");
+}
+
+TEST_F(AbstractItemTest, SetInvalidMainType) {
+  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
+      .WillRepeatedly(Invoke(__fake_app_get_name));
+
+  auto root = std::make_shared<GroupItem>("test_group");
+  auto item = std::make_shared<ButtonItem>("test_id", "title");
+  root->AddChild(item);
+
+  bool ret = root->SetMainType("test_id", AbstractItem::MainTitle);
+  EXPECT_FALSE(ret);
+}
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_app_control_action.cc b/tests/noti_ex_unittest/src/test_noti_ex_app_control_action.cc
new file mode 100644 (file)
index 0000000..70f53e1
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+#include "mock/app_common_mock.hh"
+#include "mock/test_fixture.hh"
+
+#include "notification-ex/app_control_action.h"
+#include "notification-ex/action_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+namespace {
+class Mocks :
+    virtual public ::testing::NiceMock<AppCommonMock> {};
+} // namespace
+
+class AppControlActionTest : public TestFixture {
+ public:
+  AppControlActionTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  AppControlAction* action;
+  app_control_h app_control;
+  const char* app_id = "test_appid";
+  std::string extra = "appcontrol_extra";
+
+  virtual void SetUp() {
+    app_control_create(&app_control);
+    app_control_set_app_id(app_control, app_id);
+
+    action = new AppControlAction(app_control, extra);
+  }
+  virtual void TearDown() {
+    delete action;
+    app_control_destroy(app_control);
+  }
+};
+
+TEST_F(AppControlActionTest, create) {
+  EXPECT_NE(AppControlActionTest::action, nullptr);
+}
+
+TEST_F(AppControlActionTest, IsLocal) {
+  ASSERT_EQ(AppControlActionTest::action->IsLocal(), 1);
+}
+
+TEST_F(AppControlActionTest, GetExtra) {
+  ASSERT_EQ(AppControlActionTest::action->GetExtra(),
+    AppControlActionTest::extra);
+}
+
+TEST_F(AppControlActionTest, SerializeDeserialize) {
+  Bundle b = AppControlActionTest::action->Serialize();
+
+  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
+  ASSERT_EQ(gen_action->GetType(), AbstractAction::AppControl);
+
+  AppControlAction* gen_appcontrol_action =
+    static_cast<AppControlAction*>(gen_action.get());
+
+  char* app_id = nullptr;
+  app_control_get_app_id(gen_appcontrol_action->GetAppControl(), &app_id);
+  std::unique_ptr<char, decltype(std::free)*> ptr(app_id, std::free);
+  ASSERT_STREQ(app_id, AppControlActionTest::app_id);
+}
+
+TEST_F(AppControlActionTest, AppControl) {
+  app_control_h app_control;
+  const char* app_id = "new_appid";
+
+  app_control_create(&app_control);
+  app_control_set_app_id(app_control, app_id);
+  AppControlActionTest::action->SetAppControl(app_control);
+  app_control_destroy(app_control);
+
+  Bundle b = AppControlActionTest::action->Serialize();
+
+  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
+  AppControlAction* gen_appcontrol_action =
+    static_cast<AppControlAction*>(gen_action.get());
+
+  char* app_id_ = nullptr;
+  app_control_get_app_id(gen_appcontrol_action->GetAppControl(), &app_id_);
+  std::unique_ptr<char, decltype(std::free)*> ptr(app_id_, std::free);
+  EXPECT_STREQ(app_id, app_id_);
+}
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_button_item.cc b/tests/noti_ex_unittest/src/test_noti_ex_button_item.cc
new file mode 100644 (file)
index 0000000..5ef0c11
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+#include "mock/app_common_mock.hh"
+#include "mock/test_fixture.hh"
+#include "notification-ex/button_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+using namespace std;
+
+namespace {
+class Mocks :
+    virtual public ::testing::NiceMock<AppCommonMock> {};
+} // namespace
+
+class ButtonItemTest : public TestFixture {
+ public:
+  ButtonItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
+ protected:
+  void SetUp() override {}
+  void TearDown() override {}
+};
+
+
+TEST_F(ButtonItemTest, FindByID) {
+  ButtonItem item("btn_id", "title");
+
+  AbstractItem& child = item.FindByID("btn_id");
+  ButtonItem& btn = static_cast<ButtonItem&>(child);
+  ASSERT_EQ(btn.GetTitle(), "title");
+}
+
+TEST_F(ButtonItemTest, FindByIDNullItemReturn) {
+  ButtonItem item("btn_id", "title");
+
+  AbstractItem& child = item.FindByID("not_exist_button");
+  ASSERT_EQ(child.GetType(), AbstractItem::NullObject);
+}
+
+TEST_F(ButtonItemTest, SerializeDeserializeGetTitle) {
+  ButtonItem item("title");
+  Bundle b = item.Serialize();
+  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(gen_item->GetType(), item.GetType());
+
+  auto gen_btn = std::static_pointer_cast<ButtonItem>(gen_item);
+  ASSERT_EQ(item.GetTitle(), gen_btn->GetTitle());
+}
+
+TEST_F(ButtonItemTest, GetSetPath) {
+  ButtonItem item("btn_id", "title");
+
+  item.SetImgPath("testpath");
+  std::string path = item.GetImgPath();
+  ASSERT_STREQ(path.c_str(), "testpath");
+}
+
+TEST_F(ButtonItemTest, GetSeContent) {
+  ButtonItem item("btn_id", "title");
+
+  item.SetContents("testcontents");
+  std::string content = item.GetContents();
+  ASSERT_STREQ(content.c_str(), "testcontents");
+}
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_chat_message_item.cc b/tests/noti_ex_unittest/src/test_noti_ex_chat_message_item.cc
new file mode 100644 (file)
index 0000000..aa0f9fb
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+#include "mock/app_common_mock.hh"
+#include "mock/smack_mock.hh"
+#include "mock/test_fixture.hh"
+#include "notification-ex/chat_message_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+namespace {
+class Mocks :
+    virtual public ::testing::NiceMock<SmackMock>,
+    virtual public ::testing::NiceMock<AppCommonMock> {};
+} // namespace
+
+class ChatMessageItemTest : public TestFixture {
+ public:
+  ChatMessageItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  ChatMessageItem* item;
+  ChatMessageItem::Type type = ChatMessageItem::Type::user;
+  std::string id = "chatmessage_id";
+  time_t current_time;
+  virtual void SetUp() {
+    time(&current_time);
+
+    item = new ChatMessageItem(id,
+      std::make_shared<TextItem>("name_id", "name"),
+      std::make_shared<TextItem>("text_id", "text"),
+      std::make_shared<ImageItem>("image_id", "path"),
+      std::make_shared<TimeItem>(current_time),type);
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(ChatMessageItemTest, create) {
+  EXPECT_NE(ChatMessageItemTest::item, nullptr);
+}
+
+TEST_F(ChatMessageItemTest, FindByID) {
+  AbstractItem& child = ChatMessageItemTest::item->FindByID(ChatMessageItemTest::id);
+  ChatMessageItem& message = static_cast<ChatMessageItem&>(child);
+  ASSERT_EQ(message.GetNameItem().GetContents(), "name");
+  ASSERT_EQ(message.GetTextItem().GetContents(), "text");
+  ASSERT_EQ(message.GetImageItem().GetImagePath(), "path");
+  ASSERT_EQ(message.GetMessageType(), ChatMessageItemTest::type);
+}
+
+TEST_F(ChatMessageItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = ChatMessageItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), ChatMessageItem::NullObject);
+}
+
+TEST_F(ChatMessageItemTest, SerializeDeserialize) {
+  Bundle b = ChatMessageItemTest::item->Serialize();
+
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  auto gen_message = std::static_pointer_cast<ChatMessageItem>(gen_item);
+  ASSERT_EQ(gen_message->GetNameItem().GetContents(), "name");
+  ASSERT_EQ(gen_message->GetTextItem().GetContents(), "text");
+  ASSERT_EQ(gen_message->GetImageItem().GetImagePath(), "path");
+  ASSERT_EQ(gen_message->GetTimeItem().GetTime(), ChatMessageItemTest::current_time);
+  ASSERT_EQ(gen_message->GetMessageType(), ChatMessageItemTest::type);
+}
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_checkbox_item.cc b/tests/noti_ex_unittest/src/test_noti_ex_checkbox_item.cc
new file mode 100644 (file)
index 0000000..e27f192
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+#include "mock/app_common_mock.hh"
+#include "mock/test_fixture.hh"
+#include "notification-ex/checkbox_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+namespace {
+class Mocks :
+    virtual public ::testing::NiceMock<AppCommonMock> {};
+} // namespace
+
+class CheckBoxItemTest : public TestFixture {
+ public:
+  CheckBoxItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  CheckBoxItem* item;
+  std::string id = "checkbox_id";
+  std::string title = "title";
+  bool isChecked = false;
+  virtual void SetUp() {
+    item = new CheckBoxItem(id, title, isChecked);
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(CheckBoxItemTest, create) {
+  EXPECT_NE(CheckBoxItemTest::item, nullptr);
+}
+
+TEST_F(CheckBoxItemTest, FindByID) {
+  AbstractItem& child = CheckBoxItemTest::item->FindByID(CheckBoxItemTest::id);
+  CheckBoxItem& checkbox = static_cast<CheckBoxItem&>(child);
+  ASSERT_EQ(checkbox.GetTitle(), CheckBoxItemTest::title);
+  ASSERT_EQ(checkbox.IsChecked(), CheckBoxItemTest::isChecked);
+}
+
+TEST_F(CheckBoxItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = CheckBoxItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), CheckBoxItem::NullObject);
+}
+
+TEST_F(CheckBoxItemTest, SerializeDeserialize) {
+  Bundle b = CheckBoxItemTest::item->Serialize();
+
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(CheckBoxItemTest::item->GetType(), gen_item->GetType());
+
+  auto gen_checkbox = std::static_pointer_cast<CheckBoxItem>(gen_item);
+  ASSERT_EQ(CheckBoxItemTest::item->GetTitle(), gen_checkbox->GetTitle());
+}
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_entry_item.cc b/tests/noti_ex_unittest/src/test_noti_ex_entry_item.cc
new file mode 100644 (file)
index 0000000..6234c44
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+#include "mock/app_common_mock.hh"
+#include "mock/test_fixture.hh"
+#include "notification-ex/entry_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+namespace {
+class Mocks :
+    virtual public ::testing::NiceMock<AppCommonMock> {};
+} // namespace
+
+class EntryItemTest : public TestFixture {
+ public:
+  EntryItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  virtual void SetUp() {}
+  virtual void TearDown() {}
+};
+
+TEST_F(EntryItemTest, FindByID) {
+  EntryItem item("entry_id");
+
+  AbstractItem& child = item.FindByID("entry_id");
+  EntryItem& btn = static_cast<EntryItem&>(child);
+  ASSERT_EQ(btn.GetId(), "entry_id");
+}
+
+TEST_F(EntryItemTest, FindByIDNullItemReturn) {
+  EntryItem item("entry_id");
+
+  AbstractItem& child = item.FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), EntryItem::NullObject);
+}
+
+TEST_F(EntryItemTest, SerializeDeserialize) {
+  EntryItem item("entry_id");
+
+  Bundle b = item.Serialize();
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(gen_item->GetType(), item.GetType());
+
+  auto gen_effect = std::static_pointer_cast<EntryItem>(gen_item);
+  ASSERT_EQ(item.GetId(), gen_effect->GetId());
+}
+
+TEST_F(EntryItemTest, SetTextGetText) {
+  EntryItem item("entry_id");
+  item.SetText("test");
+
+  ASSERT_EQ(item.GetText(), "test");
+}
+
+TEST_F(EntryItemTest, GetTextLimit) {
+  EntryItem item("entry_id");
+
+  ASSERT_EQ(item.GetTextLimit(), 160);
+}
\ No newline at end of file
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_event_info.cc b/tests/noti_ex_unittest/src/test_noti_ex_event_info.cc
new file mode 100644 (file)
index 0000000..d117d19
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+#include "mock/app_common_mock.hh"
+#include "mock/test_fixture.hh"
+#include "notification-ex/event_info_internal.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace std;
+
+namespace {
+class Mocks :
+    virtual public ::testing::NiceMock<AppCommonMock> {};
+} // namespace
+
+class EventInfoTest : public TestFixture {
+ public:
+  EventInfoTest() : TestFixture(std::make_unique<::Mocks>()) {}
+ protected:
+  void SetUp() override {}
+  void TearDown() override {}
+};
+
+TEST_F(EventInfoTest, SerializeDeserialize) {
+  EventInfo info(EventInfo::Get, "test", "channel", "id");
+  Bundle b = info.Serialize();
+  EventInfo serialized(b);
+  ASSERT_EQ(serialized.GetEventType(), info.GetEventType());
+  ASSERT_EQ(serialized.GetOwner(), info.GetOwner());
+  ASSERT_EQ(serialized.GetChannel(), info.GetChannel());
+  ASSERT_EQ(serialized.GetItemId(), info.GetItemId());
+  ASSERT_EQ(serialized.GetUid(), info.GetUid());
+}
+
+TEST_F(EventInfoTest, GetString) {
+  ASSERT_EQ(EventInfo::GetString(EventInfo::Post), "Post");
+  ASSERT_EQ(EventInfo::GetString(EventInfo::Update), "Update");
+  ASSERT_EQ(EventInfo::GetString(EventInfo::Delete), "Delete");
+  ASSERT_EQ(EventInfo::GetString(EventInfo::Get), "Get");
+}
+
+TEST_F(EventInfoTest, GetSetEventType) {
+  EventInfo info(EventInfo::Get, "test", "channel", "id");
+  info.SetEventType(EventInfo::Post);
+  int type = info.GetEventType();
+  EXPECT_EQ(type, EventInfo::Post);
+}
+
+TEST_F(EventInfoTest, GetSetValidOwner) {
+  EventInfo info(EventInfo::Get, "test", "channel", "id");
+  info.SetValidatedOwner("testowner");
+  std::string owner = info.GetValidatedOwner();
+  EXPECT_STREQ(owner.c_str(), "testowner");
+}
+
+TEST_F(EventInfoTest, GetSetUid) {
+  EventInfo info(EventInfo::Get, "test", "channel", "id");
+  info.SetUid(5001);
+  uid_t my_uid = info.GetUid();
+  EXPECT_EQ(my_uid, 5001);
+}
+
+TEST_F(EventInfoTest, GetSetValidUid) {
+  EventInfo info(EventInfo::Get, "test", "channel", "id");
+  info.SetValidatedUid(5001);
+  uid_t my_uid = info.GetValidatedUid();
+  EXPECT_EQ(my_uid, 5001);
+}
+
+TEST_F(EventInfoTest, GetSetError) {
+  EventInfo info(EventInfo::Get, "test", "channel", "id");
+  info.SetError(NotificationError::ERROR_NONE);
+  NotificationError err = info.GetError();
+  EXPECT_EQ(err, NotificationError::ERROR_NONE);
+}
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_group_item.cc b/tests/noti_ex_unittest/src/test_noti_ex_group_item.cc
new file mode 100644 (file)
index 0000000..e00ae1f
--- /dev/null
@@ -0,0 +1,210 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+#include "notification-ex/group_item.h"
+#include "notification-ex/button_item.h"
+#include "notification-ex/text_item.h"
+#include "notification-ex/item_inflator.h"
+#include "mock/app_common_mock.hh"
+#include "mock/test_fixture.hh"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+using namespace std;
+
+using ::testing::_;
+using ::testing::Invoke;
+
+namespace {
+  int __fake_app_get_name(char** app_name) {
+    *app_name = strdup("unittest_appname");
+    return 0;
+  }
+class Mocks :
+    virtual public ::testing::NiceMock<AppCommonMock> {};
+} // namespace
+
+class GroupItemTest : public TestFixture {
+ public:
+  GroupItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
+ protected:
+  void SetUp() override {}
+  void TearDown() override {}
+};
+
+TEST_F(GroupItemTest, AddChild) {
+  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
+      .WillRepeatedly(Invoke(__fake_app_get_name));
+
+  GroupItem item("GROUP1");
+  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
+  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
+  ASSERT_EQ(item.GetChildren().size(), 2);
+}
+
+TEST_F(GroupItemTest, RemoveChild) {
+  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
+      .WillRepeatedly(Invoke(__fake_app_get_name));
+
+  GroupItem item("GROUP1");
+  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
+  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
+  ASSERT_EQ(item.GetChildren().size(), 2);
+
+  item.RemoveChild("btn1");
+  ASSERT_EQ(item.GetChildren().size(), 1);
+}
+
+TEST_F(GroupItemTest, SerializeDeserialize) {
+  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
+      .WillRepeatedly(Invoke(__fake_app_get_name));
+
+  GroupItem item("GROUP1");
+  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
+  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
+
+  Bundle b = item.Serialize();
+  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(gen_item->GetType(), item.GetType());
+
+  auto gen_group = static_pointer_cast<GroupItem>(gen_item);
+  list<shared_ptr<AbstractItem>> gen_children_list = gen_group->GetChildren();
+  list<shared_ptr<AbstractItem>> origin_children_list = item.GetChildren();
+
+  list<shared_ptr<AbstractItem>>::iterator it = origin_children_list.begin();
+  for (auto& i : gen_children_list) {
+    ASSERT_EQ(i->GetType(), (*it)->GetType());
+    if (i->GetType() == AbstractItem::Button) {
+      ButtonItem* btn1 = static_cast<ButtonItem*>(i.get());
+      ButtonItem* btn2 = static_cast<ButtonItem*>((*it).get());
+      ASSERT_EQ(btn1->GetTitle(), btn2->GetTitle());
+    }
+    it++;
+  }
+  ASSERT_EQ(item.GetChildren().size(), 2);
+}
+
+TEST_F(GroupItemTest, FindByID) {
+  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
+      .WillRepeatedly(Invoke(__fake_app_get_name));
+
+  GroupItem item("GROUP1");
+  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
+  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
+  ASSERT_EQ(item.GetChildren().size(), 2);
+
+  AbstractItem& child = item.FindByID("btn2");
+  ButtonItem& btn = static_cast<ButtonItem&>(child);
+  ASSERT_EQ(btn.GetTitle(), "test2");
+}
+
+TEST_F(GroupItemTest, FindByIDGroupItem) {
+  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
+      .WillRepeatedly(Invoke(__fake_app_get_name));
+
+  GroupItem item("GROUP1");
+  shared_ptr<GroupItem> gr2 = shared_ptr<GroupItem>(new GroupItem("GROUP2"));
+  shared_ptr<GroupItem> gr3 = shared_ptr<GroupItem>(new GroupItem("GROUP3"));
+  gr2->AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
+  gr2->AddChild(std::make_shared<ButtonItem>("btn3", "test3"));
+  gr2->AddChild(std::make_shared<ButtonItem>("btn4", "test4"));
+  gr3->AddChild(std::make_shared<ButtonItem>("btn6", "test6"));
+  gr2->AddChild(gr3);
+
+  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
+  item.AddChild(gr2);
+  item.AddChild(std::make_shared<ButtonItem>("btn5", "test5"));
+  ASSERT_EQ(item.GetChildren().size(), 3);
+
+  AbstractItem& child = item.FindByID("btn3");
+  ButtonItem& btn = static_cast<ButtonItem&>(child);
+  ASSERT_EQ(btn.GetTitle(), "test3");
+
+  AbstractItem& child2 = item.FindByID("GROUP3");
+  GroupItem& ret_gr = static_cast<GroupItem&>(child2);
+  ASSERT_EQ(ret_gr.GetChildren().size(), 1);
+}
+
+
+TEST_F(GroupItemTest, IsItemTypeExist) {
+  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
+      .WillRepeatedly(Invoke(__fake_app_get_name));
+
+  GroupItem item("GROUP1");
+  shared_ptr<GroupItem> gr2 = shared_ptr<GroupItem>(new GroupItem("GROUP2"));
+  shared_ptr<GroupItem> gr3 = shared_ptr<GroupItem>(new GroupItem("GROUP3"));
+  gr2->AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
+  gr2->AddChild(std::make_shared<ButtonItem>("btn3", "test3"));
+  gr2->AddChild(std::make_shared<ButtonItem>("btn4", "test4"));
+  gr3->AddChild(std::make_shared<ButtonItem>("btn6", "test6"));
+  gr3->AddChild(std::make_shared<TextItem>("text1", "text1"));
+  gr2->AddChild(gr3);
+
+  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
+  item.AddChild(gr2);
+  item.AddChild(std::make_shared<ButtonItem>("btn5", "test5"));
+  ASSERT_EQ(item.GetChildren().size(), 3);
+
+  ASSERT_EQ(item.IsItemTypeExist(AbstractItem::Text), true);
+  ASSERT_EQ(item.IsItemTypeExist(AbstractItem::Image), false);
+}
+
+TEST_F(GroupItemTest, FindByIDNullItemReturn) {
+  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
+      .WillRepeatedly(Invoke(__fake_app_get_name));
+
+  GroupItem item("GROUP1");
+  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
+  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
+  ASSERT_EQ(item.GetChildren().size(), 2);
+
+  AbstractItem& child = item.FindByID("not_exist_button");
+  ASSERT_EQ(child.GetType(), AbstractItem::NullObject);
+}
+
+TEST_F(GroupItemTest, GetAppLabel) {
+  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
+      .WillRepeatedly(Invoke(__fake_app_get_name));
+
+  GroupItem item("GROUP1");
+  string app_label = item.GetAppLabel();
+
+  ASSERT_EQ(app_label, "unittest_appname");
+}
+
+TEST_F(GroupItemTest, SetAppLabel) {
+  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
+      .WillRepeatedly(Invoke(__fake_app_get_name));
+
+  GroupItem item("GROUP1");
+  item.SetAppLabel("test");
+  string app_label = item.GetAppLabel();
+
+  ASSERT_EQ(app_label, "test");
+}
+
+TEST_F(GroupItemTest, SetDirection) {
+  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
+      .WillRepeatedly(Invoke(__fake_app_get_name));
+
+  GroupItem item("GROUP1");
+  item.SetDirection(true);
+
+  ASSERT_TRUE(item.IsVertical());
+}
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_icon_item.cc b/tests/noti_ex_unittest/src/test_noti_ex_icon_item.cc
new file mode 100644 (file)
index 0000000..0ca4010
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+#include "mock/app_common_mock.hh"
+#include "mock/smack_mock.hh"
+#include "mock/test_fixture.hh"
+#include "notification-ex/icon_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+namespace {
+class Mocks :
+    virtual public ::testing::NiceMock<SmackMock>,
+    virtual public ::testing::NiceMock<AppCommonMock> {};
+} // namespace
+
+class IconItemTest : public TestFixture {
+ public:
+  IconItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  IconItem* item;
+  std::string id = "icon_id";
+  virtual void SetUp() {
+    item = new IconItem(id, "icon_path");
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(IconItemTest, create) {
+  EXPECT_NE(IconItemTest::item, nullptr);
+}
+
+TEST_F(IconItemTest, FindByID) {
+  AbstractItem& child = IconItemTest::item->FindByID(IconItemTest::id);
+  IconItem& icon = static_cast<IconItem&>(child);
+  ASSERT_EQ(icon.GetImagePath(), "icon_path");
+}
+
+TEST_F(IconItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = IconItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), IconItem::NullObject);
+}
+
+TEST_F(IconItemTest, SerializeDeserialize) {
+  Bundle b = IconItemTest::item->Serialize();
+
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(IconItemTest::item->GetType(), gen_item->GetType());
+
+  auto gen_icon = std::static_pointer_cast<IconItem>(gen_item);
+  ASSERT_EQ(IconItemTest::item->GetImagePath(), gen_icon->GetImagePath());
+}
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_image_item.cc b/tests/noti_ex_unittest/src/test_noti_ex_image_item.cc
new file mode 100644 (file)
index 0000000..0aeb77e
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+#include "mock/smack_mock.hh"
+#include "mock/app_common_mock.hh"
+#include "mock/test_fixture.hh"
+#include "notification-ex/image_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+namespace {
+class Mocks :
+    virtual public ::testing::NiceMock<SmackMock>,
+    virtual public ::testing::NiceMock<AppCommonMock> {};
+} // namespace
+
+class ImageItemTest : public TestFixture {
+ public:
+  ImageItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  ImageItem* item;
+  std::string id = "image_id";
+  std::string imagePath = "image_path";
+  virtual void SetUp() {
+    item = new ImageItem(id, imagePath);
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(ImageItemTest, create) {
+  EXPECT_NE(ImageItemTest::item, nullptr);
+}
+
+TEST_F(ImageItemTest, FindByID) {
+  AbstractItem& child = ImageItemTest::item->FindByID(ImageItemTest::id);
+  ImageItem& image = static_cast<ImageItem&>(child);
+  ASSERT_EQ(image.GetImagePath(), ImageItemTest::imagePath);
+}
+
+TEST_F(ImageItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = ImageItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), ImageItem::NullObject);
+}
+
+TEST_F(ImageItemTest, SerializeDeserialize) {
+  Bundle b = ImageItemTest::item->Serialize();
+
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(ImageItemTest::item->GetType(), gen_item->GetType());
+
+  auto gen_image = std::static_pointer_cast<ImageItem>(gen_item);
+  ASSERT_EQ(ImageItemTest::item->GetImagePath(), gen_image->GetImagePath());
+}
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_input_selector_item.cc b/tests/noti_ex_unittest/src/test_noti_ex_input_selector_item.cc
new file mode 100644 (file)
index 0000000..e8b2669
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+#include "mock/app_common_mock.hh"
+#include "mock/test_fixture.hh"
+#include "notification-ex/input_selector_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+using namespace std;
+
+namespace {
+class Mocks :
+    virtual public ::testing::NiceMock<AppCommonMock> {};
+} // namespace
+
+class InputSelectorItemTest : public TestFixture {
+ public:
+  InputSelectorItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
+ protected:
+  void SetUp() override {}
+  void TearDown() override {}
+};
+
+TEST_F(InputSelectorItemTest, SerializeDeserialize) {
+  InputSelectorItem item;
+  list<string> contents;
+  contents.push_back("AA");
+  contents.push_back("BB");
+  contents.push_back("CC");
+  item.SetContents(contents);
+
+  Bundle b = item.Serialize();
+  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(gen_item->GetType(), item.GetType());
+
+  auto gen_input = static_pointer_cast<InputSelectorItem>(gen_item);
+
+  list<string> l1 = item.GetContents();
+  list<string> l2 = gen_input->GetContents();
+  list<string>::iterator it1 = l1.begin();
+  list<string>::iterator it2 = l2.begin();
+  while(it1 != l1.end() && it2 != l2.end()) {
+    ASSERT_EQ((*it1), (*it2));
+    it1++;
+    it2++;
+  }
+}
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_progress_item.cc b/tests/noti_ex_unittest/src/test_noti_ex_progress_item.cc
new file mode 100644 (file)
index 0000000..0328ef3
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+#include "mock/app_common_mock.hh"
+#include "mock/test_fixture.hh"
+#include "notification-ex/progress_item.h"
+#include "notification-ex/item_inflator.h"
+
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+using namespace std;
+
+namespace {
+class Mocks :
+    virtual public ::testing::NiceMock<AppCommonMock> {};
+} // namespace
+
+class ProgressItemTest : public TestFixture {
+ public:
+  ProgressItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
+ protected:
+  void SetUp() override {}
+  void TearDown() override {}
+};
+
+TEST_F(ProgressItemTest, SerializeDeserializeGetTitle) {
+  ProgressItem item(1.0, 10.0, 100.0);
+  item.SetDefaultUnit("byte");
+  Bundle b = item.Serialize();
+  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+
+  auto gen_progress = std::static_pointer_cast<ProgressItem>(gen_item);
+  ASSERT_EQ(item.GetCurrent(), gen_progress->GetCurrent());
+  ASSERT_EQ(item.GetMin(), gen_progress->GetMin());
+  ASSERT_EQ(item.GetMax(), gen_progress->GetMax());
+  ASSERT_EQ(item.GetType(), gen_progress->GetType());
+  ASSERT_EQ(item.GetDefaultUnit(), gen_progress->GetDefaultUnit());
+
+  ASSERT_EQ(gen_progress->GetMin(), 1.0);
+  ASSERT_EQ(gen_progress->GetCurrent(), 10.0);
+  ASSERT_EQ(gen_progress->GetMax(), 100.0);
+  ASSERT_EQ(gen_progress->GetProgressType(), ProgressItem::Type::Default);
+  ASSERT_EQ(gen_progress->GetDefaultUnit(), "byte");
+}
+
+TEST_F(ProgressItemTest, SetGetProgressType) {
+  ProgressItem item(1.0, 10.0, 100.0);
+
+  ASSERT_EQ(item.GetProgressType(), ProgressItem::Type::Default);
+
+  item.SetProgressType(ProgressItem::Type::Pending);
+  ASSERT_EQ(item.GetProgressType(), ProgressItem::Type::Pending);
+}
+
+TEST_F(ProgressItemTest, SetGetUnit) {
+  ProgressItem item(1.0, 10.0, 100.0);
+  item.SetDefaultUnit("byte");
+
+  ASSERT_EQ(item.GetDefaultUnit(), "byte");
+}
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_shared_file.cc b/tests/noti_ex_unittest/src/test_noti_ex_shared_file.cc
new file mode 100644 (file)
index 0000000..2fe9684
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+#include "mock/app_common_mock.hh"
+#include "mock/test_fixture.hh"
+#include "notification-ex/shared_file.h"
+#include "notification-ex/image_item.h"
+#include "notification-ex/common.h"
+
+#include "mock/glib_mock.hh"
+#include "mock/smack_mock.hh"
+#include "mock/tzplatform_config_mock.hh"
+#include "mock/security_manager_mock.hh"
+#include "mock/aul_mock.hh"
+
+
+using namespace notification;
+using namespace notification::item;
+using namespace std;
+
+using ::testing::_;
+using ::testing::Invoke;
+
+namespace {
+
+// smack
+ssize_t __fake_smack_new_label_from_path(const char* path, const char* xattr,
+    int follow, char** label) {
+  *label = strdup("User::Pkg::unittest::RO");
+  return 1;
+}
+
+// tzplatform
+const char* __fake_tzplatform_getenv(tzplatform_variable id) {
+  return "/opt/usr/home/owner/apps_rw";
+}
+
+// security-manager
+int __fake_security_manager_private_sharing_req_new(private_sharing_req** pp_req) {
+  return 0;
+}
+
+int __fake_security_manager_private_sharing_req_add_paths(
+    private_sharing_req* p_req, const char** pp_paths, size_t count) {
+  return 0;
+}
+
+int __fake_security_manager_private_sharing_req_set_target_appid(
+    private_sharing_req* p_req, const char* appid) {
+  return 0;
+}
+
+int __fake_security_manager_private_sharing_apply(const private_sharing_req* p_req) {
+  return 0;
+}
+
+int __fake_security_manager_private_sharing_drop(const private_sharing_req* p_req) {
+  return 0;
+}
+
+class Mocks :
+    virtual public ::testing::NiceMock<GlibMock>,
+    virtual public ::testing::NiceMock<SmackMock>,
+    virtual public ::testing::NiceMock<TzplatformConfigMock>,
+    virtual public ::testing::NiceMock<SecurityManagerMock> {};
+} // namespace
+
+class SharedFileTest : public TestFixture {
+ public:
+  SharedFileTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  std::shared_ptr<ImageItem> item;
+  std::string id = "image_id";
+  std::string image_path = "res/image.png";
+
+  SharedFile* shared_file;
+
+  virtual void SetUp() {
+    item = make_shared<ImageItem>(id, image_path);
+    shared_file = new SharedFile();
+    item->SetSenderAppId("notification-ex-unittests");
+  }
+
+  virtual void TearDown() {
+  }
+};
+
+TEST_F(SharedFileTest, IsPrivatePath) {
+  EXPECT_CALL(GetMock<SmackMock>(), smack_new_label_from_path(_, _, _, _))
+      .WillRepeatedly(Invoke(__fake_smack_new_label_from_path));
+
+  ASSERT_TRUE(shared_file->IsPrivatePath(SharedFileTest::image_path));
+}
+
+TEST_F(SharedFileTest, GetDataPath) {
+  EXPECT_CALL(GetMock<TzplatformConfigMock>(), tzplatform_getenv(_))
+      .WillRepeatedly(Invoke(__fake_tzplatform_getenv));
+
+  ASSERT_EQ(shared_file->GetDataPath(item->GetSenderAppId(), SharedFileTest::image_path),
+    "/opt/usr/home/owner/apps_rw/notification-ex-unittests/data/.notification_ex/image.png");
+}
+
+TEST_F(SharedFileTest, SetPrivateSharing) {
+  EXPECT_CALL(GetMock<SecurityManagerMock>(),
+      security_manager_private_sharing_req_new(_))
+      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_req_new));
+  EXPECT_CALL(GetMock<SecurityManagerMock>(),
+      security_manager_private_sharing_req_add_paths(_, _, _))
+      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_req_add_paths));
+  EXPECT_CALL(GetMock<SecurityManagerMock>(),
+      security_manager_private_sharing_req_set_target_appid(_, _))
+      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_req_set_target_appid));
+  EXPECT_CALL(GetMock<SecurityManagerMock>(),
+      security_manager_private_sharing_apply(_))
+      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_apply));
+  EXPECT_CALL(GetMock<SecurityManagerMock>(),
+      security_manager_private_sharing_drop(_))
+      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_drop));
+
+  list<shared_ptr<item::AbstractItem>> notiList;
+  notiList.push_back(SharedFileTest::item);
+
+  std::multimap<std::string, std::string> map_;
+  map_.insert(make_pair("tizen.org/receiver/popup", "test_appid"));
+
+  ASSERT_EQ(shared_file->SetPrivateSharing(notiList, map_), ERROR_NONE);
+}
+
+TEST_F(SharedFileTest, RemovePrivateSharing) {
+  EXPECT_CALL(GetMock<SecurityManagerMock>(),
+      security_manager_private_sharing_req_new(_))
+      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_req_new));
+  EXPECT_CALL(GetMock<SecurityManagerMock>(),
+      security_manager_private_sharing_req_add_paths(_, _, _))
+      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_req_add_paths));
+  EXPECT_CALL(GetMock<SecurityManagerMock>(),
+      security_manager_private_sharing_req_set_target_appid(_, _))
+      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_req_set_target_appid));
+  EXPECT_CALL(GetMock<SecurityManagerMock>(),
+      security_manager_private_sharing_apply(_))
+      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_apply));
+  EXPECT_CALL(GetMock<SecurityManagerMock>(),
+      security_manager_private_sharing_drop(_))
+      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_drop));
+
+  list<shared_ptr<item::AbstractItem>> notiList;
+  notiList.push_back(SharedFileTest::item);
+
+  std::multimap<std::string, std::string> map_;
+  map_.insert(make_pair("tizen.org/receiver/popup", "test_appid"));
+
+  ASSERT_EQ(shared_file->RemovePrivateSharing(notiList, map_), ERROR_NONE);
+}
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_text_item.cc b/tests/noti_ex_unittest/src/test_noti_ex_text_item.cc
new file mode 100644 (file)
index 0000000..744a230
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+#include "mock/app_common_mock.hh"
+#include "mock/test_fixture.hh"
+#include "notification-ex/text_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+namespace {
+class Mocks :
+    virtual public ::testing::NiceMock<AppCommonMock> {};
+} // namespace
+
+class TexttItemTest : public TestFixture {
+ public:
+  TexttItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  virtual void SetUp() {
+  }
+  virtual void TearDown() {
+  }
+};
+
+TEST_F(TexttItemTest, FindByID) {
+  TextItem item("text_id", "contents", "hyperlink");
+
+  AbstractItem& child = item.FindByID("text_id");
+  TextItem& btn = static_cast<TextItem&>(child);
+  ASSERT_EQ(btn.GetContents(), "contents");
+}
+
+TEST_F(TexttItemTest, FindByIDNullItemReturn) {
+  TextItem item("text_id", "contents", "hyperlink");
+
+  AbstractItem& child = item.FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), TextItem::NullObject);
+}
+
+TEST_F(TexttItemTest, SerializeDeserializeGetContents) {
+  TextItem item("text_id", "contents");
+  Bundle b = item.Serialize();
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(gen_item->GetType(), item.GetType());
+
+  auto gen_text = std::static_pointer_cast<TextItem>(gen_item);
+  ASSERT_EQ(item.GetContents(), gen_text->GetContents());
+}
+
+TEST_F(TexttItemTest, SetContentsGetContents) {
+  TextItem item("text_id", "contents");
+  ASSERT_EQ(item.GetContents(), "contents");
+
+  item.SetContents("changed");
+  ASSERT_EQ(item.GetContents(), "changed");
+}
+
+TEST_F(TexttItemTest, GetHyperLink) {
+  TextItem item("text_id", "contents");
+  ASSERT_TRUE(item.GetHyperLink().empty());
+
+  TextItem item2("text_id", "contents", "hyperlink2");
+  ASSERT_EQ(item2.GetHyperLink(), "hyperlink2");
+}
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_time_item.cc b/tests/noti_ex_unittest/src/test_noti_ex_time_item.cc
new file mode 100644 (file)
index 0000000..94edabe
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+#include "mock/app_common_mock.hh"
+#include "mock/test_fixture.hh"
+#include "notification-ex/time_item.h"
+#include "notification-ex/item_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+namespace {
+class Mocks :
+    virtual public ::testing::NiceMock<AppCommonMock> {};
+} // namespace
+
+class TimeItemTest : public TestFixture {
+ public:
+  TimeItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  TimeItem* item;
+  time_t current_time;
+  std::string id = "time_id";
+  virtual void SetUp() {
+    time(&current_time);
+    item = new TimeItem(id, current_time);
+  }
+  virtual void TearDown() {
+    delete item;
+  }
+};
+
+TEST_F(TimeItemTest, create) {
+  EXPECT_NE(TimeItemTest::item, nullptr);
+}
+
+TEST_F(TimeItemTest, FindByID) {
+  AbstractItem& child = TimeItemTest::item->FindByID(TimeItemTest::id);
+  TimeItem& time_ = static_cast<TimeItem&>(child);
+  ASSERT_EQ(time_.GetTime(), TimeItemTest::current_time);
+}
+
+TEST_F(TimeItemTest, FindByIDNullItemReturn) {
+  AbstractItem& child = TimeItemTest::item->FindByID("not_existed_item");
+  ASSERT_EQ(child.GetType(), TimeItem::NullObject);
+}
+
+TEST_F(TimeItemTest, SerializeDeserialize) {
+  Bundle b = TimeItemTest::item->Serialize();
+
+  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
+  ASSERT_EQ(TimeItemTest::item->GetType(), gen_item->GetType());
+
+  auto gen_time = std::static_pointer_cast<TimeItem>(gen_item);
+  ASSERT_EQ(item->GetTime(), gen_time->GetTime());
+}
diff --git a/tests/noti_ex_unittest/src/test_noti_ex_visibility_action.cc b/tests/noti_ex_unittest/src/test_noti_ex_visibility_action.cc
new file mode 100644 (file)
index 0000000..d56e26d
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2019 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 <string>
+
+#include <gtest/gtest.h>
+#include <gmock/gmock.h>
+
+#include "mock/app_common_mock.hh"
+#include "mock/test_fixture.hh"
+#include "notification-ex/visibility_action.h"
+#include "notification-ex/action_inflator.h"
+
+using namespace tizen_base;
+using namespace notification;
+using namespace notification::item;
+
+namespace {
+class Mocks :
+    virtual public ::testing::NiceMock<AppCommonMock> {};
+} // namespace
+
+class VisibilityActionTest : public TestFixture {
+ public:
+  VisibilityActionTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  VisibilityAction* visibility;
+  std::string id = "visibility_id";
+  std::string extra = "visibility_extra";
+  bool visible = true;
+
+  virtual void SetUp() {
+    visibility = new VisibilityAction(extra);
+    visibility->SetVisibility("visibility_id", visible);
+  }
+  virtual void TearDown() {
+    delete visibility;
+  }
+};
+
+TEST_F(VisibilityActionTest, create) {
+  EXPECT_NE(VisibilityActionTest::visibility, nullptr);
+}
+
+TEST_F(VisibilityActionTest, IsLocal) {
+  ASSERT_EQ(VisibilityActionTest::visibility->IsLocal(), 1);
+}
+
+TEST_F(VisibilityActionTest, GetExtra) {
+  ASSERT_EQ(VisibilityActionTest::visibility->GetExtra(),
+    VisibilityActionTest::extra);
+}
+
+TEST_F(VisibilityActionTest, SerializeDeserialize) {
+  Bundle b = VisibilityActionTest::visibility->Serialize();
+
+  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
+  ASSERT_EQ(gen_action->GetType(), AbstractAction::Visibility);
+
+  auto gen_visibility_action =
+    std::static_pointer_cast<VisibilityAction>(gen_action);
+  EXPECT_NE(gen_visibility_action, nullptr);
+  ASSERT_EQ(gen_visibility_action->IsLocal(), true);
+  ASSERT_EQ(gen_visibility_action->GetExtra(), VisibilityActionTest::extra);
+}
+
+TEST_F(VisibilityActionTest, SetVisibility) {
+  VisibilityActionTest::visibility->SetVisibility("test_id", true);
+  Bundle b = VisibilityActionTest::visibility->Serialize();
+
+  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
+  ASSERT_EQ(gen_action->GetType(), AbstractAction::Visibility);
+
+  auto gen_visibility_action =
+    std::static_pointer_cast<VisibilityAction>(gen_action);
+  EXPECT_NE(gen_visibility_action, nullptr);
+  ASSERT_EQ(gen_visibility_action->IsLocal(), true);
+  ASSERT_EQ(gen_visibility_action->GetExtra(), VisibilityActionTest::extra);
+}
diff --git a/tests/noti_unittest/CMakeLists.txt b/tests/noti_unittest/CMakeLists.txt
new file mode 100644 (file)
index 0000000..79b786f
--- /dev/null
@@ -0,0 +1,57 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
+PROJECT(notification-unittests C CXX)
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(notification-unittests REQUIRED
+    dlog
+    dbus-1
+    gmock
+    capi-appfw-app-control
+    glib-2.0
+    gio-2.0
+    gio-unix-2.0
+    aul
+    security-manager
+    libtzplatform-config
+)
+
+FOREACH(flag ${notification-unittests_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall")
+
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
+SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
+
+
+SET(INIT-SRCS ${CMAKE_SOURCE_DIR}/notification/src/notification_init.c)
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/notification/src)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/notification/include)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../mock)
+
+
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES)
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../mock MOCK_SOURCES)
+AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/notification/src NOTIFICATION_SOURCES)
+
+LIST(REMOVE_ITEM NOTIFICATION_SOURCES ${INIT-SRCS})
+
+ADD_EXECUTABLE(${PROJECT_NAME}
+    ${SOURCES}
+    ${NOTIFICATION_SOURCES}
+    ${MOCK_SOURCES}
+)
+
+SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${EXTRA_CFLAGS}")
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${notification-unittests_LDFLAGS}
+    ${pkgs_LDFLAGS}
+    ${pkgs_LIBRARIES}
+    gmock
+    notification
+)
+
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
diff --git a/tests/noti_unittest/src/test_main.cc b/tests/noti_unittest/src/test_main.cc
new file mode 100644 (file)
index 0000000..ad7ec6c
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2019 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 <gmock/gmock.h>
+
+int main(int argc, char** argv) {
+  int ret = -1;
+
+  try {
+    testing::InitGoogleTest(&argc, argv);
+  } catch(...) {
+    std::cout << "Exception occurred" << std::endl;
+  }
+
+  try {
+    ret = RUN_ALL_TESTS();
+  } catch (const ::testing::internal::GoogleTestFailureException& e) {
+    ret = -1;
+    std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl;
+  }
+
+  return ret;
+}
diff --git a/tests/noti_unittest/src/test_notification.cc b/tests/noti_unittest/src/test_notification.cc
new file mode 100644 (file)
index 0000000..8058cfd
--- /dev/null
@@ -0,0 +1,403 @@
+/*
+ * 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 <gmock/gmock.h>
+
+#include "mock/test_fixture.hh"
+#include "mock/aul_mock.hh"
+#include "mock/package_manager_mock.hh"
+#include "mock/smack_mock.hh"
+#include "mock/tzplatform_config_mock.hh"
+#include "mock/glib_mock.hh"
+
+#include "notification/include/notification.h"
+#include "notification/include/notification_ipc.h"
+
+namespace {
+
+typedef struct {
+  const char *package;
+  char *locale;
+  pkgmgrinfo_app_component app_component;
+  application_x *app_info;
+} pkgmgr_appinfo_x;
+
+typedef void *pkgmgrinfo_pkginfo_h;
+
+struct package_info_s {
+  char *package;
+  pkgmgrinfo_pkginfo_h pkgmgr_pkginfo;
+};
+
+GVariant *noti_body = nullptr;
+notification_h cloned_noti = nullptr;
+
+int __fake_aul_app_get_appid_bypid(int pid, char* appid, int len) {
+  snprintf(appid, len, "%s", "org.tizen.testappid");
+  return AUL_R_OK;
+}
+
+int __fake_aul_app_get_pkgid_bypid(int pid, char* pkgid, int len) {
+  snprintf(pkgid, len, "%s", "org.tizen.testpkgid");
+  return AUL_R_OK;
+}
+
+int __fake_package_info_create(const char* package, package_info_h* package_info) {
+  *package_info  = (package_info_h)calloc(1, sizeof(struct package_info_s));
+
+  return PACKAGE_MANAGER_ERROR_NONE;
+}
+
+int __fake_package_info_get_root_path(package_info_h package_info, char** path) {
+  *path = strdup("testrootpath");
+
+  return PACKAGE_MANAGER_ERROR_NONE;
+}
+
+int __fake_pkgmgrinfo_appinfo_get_usr_appinfo(const char* appid, uid_t uid,
+    pkgmgrinfo_appinfo_h *handle) {
+  *handle = (pkgmgrinfo_appinfo_h*)calloc(1, sizeof(pkgmgr_appinfo_x));
+
+  return PMINFO_R_OK;
+}
+
+int __fake_pkgmgrinfo_appinfo_get_label(pkgmgrinfo_appinfo_h handle, char** label) {
+  *label = strdup("testlabel");
+
+  return PMINFO_R_OK;
+}
+
+ssize_t __fake_smack_new_label_from_path(const char* path, const char* xattr,
+    int follow, char** label) {
+  *label = strdup("User::Pkg::unittest::RO");
+  return 1;
+}
+
+const char* __fake_tzplatform_getenv(tzplatform_variable id) {
+  return "/opt/usr/home/owner/apps_rw";
+}
+
+GDBusConnection* __fake_g_bus_get_sync(GBusType type, GCancellable* cancellable, GError** error) {
+  GDBusConnection* conn = reinterpret_cast<GDBusConnection*>(calloc(1, 4));
+
+  return conn;
+}
+
+GDBusMessage* __fake_g_dbus_connection_send_message_with_reply_sync(
+    GDBusConnection* conn, GDBusMessage* msg, GDBusSendMessageFlags flags,
+    gint timeout, volatile guint32* out_serial, GCancellable* cancellable,
+    GError** error) {
+  GDBusMessage* ret_msg = static_cast<GDBusMessage*>(g_object_new(G_TYPE_OBJECT, NULL));
+
+  return ret_msg;
+}
+
+GVariant* __fake_g_dbus_message_get_body(GDBusMessage* arg0) {
+  GVariant* ret_body = g_variant_new("(v)", noti_body);
+
+  return ret_body;
+}
+
+GDBusMessage* __fake_g_dbus_message_new_method_call(const gchar* arg0,
+    const gchar* arg1, const gchar* arg2, const gchar* arg3) {
+  GDBusMessage* ret_msg = static_cast<GDBusMessage*>(g_object_new(G_TYPE_OBJECT, NULL));
+
+  return ret_msg;
+}
+
+class Mocks :
+    virtual public ::testing::NiceMock<AulMock>,
+    virtual public ::testing::NiceMock<SmackMock>,
+    virtual public ::testing::NiceMock<TzplatformConfigMock>,
+    virtual public ::testing::NiceMock<GlibMock>,
+    virtual public ::testing::NiceMock<PackageManagerMock> {};
+} // namespace
+
+using ::testing::_;
+using ::testing::Invoke;
+
+class NotificationTest : public TestFixture {
+ public:
+  NotificationTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  virtual void SetUp() {
+  }
+  virtual void TearDown() {
+  }
+};
+
+TEST_F(NotificationTest, notification_test) {
+  EXPECT_CALL(GetMock<AulMock>(), aul_app_get_appid_bypid(_, _, _))
+      .WillRepeatedly(Invoke(__fake_aul_app_get_appid_bypid));
+
+  EXPECT_CALL(GetMock<AulMock>(), aul_app_get_pkgid_bypid(_, _, _))
+      .WillOnce(Invoke(__fake_aul_app_get_pkgid_bypid));
+
+  EXPECT_CALL(GetMock<PackageManagerMock>(), package_info_create(_, _))
+      .WillOnce(Invoke(__fake_package_info_create));
+
+  EXPECT_CALL(GetMock<PackageManagerMock>(), package_info_get_root_path(_, _))
+      .WillOnce(Invoke(__fake_package_info_get_root_path));
+
+  EXPECT_CALL(GetMock<PackageManagerMock>(), pkgmgrinfo_appinfo_get_usr_appinfo(_, _, _))
+      .WillOnce(Invoke(__fake_pkgmgrinfo_appinfo_get_usr_appinfo));
+
+  EXPECT_CALL(GetMock<PackageManagerMock>(), pkgmgrinfo_appinfo_get_label(_, _))
+      .WillOnce(Invoke(__fake_pkgmgrinfo_appinfo_get_label));
+
+  EXPECT_CALL(GetMock<SmackMock>(), smack_new_label_from_path(_, _, _, _))
+      .WillOnce(Invoke(__fake_smack_new_label_from_path));
+
+  EXPECT_CALL(GetMock<TzplatformConfigMock>(), tzplatform_getenv(_))
+      .WillOnce(Invoke(__fake_tzplatform_getenv));
+
+  EXPECT_CALL(GetMock<GlibMock>(), g_bus_get_sync(_, _, _))
+      .WillRepeatedly(Invoke(__fake_g_bus_get_sync));
+
+  EXPECT_CALL(GetMock<GlibMock>(), g_dbus_message_new_method_call(_, _, _, _))
+      .WillRepeatedly(Invoke(__fake_g_dbus_message_new_method_call));
+
+  EXPECT_CALL(GetMock<GlibMock>(), g_dbus_connection_send_message_with_reply_sync(_, _, _, _, _, _, _))
+      .WillRepeatedly(Invoke(__fake_g_dbus_connection_send_message_with_reply_sync));
+
+  EXPECT_CALL(GetMock<GlibMock>(), g_dbus_message_get_body(_))
+      .WillRepeatedly(Invoke(__fake_g_dbus_message_get_body));
+
+  notification_h noti = nullptr;
+  int ret;
+
+  noti = notification_create(NOTIFICATION_TYPE_NOTI);
+  EXPECT_NE(noti, nullptr);
+
+  ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON,
+    "/opt/usr/home/owner/apps_rw/org.tizen.testpkgid/data/.notification/image.png");
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  char* image_path = NULL;
+  ret = notification_get_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, &image_path);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+  ASSERT_STREQ(image_path, "/opt/usr/home/owner/apps_rw/org.tizen.testpkgid/data/.notification/image.png");
+
+  ret = notification_set_time(noti, 0xFFFFFFF);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  time_t ret_time = 0;
+
+  ret = notification_get_time(noti, &ret_time);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+  EXPECT_NE(ret_time, 0);
+
+  ret_time = 0;
+
+  ret = notification_get_insert_time(noti, &ret_time);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, "testtitle", NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  char* title_text = nullptr;
+  ret = notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, &title_text);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+  ASSERT_STREQ(title_text, "testtitle");
+
+  ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, "%f %d %s %d", NULL,
+      NOTIFICATION_VARIABLE_TYPE_COUNT, NOTIFICATION_COUNT_POS_LEFT,
+      NOTIFICATION_VARIABLE_TYPE_DOUBLE, 0.0,
+      NOTIFICATION_VARIABLE_TYPE_COUNT, NOTIFICATION_COUNT_POS_IN,
+      NOTIFICATION_VARIABLE_TYPE_STRING, "Content",
+      NOTIFICATION_VARIABLE_TYPE_INT, 0,
+      NOTIFICATION_VARIABLE_TYPE_COUNT, NOTIFICATION_COUNT_POS_RIGHT,
+      NOTIFICATION_VARIABLE_TYPE_NONE);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  char* content_text = nullptr;
+  ret = notification_get_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, &content_text);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+  EXPECT_NE(content_text, nullptr);
+
+  ret = notification_set_time_to_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, time(NULL));
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret_time = 0;
+  ret = notification_get_time_from_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, &ret_time);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_set_sound(noti, NOTIFICATION_SOUND_TYPE_DEFAULT, "soundpath");
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  notification_sound_type_e sound_type = NOTIFICATION_SOUND_TYPE_NONE;
+  const char* sound_path = nullptr;
+  ret = notification_get_sound(noti, &sound_type, &sound_path);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_set_vibration(noti, NOTIFICATION_VIBRATION_TYPE_DEFAULT, "vibpath");
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  notification_vibration_type_e vib_type = NOTIFICATION_VIBRATION_TYPE_NONE;
+  const char* vib_path = nullptr;
+  ret = notification_get_vibration(noti, &vib_type, &vib_path);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_set_led(noti, NOTIFICATION_LED_OP_ON_CUSTOM_COLOR, 256);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  notification_led_op_e op = NOTIFICATION_LED_OP_OFF;
+  int led_argb = 0;
+  ret = notification_get_led(noti, &op, &led_argb);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_set_led_time_period(noti, 100, 200);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  int on_ms = 0;
+  int off_ms = 0;
+  ret = notification_get_led_time_period(noti, &on_ms, &off_ms);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  app_control_h app_control;
+  app_control_create(&app_control);
+  app_control_set_app_id(app_control, "org.tizen.testapp");
+  ret = notification_set_launch_option(noti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, app_control);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  app_control_destroy(app_control);
+
+  ret = notification_get_launch_option(noti, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, (void *)&app_control);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  app_control_destroy(app_control);
+
+  app_control_create(&app_control);
+  app_control_set_app_id(app_control, "org.tizen.testapp");
+  ret = notification_set_event_handler(noti, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, app_control);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  app_control_destroy(app_control);
+
+  ret = notification_get_event_handler(noti, NOTIFICATION_EVENT_TYPE_CLICK_ON_BUTTON_1, &app_control);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  app_control_destroy(app_control);
+
+  ret = notification_set_property(noti, NOTIFICATION_PROP_PERMANENT_DISPLAY);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  int property;
+  ret = notification_get_property(noti, &property);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_set_display_applist(noti, NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  int ret_applist;
+  ret = notification_get_display_applist(noti, &ret_applist);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_set_size(noti, 3.3);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  double ret_size;
+  ret = notification_get_size(noti, &ret_size);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_set_progress(noti, 30.);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  double percentage;
+  ret = notification_get_progress(noti, &percentage);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_set_layout(noti, NOTIFICATION_LY_NOTI_EVENT_SINGLE);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  notification_ly_type_e ret_layout;
+  ret = notification_get_layout(noti, &ret_layout);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  notification_type_e ret_type;
+  ret = notification_get_type(noti, &ret_type);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_set_tag(noti, "test_tag");
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  const char* ret_tag;
+  ret = notification_get_tag(noti, &ret_tag);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  char* pkgname;
+  ret = notification_get_pkgname(noti, &pkgname);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_add_button(noti, NOTIFICATION_BUTTON_1);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_remove_button(noti, NOTIFICATION_BUTTON_1);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_set_auto_remove(noti, true);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  bool auto_remove;
+  ret = notification_get_auto_remove(noti, &auto_remove);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_set_text_input(noti, 1000);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_set_extension_image_size(noti, 20);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  int ret_height;
+  ret = notification_get_extension_image_size(noti, &ret_height);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_clone(noti, &cloned_noti);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_free(cloned_noti);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  noti_body = notification_ipc_make_gvariant_from_noti(noti, false);
+
+  notification_block_state_e ret_state;
+  ret = notification_get_noti_block_state(&ret_state);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_save_as_template(noti, "test_template");
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  notification_h template_noti = nullptr;
+  template_noti = notification_create_from_template("test_template");
+  EXPECT_NE(template_noti, nullptr);
+
+  ret = notification_update(noti);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_post(noti);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  notification_h tag_noti;
+  tag_noti = notification_load_by_tag("test_tag");
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+  EXPECT_NE(tag_noti, nullptr);
+
+  ret = notification_delete(noti);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_delete_all(NOTIFICATION_TYPE_NOTI);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
diff --git a/tests/noti_unittest/src/test_notification_db.cc b/tests/noti_unittest/src/test_notification_db.cc
new file mode 100644 (file)
index 0000000..c1bd7c2
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * 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 <gmock/gmock.h>
+#include <bundle.h>
+
+#include "mock/test_fixture.hh"
+#include "mock/glib_mock.hh"
+#include "mock/sqlite_mock.hh"
+
+#include "notification/include/notification.h"
+#include "notification/include/notification_db.h"
+
+namespace {
+
+int __fake_sqlite3_open_v2(const char* arg0, sqlite3** arg1, int arg2, const char* arg3) {
+  char** table = (char** )calloc(10, sizeof(char*));
+  *arg1 = (sqlite3*) table;
+
+  return SQLITE_OK;
+}
+
+const unsigned char* __fake_sqlite3_column_text(sqlite3_stmt* arg0, int arg1) {
+  const unsigned char* column_text = (const unsigned char*)strdup("testcolumn");
+
+  return column_text;
+}
+
+const unsigned char* __fake_sqlite3_column_text_bundle(sqlite3_stmt* arg0, int arg1) {
+  bundle_raw *raw = nullptr;
+  int len = 0;
+  bundle* b = bundle_create();
+  bundle_add_str(b, "testkey", "testval");
+  bundle_encode(b, &raw, &len);
+
+  const unsigned char* column_text = (const unsigned char*)raw;
+
+  return column_text;
+}
+
+class Mocks :
+    virtual public ::testing::NiceMock<GlibMock>,
+    virtual public ::testing::NiceMock<SqliteMock> {};
+} // namespace
+
+using ::testing::_;
+using ::testing::Invoke;
+using ::testing::Return;
+
+class NotificationDBTest : public TestFixture {
+ public:
+  NotificationDBTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  virtual void SetUp() {
+  }
+  virtual void TearDown() {
+  }
+};
+
+TEST_F(NotificationDBTest, notification_db_test) {
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_open_v2(_, _, _, _))
+    .WillRepeatedly(Invoke(__fake_sqlite3_open_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_close(_))
+    .WillOnce(Return(SQLITE_OK));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_prepare_v2(_, _, _, _, _))
+    .WillOnce(Return(SQLITE_OK));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_step(_))
+    .WillOnce(Return(SQLITE_OK));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_changes(_))
+    .WillOnce(Return(3));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_column_text(_, _))
+    .WillOnce(Invoke(__fake_sqlite3_column_text))
+    .WillOnce(Invoke(__fake_sqlite3_column_text_bundle));
+
+  EXPECT_CALL(GetMock<GlibMock>(), access(_, _))
+    .WillOnce(Return(0));
+
+  int ret;
+
+  sqlite3* db = nullptr;
+  db = notification_db_open();
+  EXPECT_NE(db, nullptr);
+
+  int num_changed = 0;
+  ret = notification_db_exec(db, "test query", &num_changed);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+  EXPECT_EQ(num_changed, 3);
+
+  char* column_text = nullptr;
+  sqlite3_stmt *stmt;
+  column_text = notification_db_column_text(stmt, 3);
+  EXPECT_STREQ(column_text, "testcolumn");
+
+  bundle* column_b = nullptr;
+  column_b = notification_db_column_bundle(stmt, 3);
+  EXPECT_NE(column_b, nullptr);
+
+  ret = notification_db_close(&db);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
diff --git a/tests/noti_unittest/src/test_notification_list.cc b/tests/noti_unittest/src/test_notification_list.cc
new file mode 100644 (file)
index 0000000..4896900
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ * 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 <gmock/gmock.h>
+
+#include <sys/types.h>
+
+#include "mock/test_fixture.hh"
+#include "mock/glib_mock.hh"
+#include "mock/aul_mock.hh"
+#include "mock/package_manager_mock.hh"
+#include "mock/socket_mock.hh"
+
+#include "notification/include/notification.h"
+#include "notification/include/notification_list.h"
+
+namespace {
+
+typedef struct {
+       const char *package;
+       char *locale;
+       pkgmgrinfo_app_component app_component;
+       application_x *app_info;
+} pkgmgr_appinfo_x;
+
+int __fake_aul_app_get_appid_bypid(int pid, char* appid, int len) {
+  snprintf(appid, len, "%s", "org.tizen.testappid");
+  return AUL_R_OK;
+}
+
+GDBusConnection* __fake_g_bus_get_sync(GBusType type, GCancellable* cancellable, GError** error) {
+  GDBusConnection* conn = reinterpret_cast<GDBusConnection*>(calloc(1, 4));
+
+  return conn;
+}
+
+GDBusMessage* __fake_g_dbus_connection_send_message_with_reply_sync(
+    GDBusConnection* conn, GDBusMessage* msg, GDBusSendMessageFlags flags,
+    gint timeout, volatile guint32* out_serial, GCancellable* cancellable,
+    GError** error) {
+  GDBusMessage* ret_msg = static_cast<GDBusMessage*>(g_object_new(G_TYPE_OBJECT, NULL));
+
+  return ret_msg;
+}
+
+GVariant* __fake_g_dbus_message_get_body(GDBusMessage* arg0) {
+  GVariant* ret_body = g_variant_new("(i)", 1);
+
+  return ret_body;
+}
+
+GDBusMessage* __fake_g_dbus_message_new_method_call(const gchar* arg0,
+    const gchar* arg1, const gchar* arg2, const gchar* arg3) {
+  GDBusMessage* ret_msg = static_cast<GDBusMessage*>(g_object_new(G_TYPE_OBJECT, NULL));
+
+  return ret_msg;
+}
+
+class Mocks :
+    virtual public ::testing::NiceMock<AulMock>,
+    virtual public ::testing::NiceMock<PackageManagerMock>,
+    virtual public ::testing::NiceMock<SocketMock>,
+    virtual public ::testing::NiceMock<GlibMock> {};
+} // namespace
+
+using ::testing::_;
+using ::testing::Invoke;
+using ::testing::Return;
+
+class NotificationListTest : public TestFixture {
+ public:
+  NotificationListTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  virtual void SetUp() {
+  }
+  virtual void TearDown() {
+  }
+};
+
+TEST_F(NotificationListTest, notification_list_test) {
+  EXPECT_CALL(GetMock<AulMock>(), aul_app_get_appid_bypid(_, _, _))
+      .WillRepeatedly(Invoke(__fake_aul_app_get_appid_bypid));
+
+  EXPECT_CALL(GetMock<GlibMock>(), g_bus_get_sync(_, _, _))
+      .WillRepeatedly(Invoke(__fake_g_bus_get_sync));
+
+  EXPECT_CALL(GetMock<GlibMock>(), g_dbus_connection_send_message_with_reply_sync(_, _, _, _, _, _, _))
+      .WillRepeatedly(Invoke(__fake_g_dbus_connection_send_message_with_reply_sync));
+
+  EXPECT_CALL(GetMock<GlibMock>(), g_dbus_message_get_body(_))
+      .WillRepeatedly(Invoke(__fake_g_dbus_message_get_body));
+
+  EXPECT_CALL(GetMock<GlibMock>(), read(_, _, _))
+      .WillRepeatedly(Return(1));
+
+  EXPECT_CALL(GetMock<SocketMock>(), getsockopt(_, _, _, _, _))
+      .WillRepeatedly(Return(0));
+
+  EXPECT_CALL(GetMock<GlibMock>(), g_dbus_message_new_method_call(_, _, _, _))
+      .WillRepeatedly(Invoke(__fake_g_dbus_message_new_method_call));
+
+  int ret;
+  notification_list_h noti_list = nullptr;
+  notification_h noti = nullptr;
+  notification_h noti2 = nullptr;
+
+  noti = notification_create(NOTIFICATION_TYPE_NOTI);
+  EXPECT_NE(noti, nullptr);
+
+  noti2 = notification_create(NOTIFICATION_TYPE_NOTI);
+  EXPECT_NE(noti2, nullptr);
+
+  noti_list = notification_list_append(noti_list, noti);
+  EXPECT_NE(noti_list, nullptr);
+
+  noti_list = notification_list_append(noti_list, noti2);
+  EXPECT_NE(noti_list, nullptr);
+
+  notification_list_h get_list = nullptr;
+  ret = notification_get_list(NOTIFICATION_TYPE_NOTI, 3, &get_list);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  notification_list_h get_list_page = nullptr;
+  ret = notification_get_list_by_page(NOTIFICATION_TYPE_NOTI, 1, 3, &get_list_page);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  notification_list_h list_head = nullptr;
+  list_head = notification_list_get_head(nullptr);
+  EXPECT_EQ(list_head, nullptr);
+
+  list_head = notification_list_get_head(noti_list);
+  EXPECT_NE(list_head, nullptr);
+
+  notification_list_h list_tail = nullptr;
+  list_tail = notification_list_get_tail(nullptr);
+  EXPECT_EQ(list_tail, nullptr);
+
+  list_tail = notification_list_get_tail(noti_list);
+  EXPECT_NE(list_tail, nullptr);
+
+  notification_list_h list_prev = nullptr;
+  list_prev = notification_list_get_prev(nullptr);
+  EXPECT_EQ(list_prev, nullptr);
+
+  list_prev = notification_list_get_prev(noti_list);
+  EXPECT_NE(list_prev, nullptr);
+
+  notification_list_h list_next = nullptr;
+  list_next = notification_list_get_next(nullptr);
+  EXPECT_EQ(list_next, nullptr);
+
+  list_next = notification_list_get_next(noti_list);
+  EXPECT_NE(list_prev, nullptr);
+
+  notification_h noti_data = nullptr;
+  noti_data = notification_list_get_data(nullptr);
+  EXPECT_EQ(noti_data, nullptr);
+
+  noti_data = notification_list_get_data(noti_list);
+  EXPECT_NE(noti_data, nullptr);
+
+  int cnt = 0;
+  cnt = notification_list_get_count(nullptr);
+  EXPECT_EQ(cnt, 0);
+
+  cnt = notification_list_get_count(noti_list);
+  ASSERT_EQ(cnt, 2);
+
+  noti_list = notification_list_remove(noti_list, noti2);
+  EXPECT_NE(noti_list, nullptr);
+
+  ret = notification_free_list(noti_list);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
+
+TEST_F(NotificationListTest, notification_list_test2) {
+  int ret;
+
+  notification_list_h get_list_detail = nullptr;
+  ret = notification_get_detail_list("org.tizen.testappid", 1, 1, 1, &get_list_detail);
+}
diff --git a/tests/noti_unittest/src/test_notification_noti.cc b/tests/noti_unittest/src/test_notification_noti.cc
new file mode 100644 (file)
index 0000000..d9ca168
--- /dev/null
@@ -0,0 +1,379 @@
+/*
+ * 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 <gmock/gmock.h>
+
+#include "mock/test_fixture.hh"
+#include "mock/aul_mock.hh"
+#include "mock/package_manager_mock.hh"
+#include "mock/glib_mock.hh"
+#include "mock/sqlite_mock.hh"
+
+#include "notification/include/notification.h"
+#include "notification/include/notification_noti.h"
+
+namespace {
+
+notification_h noti = nullptr;
+
+typedef struct {
+  const char *package;
+  char *locale;
+  pkgmgrinfo_app_component app_component;
+  application_x *app_info;
+} pkgmgr_appinfo_x;
+
+int __fake_aul_app_get_appid_bypid(int pid, char* appid, int len) {
+  snprintf(appid, len, "%s", "org.tizen.testappid");
+  return AUL_R_OK;
+}
+
+int __fake_sqlite3_open_v2(const char* arg0, sqlite3** arg1, int arg2, const char* arg3) {
+  char** table = (char** )calloc(10, sizeof(char*));
+  *arg1 = (sqlite3*) table;
+
+  return SQLITE_OK;
+}
+
+int __fake_sqlite3_prepare_v2(sqlite3* arg0, const char* arg1,
+    int arg2, sqlite3_stmt** arg3, const char** arg4) {
+  sqlite3_stmt* stmt = (sqlite3_stmt*)malloc(sizeof(sqlite3_stmt*));
+  *arg3 = stmt;
+
+  return SQLITE_OK;
+};
+
+extern "C" char* sqlite3_mprintf(const char*,...) {
+  return (char*)strdup("test_query");
+}
+
+class Mocks :
+    virtual public ::testing::NiceMock<AulMock>,
+    virtual public ::testing::NiceMock<GlibMock>,
+    virtual public ::testing::NiceMock<SqliteMock>,
+    virtual public ::testing::NiceMock<PackageManagerMock> {};
+} // namespace
+
+using ::testing::_;
+using ::testing::Invoke;
+using ::testing::Return;
+
+class NotificationNotiTest : public TestFixture {
+ public:
+  NotificationNotiTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  virtual void SetUp() {
+  }
+  virtual void TearDown() {
+  }
+};
+
+TEST_F(NotificationNotiTest, notification_noti_test) {
+  EXPECT_CALL(GetMock<AulMock>(), aul_app_get_appid_bypid(_, _, _))
+      .WillRepeatedly(Invoke(__fake_aul_app_get_appid_bypid));
+
+  EXPECT_CALL(GetMock<GlibMock>(), access(_, _))
+      .WillRepeatedly(Return(0));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_open_v2(_, _, _, _))
+      .WillRepeatedly(Invoke(__fake_sqlite3_open_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_prepare_v2(_, _, _, _, _))
+      .WillRepeatedly(Invoke(__fake_sqlite3_prepare_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_get_table(_, _, _, _, _, _))
+      .WillRepeatedly(Return(1));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_bind_int(_, _, _))
+      .WillRepeatedly(Return(SQLITE_OK));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_bind_double(_, _, _))
+      .WillRepeatedly(Return(SQLITE_OK));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_bind_text(_, _, _, _, _))
+      .WillRepeatedly(Return(SQLITE_OK));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_step(_))
+      .WillOnce(Return(SQLITE_OK))
+      .WillOnce(Return(SQLITE_ROW))
+      .WillOnce(Return(SQLITE_OK))
+      .WillOnce(Return(SQLITE_ROW))
+      .WillRepeatedly(Return(SQLITE_OK));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_finalize(_))
+      .WillRepeatedly(Return(SQLITE_OK));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_free(_))
+      .WillRepeatedly(Return());
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_column_int(_, _))
+      .WillRepeatedly(Return(1));
+
+  int ret;
+
+  noti = notification_create(NOTIFICATION_TYPE_NOTI);
+  EXPECT_NE(noti, nullptr);
+
+  ret = notification_noti_insert(noti);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_noti_update(noti);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  int deleted_num;
+  int* deleted_list;
+  ret = notification_noti_delete_all(NOTIFICATION_TYPE_NOTI, "org.tizen.testappid",
+      &deleted_num, &deleted_list, 5001);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
+
+TEST_F(NotificationNotiTest, notification_noti_test2) {
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_open_v2(_, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_open_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_prepare_v2(_, _, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_prepare_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_step(_))
+      .WillOnce(Return(SQLITE_ROW));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_finalize(_))
+      .WillOnce(Return(SQLITE_OK));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_free(_))
+      .WillRepeatedly(Return());
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_column_int(_, _))
+      .WillRepeatedly(Return(1));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_column_double(_, _))
+      .WillRepeatedly(Return(1.0));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_column_text(_, _))
+      .WillRepeatedly(Return(nullptr));
+
+  int ret;
+  ret = notification_noti_get_by_tag(noti, "org.tizen.testappid", "test_tag", 5001);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
+
+TEST_F(NotificationNotiTest, notification_noti_test3) {
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_open_v2(_, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_open_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_prepare_v2(_, _, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_prepare_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_step(_))
+      .WillOnce(Return(SQLITE_OK));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_finalize(_))
+      .WillOnce(Return(SQLITE_OK));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_free(_))
+      .WillOnce(Return());
+
+  int ret;
+
+  int num_changes;
+  ret = notification_noti_delete_by_priv_id_get_changes("org.tizen.testappid", 1, &num_changes, 5001);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
+
+
+TEST_F(NotificationNotiTest, notification_noti_test4) {
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_open_v2(_, _, _, _))
+      .WillRepeatedly(Invoke(__fake_sqlite3_open_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_prepare_v2(_, _, _, _, _))
+      .WillRepeatedly(Invoke(__fake_sqlite3_prepare_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_step(_))
+    .WillOnce(Return(SQLITE_ROW))
+    .WillOnce(Return(SQLITE_ROW))
+    .WillRepeatedly(Return(SQLITE_OK));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_finalize(_))
+      .WillRepeatedly(Return(SQLITE_OK));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_free(_))
+      .WillRepeatedly(Return());
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_column_int(_, _))
+      .WillRepeatedly(Return(1));
+
+  int ret;
+
+  int deleted_num;
+  notification_deleted_list_info_s *deleted_list;
+  ret = notification_noti_delete_by_display_applist(NOTIFICATION_DISPLAY_APP_INDICATOR,
+      &deleted_num, &deleted_list, 5001);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
+
+TEST_F(NotificationNotiTest, notification_noti_test5) {
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_open_v2(_, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_open_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_prepare_v2(_, _, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_prepare_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_step(_))
+      .WillOnce(Return(SQLITE_ROW));
+
+  int ret;
+  int count;
+  ret = notification_noti_get_all_count(NOTIFICATION_TYPE_NOTI, &count, 5001);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
+
+TEST_F(NotificationNotiTest, notification_noti_test6) {
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_open_v2(_, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_open_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_prepare_v2(_, _, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_prepare_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_step(_))
+      .WillOnce(Return(SQLITE_ROW));
+
+  int ret;
+  int count;
+  notification_list_h group_list;
+  int list_count;
+  ret = notification_noti_get_grouping_list(NOTIFICATION_TYPE_NOTI, 1,1, &group_list, &list_count, 5001);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
+
+TEST_F(NotificationNotiTest, notification_noti_test7) {
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_open_v2(_, _, _, _))
+      .WillRepeatedly(Invoke(__fake_sqlite3_open_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_prepare_v2(_, _, _, _, _))
+      .WillRepeatedly(Invoke(__fake_sqlite3_prepare_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_step(_))
+      .WillRepeatedly(Return(SQLITE_ROW));
+
+  int ret;
+  notification_list_h detail_list;
+  ret = notification_noti_get_detail_list("org.tizen.testappid", 1, 1, 1, &detail_list, 5001);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
+
+TEST_F(NotificationNotiTest, notification_noti_test8) {
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_open_v2(_, _, _, _))
+      .WillRepeatedly(Invoke(__fake_sqlite3_open_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_prepare_v2(_, _, _, _, _))
+      .WillRepeatedly(Invoke(__fake_sqlite3_prepare_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_step(_))
+      .WillRepeatedly(Return(SQLITE_ROW));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_column_int(_, _))
+      .WillRepeatedly(Return(1));
+
+  int ret;
+  ret = notification_set_tag(noti, "test_tag");
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_noti_check_tag(noti);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_ALREADY_EXIST_ID);
+}
+
+TEST_F(NotificationNotiTest, notification_noti_test9) {
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_open_v2(_, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_open_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_prepare_v2(_, _, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_prepare_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_step(_))
+      .WillOnce(Return(SQLITE_OK));
+
+  int ret;
+  int count;
+  ret = notification_noti_check_count_for_template(noti, &count);
+  ASSERT_EQ(ret, 0);
+}
+
+TEST_F(NotificationNotiTest, notification_noti_test10) {
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_open_v2(_, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_open_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_prepare_v2(_, _, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_prepare_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_step(_))
+      .WillOnce(Return(SQLITE_OK));
+
+  int ret;
+  ret = notification_noti_add_template(noti, "test_template");
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
+
+TEST_F(NotificationNotiTest, notification_noti_test11) {
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_open_v2(_, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_open_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_prepare_v2(_, _, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_prepare_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_step(_))
+      .WillOnce(Return(SQLITE_ROW));
+
+  int ret;
+  ret = notification_noti_get_package_template(noti, "org.tizen.testappid", "test_template");
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
+
+TEST_F(NotificationNotiTest, notification_noti_test12) {
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_open_v2(_, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_open_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_prepare_v2(_, _, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_prepare_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_step(_))
+      .WillOnce(Return(SQLITE_OK));
+
+  int ret;
+  ret = notification_noti_delete_template("org.tizen.testpkgid");
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
+
+TEST_F(NotificationNotiTest, notification_noti_test13) {
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_open_v2(_, _, _, _))
+      .WillOnce(Invoke(__fake_sqlite3_open_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_prepare_v2(_, _, _, _, _))
+      .WillRepeatedly(Invoke(__fake_sqlite3_prepare_v2));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_step(_))
+      .WillRepeatedly(Return(SQLITE_ROW));
+
+  EXPECT_CALL(GetMock<SqliteMock>(), sqlite3_column_int(_, _))
+      .WillRepeatedly(Return(101));
+
+  EXPECT_CALL(GetMock<GlibMock>(), g_list_append(_, _))
+      .WillOnce(Return(nullptr));
+
+  int ret;
+  GList* list;
+  ret = notification_noti_check_limit(noti, 5001, &list);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
diff --git a/tests/noti_unittest/src/test_notification_ongoing.cc b/tests/noti_unittest/src/test_notification_ongoing.cc
new file mode 100644 (file)
index 0000000..c29db7a
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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 <gmock/gmock.h>
+
+#include "mock/test_fixture.hh"
+#include "mock/glib_mock.hh"
+
+#include "notification/include/notification.h"
+#include "notification/include/notification_ongoing.h"
+
+namespace {
+
+GDBusConnection* __fake_g_bus_get_sync(GBusType type, GCancellable* cancellable, GError** error) {
+  GDBusConnection* conn = reinterpret_cast<GDBusConnection*>(calloc(1, 4));
+
+  return conn;
+}
+
+guint __fake_g_dbus_connection_signal_subscribe(GDBusConnection* arg0,
+    const gchar* arg1, const gchar* arg2, const gchar* arg3, const gchar* arg4,
+    const gchar* arg5, GDBusSignalFlags arg6, GDBusSignalCallback arg7,
+    gpointer arg8, GDestroyNotify arg9) {
+  arg7(nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
+
+  return 1;
+}
+
+class Mocks :
+    virtual public ::testing::NiceMock<GlibMock> {};
+} // namespace
+
+using ::testing::_;
+using ::testing::Invoke;
+using ::testing::Return;
+
+class NotificationOngoingTest : public TestFixture {
+ public:
+  NotificationOngoingTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  virtual void SetUp() {
+  }
+  virtual void TearDown() {
+  }
+};
+
+void __notification_ongoing_update_cb(struct ongoing_info_s *info, void *data) {
+}
+
+TEST_F(NotificationOngoingTest, notification_ongoing_test) {
+  EXPECT_CALL(GetMock<GlibMock>(), g_bus_get_sync(_, _, _))
+      .WillRepeatedly(Invoke(__fake_g_bus_get_sync));
+
+  EXPECT_CALL(GetMock<GlibMock>(),
+      g_dbus_connection_signal_subscribe(_, _, _, _, _, _, _, _, _, _))
+      .WillOnce(Invoke(__fake_g_dbus_connection_signal_subscribe));
+
+  EXPECT_CALL(GetMock<GlibMock>(), g_dbus_connection_emit_signal(_, _, _, _, _, _, _))
+      .WillRepeatedly(Return(true));
+
+  EXPECT_CALL(GetMock<GlibMock>(), g_dbus_connection_flush_sync(_, _, _))
+      .WillRepeatedly(Return(true));
+
+  int ret;
+
+  ret = notification_ongoing_update_cb_set(__notification_ongoing_update_cb, nullptr);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_ongoing_update_cb_unset();
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_ongoing_update_progress("org.tizen.caller_appid", 1, 10.0);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_ongoing_update_size("org.tizen.caller_appid", 1, 10.0);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_ongoing_update_content("org.tizen.caller_appid", 1, "test_content");
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
diff --git a/tests/noti_unittest/src/test_notification_setting.cc b/tests/noti_unittest/src/test_notification_setting.cc
new file mode 100644 (file)
index 0000000..0aa4b90
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * 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 <gmock/gmock.h>
+
+#include "mock/test_fixture.hh"
+#include "mock/aul_mock.hh"
+#include "mock/glib_mock.hh"
+#include "mock/sqlite_mock.hh"
+
+#include "notification/include/notification.h"
+#include "notification/include/notification_setting.h"
+#include "notification/include/notification_setting_internal.h"
+
+namespace {
+
+GDBusMessage* __fake_g_dbus_connection_send_message_with_reply_sync(
+    GDBusConnection* conn, GDBusMessage* msg, GDBusSendMessageFlags flags,
+    gint timeout, volatile guint32* out_serial, GCancellable* cancellable,
+    GError** error) {
+  GDBusMessage* ret_msg = static_cast<GDBusMessage*>(g_object_new(G_TYPE_OBJECT, NULL));
+
+  return ret_msg;
+}
+
+GDBusMessage* __fake_g_dbus_message_new_method_call(const gchar* arg0,
+    const gchar* arg1, const gchar* arg2, const gchar* arg3) {
+  GDBusMessage* ret_msg = static_cast<GDBusMessage*>(g_object_new(G_TYPE_OBJECT, NULL));
+
+  return ret_msg;
+}
+
+class Mocks :
+    virtual public ::testing::NiceMock<AulMock>,
+    virtual public ::testing::NiceMock<GlibMock> {};
+} // namespace
+
+using ::testing::_;
+using ::testing::Invoke;
+using ::testing::Return;
+
+class NotificationSettingTest : public TestFixture {
+ public:
+  NotificationSettingTest() : TestFixture(std::make_unique<::Mocks>()) {}
+  virtual void SetUp() {
+  }
+  virtual void TearDown() {
+  }
+};
+
+TEST_F(NotificationSettingTest, notification_setting_test) {
+  EXPECT_CALL(GetMock<GlibMock>(), g_bus_watch_name(_, _, _, _, _, _, _))
+      .WillOnce(Return(1));
+
+  EXPECT_CALL(GetMock<GlibMock>(), g_dbus_message_new_method_call(_, _, _, _))
+      .WillOnce(Invoke(__fake_g_dbus_message_new_method_call));
+
+  EXPECT_CALL(GetMock<GlibMock>(), g_dbus_connection_send_message_with_reply_sync(_, _, _, _, _, _, _))
+      .WillOnce(Invoke(__fake_g_dbus_connection_send_message_with_reply_sync));
+
+  int ret;
+
+  notification_setting_h setting;
+  setting = (struct notification_setting *)malloc(sizeof(struct notification_setting));
+
+  setting->package_name = strdup("org.tizen.testpkg");
+  setting->app_id = strdup("org.tizen.testapp");
+  setting->allow_to_notify = true;
+  setting->do_not_disturb_except = false;
+  setting->pop_up_notification = false;
+  setting->visibility_class = 1;
+  setting->lock_screen_content_level = SHOW_ALL_CONTENT;
+  setting->app_disabled = false;
+
+  int visibility;
+  ret = notification_setting_get_visibility_class(setting, &visibility);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_setting_set_visibility_class(setting, 3);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_setting_update_setting(setting);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+
+  ret = notification_setting_free_notification(setting);
+  ASSERT_EQ(ret, NOTIFICATION_ERROR_NONE);
+}
diff --git a/tests/unittest/CMakeLists.txt b/tests/unittest/CMakeLists.txt
deleted file mode 100644 (file)
index 58e266b..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
-PROJECT(notification-ex_unittests CXX)
-
-INCLUDE(FindPkgConfig)
-PKG_CHECK_MODULES(notification-ex_unittests REQUIRED
-    dlog
-    gmock
-    capi-appfw-app-control
-    glib-2.0
-    gio-2.0
-    gio-unix-2.0
-    aul
-    security-manager
-    libtzplatform-config
-)
-
-FOREACH(flag ${notification-ex_unittests_CFLAGS})
-    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall")
-
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
-SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
-SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
-
-INCLUDE_DIRECTORIES(
-    ${CMAKE_SOURCE_DIR}/
-    ${CMAKE_SOURCE_DIR}/notification-ex/
-    ${CMAKE_SOURCE_DIR}/notification-ex/api
-    ${CMAKE_CURRENT_SOURCE_DIR}/../
-    ${CMAKE_CURRENT_SOURCE_DIR}/../mock
-)
-
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/src SOURCES)
-AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/../mock MOCK_SOURCES)
-AUX_SOURCE_DIRECTORY(${CMAKE_SOURCE_DIR}/notification-ex NOTIFICATION_EX_SOURCES)
-ADD_EXECUTABLE(${PROJECT_NAME}
-    ${SOURCES}
-    ${NOTIFICATION_EX_SOURCES}
-    ${MOCK_SOURCES}
-)
-
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${notification-ex_unittests_LDFLAGS}
-    ${pkgs_LDFLAGS}
-    ${pkgs_LIBRARIES}
-    gmock
-    notification-ex
-)
-
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin/)
diff --git a/tests/unittest/src/test_main.cc b/tests/unittest/src/test_main.cc
deleted file mode 100644 (file)
index ad7ec6c..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-
-int main(int argc, char** argv) {
-  int ret = -1;
-
-  try {
-    testing::InitGoogleTest(&argc, argv);
-  } catch(...) {
-    std::cout << "Exception occurred" << std::endl;
-  }
-
-  try {
-    ret = RUN_ALL_TESTS();
-  } catch (const ::testing::internal::GoogleTestFailureException& e) {
-    ret = -1;
-    std::cout << "GoogleTestFailureException was thrown:" << e.what() << std::endl;
-  }
-
-  return ret;
-}
diff --git a/tests/unittest/src/test_noti_ex_abstract_item.cc b/tests/unittest/src/test_noti_ex_abstract_item.cc
deleted file mode 100644 (file)
index e9d8459..0000000
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-#include <app_control.h>
-#include <app_common.h>
-
-#include "notification-ex/item_inflator.h"
-#include "notification-ex/app_control_action.h"
-#include "notification-ex/item_info_internal.h"
-#include "notification-ex/iitem_factory.h"
-#include "notification-ex/factory_manager.h"
-#include "notification-ex/default_item_factory.h"
-#include "notification-ex/group_item.h"
-#include "notification-ex/button_item.h"
-
-#include "mock/test_fixture.h"
-#include "mock/smack_mock.h"
-#include "mock/app_common_mock.h"
-
-#define MY_ITEM_TYPE AbstractItem::Type::Custom + 1
-
-using namespace notification;
-using namespace tizen_base;
-using namespace notification::item;
-
-using ::testing::_;
-using ::testing::Invoke;
-
-namespace {
-class TestItem : public AbstractItem {
-  public:
-   TestItem(std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}))
-     : AbstractItem(action) {
-   }
-   TestItem(std::string id, std::shared_ptr<AbstractAction> action = std::shared_ptr<AbstractAction>({}))
-     : AbstractItem(id, action) {
-   }
-   virtual ~TestItem() {}
-
-  Bundle Serialize() const override {
-    Bundle b;
-    b = AbstractItem::Serialize();
-    return b;
-  }
-  void Deserialize(Bundle b) override {
-    AbstractItem::Deserialize(b);
-  }
-  AbstractItem& FindByID(std::string id) override {
-    return *this;
-  }
-  bool IsItemTypeExist(int type) {
-  if (GetType() == type)
-      return true;
-    return false;
-  }
-  int GetType() const override {
-    return MY_ITEM_TYPE;
-  }
-};
-
-class MyFactory : public IItemFactory {
- public:
-  MyFactory() {}
-  virtual ~MyFactory() {}
-
-  std::unique_ptr<AbstractItem> CreateItem(int type) override {
-    if (type == MY_ITEM_TYPE)
-      return std::unique_ptr<AbstractItem>(new TestItem(""));
-
-    return nullptr;
-  }
-};
-
-class Mocks :
-    virtual public ::testing::NiceMock<SmackMock>,
-    virtual public ::testing::NiceMock<AppCommonMock> {};
-} // namespace
-
-class AbstractItemTest : public TestFixture {
- public:
-  AbstractItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
-
-  virtual void SetUp() {
-    FactoryManager::GetInst().RegisterFactory(std::unique_ptr<IItemFactory>(new MyFactory()));
-  }
-  virtual void TearDown() {
-    FactoryManager::GetInst().RegisterFactory(std::unique_ptr<IItemFactory>(new DefaultItemFactory()));
-  }
-};
-
-TEST_F(AbstractItemTest, SerializeDeserialize) {
-  /* Serialize */
-  app_control_h app_control, app_control_1;
-  char* app_id = NULL;
-  time_t current_time;
-  Bundle extension_b;
-
-  app_control_create(&app_control);
-  app_control_set_app_id(app_control, "new_appid");
-  std::shared_ptr<AppControlAction> action = std::make_shared<AppControlAction>(app_control);
-  app_control_destroy(app_control);
-
-  app_control_create(&app_control_1);
-  app_control_set_app_id(app_control_1, "new_appid_1");
-  std::shared_ptr<AppControlAction> action_1 = std::make_shared<AppControlAction>(app_control_1);
-  app_control_destroy(app_control_1);
-
-  TestItem item("test_id", action);
-
-  std::shared_ptr<Color> color = std::make_shared<Color>(50, 100,150,200);
-  std::shared_ptr<Padding> padding = std::make_shared<Padding>(10, 20, 30, 40);
-  std::shared_ptr<Geometry> geometry = std::make_shared<Geometry>(110, 120, 130, 140);
-  std::shared_ptr<Color> bg_color = std::make_shared<Color>(71, 72, 73, 74);
-
-  item.SetStyle(std::make_shared<Style>(color, padding, geometry, bg_color, "bg path"));
-  item.SetVisible(false);
-  item.SetEnable(false);
-  item.AddReceiver("receiver_1");
-  item.AddReceiver("receiver_2");
-  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->AddHideViewer("hide_1");
-  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->AddHideViewer("hide_2");
-  item.SetPolicy(AbstractItem::Policy::OnBootClear);
-  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetVersion(3);
-  item.GetInfo()->SetHideTime(5);
-  item.GetInfo()->SetDeleteTime(9);
-  item.SetChannel("channel99");
-  item.SetSoundPath("soundpath");
-  item.SetVibrationPath("vibrationpath");
-  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetUid(3);
-  item.SetSenderAppId("sender");
-  item.SetTag("tag");
-
-  time(&current_time);
-  std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->SetTime(current_time);
-
-  std::shared_ptr<Color> color2 = std::make_shared<Color>(150, 160, 170, 180);
-  std::shared_ptr<LEDInfo> led = std::make_shared<LEDInfo>(color2);
-  led->SetOnPeriod(10);
-  led->SetOffPeriod(20);
-
-  item.SetLEDInfo(led);
-  item.SetOnGoingState(true);
-
-  extension_b.Add("test_key", "test_value");
-  item.SetExtensionData("extension_key", extension_b);
-
-  /* Deserialize */
-  Bundle b = item.Serialize();
-
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  TestItem* gen_test = static_cast<TestItem*>(gen_item.get());
-
-  ASSERT_EQ(gen_test->GetId(), "test_id");
-  ASSERT_EQ(gen_test->GetType(), MY_ITEM_TYPE);
-  ASSERT_EQ(std::static_pointer_cast<IItemInfoInternal>(gen_test->GetInfo())->GetUid(), 3);
-  ASSERT_EQ(gen_test->GetEnable(), false);
-  ASSERT_EQ(gen_test->GetVisible(),false);
-  ASSERT_EQ(gen_test->GetPolicy(), AbstractItem::Policy::OnBootClear);
-  ASSERT_EQ(std::static_pointer_cast<IItemInfoInternal>(gen_test->GetInfo())->GetVersion(), 3);
-  ASSERT_EQ(gen_test->GetInfo()->GetHideTime(), 5);
-  ASSERT_EQ(gen_test->GetInfo()->GetDeleteTime(), 9);
-  ASSERT_EQ(gen_test->GetChannel(), "channel99");
-  ASSERT_EQ(gen_test->GetSoundPath(), "soundpath");
-  ASSERT_EQ(gen_test->GetVibrationPath(), "vibrationpath");
-  ASSERT_EQ(gen_test->GetSenderAppId(), "sender");
-  ASSERT_EQ(gen_test->GetTag(), "tag");
-  ASSERT_EQ(gen_test->GetInfo()->GetTime(), current_time);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetLeft(), 10);
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetTop(), 20);
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetRight(), 30);
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetBottom(), 40);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetAVal(), 50);
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetRVal(), 100);
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetGVal(), 150);
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetBVal(), 200);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetX(), 110);
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetY(), 120);
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetWidth(), 130);
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetHeight(), 140);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetAVal(), 71);
-  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetRVal(), 72);
-  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetGVal(), 73);
-  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor()->GetBVal(), 74);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundImage(), "bg path");
-
-  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetAVal(), 150);
-  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetRVal(), 160);
-  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetGVal(), 170);
-  ASSERT_EQ(gen_test->GetLEDInfo()->GetColor()->GetBVal(), 180);
-  ASSERT_EQ(gen_test->GetLEDInfo()->GetOnPeriod(), 10);
-  ASSERT_EQ(gen_test->GetLEDInfo()->GetOffPeriod(), 20);
-
-  std::list<std::string> receiver1 = item.GetReceiverList();
-  std::list<std::string> receiver2 = gen_test->GetReceiverList();
-
-  ASSERT_EQ(receiver1.size(), receiver2.size());
-
-  for (unsigned int i = 0; i < receiver1.size(); i++) {
-    ASSERT_EQ(receiver1.front(), receiver2.front());
-    receiver1.pop_front();
-    receiver2.pop_front();
-  }
-
-  std::list<std::string> hide1 =
-      std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->GetHideViewerList();
-  std::list<std::string> hide2 =
-      std::static_pointer_cast<IItemInfoInternal>(gen_test->GetInfo())->GetHideViewerList();
-
-  ASSERT_EQ(hide1.size(), hide2.size());
-
-  for (unsigned int i = 0; i < hide1.size(); i++) {
-    ASSERT_EQ(hide1.front(), hide2.front());
-    hide1.pop_front();
-    hide2.pop_front();
-  }
-
-  ASSERT_EQ(gen_test->GetAction()->GetType(), AbstractAction::Type::AppControl);
-
-  std::shared_ptr<AppControlAction> ac =
-      std::static_pointer_cast<AppControlAction>(gen_test->GetAction());
-  app_control_get_app_id(ac->GetAppControl(), &app_id);
-
-  ASSERT_STREQ(app_id, "new_appid");
-
-  item.SetAction(action_1);
-
-  b = item.Serialize();
-  gen_item = ItemInflator::Create(b);
-  gen_test = static_cast<TestItem*>(gen_item.get());
-
-  ac = std::static_pointer_cast<AppControlAction>(gen_test->GetAction());
-  app_control_get_app_id(ac->GetAppControl(), &app_id);
-
-  ASSERT_STREQ(app_id, "new_appid_1");
-  ASSERT_EQ(gen_test->GetOnGoingState(), true);
-
-  Bundle extension_b2 = gen_test->GetExtensionData("extension_key");
-  ASSERT_EQ(extension_b2.GetString("test_key"), "test_value");
-}
-
-TEST_F(AbstractItemTest, SerializeDeserialize2) {
-  /* Serialize */
-  TestItem item("test_id");
-
-  std::shared_ptr<Color> color = std::make_shared<Color>(50, 100,150,200);
-  std::shared_ptr<Padding> padding = std::make_shared<Padding>(10, 20, 30, 40);
-  std::shared_ptr<Geometry> geometry = std::make_shared<Geometry>(110, 120, 130, 140);
-
-  item.SetStyle(std::make_shared<Style>(color, padding, geometry, nullptr, ""));
-
-  /* Deserialize */
-  Bundle b = item.Serialize();
-
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  TestItem* gen_test = static_cast<TestItem*>(gen_item.get());
-
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetLeft(), 10);
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetTop(), 20);
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetRight(), 30);
-  ASSERT_EQ(gen_test->GetStyle()->GetPadding()->GetBottom(), 40);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetAVal(), 50);
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetRVal(), 100);
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetGVal(), 150);
-  ASSERT_EQ(gen_test->GetStyle()->GetColor()->GetBVal(), 200);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetX(), 110);
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetY(), 120);
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetWidth(), 130);
-  ASSERT_EQ(gen_test->GetStyle()->GetGeometry()->GetHeight(), 140);
-
-  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundColor(), nullptr);
-  ASSERT_EQ(gen_test->GetStyle()->GetBackgroundImage(), "");
-}
-
-TEST_F(AbstractItemTest, ItemInfoCanReceive) {
-  TestItem item("test_id");
-
-  item.AddReceiver(ReceiverGroup::Panel);
-  item.AddReceiver(ReceiverGroup::LockScreen);
-
-  ASSERT_TRUE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::Panel));
-  ASSERT_TRUE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::LockScreen));
-  ASSERT_FALSE(std::static_pointer_cast<IItemInfoInternal>(item.GetInfo())->CanReceive(ReceiverGroup::Popup));
-}
-
-TEST_F(AbstractItemTest, SetGetOnGoingState) {
-  TestItem item("test_id");
-
-  ASSERT_EQ(item.GetOnGoingState(), false);
-
-  item.SetOnGoingState(true);
-
-  ASSERT_EQ(item.GetOnGoingState(), true);
-}
-
-int __fake_app_get_name(char** app_name) {
-  *app_name = strdup("unittest_appname");
-  return 0;
-}
-
-TEST_F(AbstractItemTest, SetGetFindMainType) {
-  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
-      .WillRepeatedly(Invoke(__fake_app_get_name));
-
-  auto root = std::make_shared<GroupItem>("test_group");
-  auto item = std::make_shared<ButtonItem>("test_id", "title");
-  root->AddChild(item);
-
-  bool ret = root->SetMainType("test_id", AbstractItem::MainButton);
-  EXPECT_TRUE(ret);
-  EXPECT_EQ(item->GetMainType(), AbstractItem::MainButton);
-  auto& i = root->FindByMainType(AbstractItem::MainButton);
-  EXPECT_EQ(i.GetId(), "test_id");
-}
-
-TEST_F(AbstractItemTest, SetInvalidMainType) {
-  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
-      .WillRepeatedly(Invoke(__fake_app_get_name));
-
-  auto root = std::make_shared<GroupItem>("test_group");
-  auto item = std::make_shared<ButtonItem>("test_id", "title");
-  root->AddChild(item);
-
-  bool ret = root->SetMainType("test_id", AbstractItem::MainTitle);
-  EXPECT_FALSE(ret);
-}
diff --git a/tests/unittest/src/test_noti_ex_app_control_action.cc b/tests/unittest/src/test_noti_ex_app_control_action.cc
deleted file mode 100644 (file)
index 1bdd3c4..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-
-#include "mock/app_common_mock.h"
-#include "mock/test_fixture.h"
-
-#include "notification-ex/app_control_action.h"
-#include "notification-ex/action_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-namespace {
-class Mocks :
-    virtual public ::testing::NiceMock<AppCommonMock> {};
-} // namespace
-
-class AppControlActionTest : public TestFixture {
- public:
-  AppControlActionTest() : TestFixture(std::make_unique<::Mocks>()) {}
-  AppControlAction* action;
-  app_control_h app_control;
-  const char* app_id = "test_appid";
-  std::string extra = "appcontrol_extra";
-
-  virtual void SetUp() {
-    app_control_create(&app_control);
-    app_control_set_app_id(app_control, app_id);
-
-    action = new AppControlAction(app_control, extra);
-  }
-  virtual void TearDown() {
-    delete action;
-    app_control_destroy(app_control);
-  }
-};
-
-TEST_F(AppControlActionTest, create) {
-  EXPECT_NE(AppControlActionTest::action, nullptr);
-}
-
-TEST_F(AppControlActionTest, IsLocal) {
-  ASSERT_EQ(AppControlActionTest::action->IsLocal(), 1);
-}
-
-TEST_F(AppControlActionTest, GetExtra) {
-  ASSERT_EQ(AppControlActionTest::action->GetExtra(),
-    AppControlActionTest::extra);
-}
-
-TEST_F(AppControlActionTest, SerializeDeserialize) {
-  Bundle b = AppControlActionTest::action->Serialize();
-
-  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
-  ASSERT_EQ(gen_action->GetType(), AbstractAction::AppControl);
-
-  AppControlAction* gen_appcontrol_action =
-    static_cast<AppControlAction*>(gen_action.get());
-
-  char* app_id = nullptr;
-  app_control_get_app_id(gen_appcontrol_action->GetAppControl(), &app_id);
-  std::unique_ptr<char, decltype(std::free)*> ptr(app_id, std::free);
-  ASSERT_STREQ(app_id, AppControlActionTest::app_id);
-}
-
-TEST_F(AppControlActionTest, AppControl) {
-  app_control_h app_control;
-  const char* app_id = "new_appid";
-
-  app_control_create(&app_control);
-  app_control_set_app_id(app_control, app_id);
-  AppControlActionTest::action->SetAppControl(app_control);
-  app_control_destroy(app_control);
-
-  Bundle b = AppControlActionTest::action->Serialize();
-
-  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
-  AppControlAction* gen_appcontrol_action =
-    static_cast<AppControlAction*>(gen_action.get());
-
-  char* app_id_ = nullptr;
-  app_control_get_app_id(gen_appcontrol_action->GetAppControl(), &app_id_);
-  std::unique_ptr<char, decltype(std::free)*> ptr(app_id_, std::free);
-  EXPECT_STREQ(app_id, app_id_);
-}
diff --git a/tests/unittest/src/test_noti_ex_button_item.cc b/tests/unittest/src/test_noti_ex_button_item.cc
deleted file mode 100644 (file)
index edc1560..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-
-#include "mock/app_common_mock.h"
-#include "mock/test_fixture.h"
-#include "notification-ex/button_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-using namespace std;
-
-namespace {
-class Mocks :
-    virtual public ::testing::NiceMock<AppCommonMock> {};
-} // namespace
-
-class ButtonItemTest : public TestFixture {
- public:
-  ButtonItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
- protected:
-  void SetUp() override {}
-  void TearDown() override {}
-};
-
-
-TEST_F(ButtonItemTest, FindByID) {
-  ButtonItem item("btn_id", "title");
-
-  AbstractItem& child = item.FindByID("btn_id");
-  ButtonItem& btn = static_cast<ButtonItem&>(child);
-  ASSERT_EQ(btn.GetTitle(), "title");
-}
-
-TEST_F(ButtonItemTest, FindByIDNullItemReturn) {
-  ButtonItem item("btn_id", "title");
-
-  AbstractItem& child = item.FindByID("not_exist_button");
-  ASSERT_EQ(child.GetType(), AbstractItem::NullObject);
-}
-
-TEST_F(ButtonItemTest, SerializeDeserializeGetTitle) {
-  ButtonItem item("title");
-  Bundle b = item.Serialize();
-  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(gen_item->GetType(), item.GetType());
-
-  auto gen_btn = std::static_pointer_cast<ButtonItem>(gen_item);
-  ASSERT_EQ(item.GetTitle(), gen_btn->GetTitle());
-}
diff --git a/tests/unittest/src/test_noti_ex_chat_message_item.cc b/tests/unittest/src/test_noti_ex_chat_message_item.cc
deleted file mode 100644 (file)
index e5b8772..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-
-#include "mock/app_common_mock.h"
-#include "mock/smack_mock.h"
-#include "mock/test_fixture.h"
-#include "notification-ex/chat_message_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-namespace {
-class Mocks :
-    virtual public ::testing::NiceMock<SmackMock>,
-    virtual public ::testing::NiceMock<AppCommonMock> {};
-} // namespace
-
-class ChatMessageItemTest : public TestFixture {
- public:
-  ChatMessageItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
-  ChatMessageItem* item;
-  ChatMessageItem::Type type = ChatMessageItem::Type::user;
-  std::string id = "chatmessage_id";
-  time_t current_time;
-  virtual void SetUp() {
-    time(&current_time);
-
-    item = new ChatMessageItem(id,
-      std::make_shared<TextItem>("name_id", "name"),
-      std::make_shared<TextItem>("text_id", "text"),
-      std::make_shared<ImageItem>("image_id", "path"),
-      std::make_shared<TimeItem>(current_time),type);
-  }
-  virtual void TearDown() {
-    delete item;
-  }
-};
-
-TEST_F(ChatMessageItemTest, create) {
-  EXPECT_NE(ChatMessageItemTest::item, nullptr);
-}
-
-TEST_F(ChatMessageItemTest, FindByID) {
-  AbstractItem& child = ChatMessageItemTest::item->FindByID(ChatMessageItemTest::id);
-  ChatMessageItem& message = static_cast<ChatMessageItem&>(child);
-  ASSERT_EQ(message.GetNameItem().GetContents(), "name");
-  ASSERT_EQ(message.GetTextItem().GetContents(), "text");
-  ASSERT_EQ(message.GetImageItem().GetImagePath(), "path");
-  ASSERT_EQ(message.GetMessageType(), ChatMessageItemTest::type);
-}
-
-TEST_F(ChatMessageItemTest, FindByIDNullItemReturn) {
-  AbstractItem& child = ChatMessageItemTest::item->FindByID("not_existed_item");
-  ASSERT_EQ(child.GetType(), ChatMessageItem::NullObject);
-}
-
-TEST_F(ChatMessageItemTest, SerializeDeserialize) {
-  Bundle b = ChatMessageItemTest::item->Serialize();
-
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  auto gen_message = std::static_pointer_cast<ChatMessageItem>(gen_item);
-  ASSERT_EQ(gen_message->GetNameItem().GetContents(), "name");
-  ASSERT_EQ(gen_message->GetTextItem().GetContents(), "text");
-  ASSERT_EQ(gen_message->GetImageItem().GetImagePath(), "path");
-  ASSERT_EQ(gen_message->GetTimeItem().GetTime(), ChatMessageItemTest::current_time);
-  ASSERT_EQ(gen_message->GetMessageType(), ChatMessageItemTest::type);
-}
diff --git a/tests/unittest/src/test_noti_ex_checkbox_item.cc b/tests/unittest/src/test_noti_ex_checkbox_item.cc
deleted file mode 100644 (file)
index a2f2a6a..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-
-#include "mock/app_common_mock.h"
-#include "mock/test_fixture.h"
-#include "notification-ex/checkbox_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-namespace {
-class Mocks :
-    virtual public ::testing::NiceMock<AppCommonMock> {};
-} // namespace
-
-class CheckBoxItemTest : public TestFixture {
- public:
-  CheckBoxItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
-  CheckBoxItem* item;
-  std::string id = "checkbox_id";
-  std::string title = "title";
-  bool isChecked = false;
-  virtual void SetUp() {
-    item = new CheckBoxItem(id, title, isChecked);
-  }
-  virtual void TearDown() {
-    delete item;
-  }
-};
-
-TEST_F(CheckBoxItemTest, create) {
-  EXPECT_NE(CheckBoxItemTest::item, nullptr);
-}
-
-TEST_F(CheckBoxItemTest, FindByID) {
-  AbstractItem& child = CheckBoxItemTest::item->FindByID(CheckBoxItemTest::id);
-  CheckBoxItem& checkbox = static_cast<CheckBoxItem&>(child);
-  ASSERT_EQ(checkbox.GetTitle(), CheckBoxItemTest::title);
-  ASSERT_EQ(checkbox.IsChecked(), CheckBoxItemTest::isChecked);
-}
-
-TEST_F(CheckBoxItemTest, FindByIDNullItemReturn) {
-  AbstractItem& child = CheckBoxItemTest::item->FindByID("not_existed_item");
-  ASSERT_EQ(child.GetType(), CheckBoxItem::NullObject);
-}
-
-TEST_F(CheckBoxItemTest, SerializeDeserialize) {
-  Bundle b = CheckBoxItemTest::item->Serialize();
-
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(CheckBoxItemTest::item->GetType(), gen_item->GetType());
-
-  auto gen_checkbox = std::static_pointer_cast<CheckBoxItem>(gen_item);
-  ASSERT_EQ(CheckBoxItemTest::item->GetTitle(), gen_checkbox->GetTitle());
-}
diff --git a/tests/unittest/src/test_noti_ex_entry_item.cc b/tests/unittest/src/test_noti_ex_entry_item.cc
deleted file mode 100644 (file)
index 869e25a..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-
-#include "mock/app_common_mock.h"
-#include "mock/test_fixture.h"
-#include "notification-ex/entry_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-namespace {
-class Mocks :
-    virtual public ::testing::NiceMock<AppCommonMock> {};
-} // namespace
-
-class EntryItemTest : public TestFixture {
- public:
-  EntryItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
-  virtual void SetUp() {}
-  virtual void TearDown() {}
-};
-
-TEST_F(EntryItemTest, FindByID) {
-  EntryItem item("entry_id");
-
-  AbstractItem& child = item.FindByID("entry_id");
-  EntryItem& btn = static_cast<EntryItem&>(child);
-  ASSERT_EQ(btn.GetId(), "entry_id");
-}
-
-TEST_F(EntryItemTest, FindByIDNullItemReturn) {
-  EntryItem item("entry_id");
-
-  AbstractItem& child = item.FindByID("not_existed_item");
-  ASSERT_EQ(child.GetType(), EntryItem::NullObject);
-}
-
-TEST_F(EntryItemTest, SerializeDeserialize) {
-  EntryItem item("entry_id");
-
-  Bundle b = item.Serialize();
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(gen_item->GetType(), item.GetType());
-
-  auto gen_effect = std::static_pointer_cast<EntryItem>(gen_item);
-  ASSERT_EQ(item.GetId(), gen_effect->GetId());
-}
-
-TEST_F(EntryItemTest, SetTextGetText) {
-  EntryItem item("entry_id");
-  item.SetText("test");
-
-  ASSERT_EQ(item.GetText(), "test");
-}
-
-TEST_F(EntryItemTest, GetTextLimit) {
-  EntryItem item("entry_id");
-
-  ASSERT_EQ(item.GetTextLimit(), 160);
-}
\ No newline at end of file
diff --git a/tests/unittest/src/test_noti_ex_event_info.cc b/tests/unittest/src/test_noti_ex_event_info.cc
deleted file mode 100644 (file)
index c480953..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-
-#include "mock/app_common_mock.h"
-#include "mock/test_fixture.h"
-#include "notification-ex/event_info_internal.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace std;
-
-namespace {
-class Mocks :
-    virtual public ::testing::NiceMock<AppCommonMock> {};
-} // namespace
-
-class EventInfoTest : public TestFixture {
- public:
-  EventInfoTest() : TestFixture(std::make_unique<::Mocks>()) {}
- protected:
-  void SetUp() override {}
-  void TearDown() override {}
-};
-
-TEST_F(EventInfoTest, SerializeDeserialize) {
-  EventInfo info(EventInfo::Get, "test", "channel", "id");
-  Bundle b = info.Serialize();
-  EventInfo serialized(b);
-  ASSERT_EQ(serialized.GetEventType(), info.GetEventType());
-  ASSERT_EQ(serialized.GetOwner(), info.GetOwner());
-  ASSERT_EQ(serialized.GetChannel(), info.GetChannel());
-  ASSERT_EQ(serialized.GetItemId(), info.GetItemId());
-  ASSERT_EQ(serialized.GetUid(), info.GetUid());
-}
-
-TEST_F(EventInfoTest, GetString) {
-  ASSERT_EQ(EventInfo::GetString(EventInfo::Post), "Post");
-  ASSERT_EQ(EventInfo::GetString(EventInfo::Update), "Update");
-  ASSERT_EQ(EventInfo::GetString(EventInfo::Delete), "Delete");
-  ASSERT_EQ(EventInfo::GetString(EventInfo::Get), "Get");
-}
diff --git a/tests/unittest/src/test_noti_ex_group_item.cc b/tests/unittest/src/test_noti_ex_group_item.cc
deleted file mode 100644 (file)
index 5a1dc89..0000000
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-
-#include "notification-ex/group_item.h"
-#include "notification-ex/button_item.h"
-#include "notification-ex/text_item.h"
-#include "notification-ex/item_inflator.h"
-#include "mock/app_common_mock.h"
-#include "mock/test_fixture.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-using namespace std;
-
-using ::testing::_;
-using ::testing::Invoke;
-
-namespace {
-  int __fake_app_get_name(char** app_name) {
-    *app_name = strdup("unittest_appname");
-    return 0;
-  }
-class Mocks :
-    virtual public ::testing::NiceMock<AppCommonMock> {};
-} // namespace
-
-class GroupItemTest : public TestFixture {
- public:
-  GroupItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
- protected:
-  void SetUp() override {}
-  void TearDown() override {}
-};
-
-TEST_F(GroupItemTest, AddChild) {
-  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
-      .WillRepeatedly(Invoke(__fake_app_get_name));
-
-  GroupItem item("GROUP1");
-  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
-  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
-  ASSERT_EQ(item.GetChildren().size(), 2);
-}
-
-TEST_F(GroupItemTest, RemoveChild) {
-  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
-      .WillRepeatedly(Invoke(__fake_app_get_name));
-
-  GroupItem item("GROUP1");
-  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
-  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
-  ASSERT_EQ(item.GetChildren().size(), 2);
-
-  item.RemoveChild("btn1");
-  ASSERT_EQ(item.GetChildren().size(), 1);
-}
-
-TEST_F(GroupItemTest, SerializeDeserialize) {
-  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
-      .WillRepeatedly(Invoke(__fake_app_get_name));
-
-  GroupItem item("GROUP1");
-  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
-  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
-
-  Bundle b = item.Serialize();
-  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(gen_item->GetType(), item.GetType());
-
-  auto gen_group = static_pointer_cast<GroupItem>(gen_item);
-  list<shared_ptr<AbstractItem>> gen_children_list = gen_group->GetChildren();
-  list<shared_ptr<AbstractItem>> origin_children_list = item.GetChildren();
-
-  list<shared_ptr<AbstractItem>>::iterator it = origin_children_list.begin();
-  for (auto& i : gen_children_list) {
-    ASSERT_EQ(i->GetType(), (*it)->GetType());
-    if (i->GetType() == AbstractItem::Button) {
-      ButtonItem* btn1 = static_cast<ButtonItem*>(i.get());
-      ButtonItem* btn2 = static_cast<ButtonItem*>((*it).get());
-      ASSERT_EQ(btn1->GetTitle(), btn2->GetTitle());
-    }
-    it++;
-  }
-  ASSERT_EQ(item.GetChildren().size(), 2);
-}
-
-TEST_F(GroupItemTest, FindByID) {
-  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
-      .WillRepeatedly(Invoke(__fake_app_get_name));
-
-  GroupItem item("GROUP1");
-  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
-  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
-  ASSERT_EQ(item.GetChildren().size(), 2);
-
-  AbstractItem& child = item.FindByID("btn2");
-  ButtonItem& btn = static_cast<ButtonItem&>(child);
-  ASSERT_EQ(btn.GetTitle(), "test2");
-}
-
-TEST_F(GroupItemTest, FindByIDGroupItem) {
-  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
-      .WillRepeatedly(Invoke(__fake_app_get_name));
-
-  GroupItem item("GROUP1");
-  shared_ptr<GroupItem> gr2 = shared_ptr<GroupItem>(new GroupItem("GROUP2"));
-  shared_ptr<GroupItem> gr3 = shared_ptr<GroupItem>(new GroupItem("GROUP3"));
-  gr2->AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
-  gr2->AddChild(std::make_shared<ButtonItem>("btn3", "test3"));
-  gr2->AddChild(std::make_shared<ButtonItem>("btn4", "test4"));
-  gr3->AddChild(std::make_shared<ButtonItem>("btn6", "test6"));
-  gr2->AddChild(gr3);
-
-  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
-  item.AddChild(gr2);
-  item.AddChild(std::make_shared<ButtonItem>("btn5", "test5"));
-  ASSERT_EQ(item.GetChildren().size(), 3);
-
-  AbstractItem& child = item.FindByID("btn3");
-  ButtonItem& btn = static_cast<ButtonItem&>(child);
-  ASSERT_EQ(btn.GetTitle(), "test3");
-
-  AbstractItem& child2 = item.FindByID("GROUP3");
-  GroupItem& ret_gr = static_cast<GroupItem&>(child2);
-  ASSERT_EQ(ret_gr.GetChildren().size(), 1);
-}
-
-
-TEST_F(GroupItemTest, IsItemTypeExist) {
-  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
-      .WillRepeatedly(Invoke(__fake_app_get_name));
-
-  GroupItem item("GROUP1");
-  shared_ptr<GroupItem> gr2 = shared_ptr<GroupItem>(new GroupItem("GROUP2"));
-  shared_ptr<GroupItem> gr3 = shared_ptr<GroupItem>(new GroupItem("GROUP3"));
-  gr2->AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
-  gr2->AddChild(std::make_shared<ButtonItem>("btn3", "test3"));
-  gr2->AddChild(std::make_shared<ButtonItem>("btn4", "test4"));
-  gr3->AddChild(std::make_shared<ButtonItem>("btn6", "test6"));
-  gr3->AddChild(std::make_shared<TextItem>("text1", "text1"));
-  gr2->AddChild(gr3);
-
-  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
-  item.AddChild(gr2);
-  item.AddChild(std::make_shared<ButtonItem>("btn5", "test5"));
-  ASSERT_EQ(item.GetChildren().size(), 3);
-
-  ASSERT_EQ(item.IsItemTypeExist(AbstractItem::Text), true);
-  ASSERT_EQ(item.IsItemTypeExist(AbstractItem::Image), false);
-}
-
-TEST_F(GroupItemTest, FindByIDNullItemReturn) {
-  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
-      .WillRepeatedly(Invoke(__fake_app_get_name));
-
-  GroupItem item("GROUP1");
-  item.AddChild(std::make_shared<ButtonItem>("btn1", "test1"));
-  item.AddChild(std::make_shared<ButtonItem>("btn2", "test2"));
-  ASSERT_EQ(item.GetChildren().size(), 2);
-
-  AbstractItem& child = item.FindByID("not_exist_button");
-  ASSERT_EQ(child.GetType(), AbstractItem::NullObject);
-}
-
-TEST_F(GroupItemTest, GetAppLabel) {
-  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
-      .WillRepeatedly(Invoke(__fake_app_get_name));
-
-  GroupItem item("GROUP1");
-  string app_label = item.GetAppLabel();
-
-  ASSERT_EQ(app_label, "unittest_appname");
-}
-
-TEST_F(GroupItemTest, SetAppLabel) {
-  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
-      .WillRepeatedly(Invoke(__fake_app_get_name));
-
-  GroupItem item("GROUP1");
-  item.SetAppLabel("test");
-  string app_label = item.GetAppLabel();
-
-  ASSERT_EQ(app_label, "test");
-}
-
-TEST_F(GroupItemTest, SetDirection) {
-  EXPECT_CALL(GetMock<AppCommonMock>(), app_get_name(_))
-      .WillRepeatedly(Invoke(__fake_app_get_name));
-
-  GroupItem item("GROUP1");
-  item.SetDirection(true);
-
-  ASSERT_TRUE(item.IsVertical());
-}
diff --git a/tests/unittest/src/test_noti_ex_icon_item.cc b/tests/unittest/src/test_noti_ex_icon_item.cc
deleted file mode 100644 (file)
index 5925d3c..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-
-#include "mock/app_common_mock.h"
-#include "mock/smack_mock.h"
-#include "mock/test_fixture.h"
-#include "notification-ex/icon_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-namespace {
-class Mocks :
-    virtual public ::testing::NiceMock<SmackMock>,
-    virtual public ::testing::NiceMock<AppCommonMock> {};
-} // namespace
-
-class IconItemTest : public TestFixture {
- public:
-  IconItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
-  IconItem* item;
-  std::string id = "icon_id";
-  virtual void SetUp() {
-    item = new IconItem(id, "icon_path");
-  }
-  virtual void TearDown() {
-    delete item;
-  }
-};
-
-TEST_F(IconItemTest, create) {
-  EXPECT_NE(IconItemTest::item, nullptr);
-}
-
-TEST_F(IconItemTest, FindByID) {
-  AbstractItem& child = IconItemTest::item->FindByID(IconItemTest::id);
-  IconItem& icon = static_cast<IconItem&>(child);
-  ASSERT_EQ(icon.GetImagePath(), "icon_path");
-}
-
-TEST_F(IconItemTest, FindByIDNullItemReturn) {
-  AbstractItem& child = IconItemTest::item->FindByID("not_existed_item");
-  ASSERT_EQ(child.GetType(), IconItem::NullObject);
-}
-
-TEST_F(IconItemTest, SerializeDeserialize) {
-  Bundle b = IconItemTest::item->Serialize();
-
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(IconItemTest::item->GetType(), gen_item->GetType());
-
-  auto gen_icon = std::static_pointer_cast<IconItem>(gen_item);
-  ASSERT_EQ(IconItemTest::item->GetImagePath(), gen_icon->GetImagePath());
-}
diff --git a/tests/unittest/src/test_noti_ex_image_item.cc b/tests/unittest/src/test_noti_ex_image_item.cc
deleted file mode 100644 (file)
index 63968cb..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-
-#include "mock/smack_mock.h"
-#include "mock/app_common_mock.h"
-#include "mock/test_fixture.h"
-#include "notification-ex/image_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-namespace {
-class Mocks :
-    virtual public ::testing::NiceMock<SmackMock>,
-    virtual public ::testing::NiceMock<AppCommonMock> {};
-} // namespace
-
-class ImageItemTest : public TestFixture {
- public:
-  ImageItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
-  ImageItem* item;
-  std::string id = "image_id";
-  std::string imagePath = "image_path";
-  virtual void SetUp() {
-    item = new ImageItem(id, imagePath);
-  }
-  virtual void TearDown() {
-    delete item;
-  }
-};
-
-TEST_F(ImageItemTest, create) {
-  EXPECT_NE(ImageItemTest::item, nullptr);
-}
-
-TEST_F(ImageItemTest, FindByID) {
-  AbstractItem& child = ImageItemTest::item->FindByID(ImageItemTest::id);
-  ImageItem& image = static_cast<ImageItem&>(child);
-  ASSERT_EQ(image.GetImagePath(), ImageItemTest::imagePath);
-}
-
-TEST_F(ImageItemTest, FindByIDNullItemReturn) {
-  AbstractItem& child = ImageItemTest::item->FindByID("not_existed_item");
-  ASSERT_EQ(child.GetType(), ImageItem::NullObject);
-}
-
-TEST_F(ImageItemTest, SerializeDeserialize) {
-  Bundle b = ImageItemTest::item->Serialize();
-
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(ImageItemTest::item->GetType(), gen_item->GetType());
-
-  auto gen_image = std::static_pointer_cast<ImageItem>(gen_item);
-  ASSERT_EQ(ImageItemTest::item->GetImagePath(), gen_image->GetImagePath());
-}
diff --git a/tests/unittest/src/test_noti_ex_input_selector_item.cc b/tests/unittest/src/test_noti_ex_input_selector_item.cc
deleted file mode 100644 (file)
index 2e13a6e..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-
-#include "mock/app_common_mock.h"
-#include "mock/test_fixture.h"
-#include "notification-ex/input_selector_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-using namespace std;
-
-namespace {
-class Mocks :
-    virtual public ::testing::NiceMock<AppCommonMock> {};
-} // namespace
-
-class InputSelectorItemTest : public TestFixture {
- public:
-  InputSelectorItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
- protected:
-  void SetUp() override {}
-  void TearDown() override {}
-};
-
-TEST_F(InputSelectorItemTest, SerializeDeserialize) {
-  InputSelectorItem item;
-  list<string> contents;
-  contents.push_back("AA");
-  contents.push_back("BB");
-  contents.push_back("CC");
-  item.SetContents(contents);
-
-  Bundle b = item.Serialize();
-  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(gen_item->GetType(), item.GetType());
-
-  auto gen_input = static_pointer_cast<InputSelectorItem>(gen_item);
-
-  list<string> l1 = item.GetContents();
-  list<string> l2 = gen_input->GetContents();
-  list<string>::iterator it1 = l1.begin();
-  list<string>::iterator it2 = l2.begin();
-  while(it1 != l1.end() && it2 != l2.end()) {
-    ASSERT_EQ((*it1), (*it2));
-    it1++;
-    it2++;
-  }
-}
diff --git a/tests/unittest/src/test_noti_ex_progress_item.cc b/tests/unittest/src/test_noti_ex_progress_item.cc
deleted file mode 100644 (file)
index 348e0c5..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-
-#include "mock/app_common_mock.h"
-#include "mock/test_fixture.h"
-#include "notification-ex/progress_item.h"
-#include "notification-ex/item_inflator.h"
-
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-using namespace std;
-
-namespace {
-class Mocks :
-    virtual public ::testing::NiceMock<AppCommonMock> {};
-} // namespace
-
-class ProgressItemTest : public TestFixture {
- public:
-  ProgressItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
- protected:
-  void SetUp() override {}
-  void TearDown() override {}
-};
-
-TEST_F(ProgressItemTest, SerializeDeserializeGetTitle) {
-  ProgressItem item(1.0, 10.0, 100.0);
-  item.SetDefaultUnit("byte");
-  Bundle b = item.Serialize();
-  shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-
-  auto gen_progress = std::static_pointer_cast<ProgressItem>(gen_item);
-  ASSERT_EQ(item.GetCurrent(), gen_progress->GetCurrent());
-  ASSERT_EQ(item.GetMin(), gen_progress->GetMin());
-  ASSERT_EQ(item.GetMax(), gen_progress->GetMax());
-  ASSERT_EQ(item.GetType(), gen_progress->GetType());
-  ASSERT_EQ(item.GetDefaultUnit(), gen_progress->GetDefaultUnit());
-
-  ASSERT_EQ(gen_progress->GetMin(), 1.0);
-  ASSERT_EQ(gen_progress->GetCurrent(), 10.0);
-  ASSERT_EQ(gen_progress->GetMax(), 100.0);
-  ASSERT_EQ(gen_progress->GetProgressType(), ProgressItem::Type::Default);
-  ASSERT_EQ(gen_progress->GetDefaultUnit(), "byte");
-}
-
-TEST_F(ProgressItemTest, SetGetProgressType) {
-  ProgressItem item(1.0, 10.0, 100.0);
-
-  ASSERT_EQ(item.GetProgressType(), ProgressItem::Type::Default);
-
-  item.SetProgressType(ProgressItem::Type::Pending);
-  ASSERT_EQ(item.GetProgressType(), ProgressItem::Type::Pending);
-}
-
-TEST_F(ProgressItemTest, SetGetUnit) {
-  ProgressItem item(1.0, 10.0, 100.0);
-  item.SetDefaultUnit("byte");
-
-  ASSERT_EQ(item.GetDefaultUnit(), "byte");
-}
diff --git a/tests/unittest/src/test_noti_ex_shared_file.cc b/tests/unittest/src/test_noti_ex_shared_file.cc
deleted file mode 100644 (file)
index 2b58335..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-
-#include "mock/app_common_mock.h"
-#include "mock/test_fixture.h"
-#include "notification-ex/shared_file.h"
-#include "notification-ex/image_item.h"
-#include "notification-ex/common.h"
-
-#include "mock/glib_mock.h"
-#include "mock/smack_mock.h"
-#include "mock/tzplatform_config_mock.h"
-#include "mock/security_manager_mock.h"
-
-
-using namespace notification;
-using namespace notification::item;
-using namespace std;
-
-using ::testing::_;
-using ::testing::Invoke;
-
-namespace {
-
-// smack
-ssize_t __fake_smack_new_label_from_path(const char* path, const char* xattr,
-    int follow, char** label) {
-  *label = strdup("User::Pkg::unittest::RO");
-  return 1;
-}
-
-// tzplatform
-const char* __fake_tzplatform_getenv(tzplatform_variable id) {
-  return "/opt/usr/home/owner/apps_rw";
-}
-
-// security-manager
-int __fake_security_manager_private_sharing_req_new(private_sharing_req** pp_req) {
-  return 0;
-}
-
-int __fake_security_manager_private_sharing_req_add_paths(
-    private_sharing_req* p_req, const char** pp_paths, size_t count) {
-  return 0;
-}
-
-int __fake_security_manager_private_sharing_req_set_target_appid(
-    private_sharing_req* p_req, const char* appid) {
-  return 0;
-}
-
-int __fake_security_manager_private_sharing_apply(const private_sharing_req* p_req) {
-  return 0;
-}
-
-int __fake_security_manager_private_sharing_drop(const private_sharing_req* p_req) {
-  return 0;
-}
-
-class Mocks :
-    virtual public ::testing::NiceMock<GlibMock>,
-    virtual public ::testing::NiceMock<SmackMock>,
-    virtual public ::testing::NiceMock<TzplatformConfigMock>,
-    virtual public ::testing::NiceMock<SecurityManagerMock> {};
-} // namespace
-
-class SharedFileTest : public TestFixture {
- public:
-  SharedFileTest() : TestFixture(std::make_unique<::Mocks>()) {}
-  std::shared_ptr<ImageItem> item;
-  std::string id = "image_id";
-  std::string image_path = "res/image.png";
-
-  SharedFile* shared_file;
-
-  virtual void SetUp() {
-    item = make_shared<ImageItem>(id, image_path);
-    shared_file = new SharedFile();
-  }
-
-  virtual void TearDown() {
-  }
-};
-
-TEST_F(SharedFileTest, IsPrivatePath) {
-  EXPECT_CALL(GetMock<SmackMock>(), smack_new_label_from_path(_, _, _, _))
-      .WillRepeatedly(Invoke(__fake_smack_new_label_from_path));
-
-  ASSERT_TRUE(shared_file->IsPrivatePath(SharedFileTest::image_path));
-}
-
-TEST_F(SharedFileTest, GetDataPath) {
-  EXPECT_CALL(GetMock<TzplatformConfigMock>(), tzplatform_getenv(_))
-      .WillRepeatedly(Invoke(__fake_tzplatform_getenv));
-
-  ASSERT_EQ(shared_file->GetDataPath(item->GetSenderAppId(), SharedFileTest::image_path),
-    "/opt/usr/home/owner/apps_rw/notification-ex_unittests/data/.notification_ex/image.png");
-}
-
-TEST_F(SharedFileTest, SetPrivateSharing) {
-  EXPECT_CALL(GetMock<SecurityManagerMock>(),
-      security_manager_private_sharing_req_new(_))
-      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_req_new));
-  EXPECT_CALL(GetMock<SecurityManagerMock>(),
-      security_manager_private_sharing_req_add_paths(_, _, _))
-      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_req_add_paths));
-  EXPECT_CALL(GetMock<SecurityManagerMock>(),
-      security_manager_private_sharing_req_set_target_appid(_, _))
-      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_req_set_target_appid));
-  EXPECT_CALL(GetMock<SecurityManagerMock>(),
-      security_manager_private_sharing_apply(_))
-      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_apply));
-  EXPECT_CALL(GetMock<SecurityManagerMock>(),
-      security_manager_private_sharing_drop(_))
-      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_drop));
-
-  list<shared_ptr<item::AbstractItem>> notiList;
-  notiList.push_back(SharedFileTest::item);
-
-  std::multimap<std::string, std::string> map_;
-  map_.insert(make_pair("tizen.org/receiver/popup", "test_appid"));
-
-  ASSERT_EQ(shared_file->SetPrivateSharing(notiList, map_), ERROR_NONE);
-}
-
-TEST_F(SharedFileTest, RemovePrivateSharing) {
-  EXPECT_CALL(GetMock<SecurityManagerMock>(),
-      security_manager_private_sharing_req_new(_))
-      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_req_new));
-  EXPECT_CALL(GetMock<SecurityManagerMock>(),
-      security_manager_private_sharing_req_add_paths(_, _, _))
-      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_req_add_paths));
-  EXPECT_CALL(GetMock<SecurityManagerMock>(),
-      security_manager_private_sharing_req_set_target_appid(_, _))
-      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_req_set_target_appid));
-  EXPECT_CALL(GetMock<SecurityManagerMock>(),
-      security_manager_private_sharing_apply(_))
-      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_apply));
-  EXPECT_CALL(GetMock<SecurityManagerMock>(),
-      security_manager_private_sharing_drop(_))
-      .WillRepeatedly(Invoke(__fake_security_manager_private_sharing_drop));
-
-  list<shared_ptr<item::AbstractItem>> notiList;
-  notiList.push_back(SharedFileTest::item);
-
-  std::multimap<std::string, std::string> map_;
-  map_.insert(make_pair("tizen.org/receiver/popup", "test_appid"));
-
-  ASSERT_EQ(shared_file->RemovePrivateSharing(notiList, map_), ERROR_NONE);
-}
diff --git a/tests/unittest/src/test_noti_ex_text_item.cc b/tests/unittest/src/test_noti_ex_text_item.cc
deleted file mode 100644 (file)
index 7f5c318..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-
-#include "mock/app_common_mock.h"
-#include "mock/test_fixture.h"
-#include "notification-ex/text_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-namespace {
-class Mocks :
-    virtual public ::testing::NiceMock<AppCommonMock> {};
-} // namespace
-
-class TexttItemTest : public TestFixture {
- public:
-  TexttItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
-  virtual void SetUp() {
-  }
-  virtual void TearDown() {
-  }
-};
-
-TEST_F(TexttItemTest, FindByID) {
-  TextItem item("text_id", "contents", "hyperlink");
-
-  AbstractItem& child = item.FindByID("text_id");
-  TextItem& btn = static_cast<TextItem&>(child);
-  ASSERT_EQ(btn.GetContents(), "contents");
-}
-
-TEST_F(TexttItemTest, FindByIDNullItemReturn) {
-  TextItem item("text_id", "contents", "hyperlink");
-
-  AbstractItem& child = item.FindByID("not_existed_item");
-  ASSERT_EQ(child.GetType(), TextItem::NullObject);
-}
-
-TEST_F(TexttItemTest, SerializeDeserializeGetContents) {
-  TextItem item("text_id", "contents");
-  Bundle b = item.Serialize();
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(gen_item->GetType(), item.GetType());
-
-  auto gen_text = std::static_pointer_cast<TextItem>(gen_item);
-  ASSERT_EQ(item.GetContents(), gen_text->GetContents());
-}
-
-TEST_F(TexttItemTest, SetContentsGetContents) {
-  TextItem item("text_id", "contents");
-  ASSERT_EQ(item.GetContents(), "contents");
-
-  item.SetContents("changed");
-  ASSERT_EQ(item.GetContents(), "changed");
-}
-
-TEST_F(TexttItemTest, GetHyperLink) {
-  TextItem item("text_id", "contents");
-  ASSERT_TRUE(item.GetHyperLink().empty());
-
-  TextItem item2("text_id", "contents", "hyperlink2");
-  ASSERT_EQ(item2.GetHyperLink(), "hyperlink2");
-}
diff --git a/tests/unittest/src/test_noti_ex_time_item.cc b/tests/unittest/src/test_noti_ex_time_item.cc
deleted file mode 100644 (file)
index 1e5c29b..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2019 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 <gmock/gmock.h>
-
-#include "mock/app_common_mock.h"
-#include "mock/test_fixture.h"
-#include "notification-ex/time_item.h"
-#include "notification-ex/item_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-namespace {
-class Mocks :
-    virtual public ::testing::NiceMock<AppCommonMock> {};
-} // namespace
-
-class TimeItemTest : public TestFixture {
- public:
-  TimeItemTest() : TestFixture(std::make_unique<::Mocks>()) {}
-  TimeItem* item;
-  time_t current_time;
-  std::string id = "time_id";
-  virtual void SetUp() {
-    time(&current_time);
-    item = new TimeItem(id, current_time);
-  }
-  virtual void TearDown() {
-    delete item;
-  }
-};
-
-TEST_F(TimeItemTest, create) {
-  EXPECT_NE(TimeItemTest::item, nullptr);
-}
-
-TEST_F(TimeItemTest, FindByID) {
-  AbstractItem& child = TimeItemTest::item->FindByID(TimeItemTest::id);
-  TimeItem& time_ = static_cast<TimeItem&>(child);
-  ASSERT_EQ(time_.GetTime(), TimeItemTest::current_time);
-}
-
-TEST_F(TimeItemTest, FindByIDNullItemReturn) {
-  AbstractItem& child = TimeItemTest::item->FindByID("not_existed_item");
-  ASSERT_EQ(child.GetType(), TimeItem::NullObject);
-}
-
-TEST_F(TimeItemTest, SerializeDeserialize) {
-  Bundle b = TimeItemTest::item->Serialize();
-
-  std::shared_ptr<AbstractItem> gen_item = ItemInflator::Create(b);
-  ASSERT_EQ(TimeItemTest::item->GetType(), gen_item->GetType());
-
-  auto gen_time = std::static_pointer_cast<TimeItem>(gen_item);
-  ASSERT_EQ(item->GetTime(), gen_time->GetTime());
-}
diff --git a/tests/unittest/src/test_noti_ex_visibility_action.cc b/tests/unittest/src/test_noti_ex_visibility_action.cc
deleted file mode 100644 (file)
index 258d8e5..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2019 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 <string>
-
-#include <gtest/gtest.h>
-#include <gmock/gmock.h>
-
-#include "mock/app_common_mock.h"
-#include "mock/test_fixture.h"
-#include "notification-ex/visibility_action.h"
-#include "notification-ex/action_inflator.h"
-
-using namespace tizen_base;
-using namespace notification;
-using namespace notification::item;
-
-namespace {
-class Mocks :
-    virtual public ::testing::NiceMock<AppCommonMock> {};
-} // namespace
-
-class VisibilityActionTest : public TestFixture {
- public:
-  VisibilityActionTest() : TestFixture(std::make_unique<::Mocks>()) {}
-  VisibilityAction* visibility;
-  std::string id = "visibility_id";
-  std::string extra = "visibility_extra";
-  bool visible = true;
-
-  virtual void SetUp() {
-    visibility = new VisibilityAction(extra);
-    visibility->SetVisibility("visibility_id", visible);
-  }
-  virtual void TearDown() {
-    delete visibility;
-  }
-};
-
-TEST_F(VisibilityActionTest, create) {
-  EXPECT_NE(VisibilityActionTest::visibility, nullptr);
-}
-
-TEST_F(VisibilityActionTest, IsLocal) {
-  ASSERT_EQ(VisibilityActionTest::visibility->IsLocal(), 1);
-}
-
-TEST_F(VisibilityActionTest, GetExtra) {
-  ASSERT_EQ(VisibilityActionTest::visibility->GetExtra(),
-    VisibilityActionTest::extra);
-}
-
-TEST_F(VisibilityActionTest, SerializeDeserialize) {
-  Bundle b = VisibilityActionTest::visibility->Serialize();
-
-  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
-  ASSERT_EQ(gen_action->GetType(), AbstractAction::Visibility);
-
-  auto gen_visibility_action =
-    std::static_pointer_cast<VisibilityAction>(gen_action);
-  EXPECT_NE(gen_visibility_action, nullptr);
-  ASSERT_EQ(gen_visibility_action->IsLocal(), true);
-  ASSERT_EQ(gen_visibility_action->GetExtra(), VisibilityActionTest::extra);
-}
-
-TEST_F(VisibilityActionTest, SetVisibility) {
-  VisibilityActionTest::visibility->SetVisibility("test_id", true);
-  Bundle b = VisibilityActionTest::visibility->Serialize();
-
-  std::shared_ptr<AbstractAction> gen_action = ActionInflator::Create(b);
-  ASSERT_EQ(gen_action->GetType(), AbstractAction::Visibility);
-
-  auto gen_visibility_action =
-    std::static_pointer_cast<VisibilityAction>(gen_action);
-  EXPECT_NE(gen_visibility_action, nullptr);
-  ASSERT_EQ(gen_visibility_action->IsLocal(), true);
-  ASSERT_EQ(gen_visibility_action->GetExtra(), VisibilityActionTest::extra);
-}