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)
namespace notification {
namespace item {
+/* LCOV_EXCL_START */
/**
* @brief The class for ReceiverGroup.
* @details The class to define receiver group of notification.
void UpdateSoundPrivatePath();
void UpdateVibrationPrivatePath();
}; // class AbstractItem
+/* LCOV_EXCL_STOP */
} // namespace item
} // namespace notification
return FactoryManager::GetInst().GetNullItem();
}
+/* LCOV_EXCL_START */
AbstractItem& ChatMessageItem::FindByMainType(MainType type) {
if (GetMainType() == type)
return *this;
return ret;
}
+/* LCOV_EXCL_STOP */
TextItem& ChatMessageItem::GetNameItem() const {
if (impl_->name_ == nullptr)
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"},
dbus_error_entries, G_N_ELEMENTS(dbus_error_entries));
return (GQuark)quark_volatile;
}
+/* LCOV_EXCL_STOP */
} // namespace notification
DBManager::DBManager() = default;
DBManager::~DBManager() = default;
+/* LCOV_EXCL_START */
sqlite3* DBManager::OpenDB() {
int ret;
sqlite3* db;
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);
*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);
" 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);
*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);
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;
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) {
}
return pkgid;
}
+/* LCOV_EXCL_STOP */
+
} // namespace notification
namespace notification {
+/* LCOV_EXCL_START */
class EXPORT_API DBManager {
public:
static int InitializeDB();
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_
using namespace std;
namespace notification {
+/* LCOV_EXCL_START */
DBusConnectionManager::DBusConnectionManager() = default;
DBusConnectionManager::~DBusConnectionManager() = default;
}
return ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
} // namespace notification
namespace notification {
+/* LCOV_EXCL_START */
class EXPORT_API DBusConnectionManager {
public:
static DBusConnectionManager& GetInst();
GDBusConnection* connection_ = nullptr;
bool is_DPM_ = false;
};
+/* LCOV_EXCL_STOP */
} // namespace notification
namespace notification {
+/* LCOV_EXCL_START */
DBusEventListener::DBusEventListener(string path)
: impl_(new Impl(this, path)) {
LOGW("Created (%s)", path.c_str());
int DBusEventListener::NotifyNumberRequest(const IEventInfo& info) {
return impl_->observer_->OnRequestNumber(info);
}
+/* LCOV_EXCL_STOP */
} // namespace notification
namespace notification {
+/* LCOV_EXCL_START */
class DBusEventListener::Impl {
public:
virtual ~Impl();
std::string path_;
DBusEventListener* parent_;
};
+/* LCOV_EXCL_STOP */
} // namespace notification
#endif // NOTIFICATION_EX_DBUS_EVENT_LISTENER_IMPLEMENTATION_H_
using namespace tizen_base;
namespace notification {
+/* LCOV_EXCL_START */
DBusSender::DBusSender(string path) : impl_(new Impl(this, path)) {
LOGW("Created (%s)", path.c_str());
}
Bundle serialized = info.Serialize();
return impl_->MethodCall(appid, method_name, serialized);
}
+/* LCOV_EXCL_STOP */
} // namespace notification
namespace notification {
+/* LCOV_EXCL_START */
class DBusSender::Impl {
public:
virtual ~Impl();
std::string path_;
DBusSender* parent_;
};
+/* LCOV_EXCL_STOP */
} // namespace notification
#endif // NOTIFICATION_EX_DBUS_SENDER_IMPLEMENTATION_H_
\ No newline at end of file
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_;
namespace notification {
+/* LCOV_EXCL_START */
class EXPORT_API IEventListener {
public:
virtual ~IEventListener() = default;
virtual std::list<tizen_base::Bundle> NotifyObserver(const IEventInfo& info) = 0;
virtual int NotifyNumberRequest(const IEventInfo& info) = 0;
};
+/* LCOV_EXCL_STOP */
} // namespace notification
namespace notification {
+/* LCOV_EXCL_START */
class EXPORT_API IEventObserver {
public:
virtual ~IEventObserver() = default;
virtual std::list<tizen_base::Bundle> OnRequest(const IEventInfo& info) = 0;
virtual int OnRequestNumber(const IEventInfo& info) = 0;
};
+/* LCOV_EXCL_STOP */
} // namespace notification
namespace notification {
+/* LCOV_EXCL_START */
class EXPORT_API IEventSender {
public:
virtual ~IEventSender() = default;
virtual std::list<tizen_base::Bundle> Request(const IEventInfo& info) = 0;
virtual int RequestReturnValue(const IEventInfo& info) = 0;
};
+/* LCOV_EXCL_STOP */
} // namespace notification
using namespace std;
+/* LCOV_EXCL_START */
namespace {
constexpr int MAX_PACKAGE_STR_SIZE = 512;
constexpr int MAX_CACHE_SIZE = 100;
return ERROR_IO_ERROR;
}
-
+/* LCOV_EXCL_STOP */
} // namespace util
} // namespace notification
namespace notification {
+/* LCOV_EXCL_START */
class Exception : public std::exception {
public:
explicit Exception(int error_code, std::string file = __FILE__,
}
}
}; // class Exception
+/* LCOV_EXCL_STOP */
} // namespace notification
#define EXPORT_API __attribute__((visibility("default")))
#endif
+/* LCOV_EXCL_START */
class EXPORT_API IEventInfo {
public:
enum EventType {
virtual int GetRequestId() const = 0;
virtual tizen_base::Bundle Serialize() const = 0;
};
+/* LCOV_EXCL_STOP */
} // namespace notification
#endif // NOTIFICATION_EX_IEVENT_INFO_H_
namespace notification {
+/* LCOV_EXCL_START */
class IEventInfoInternal : public IEventInfo {
public:
virtual ~IEventInfoInternal() = default;
virtual void SetError(NotificationError error) = 0;
virtual void SetEventType(int type) = 0;
};
+/* LCOV_EXCL_STOP */
} // namespace notification
#endif // NOTIFICATION_EX_IEVENT_INFO_INTERNAL_H_
namespace notification {
namespace item {
+/* LCOV_EXCL_START */
/**
* @brief The interface class for ItemInfo
* @since_tizen 5.5
*/
virtual time_t GetTime() const = 0;
};
+/* LCOV_EXCL_STOP */
} // namespace item
} // namespace notification
namespace notification {
namespace item {
+/* LCOV_EXCL_START */
class EXPORT_API IItemInfoInternal : public IItemInfo {
public:
virtual ~IItemInfoInternal() = default;
virtual void SetTime(time_t time) = 0;
virtual bool CanReceive(std::string receiver_group) const = 0;
};
+/* LCOV_EXCL_STOP */
} // namespace item
} // namespace notification
return ret;
}
+/* LCOV_EXCL_START */
void ImageItem::SetSharedPath() {
if (!impl_->priv_image_path_.empty())
impl_->image_path_ = impl_->priv_image_path_;
return path_map_list;
}
+/* LCOV_EXCL_STOP */
void ImageItem::UpdatePrivatePath() {
std::string path;
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)) {
string Manager::GetPath() {
return NOTIFICATION_EX_MANAGER_OBJECT_PATH;
}
+/* LCOV_EXCL_STOP */
} // namespace notification
namespace notification {
+/* LCOV_EXCL_START */
class EXPORT_API Manager : public IEventObserver {
public:
Manager(std::unique_ptr<IEventSender> sender,
class Impl;
std::unique_ptr<Impl> impl_;
};
+/* LCOV_EXCL_STOP */
} // namespace notification
namespace notification {
namespace item {
+/* LCOV_EXCL_START */
MultiLanguage::MultiLanguage(string msgid, string format,
vector<string> args)
: impl_(new Impl(msgid, format, args, this)) {
string MultiLanguage::GetTranslatedString() {
return impl_->translated_;
}
+/* LCOV_EXCL_STOP */
} // namespace item
} // namespace notification
\ No newline at end of file
namespace notification {
namespace item {
+/* LCOV_EXCL_START */
/**
* @brief The class for MultiLanguage type notification.
* @details The class to make the notification with multi language.
class Impl;
std::unique_ptr<Impl> impl_;
}; // class MultiLanguage
+/* LCOV_EXCL_STOP */
} // namespace item
} // namespace notification
namespace notification {
namespace item {
+/* LCOV_EXCL_START */
class MultiLanguage::Impl {
public:
virtual ~Impl();
std::string locale_directory_;
MultiLanguage* parent_;
};
+/* LCOV_EXCL_STOP */
} // namespace item
} // namespace notification
namespace notification {
namespace item {
+/* LCOV_EXCL_START */
NullItem::NullItem(shared_ptr<AbstractAction> action)
: AbstractItem(action) {
}
return true;
return false;
}
+/* LCOV_EXCL_STOP */
} // namespace item
} // namespace notification
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))) {
void Reporter::OnRegister(const IEventInfo& info) {
}
+/* LCOV_EXCL_STOP */
} // namespace notification
namespace notification {
+/* LCOV_EXCL_START */
class EXPORT_API Reporter : public IEventObserver {
public:
Reporter(std::unique_ptr<IEventSender> sender,
class Impl;
std::unique_ptr<Impl> impl_;
};
+/* LCOV_EXCL_STOP */
} // namespace notification
return nullptr;
}
+/* LCOV_EXCL_START */
bool SharedFile::MakeDir(const char* path) {
if (access(path, R_OK) == 0)
return true;
return ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
} // namespace item
} // namespace notification
namespace notification {
namespace item {
+/* LCOV_EXCL_START */
class EXPORT_API SharedFile {
public:
SharedFile();
std::list<SharingData> sharing_data_list_;
std::list<SharingTarget> sharing_target_list_;
}; // class SharedFile
+/* LCOV_EXCL_STOP */
} // namespace item
} // namespace notification
namespace notification {
+/* LCOV_EXCL_START */
class SocketHandler {
public:
SocketHandler(int fd):fd_(fd){}
private:
int fd_ = -1;
};
+/* LCOV_EXCL_STOP */
} // namespace notification
#endif // NOTIFICATION_EX_SOCKET_HANDLER_H_
\ No newline at end of file
namespace {
+/* LCOV_EXCL_START */
class Handle {
public:
explicit Handle(item::AbstractItem* ref) : ref_(ref) { }
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++)
return NOTI_EX_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
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;
}
}
-/* LCOV_EXCL_START */
static void __free_changed_cb_info(gpointer data)
{
notification_cb_info_s *noti_cb_info = (notification_cb_info_s *)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;
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)
}
/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
EXPORT_API int notification_add_deferred_task(
void (*deferred_task_cb)(void *data), void *user_data)
{
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)
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;
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)
return ret;
}
+/* LCOV_EXCL_STOP */
/* notification_set_icon will be removed */
/* LCOV_EXCL_START */
}
/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
EXPORT_API int notification_translate_localized_text(notification_h noti)
{
int ret = NOTIFICATION_ERROR_NONE;
return ret;
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
EXPORT_API int notification_set_title(notification_h noti,
}
/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
EXPORT_API int notification_set_app_id(notification_h noti,
const char *app_id)
{
return NOTIFICATION_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
int notification_delete_all_by_type_for_uid(const char *app_id,
}
/* 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)
return NOTIFICATION_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
notification_h notification_load_for_uid(char *app_id,
}
/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
EXPORT_API int notification_insert_for_uid(notification_h noti,
int *priv_id, uid_t uid)
{
{
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)
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;
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)
{
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)
}
/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
EXPORT_API int notification_set_uid(notification_h noti,
uid_t uid)
{
return file_list;
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
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;
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;
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);
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;
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);
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)
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)
{
} 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;
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());
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)
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:
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)
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;
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;
return NOTIFICATION_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
/*
* store tasks when daemon stopped
*/
+ /* LCOV_EXCL_START */
int notification_ipc_add_deffered_task(
void (*deferred_task_cb)(void *data),
void *user_data)
return NOTIFICATION_ERROR_INVALID_PARAMETER;
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
static void _do_deffered_task(void)
}
/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
static void _delete_by_display_applist_notify(GVariant *parameters)
{
int *buf;
free(noti_op);
free(buf);
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
static void _change_dnd_notify(GVariant *parameters)
}
/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
static void _send_event(GVariant *parameters)
{
int ret;
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);
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)
}
/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
static void _handle_noti_event_handler_notify(GDBusConnection *connection,
const gchar *sender_name,
const gchar *object_path,
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;
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;
}
return ret;
}
+/* LCOV_EXCL_START */
static int _dbus_signal_init(void)
{
int id;
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;
return ret;
}
+/* LCOV_EXCL_STOP */
static GDBusMessage *__get_new_msg(GVariant *body, const char *cmd)
{
return ret;
}
+/* LCOV_EXCL_START */
static void _send_message_with_reply_async_cb(GDBusConnection *connection,
GAsyncResult *res,
gpointer user_data)
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(
&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
ERR("Failed to send message[%s]", err->message);
g_error_free(err);
- /* LCOV_EXCL_STOP */
}
INFO("Async message callback result[%d]", result);
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;
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))
DBG("Success to send async message");
return NOTIFICATION_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
+
int notification_ipc_request_insert(notification_h noti, int *priv_id)
{
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)
{
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));
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;
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);
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)
{
return result;
}
+/* LCOV_EXCL_START */
int notification_ipc_request_delete_by_display_applist(int display_applist, uid_t uid)
{
int result;
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)
{
return result;
}
+/* LCOV_EXCL_START */
int notification_ipc_request_get_setting_array(
notification_setting_h *setting_array,
int *count,
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");
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;
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)
{
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);
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;
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");
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);
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);
DBG("result[%d]", result);
return result;
}
+/* LCOV_EXCL_START */
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;
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)",
DBG("result[%d]", result);
return result;
}
+/* LCOV_EXCL_STOP */
int notification_ipc_request_save_as_template(notification_h noti, const char *template_name)
{
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;
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);
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,
return ret;
}
+/* LCOV_EXCL_START */
int notification_ipc_request_get_all_count(notification_type_e type, int *count, uid_t uid)
{
int ret;
DBG("result[%d]", ret);
return ret;
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
void notification_ipc_reset_event_handler(int priv_id)
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;
{
return _send_service_register(uid);
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
static void _on_name_appeared(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) {
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) {
{
return _ipc_monitor_deregister();
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
void notification_ipc_event_monitor_fini(void)
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;
errno = 0;
nb = write(fd, buffer, left);
if (nb == -1) {
- /* LCOV_EXCL_START */
if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) {
ERR("continue..");
retry_cnt++;
}
ERR("error fd [%d] errno [%d]", fd, errno);
return NOTIFICATION_ERROR_IO_ERROR;
- /* LCOV_EXCL_STOP */
}
left -= nb;
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)
{
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) {
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)
}
/* 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) {
}
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) {
}
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) {
return NOTIFICATION_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
EXPORT_API int notification_setting_get_visibility_class(notification_setting_h setting, int *value)
{
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) {
return NOTIFICATION_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
EXPORT_API int notification_setting_update_setting_for_uid(notification_setting_h setting, uid_t uid)
{
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)
{
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);
}
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:
return err;
}
+/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
static int _foreach_app_info_callback(const pkgmgrinfo_appinfo_h handle,
void *user_data)
{
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) {
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);
return err;
}
+/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
static int _install_and_update_package(const char *package_name, uid_t uid)
{
sqlite3 *db;
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;
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:
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;
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);
return err;
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
EXPORT_API int notification_setting_refresh_setting_table(uid_t uid)
}
/* 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);
return 1;
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
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;
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)
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());
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)
#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) {
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)
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];
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) {
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;
"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) {
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;
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;
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++);
_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;
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);
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);
return ret;
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
EXPORT_API
}
/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
EXPORT_API
int notification_get_dnd_and_allow_to_notify(const char *app_id,
int *do_not_disturb,
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) {
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) {
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) {
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);
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;
return ret;
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
EXPORT_API
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)
{
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)
{
return NULL;
}
+/* LCOV_EXCL_STOP */
/* Check path that include res directory */
/* LCOV_EXCL_START */
}
/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
static bool __is_RO_file(const char *smack_label)
{
#define CHECK_LABEL "::RO"
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)
{
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) {
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);
}
ret = NOTIFICATION_ERROR_IO_ERROR;
goto out;
- /* LCOV_EXCL_STOP */
}
ut.modtime = time(NULL);
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;
free(info);
}
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
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;
return strcmp(new_file, file);
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
static gint __comp_file_info(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;
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)
{
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) {
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 */
}
}
}
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 */
}
}
return ret;
}
+/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
EXPORT_API int notification_set_private_sharing(notification_h noti,
uid_t uid)
{
}
}
+/* LCOV_EXCL_STOP */
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,
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)
{
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 */
}
}
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 */
}
}
return NOTIFICATION_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
EXPORT_API
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)
{
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);
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:
return ret;
}
+/* LCOV_EXCL_STOP */
}
/* LCOV_EXCL_STOP */
+/* LCOV_EXCL_START */
static int __pop_delayed_noti() {
delayed_noti_info_s *noti = g_list_nth_data(_delayed_noti_list, 0);
return NOTIFICATION_ERROR_NONE;
}
+/* LCOV_EXCL_STOP */
/* LCOV_EXCL_START */
EXPORT_API int notification_launch_default_viewer(int priv_id,
%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
test_main() {
echo "test_main start"
- /usr/bin/notification-ex_unittests
+ /usr/bin/<NAME>-unittests
}
teardown() {
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}
%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/*
-ADD_SUBDIRECTORY(unittest)
-ADD_DEPENDENCIES(notification-ex_unittests notification-ex)
+ADD_SUBDIRECTORY(noti_unittest)
+ADD_SUBDIRECTORY(noti_ex_unittest)
* 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);
+++ /dev/null
-/*
- * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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_
* 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);
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);
+}
+++ /dev/null
-/*
- * 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_
--- /dev/null
+/*
+ * 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_
+++ /dev/null
-/*
- * 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_
--- /dev/null
+/*
+ * 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_
+++ /dev/null
-/*
- * 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_
--- /dev/null
+/*
+ * 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_
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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_
* 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);
+++ /dev/null
-/*
- * 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_
--- /dev/null
+/*
+ * 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_
* 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) {
+++ /dev/null
-/*
- * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "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);
+}
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef 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_
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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_
* limitations under the License.
*/
-#include "test_fixture.h"
+#include "test_fixture.hh"
#include <memory>
+++ /dev/null
-/*
- * 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_
--- /dev/null
+/*
+ * 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_
* 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);
+++ /dev/null
-/*
- * 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
--- /dev/null
+/*
+ * 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
--- /dev/null
+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/)
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * 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(¤t_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);
+}
--- /dev/null
+/*
+ * 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_);
+}
--- /dev/null
+/*
+ * 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");
+}
--- /dev/null
+/*
+ * 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(¤t_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);
+}
--- /dev/null
+/*
+ * 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());
+}
--- /dev/null
+/*
+ * 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
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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());
+}
--- /dev/null
+/*
+ * 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());
+}
--- /dev/null
+/*
+ * 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());
+}
--- /dev/null
+/*
+ * 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++;
+ }
+}
--- /dev/null
+/*
+ * 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");
+}
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+/*
+ * 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");
+}
--- /dev/null
+/*
+ * 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(¤t_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());
+}
--- /dev/null
+/*
+ * 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);
+}
--- /dev/null
+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/)
--- /dev/null
+/*
+ * 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;
+}
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+#include <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);
+}
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+#include <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);
+}
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+#include <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);
+}
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+#include <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);
+}
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+#include <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);
+}
--- /dev/null
+/*
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <gtest/gtest.h>
+#include <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);
+}
+++ /dev/null
-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/)
+++ /dev/null
-/*
- * 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;
-}
+++ /dev/null
-/*
- * 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(¤t_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);
-}
+++ /dev/null
-/*
- * 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_);
-}
+++ /dev/null
-/*
- * 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());
-}
+++ /dev/null
-/*
- * 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(¤t_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);
-}
+++ /dev/null
-/*
- * 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());
-}
+++ /dev/null
-/*
- * 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
+++ /dev/null
-/*
- * 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");
-}
+++ /dev/null
-/*
- * 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());
-}
+++ /dev/null
-/*
- * 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());
-}
+++ /dev/null
-/*
- * 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());
-}
+++ /dev/null
-/*
- * 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++;
- }
-}
+++ /dev/null
-/*
- * 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");
-}
+++ /dev/null
-/*
- * 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);
-}
+++ /dev/null
-/*
- * 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");
-}
+++ /dev/null
-/*
- * 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(¤t_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());
-}
+++ /dev/null
-/*
- * 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);
-}