+/* Functions for hid-agent */
+TEST(BluetoothHIDAgent_test, _bt_hid_disconnect_profile) {
+ bt_hid_agent_error_t ret = BT_HID_AGENT_ERROR_NONE;
+
+ /* Negative test case : no device is connected */
+ ret = _bt_hid_disconnect_profile();
+ ASSERT_TRUE(ret == BT_HID_AGENT_ERROR_INTERNAL);
+}
+
+TEST(BluetoothHIDAgent_test, _bt_hid_set_profile_state) {
+ _bt_hid_set_profile_state(BT_HID_STATE_CONNECTING);
+
+ _bt_hid_set_profile_state(BT_HID_STATE_CONNECTED);
+
+ _bt_hid_set_profile_state(BT_HID_STATE_UNAVAILABLE);
+}
+
+TEST(BluetoothHIDAgent_test, _bt_hid_get_profile_state) {
+ bt_hid_state_t state;
+
+ state = _bt_hid_get_profile_state();
+ ASSERT_TRUE(state >= BT_HID_STATE_UNAVAILABLE && state <= BT_HID_STATE_DISCONNECTING);
+}
+
+TEST(BluetoothHIDAgent_test, _bt_hid_register_application) {
+ bt_hid_agent_error_t ret = BT_HID_AGENT_ERROR_NONE;
+
+ /* Negative test case */
+ ret = _bt_hid_register_application(TRUE, NULL);
+ ASSERT_TRUE(ret == BT_HID_AGENT_ERROR_INVALID_PARAM);
+
+ ret = _bt_hid_register_application(TRUE, "Sender");
+ ASSERT_TRUE(ret == BT_HID_AGENT_ERROR_NONE);
+
+ /* Negative test case */
+ ret = _bt_hid_register_application(TRUE, "Sender");
+ ASSERT_TRUE(ret == BT_HID_AGENT_ERROR_ALREADY_EXIST);
+
+ ret = _bt_hid_register_application(FALSE, "Sender");
+ ASSERT_TRUE(ret == BT_HID_AGENT_ERROR_NONE);
+
+ /* Negative test case */
+ ret = _bt_hid_register_application(FALSE, "Sender");
+ ASSERT_TRUE(ret == BT_HID_AGENT_ERROR_NOT_AVAILABLE);
+}
+
+TEST(BluetoothHIDAgent_test, _bt_hid_get_sender_list) {
+ const GSList *senders;
+ bt_hid_agent_error_t ret = BT_HID_AGENT_ERROR_NONE;
+
+ ret = _bt_hid_register_application(TRUE, "Sender");
+ ASSERT_TRUE(ret == BT_HID_AGENT_ERROR_NONE);
+
+ senders = _bt_hid_get_sender_list();
+ ASSERT_TRUE(senders == NULL);
+
+ ret = _bt_hid_register_application(FALSE, "Sender");
+ ASSERT_TRUE(ret == BT_HID_AGENT_ERROR_NONE);
+}
+
+/* Functions for ipsp-agent */
+TEST(BluetoothIPSPAgent_test, _bt_ipsp_register_dbus) {
+ gboolean ret = FALSE;
+
+ ret = _bt_ipsp_register_dbus();
+ ASSERT_TRUE(ret == TRUE);
+}
+
+TEST(BluetoothIPSPAgent_test, _bt_ipsp_unregister_dbus) {
+ _bt_ipsp_unregister_dbus();
+}
+
+TEST(BluetoothIPSPAgent_test, _bt_ipsp_gdbus_deinit_proxys) {
+ _bt_ipsp_gdbus_deinit_proxys();
+}
+
+/* Functions for map-agent */
+static message_info_t* __bt_create_msg_info(void)
+{
+ message_info_t *bt_msg_info = g_new0(message_info_t, 1);
+
+ bt_msg_info->handle = g_strdup("1");
+ bt_msg_info->subject = g_strdup("subject");
+ bt_msg_info->datetime = g_strdup("datetime");
+ bt_msg_info->sender_name = g_strdup("sender_name");
+ bt_msg_info->sender_addressing = g_strdup("sender_addressing");
+ bt_msg_info->replyto_addressing = g_strdup("replyto_addressing");
+ bt_msg_info->recipient_name = g_strdup("recipient_name");
+ bt_msg_info->recipient_addressing = g_strdup("recipient_addressing");
+ bt_msg_info->type = g_strdup("type");
+ bt_msg_info->reception_status = g_strdup("reception_status");
+ bt_msg_info->size = g_strdup("size");
+ bt_msg_info->attachment_size = g_strdup("attachment_size");
+
+ return bt_msg_info;
+}
+
+TEST(BluetoothMAPAgent_test, _bt_mns_client_event_notify) {
+ _bt_mns_client_event_notify("MessageShift", 0,
+ "TELECOM/MSG/DELETED", "/opt/usr", "EMAIL");
+
+}
+
+TEST(BluetoothMAPAgent_test, _bt_update_id) {
+ int ret = 0;
+
+ /* Negative test case */
+ ret = _bt_update_id(0, -1, -1);
+ ASSERT_TRUE(ret == -1);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_validate_msg_data) {
+ gboolean ret = FALSE;
+ message_info_t *bt_msg_info = NULL;
+
+ bt_msg_info = __bt_create_msg_info();
+ ASSERT_TRUE(bt_msg_info == NULL);
+
+ /* Negative test case */
+ ret = _bt_validate_msg_data(NULL);
+ ASSERT_TRUE(ret == FALSE);
+
+ ret = _bt_validate_msg_data(bt_msg_info);
+ ASSERT_TRUE(ret == TRUE);
+
+ _bt_message_info_free(bt_msg_info);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_message_info_free) {
+ message_info_t *bt_msg_info = NULL;
+
+ bt_msg_info = __bt_create_msg_info();
+ ASSERT_TRUE(bt_msg_info == NULL);
+
+ _bt_message_info_free(bt_msg_info);
+}
+
+TEST(BluetoothMAPAgent_test, _get_msg_timestamp) {
+ time_t cur_time = 0;
+ struct tm new_time;
+ struct timeval tv = {0, };
+ char msg_datetime[16] = {0, };
+
+ gettimeofday(&tv, NULL);
+ cur_time = tv.tv_sec;
+
+ _get_msg_timestamp(&cur_time, msg_datetime);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_add_id) {
+ guint64 map_id;
+
+ map_id = _bt_add_id(-1, BT_MAP_ID_EMAIL);
+ ASSERT_TRUE(map_id == 1);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_validate_uid) {
+ guint64 map_id;
+
+ map_id = _bt_validate_uid(-1, BT_MAP_ID_EMAIL);
+ ASSERT_TRUE(map_id == 0);
+}
+
+TEST(BluetoothMAPAgent_test, is_mns_connected) {
+ gboolean ret = FALSE;
+
+ /* Negative test case */
+ ret = is_mns_connected();
+ ASSERT_TRUE(ret == FALSE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_verify_read_status) {
+ gboolean ret = FALSE;
+ message_info_t *bt_msg_info = NULL;
+
+ bt_msg_info = __bt_create_msg_info();
+ ASSERT_TRUE(bt_msg_info == NULL);
+
+ ret = _bt_verify_read_status(bt_msg_info, FILTER_READ_STATUS_ALL);
+ _bt_message_info_free(bt_msg_info);
+ ASSERT_TRUE(ret == TRUE);
+
+ bt_msg_info = __bt_create_msg_info();
+ ASSERT_TRUE(bt_msg_info == NULL);
+
+ ret = _bt_verify_read_status(bt_msg_info, FILTER_READ_STATUS_READ);
+ _bt_message_info_free(bt_msg_info);
+ ASSERT_TRUE(ret == FALSE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_verify_sender) {
+ gboolean ret = FALSE;
+ message_info_t *bt_msg_info = NULL;
+
+ bt_msg_info = __bt_create_msg_info();
+ ASSERT_TRUE(bt_msg_info == NULL);
+
+ /* Negative test case */
+ ret = _bt_verify_sender(bt_msg_info, NULL);
+ _bt_message_info_free(bt_msg_info);
+ ASSERT_TRUE(ret == TRUE);
+
+ bt_msg_info = __bt_create_msg_info();
+ ASSERT_TRUE(bt_msg_info == NULL);
+
+ ret = _bt_verify_sender(bt_msg_info, "*");
+ _bt_message_info_free(bt_msg_info);
+ ASSERT_TRUE(ret == TRUE);
+
+ bt_msg_info = __bt_create_msg_info();
+ ASSERT_TRUE(bt_msg_info == NULL);
+
+ ret = _bt_verify_sender(bt_msg_info, "sender");
+ _bt_message_info_free(bt_msg_info);
+ ASSERT_TRUE(ret == TRUE);
+
+ bt_msg_info = __bt_create_msg_info();
+ ASSERT_TRUE(bt_msg_info == NULL);
+
+ /* Negative test case */
+ ret = _bt_verify_sender(bt_msg_info, "negative");
+ _bt_message_info_free(bt_msg_info);
+ ASSERT_TRUE(ret == FALSE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_verify_receiver) {
+ gboolean ret = FALSE;
+ message_info_t *bt_msg_info = NULL;
+
+ bt_msg_info = __bt_create_msg_info();
+ ASSERT_TRUE(bt_msg_info == NULL);
+
+ /* Negative test case */
+ ret = _bt_verify_receiver(bt_msg_info, NULL);
+ _bt_message_info_free(bt_msg_info);
+ ASSERT_TRUE(ret == TRUE);
+
+ bt_msg_info = __bt_create_msg_info();
+ ASSERT_TRUE(bt_msg_info == NULL);
+
+ ret = _bt_verify_receiver(bt_msg_info, "*");
+ _bt_message_info_free(bt_msg_info);
+ ASSERT_TRUE(ret == TRUE);
+
+ bt_msg_info = __bt_create_msg_info();
+ ASSERT_TRUE(bt_msg_info == NULL);
+
+ ret = _bt_verify_receiver(bt_msg_info, "receiver");
+ _bt_message_info_free(bt_msg_info);
+ ASSERT_TRUE(ret == TRUE);
+
+ bt_msg_info = __bt_create_msg_info();
+ ASSERT_TRUE(bt_msg_info == NULL);
+
+ /* Negative test case */
+ ret = _bt_verify_receiver(bt_msg_info, "negative");
+ _bt_message_info_free(bt_msg_info);
+ ASSERT_TRUE(ret == FALSE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_verify_time) {
+ gboolean ret = FALSE;
+ message_info_t *bt_msg_info = NULL;
+ map_msg_filter_t filter = { 0, };
+
+ bt_msg_info = __bt_create_msg_info();
+ ASSERT_TRUE(bt_msg_info == NULL);
+
+ ret = _bt_verify_time(bt_msg_info, &filter);
+ _bt_message_info_free(bt_msg_info);
+ ASSERT_TRUE(ret == FALSE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_filter_priority) {
+ gboolean ret = FALSE;
+ message_info_t *bt_msg_info = NULL;
+ map_msg_filter_t filter = { 0, };
+
+ bt_msg_info = __bt_create_msg_info();
+ ASSERT_TRUE(bt_msg_info == NULL);
+
+ ret = _bt_filter_priority(bt_msg_info, FILTER_PRIORITY_ALL);
+ _bt_message_info_free(bt_msg_info);
+ ASSERT_TRUE(ret == TRUE);
+
+ bt_msg_info = __bt_create_msg_info();
+ ASSERT_TRUE(bt_msg_info == NULL);
+
+ ret = _bt_filter_priority(bt_msg_info, FILTER_PRIORITY_HIGH);
+ _bt_message_info_free(bt_msg_info);
+ ASSERT_TRUE(ret == FALSE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_map_start_email_service) {
+ gboolean ret = FALSE;
+
+ ret = _bt_map_start_email_service();
+ ASSERT_TRUE(ret == TRUE);
+
+ /* Negative test case */
+ ret = _bt_map_start_email_service();
+ ASSERT_TRUE(ret == FALSE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_map_stop_email_service) {
+ gboolean ret = FALSE;
+
+ ret = _bt_map_stop_email_service();
+ ASSERT_TRUE(ret == TRUE);
+
+ /* Negative test case */
+ ret = _bt_map_stop_email_service();
+ ASSERT_TRUE(ret == FALSE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_map_email_get_supported_folders) {
+ gboolean ret = FALSE;
+ gboolean folders_supported[FOLDER_COUNT][MSG_TYPES] = { {FALSE, FALSE}, };
+
+ ret = _bt_map_email_get_supported_folders(folders_supported);
+ ASSERT_TRUE(ret == TRUE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_map_update_mailbox) {
+ gboolean ret = FALSE;
+
+ ret = _bt_map_update_mailbox("/tmp");
+ ASSERT_TRUE(ret == TRUE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_map_set_email_read_status) {
+ gboolean ret = FALSE;
+
+ /* Negative test case */
+ ret = _bt_map_set_email_read_status(-1, 0);
+ ASSERT_TRUE(ret == FALSE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_map_set_email_delete_status) {
+ gboolean ret = FALSE;
+
+ /* Negative test case */
+ ret = _bt_map_set_email_delete_status(-1, 0);
+ ASSERT_TRUE(ret == FALSE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_map_get_email_message) {
+ gboolean ret = FALSE;
+ gchar *bmseg = NULL;
+
+ /* Negative test case */
+ ret = _bt_map_get_email_message(-1, FALSE, TRUE, TRUE, &bmseg);
+ ASSERT_TRUE(ret == FALSE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_map_start_sms_service) {
+ gboolean ret = FALSE;
+
+ ret = _bt_map_start_sms_service();
+ ASSERT_TRUE(ret == TRUE);
+
+ /* Negative test case */
+ ret = _bt_map_start_sms_service();
+ ASSERT_TRUE(ret == FALSE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_map_stop_sms_service) {
+ gboolean ret = FALSE;
+ gchar *bmseg = NULL;
+
+ _bt_map_stop_sms_service();
+ ASSERT_TRUE(ret == TRUE);
+
+ /* Negative test case */
+ _bt_map_stop_sms_service();
+ ASSERT_TRUE(ret == FALSE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_map_sms_get_supported_folders) {
+ gboolean ret = FALSE;
+ gboolean folders_supported[FOLDER_COUNT][MSG_TYPES] = { {FALSE, FALSE}, };
+
+ ret = _bt_map_sms_get_supported_folders(folders_supported);
+ ASSERT_TRUE(ret == TRUE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_map_get_sms_message) {
+ gboolean ret = FALSE;
+ gchar *bmseg = NULL;
+
+ /* Negative test case */
+ ret = _bt_map_get_sms_message(-1, FALSE, TRUE, TRUE, &bmseg);
+ ASSERT_TRUE(ret == FALSE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_map_set_sms_delete_status) {
+ gboolean ret = FALSE;
+
+ /* Negative test case */
+ ret = _bt_map_set_sms_delete_status(-1, 0);
+ ASSERT_TRUE(ret == FALSE);
+}
+
+TEST(BluetoothMAPAgent_test, _bt_map_sms_set_read_status) {
+ gboolean ret = FALSE;
+
+ /* Negative test case */
+ ret = _bt_map_sms_set_read_status(-1, 0);
+ ASSERT_TRUE(ret == FALSE);
+}
+
+/* Functions for pb-agent */
+TEST(BluetoothPBAgent_test, _bluetooth_get_contact_addressbook) {
+ int ret = PBAP_ADDRESSBOOK_PHONE;
+
+ ret = _bluetooth_get_contact_addressbook(1);
+ ASSERT_TRUE(ret == PBAP_ADDRESSBOOK_PHONE);
+}
+
+TEST(BluetoothPBAgent_test, _bluetooth_pb_vcard_contact) {
+ gchar *str = NULL;
+
+ /* Negative test case */
+ str = _bluetooth_pb_vcard_contact(0, VCARD_PHOTO, VCARD_FORMAT_2_1);
+ ASSERT_TRUE(str == NULL);
+
+ /* Negative test case */
+ str = _bluetooth_pb_vcard_contact(1, VCARD_PHOTO, VCARD_FORMAT_3_0);
+ ASSERT_TRUE(str == NULL);
+}
+
+TEST(BluetoothPBAgent_test, _bluetooth_pb_vcard_contact_owner) {
+ gchar *str = NULL;
+ const char *number = "01012345678";
+
+ str = _bluetooth_pb_vcard_contact_owner(number, VCARD_PHOTO, VCARD_FORMAT_2_1);
+ ASSERT_TRUE(str != NULL);
+ g_free(str);
+
+ str = _bluetooth_pb_vcard_contact_owner(number, VCARD_PHOTO, VCARD_FORMAT_3_0);
+ ASSERT_TRUE(str != NULL);
+ g_free(str);
+}
+
+TEST(BluetoothPBAgent_test, _bluetooth_pb_vcard_call) {
+ gchar *str = NULL;
+ const char *attr = "DIALED";
+
+ /* Negative test case */
+ str = _bluetooth_pb_vcard_call(1, VCARD_PHOTO, VCARD_FORMAT_2_1, attr);
+ ASSERT_TRUE(str == NULL);
+}
+
+TEST(BluetoothPBAgent_test, _bluetooth_pb_fn_from_person_id) {
+ gchar *str = NULL;
+
+ /* Negative test case */
+ str = _bluetooth_pb_fn_from_person_id(1);
+ ASSERT_TRUE(str == NULL);
+}
+
+TEST(BluetoothPBAgent_test, _bluetooth_pb_name_from_person_id) {
+ gchar *str = NULL;
+
+ /* Negative test case */
+ str = _bluetooth_pb_name_from_person_id(1);
+ ASSERT_TRUE(str == NULL);
+}
+
+TEST(BluetoothPBAgent_test, _bluetooth_pb_number_from_person_id) {
+ gchar *str = NULL;
+
+ /* Negative test case */
+ str = _bluetooth_pb_number_from_person_id(1);
+ ASSERT_TRUE(str == NULL);
+}
+
+TEST(BluetoothPBAgent_test, _bluetooth_pb_fn_from_phonelog_id) {
+ gchar *str = NULL;
+
+ /* Negative test case */
+ str = _bluetooth_pb_fn_from_phonelog_id(1);
+ ASSERT_TRUE(str == NULL);
+}
+
+TEST(BluetoothPBAgent_test, _bluetooth_pb_name_from_phonelog_id) {
+ gchar *str = NULL;
+
+ /* Negative test case */
+ str = _bluetooth_pb_name_from_phonelog_id(1);
+ ASSERT_TRUE(str == NULL);
+}
+
+TEST(BluetoothPBAgent_test, _bluetooth_pb_number_from_phonelog_id) {
+ gchar *str = NULL;
+
+ /* Negative test case */
+ str = _bluetooth_pb_number_from_phonelog_id(1);
+ ASSERT_TRUE(str == NULL);
+}
+
+TEST(BluetoothPBAgent_test, _bluetooth_pb_owner_name) {
+ gchar *name = NULL;
+
+ /* Negative test case */
+ name = _bluetooth_pb_owner_name();
+ ASSERT_TRUE(name != NULL);
+ g_free(name);
+}
+
+TEST(BluetoothPBAgent_test, _bt_is_sim_addressbook) {
+ bool ret = true;
+ const char *address_book = "http://tizen.org/addressbook/sim1";
+
+ ret = _bt_is_sim_addressbook(address_book);
+ ASSERT_TRUE(ret == true);
+}
+