3 #include <account_internal.h>
4 #include <account-types.h>
5 #include <account-error.h>
9 #define TEST_PACKAGE_NAME "core-accounts-svc-tests" // app_id
10 #define USER_NAME "user_name"
11 #define ICON_PATH "/usr/share/icons/default/small/com.samsung.phone.png"
13 #define check_fail(exp) \
16 FILE *fp = fopen(ERR_LOG,"w"); \
18 "Assert fail in %s:%d\n", __FILE__, __LINE__); \
20 "Following expression is not true:\n" \
26 #define check_fail_eq(var, ref) \
28 FILE *fp = fopen(ERR_LOG,"w"); \
30 "Assert fail in %s:%d\n", __FILE__, __LINE__); \
32 "Values \"%s\" and \"%s\" are not equal:\n" \
33 "%s == %d, %s == %d\n", \
34 #var, #ref, #var, (int)var, #ref, (int)ref); \
40 #define is_callback_fail() \
41 if (_is_fail == true) \
45 static bool connected = false;
46 static bool created = false;
47 static account_h account = NULL;
48 static GMainLoop* mainloop = NULL;
49 static int _is_fail = true;
50 static const char* package_name = TEST_PACKAGE_NAME;
51 static const char* icon_path = ICON_PATH;
52 static const char* label_default = "AccountTest";
53 static const char* label_en_gb = "Application en-gb Test";
54 static const char* contact_capability = ACCOUNT_SUPPORTS_CAPABILITY_CONTACT;
55 static const char* calendar_capability = ACCOUNT_SUPPORTS_CAPABILITY_CALENDAR;
56 static const char* user_name = USER_NAME;
57 static const account_capability_state_e capability_state = ACCOUNT_CAPABILITY_ENABLED;
59 static gboolean timeout_cb(gpointer data) {
62 g_main_loop_quit((GMainLoop*)data);
66 void utc_account_startup(void)
68 account_type_h account_type = NULL;
69 int account_type_id = -1;
70 int ret1 = ACCOUNT_ERROR_NONE, ret2 = ACCOUNT_ERROR_NONE;
71 ret1 = account_connect();
72 if (ACCOUNT_ERROR_NONE == ret1) {
74 ret2 = account_create(&account);
75 if (ACCOUNT_ERROR_NONE == ret2) {
80 if(account_type_query_app_id_exist(package_name) == ACCOUNT_ERROR_RECORD_NOT_FOUND) {
81 ret1 = account_type_create(&account_type);
82 assert_eq(ret1, ACCOUNT_ERROR_NONE);
84 ret1 = account_type_set_app_id_internal(account_type, package_name);
85 assert_eq(ret1, ACCOUNT_ERROR_NONE);
87 ret1 = account_type_set_service_provider_id_internal(account_type, "http://www.samsung.com/");
88 assert_eq(ret1, ACCOUNT_ERROR_NONE);
90 ret1 = account_type_set_multiple_account_support_internal(account_type, true);
91 assert_eq(ret1, ACCOUNT_ERROR_NONE);
93 ret1 = account_type_set_label_internal(account_type, label_default, NULL);
94 assert_eq(ret1, ACCOUNT_ERROR_NONE);
96 ret1 = account_type_set_label_internal(account_type, label_en_gb, "en_GB");
97 assert_eq(ret1, ACCOUNT_ERROR_NONE);
99 ret1 = account_type_set_icon_path_internal(account_type, icon_path);
100 assert_eq(ret1, ACCOUNT_ERROR_NONE);
102 ret1 = account_type_set_small_icon_path_internal(account_type, icon_path);
103 assert_eq(ret1, ACCOUNT_ERROR_NONE);
105 ret1 = account_type_set_provider_feature_internal(account_type, contact_capability);
106 assert_eq(ret1, ACCOUNT_ERROR_NONE);
108 ret1 = account_type_set_provider_feature_internal(account_type, calendar_capability);
109 assert_eq(ret1, ACCOUNT_ERROR_NONE);
111 ret1 = account_type_insert_to_db_internal(account_type, &account_type_id);
112 assert_eq(ret1, ACCOUNT_ERROR_NONE);
114 ret1 = account_type_destroy(account_type);
115 assert_eq(ret1, ACCOUNT_ERROR_NONE);
119 void utc_account_cleanup(void)
121 int ret1 = ACCOUNT_ERROR_NONE, ret2 = ACCOUNT_ERROR_NONE;
122 ret1 = account_destroy(account);
123 if (ACCOUNT_ERROR_NONE == ret1) {
125 ret2 = account_disconnect();
126 if (ACCOUNT_ERROR_NONE == ret2) {
132 static void _account_free_text(char *text)
140 int utc_account_connect_p(void)
148 int utc_account_connect_n(void)
151 There is no way to test account_connect_n().
156 int utc_account_connect_readonly_p(void)
158 int ret = ACCOUNT_ERROR_NONE;
161 ret = account_disconnect();
162 assert_eq(ret, ACCOUNT_ERROR_NONE);
165 ret = account_connect_readonly();
166 assert_eq(ret, ACCOUNT_ERROR_NONE);
171 int utc_account_connect_readonly_n(void)
174 There is no way to test account_connect_readonly_n().
179 int utc_account_disconnect_p(void)
183 int ret = ACCOUNT_ERROR_NONE;
184 ret = account_disconnect();
185 assert_eq(ret, ACCOUNT_ERROR_NONE);
187 ret = account_connect();
188 assert_eq(ret, ACCOUNT_ERROR_NONE);
193 int utc_account_disconnect_n(void)
196 There is no way to test account_disconnect_n().
201 int utc_account_destroy_p(void)
203 int ret = ACCOUNT_ERROR_NONE;
204 account_h account_data = NULL;
207 ret = account_create(&account_data);
208 assert_eq(ret, ACCOUNT_ERROR_NONE);
210 ret = account_destroy(account_data);
211 assert_eq(ret, ACCOUNT_ERROR_NONE);
217 int utc_account_destroy_n(void)
221 utc_account_cleanup();
222 int ret = ACCOUNT_ERROR_NONE;
224 ret = rename("/opt/usr/dbspace/.account.db", "/opt/usr/dbspace/.account-tmp.db");
226 ret = rename("/opt/usr/dbspace/.account.db-journal", "/opt/usr/dbspace/.account-tmp.db-journal");
228 ret = account_destroy(NULL);
230 assert_neq(ret, ACCOUNT_ERROR_NONE);
232 ret = rename("/opt/usr/dbspace/.account-tmp.db", "/opt/usr/dbspace/.account.db");
233 ret = rename("/opt/usr/dbspace/.account-tmp.db-journal", "/opt/usr/dbspace/.account.db-journal");
235 utc_account_startup();
241 int utc_account_create_p(void)
249 int utc_account_create_n(void)
252 int ret = ACCOUNT_ERROR_NONE;
254 ret = account_create(NULL);
255 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
260 int utc_account_insert_to_db_p(void)
265 int ret = ACCOUNT_ERROR_NONE;
266 char* ret_user_name = NULL;
267 char* ret_package_name = NULL;
268 const char* display_name = "display_name";
269 char* ret_display_name = NULL;
270 const char* icon_path = "icon_path";
271 char* ret_icon_path = NULL;
272 const char* domain_name = "domain_name";
273 char* ret_domain_name = NULL;
274 const char* email_address = "email_address";
275 char* ret_email_address = NULL;
276 const char* source = "source";
277 char* ret_source = NULL;
278 const char* key = "key";
279 const char* value = "value";
280 char* ret_value = NULL;
281 const char* user_text = "user_text";
282 char* ret_user_text = NULL;
283 const char* access_token = "access_token";
284 char* ret_access_token = NULL;
285 const account_auth_type_e auth_type = ACCOUNT_AUTH_TYPE_OAUTH;
286 const account_auth_type_e ret_auth_type = 0;
287 const account_capability_state_e capability_state = ACCOUNT_CAPABILITY_ENABLED;
288 const account_capability_state_e ret_capability_state = 0;
289 const account_secrecy_state_e secrecy_state = ACCOUNT_SECRECY_VISIBLE;
290 const account_secrecy_state_e ret_secrecy_state = 0;
291 const account_sync_state_e sync_state = ACCOUNT_SYNC_STATUS_OFF;
292 const account_sync_state_e ret_sync_state = 0;
293 account_h ret_account = NULL;
296 ret = account_set_user_name(account, user_name);
297 assert_eq(ret, ACCOUNT_ERROR_NONE);
299 ret = account_set_package_name(account, package_name);
300 assert_eq(ret, ACCOUNT_ERROR_NONE);
302 ret = account_set_display_name(account, display_name);
303 assert_eq(ret, ACCOUNT_ERROR_NONE);
305 ret = account_set_icon_path(account, icon_path);
306 assert_eq(ret, ACCOUNT_ERROR_NONE);
308 ret = account_set_domain_name(account, domain_name);
309 assert_eq(ret, ACCOUNT_ERROR_NONE);
311 ret = account_set_email_address(account, email_address);
312 assert_eq(ret, ACCOUNT_ERROR_NONE);
314 ret = account_set_source(account, source);
315 assert_eq(ret, ACCOUNT_ERROR_NONE);
317 ret = account_set_custom(account, key, value);
318 assert_eq(ret, ACCOUNT_ERROR_NONE);
320 ret = account_set_capability(account, contact_capability, capability_state);
321 assert_eq(ret, ACCOUNT_ERROR_NONE);
323 ret = account_set_access_token(account, access_token);
324 assert_eq(ret, ACCOUNT_ERROR_NONE);
326 for (i = 0; i < 5; i++){
327 ret = account_set_user_text(account, i, user_text);
328 assert_eq(ret, ACCOUNT_ERROR_NONE);
331 for (i = 0; i < 5; i++){
332 ret = account_set_user_int(account, i, i*10);
333 assert_eq(ret, ACCOUNT_ERROR_NONE);
336 ret = account_set_auth_type(account, auth_type);
337 assert_eq(ret, ACCOUNT_ERROR_NONE);
339 ret = account_set_secret(account, secrecy_state);
340 assert_eq(ret, ACCOUNT_ERROR_NONE);
342 ret = account_set_sync_support(account, sync_state);
343 assert_eq(ret, ACCOUNT_ERROR_NONE);
345 ret = account_insert_to_db(account, &account_id);
346 assert_eq(ret, ACCOUNT_ERROR_NONE);
348 ret = account_destroy(account);
349 assert_eq(ret, ACCOUNT_ERROR_NONE);
351 ret = account_create(&ret_account);
352 assert_eq(ret, ACCOUNT_ERROR_NONE);
354 ret = account_query_account_by_account_id(account_id, &ret_account);
355 assert_eq(ret, ACCOUNT_ERROR_NONE);
357 ret = account_get_user_name(ret_account, &ret_user_name);
358 assert_eq(ret, ACCOUNT_ERROR_NONE);
359 assert_eq(strcmp(ret_user_name, user_name), 0);
360 _account_free_text(ret_user_name);
362 ret = account_get_package_name(ret_account, &ret_package_name);
363 assert_eq(ret, ACCOUNT_ERROR_NONE);
364 assert_eq(strcmp(ret_package_name, package_name), 0);
365 _account_free_text(ret_package_name);
367 ret = account_get_display_name(ret_account, &ret_display_name);
368 assert_eq(ret, ACCOUNT_ERROR_NONE);
369 assert_eq(strcmp(ret_display_name, display_name), 0);
370 _account_free_text(ret_display_name);
372 ret = account_get_icon_path(ret_account, &ret_icon_path);
373 assert_eq(ret, ACCOUNT_ERROR_NONE);
374 assert_eq(strcmp(ret_icon_path, icon_path), 0);
375 _account_free_text(ret_icon_path);
377 ret = account_get_domain_name(ret_account, &ret_domain_name);
378 assert_eq(ret, ACCOUNT_ERROR_NONE);
379 assert_eq(strcmp(ret_domain_name, domain_name), 0);
380 _account_free_text(ret_domain_name);
382 ret = account_get_email_address(ret_account, &ret_email_address);
383 assert_eq(ret, ACCOUNT_ERROR_NONE);
384 assert_eq(strcmp(ret_email_address, email_address), 0);
385 _account_free_text(ret_email_address);
387 ret = account_get_source(ret_account, &ret_source);
388 assert_eq(ret, ACCOUNT_ERROR_NONE);
389 assert_eq(strcmp(ret_source, source), 0);
390 _account_free_text(ret_source);
392 ret = account_get_custom(ret_account, key, &ret_value);
393 assert_eq(ret, ACCOUNT_ERROR_NONE);
394 assert_eq(strcmp(ret_value, value), 0);
395 _account_free_text(ret_value);
397 ret = account_get_capability(ret_account, contact_capability, &ret_capability_state);
398 assert_eq(ret, ACCOUNT_ERROR_NONE);
399 assert_eq(ret_capability_state, capability_state);
401 ret = account_get_access_token(ret_account, &ret_access_token);
402 assert_eq(ret, ACCOUNT_ERROR_NONE);
403 assert_eq(strcmp(ret_access_token, access_token), 0);
404 _account_free_text(ret_access_token);
406 for (i = 0; i < 5; i++){
407 ret = account_get_user_text(ret_account, i, &ret_user_text);
408 assert_eq(ret, ACCOUNT_ERROR_NONE);
409 assert_eq(strcmp(ret_user_text, user_text), 0);
410 _account_free_text(ret_user_text);
413 for (i = 0; i < 5; i++){
414 int ret_user_int = -1;
415 ret = account_get_user_int(ret_account, i, &ret_user_int);
416 assert_eq(ret, ACCOUNT_ERROR_NONE);
417 assert_eq(ret_user_int, i*10);
420 ret = account_get_auth_type(ret_account, &ret_auth_type);
421 assert_eq(ret, ACCOUNT_ERROR_NONE);
422 assert_eq(ret_auth_type, auth_type);
424 ret = account_get_secret(ret_account, &ret_secrecy_state);
425 assert_eq(ret, ACCOUNT_ERROR_NONE);
426 assert_eq(ret_secrecy_state, secrecy_state);
428 ret = account_get_sync_support(ret_account, &ret_sync_state);
429 assert_eq(ret, ACCOUNT_ERROR_NONE);
430 assert_eq(ret_sync_state, sync_state);
432 ret = account_delete_from_db_by_id(account_id);
433 assert_eq(ret, ACCOUNT_ERROR_NONE);
438 int utc_account_insert_to_db_n(void)
443 int ret = ACCOUNT_ERROR_NONE;
445 ret = account_insert_to_db(NULL, &account_id);
446 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
448 ret = account_insert_to_db(account, NULL);
449 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
454 int utc_account_set_display_name_p(void)
458 int ret = ACCOUNT_ERROR_NONE;
459 const char* display_name = "display_name";
461 ret = account_set_display_name(account, display_name);
462 assert_eq(ret, ACCOUNT_ERROR_NONE);
467 int utc_account_set_display_name_n(void)
471 int ret = ACCOUNT_ERROR_NONE;
472 const char* display_name = "display_name";
474 ret = account_set_display_name(account, NULL);
475 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
477 ret = account_set_display_name(NULL, display_name);
478 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
483 int utc_account_set_user_name_p(void)
487 int ret = ACCOUNT_ERROR_NONE;
489 ret = account_set_user_name(account, user_name);
490 assert_eq(ret, ACCOUNT_ERROR_NONE);
495 int utc_account_set_user_name_n(void)
499 int ret = ACCOUNT_ERROR_NONE;
501 ret = account_set_user_name(account, NULL);
502 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
504 ret = account_set_user_name(NULL, user_name);
505 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
510 int utc_account_set_icon_path_p(void)
514 int ret = ACCOUNT_ERROR_NONE;
515 const char* icon_path = "icon_path";
517 ret = account_set_icon_path(account, icon_path);
518 assert_eq(ret, ACCOUNT_ERROR_NONE);
523 int utc_account_set_icon_path_n(void)
527 int ret = ACCOUNT_ERROR_NONE;
528 const char* icon_path = "icon_path";
530 ret = account_set_icon_path(account, NULL);
531 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
533 ret = account_set_icon_path(NULL, icon_path);
534 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
539 int utc_account_set_domain_name_p(void)
543 int ret = ACCOUNT_ERROR_NONE;
544 const char* domain_name = "domain_name";
546 ret = account_set_domain_name(account, domain_name);
547 assert_eq(ret, ACCOUNT_ERROR_NONE);
552 int utc_account_set_domain_name_n(void)
556 int ret = ACCOUNT_ERROR_NONE;
557 const char* domain_name = "domain_name";
559 ret = account_set_domain_name(account, NULL);
560 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
562 ret = account_set_domain_name(NULL, domain_name);
563 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
568 int utc_account_set_email_address_p(void)
572 int ret = ACCOUNT_ERROR_NONE;
573 const char* email_address = "email_address";
575 ret = account_set_email_address(account, email_address);
576 assert_eq(ret, ACCOUNT_ERROR_NONE);
581 int utc_account_set_email_address_n(void)
585 int ret = ACCOUNT_ERROR_NONE;
586 const char* email_address = "email_address";
588 ret = account_set_email_address(account, NULL);
589 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
591 ret = account_set_email_address(NULL, email_address);
592 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
597 int utc_account_set_source_p(void)
601 int ret = ACCOUNT_ERROR_NONE;
602 const char* source = "source";
604 ret = account_set_source(account, source);
605 assert_eq(ret, ACCOUNT_ERROR_NONE);
610 int utc_account_set_source_n(void)
614 int ret = ACCOUNT_ERROR_NONE;
615 const char* source = "source";
617 ret = account_set_source(account, NULL);
618 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
620 ret = account_set_source(NULL, source);
621 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
626 int utc_account_set_custom_p(void)
630 int ret = ACCOUNT_ERROR_NONE;
631 const char* key = "key";
632 const char* value = "value";
634 ret = account_set_custom(account, key, value);
635 assert_eq(ret, ACCOUNT_ERROR_NONE);
640 int utc_account_set_custom_n(void)
644 int ret = ACCOUNT_ERROR_NONE;
645 const char* key = "key";
646 const char* value = "value";
648 ret = account_set_custom(account, NULL, value);
649 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
651 ret = account_set_custom(account, key, NULL);
652 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
654 ret = account_set_custom(NULL, key, value);
655 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
660 int utc_account_get_custom_p(void)
664 int ret = ACCOUNT_ERROR_NONE;
665 const char* key = "key";
666 const char* value = "value";
667 char* ret_value = NULL;
669 ret = account_set_custom(account, key, value);
670 assert_eq(ret, ACCOUNT_ERROR_NONE);
672 ret = account_get_custom(account, key, &ret_value);
673 assert_eq(ret, ACCOUNT_ERROR_NONE);
674 assert_eq(strcmp(ret_value, value), 0);
675 _account_free_text(ret_value);
680 int utc_account_get_custom_n(void)
684 int ret = ACCOUNT_ERROR_NONE;
685 char* returned_val = NULL;
687 ret = account_get_custom(account, NULL, &returned_val);
689 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
694 static bool account_custom_cb_func (char* key, char* value, void *user_data) {
695 const char* original_value = (const char*)user_data;
696 if(strcmp(value, original_value) == 0) {
699 // g_main_loop_quit(mainloop);
705 int utc_account_get_custom_all_p(void)
709 int ret = ACCOUNT_ERROR_NONE;
710 const char* key = "key";
711 const char* value = "value";
713 ret = account_set_custom(account, key, value);
714 assert_eq(ret, ACCOUNT_ERROR_NONE);
716 // mainloop = g_main_loop_new(NULL, FALSE);
718 ret = account_get_custom_all(account, account_custom_cb_func, value);
719 // assert_eq(_is_fail, false);
721 assert_eq(ret, ACCOUNT_ERROR_NONE);
722 // int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
723 // g_main_loop_run(mainloop);
724 // g_source_remove(timeout_id);
730 int utc_account_get_custom_all_n(void)
734 int ret = ACCOUNT_ERROR_NONE;
736 ret = account_get_custom_all(account, NULL, NULL);
737 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
739 ret = account_get_custom_all(NULL, account_custom_cb_func, NULL);
740 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
745 int utc_account_set_package_name_p(void)
749 int ret = ACCOUNT_ERROR_NONE;
751 ret = account_set_package_name(account, package_name);
752 assert_eq(ret, ACCOUNT_ERROR_NONE);
757 int utc_account_set_package_name_n(void)
761 int ret = ACCOUNT_ERROR_NONE;
763 ret = account_set_package_name(account, NULL);
764 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
766 ret = account_set_package_name(NULL, package_name);
767 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
772 int utc_account_set_access_token_p(void)
776 int ret = ACCOUNT_ERROR_NONE;
777 const char* access_token = "access_token";
779 ret = account_set_access_token(account, access_token);
780 assert_eq(ret, ACCOUNT_ERROR_NONE);
785 int utc_account_set_access_token_n(void)
789 int ret = ACCOUNT_ERROR_NONE;
791 ret = account_set_access_token(account, NULL);
792 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
797 int utc_account_set_auth_type_p(void)
801 int ret = ACCOUNT_ERROR_NONE;
803 ret = account_set_auth_type(account, ACCOUNT_AUTH_TYPE_OAUTH);
804 assert_eq(ret, ACCOUNT_ERROR_NONE);
809 int utc_account_set_auth_type_n(void)
813 int ret = ACCOUNT_ERROR_NONE;
815 ret = account_set_auth_type(account, -999);
816 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
818 ret = account_set_auth_type(NULL, ACCOUNT_AUTH_TYPE_OAUTH);
819 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
824 int utc_account_set_secret_p(void)
828 int ret = ACCOUNT_ERROR_NONE;
830 ret = account_set_secret(account, ACCOUNT_SECRECY_INVISIBLE);
831 assert_eq(ret, ACCOUNT_ERROR_NONE);
836 int utc_account_set_secret_n(void)
840 int ret = ACCOUNT_ERROR_NONE;
842 ret = account_set_secret(account, -999);
843 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
845 ret = account_set_secret(NULL, ACCOUNT_SECRECY_INVISIBLE);
846 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
851 int utc_account_set_sync_support_p(void)
855 int ret = ACCOUNT_ERROR_NONE;
857 ret = account_set_sync_support(account, ACCOUNT_SYNC_STATUS_IDLE);
858 assert_eq(ret, ACCOUNT_ERROR_NONE);
863 int utc_account_set_sync_support_n(void)
867 int ret = ACCOUNT_ERROR_NONE;
869 ret = account_set_sync_support(account, -999);
870 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
872 ret = account_set_sync_support(NULL, ACCOUNT_SYNC_STATUS_IDLE);
873 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
878 int utc_account_set_user_text_p(void)
882 int ret = ACCOUNT_ERROR_NONE;
883 const char* user_text = "user_text";
886 for ( i = 0; i < 5; i++){
887 ret = account_set_user_text(account, i, user_text);
888 assert_eq(ret, ACCOUNT_ERROR_NONE);
894 int utc_account_set_user_text_n(void)
898 int ret = ACCOUNT_ERROR_NONE;
899 const char* user_text = "user_text";
902 for (i = 0; i < 5; i++){
903 ret = account_set_user_text(account, i, NULL);
904 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
906 ret = account_set_user_text(account, 100, user_text);
907 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
909 ret = account_set_user_text(NULL, 1, user_text);
910 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
915 int utc_account_set_user_int_p(void)
919 int ret = ACCOUNT_ERROR_NONE;
922 for (i = 0; i < 5; i++){
923 ret = account_set_user_int(account, i, 999);
924 assert_eq(ret, ACCOUNT_ERROR_NONE);
930 int utc_account_set_user_int_n(void)
934 int ret = ACCOUNT_ERROR_NONE;
937 for (i = 0; i < 5; i++){
938 ret = account_set_user_int(NULL, i, 999);
939 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
941 ret = account_set_user_int(account, 100, 999);
942 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
947 int utc_account_set_capability_p(void)
951 int ret = ACCOUNT_ERROR_NONE;
953 ret = account_set_capability(account, contact_capability, ACCOUNT_CAPABILITY_ENABLED);
954 assert_eq(ret, ACCOUNT_ERROR_NONE);
960 int utc_account_set_capability_n(void)
964 int ret = ACCOUNT_ERROR_NONE;
966 ret = account_set_capability(NULL, contact_capability, ACCOUNT_CAPABILITY_ENABLED);
967 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
969 ret = account_set_capability(account, NULL, ACCOUNT_CAPABILITY_ENABLED);
970 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
972 ret = account_set_capability(account, contact_capability, -1);
973 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
978 static bool capability_cb_func (const char* capability_type, account_capability_state_e capability_state, void *user_data) {
979 account_capability_state_e* _capability_state = (account_capability_state_e*)user_data;
980 if(capability_state == *_capability_state)
982 // g_main_loop_quit(mainloop);
988 int utc_account_get_capability_all_p(void)
992 int ret = ACCOUNT_ERROR_NONE;
993 const account_capability_state_e capability_state = ACCOUNT_CAPABILITY_ENABLED;
995 ret = account_set_capability(account, contact_capability, capability_state);
996 assert_eq(ret, ACCOUNT_ERROR_NONE);
997 // mainloop = g_main_loop_new(NULL, FALSE);
999 ret = account_get_capability_all(account, capability_cb_func, &capability_state);
1000 // assert_eq(_is_fail, false);
1002 assert_eq(ret, ACCOUNT_ERROR_NONE);
1003 // int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
1004 // g_main_loop_run(mainloop);
1005 // g_source_remove(timeout_id);
1011 int utc_account_get_capability_all_n(void)
1015 int ret = ACCOUNT_ERROR_NONE;
1017 ret = account_get_capability_all(NULL, capability_cb_func, NULL);
1018 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1020 ret = account_get_capability_all(account, NULL, NULL);
1021 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1026 int utc_account_get_display_name_p(void)
1030 const char* display_name = "display_name";
1031 char * ret_display_name = NULL;
1032 int ret = ACCOUNT_ERROR_NONE;
1034 ret = account_set_display_name(account, display_name);
1035 assert_eq(ret, ACCOUNT_ERROR_NONE);
1037 ret = account_get_display_name(account, &ret_display_name);
1038 assert_eq(ret, ACCOUNT_ERROR_NONE);
1039 assert_eq(strcmp(ret_display_name, display_name), 0);
1040 _account_free_text(ret_display_name);
1045 int utc_account_get_display_name_n(void)
1049 int ret = ACCOUNT_ERROR_NONE;
1050 char * display_name;
1052 ret = account_get_display_name(NULL, &display_name);
1053 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1055 ret = account_get_display_name(account, NULL);
1056 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1061 int utc_account_get_account_id_p(void)
1065 int account_id = -1;
1066 int ret_account_id = -2;
1067 int ret = ACCOUNT_ERROR_NONE;
1069 ret = account_set_user_name(account, user_name);
1070 assert_eq(ret, ACCOUNT_ERROR_NONE);
1072 ret = account_insert_to_db(account, &account_id);
1073 assert_eq(ret, ACCOUNT_ERROR_NONE);
1075 ret = account_query_account_by_account_id(account_id, &account);
1076 assert_eq(ret, ACCOUNT_ERROR_NONE);
1078 ret = account_get_account_id(account, &ret_account_id);
1079 assert_eq(ret, ACCOUNT_ERROR_NONE);
1080 assert_eq(account_id, ret_account_id);
1082 ret = account_delete_from_db_by_id(account_id);
1083 assert_eq(ret, ACCOUNT_ERROR_NONE);
1088 int utc_account_get_account_id_n(void)
1092 int ret = ACCOUNT_ERROR_NONE;
1093 int account_id = -1;
1095 ret = account_get_account_id(NULL, &account_id);
1096 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1098 ret = account_get_account_id(account, NULL);
1099 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1104 int utc_account_get_user_name_p(void)
1108 char *ret_user_name;
1109 int ret = ACCOUNT_ERROR_NONE;
1111 ret = account_set_user_name(account, user_name);
1112 assert_eq(ret, ACCOUNT_ERROR_NONE);
1114 ret = account_get_user_name(account, &ret_user_name);
1115 assert_eq(ret, ACCOUNT_ERROR_NONE);
1116 assert_eq(strcmp(ret_user_name, user_name), 0);
1117 _account_free_text(ret_user_name);
1122 int utc_account_get_user_name_n(void)
1126 char *get_user_name;
1127 int ret = ACCOUNT_ERROR_NONE;
1129 ret = account_get_user_name(NULL, &get_user_name);
1130 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1132 ret = account_get_user_name(account, NULL);
1133 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1138 int utc_account_get_icon_path_p(void)
1142 char *ret_icon_path = NULL;
1143 const char* icon_path = "icon_path";
1144 int ret = ACCOUNT_ERROR_NONE;
1146 ret = account_set_icon_path(account, icon_path);
1147 assert_eq(ret, ACCOUNT_ERROR_NONE);
1149 ret = account_get_icon_path(account, &ret_icon_path);
1150 assert_eq(ret, ACCOUNT_ERROR_NONE);
1151 assert_eq(strcmp(ret_icon_path, icon_path), 0);
1152 _account_free_text(ret_icon_path);
1157 int utc_account_get_icon_path_n(void)
1161 char *ret_icon_path;
1162 int ret = ACCOUNT_ERROR_NONE;
1164 ret = account_get_icon_path(NULL, &ret_icon_path);
1165 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1167 ret = account_get_icon_path(account, NULL);
1168 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1173 int utc_account_get_domain_name_p(void)
1177 char *ret_domain_name;
1178 const char* domain_name = "domain_name";
1179 int ret = ACCOUNT_ERROR_NONE;
1181 ret = account_set_domain_name(account, domain_name);
1182 assert_eq(ret, ACCOUNT_ERROR_NONE);
1184 ret = account_get_domain_name(account, &ret_domain_name);
1185 assert_eq(ret, ACCOUNT_ERROR_NONE);
1186 assert_eq(strcmp(ret_domain_name, domain_name), 0);
1187 _account_free_text(ret_domain_name);
1192 int utc_account_get_domain_name_n(void)
1197 int ret = ACCOUNT_ERROR_NONE;
1199 ret = account_get_domain_name(NULL, &domain_name);
1200 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1202 ret = account_get_domain_name(account, NULL);
1203 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1208 int utc_account_get_email_address_p(void)
1212 char *ret_email_address;
1213 const char* email_address = "email_address";
1214 int ret = ACCOUNT_ERROR_NONE;
1216 ret = account_set_email_address(account, email_address);
1217 assert_eq(ret, ACCOUNT_ERROR_NONE);
1219 ret = account_get_email_address(account, &ret_email_address);
1220 assert_eq(ret, ACCOUNT_ERROR_NONE);
1221 assert_eq(strcmp(ret_email_address, email_address), 0);
1222 _account_free_text(ret_email_address);
1227 int utc_account_get_email_address_n(void)
1231 char *ret_email_address;
1232 int ret = ACCOUNT_ERROR_NONE;
1234 ret = account_get_email_address(NULL, &ret_email_address);
1235 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1237 ret = account_get_email_address(account, NULL);
1238 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1243 int utc_account_get_source_p(void)
1247 char *ret_source = NULL;
1248 const char* source = "source";
1249 int ret = ACCOUNT_ERROR_NONE;
1251 ret = account_set_source(account, source);
1252 assert_eq(ret, ACCOUNT_ERROR_NONE);
1254 ret = account_get_source(account, &ret_source);
1255 assert_eq(ret, ACCOUNT_ERROR_NONE);
1256 assert_eq(strcmp(ret_source, source), 0);
1257 _account_free_text(ret_source);
1262 int utc_account_get_source_n(void)
1266 char *ret_source = NULL;
1267 int ret = ACCOUNT_ERROR_NONE;
1269 ret = account_get_source(NULL, &ret_source);
1270 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1272 ret = account_get_source(account, NULL);
1273 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1278 int utc_account_get_package_name_p(void)
1282 char *ret_package_name = NULL;
1283 int ret = ACCOUNT_ERROR_NONE;
1285 ret = account_set_package_name(account, package_name);
1286 assert_eq(ret, ACCOUNT_ERROR_NONE);
1288 ret = account_get_package_name(account, &ret_package_name);
1289 assert_eq(ret, ACCOUNT_ERROR_NONE);
1290 assert_eq(strcmp(ret_package_name, package_name), 0);
1291 _account_free_text(ret_package_name);
1296 int utc_account_get_package_name_n(void)
1300 char *ret_package_name = NULL;
1301 int ret = ACCOUNT_ERROR_NONE;
1303 ret = account_get_package_name(NULL, &ret_package_name);
1304 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1306 ret = account_get_package_name(account, NULL);
1307 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1312 int utc_account_get_access_token_p(void)
1316 char *ret_access_token = NULL;
1317 const char* access_token = "access_token";
1318 int ret = ACCOUNT_ERROR_NONE;
1320 ret = account_set_access_token(account, access_token);
1321 assert_eq(ret, ACCOUNT_ERROR_NONE);
1323 ret = account_get_access_token(account, &ret_access_token);
1324 assert_eq(ret, ACCOUNT_ERROR_NONE);
1325 assert_eq(strcmp(access_token, ret_access_token), 0);
1326 _account_free_text(ret_access_token);
1331 int utc_account_get_access_token_n(void)
1335 int ret = ACCOUNT_ERROR_NONE;
1336 char *ret_access_token = NULL;
1338 ret = account_get_access_token(NULL, &ret_access_token);
1339 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1341 ret = account_get_access_token(account, NULL);
1342 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1347 int utc_account_get_auth_type_p(void)
1351 account_auth_type_e auth_type;
1352 int ret = ACCOUNT_ERROR_NONE;
1354 ret = account_set_auth_type(account, ACCOUNT_AUTH_TYPE_XAUTH);
1355 assert_eq(ret, ACCOUNT_ERROR_NONE);
1357 ret = account_get_auth_type(account, &auth_type);
1358 assert_eq(ret, ACCOUNT_ERROR_NONE);
1359 assert_eq(auth_type, ACCOUNT_AUTH_TYPE_XAUTH);
1364 int utc_account_get_auth_type_n(void)
1368 account_auth_type_e auth_type;
1369 int ret = ACCOUNT_ERROR_NONE;
1371 ret = account_get_auth_type(NULL, &auth_type);
1372 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1374 ret = account_get_auth_type(account, NULL);
1375 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1380 int utc_account_get_secret_p(void)
1384 account_secrecy_state_e secret;
1385 int ret = ACCOUNT_ERROR_NONE;
1387 ret = account_set_secret(account, ACCOUNT_SECRECY_INVISIBLE);
1388 assert_eq(ret, ACCOUNT_ERROR_NONE);
1390 ret = account_get_secret(account, &secret);
1391 assert_eq(ret, ACCOUNT_ERROR_NONE);
1392 assert_eq(secret, ACCOUNT_SECRECY_INVISIBLE);
1397 int utc_account_get_sync_support_p(void)
1401 account_sync_state_e sync_support;
1402 int ret = ACCOUNT_ERROR_NONE;
1404 ret = account_set_sync_support(account, ACCOUNT_SYNC_STATUS_IDLE);
1405 assert_eq(ret, ACCOUNT_ERROR_NONE);
1407 ret = account_get_sync_support(account, &sync_support);
1408 assert_eq(ret, ACCOUNT_ERROR_NONE);
1409 assert_eq(sync_support, ACCOUNT_SYNC_STATUS_IDLE);
1414 int utc_account_get_secret_n(void)
1418 int ret = ACCOUNT_ERROR_NONE;
1419 account_secrecy_state_e secret;
1421 ret = account_get_secret(NULL, &secret);
1422 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1424 ret = account_get_secret(account, NULL);
1425 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1430 int utc_account_get_sync_support_n(void)
1434 account_sync_state_e sync_support;
1435 int ret = ACCOUNT_ERROR_NONE;
1437 ret = account_get_sync_support(NULL, &sync_support);
1438 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1440 ret = account_get_sync_support(account, NULL);
1441 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1446 int utc_account_get_user_text_p(void)
1450 char *ret_user_text = NULL;
1451 const char* user_text = "user_text";
1452 int ret = ACCOUNT_ERROR_NONE;
1455 for ( i = 0; i < 5; i++){
1456 ret = account_set_user_text(account, i, user_text);
1457 assert_eq(ret, ACCOUNT_ERROR_NONE);
1459 for ( i = 0; i < 5; i++){
1460 ret = account_get_user_text(account, i, &ret_user_text);
1461 assert_eq(ret, ACCOUNT_ERROR_NONE);
1462 assert_eq(strcmp(ret_user_text, user_text), 0);
1463 _account_free_text(ret_user_text);
1469 int utc_account_get_user_text_n(void)
1473 char *ret_user_text = NULL;
1474 int ret = ACCOUNT_ERROR_NONE;
1476 ret = account_get_user_text(NULL, 0, &ret_user_text);
1477 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1479 ret = account_get_user_text(account, 100, &ret_user_text);
1480 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1482 ret = account_get_user_text(account, 0, NULL);
1483 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1488 int utc_account_get_user_int_p(void)
1493 int ret = ACCOUNT_ERROR_NONE;
1496 for (i = 0; i < 5; i++){
1497 ret = account_set_user_int(account, i, i*10);
1498 assert_eq(ret, ACCOUNT_ERROR_NONE);
1501 for (i = 0; i < 5; i++){
1502 ret = account_get_user_int(account, i, &user_int);
1503 assert_eq(ret, ACCOUNT_ERROR_NONE);
1504 assert_eq(user_int, i*10);
1510 int utc_account_get_user_int_n(void)
1514 int ret = ACCOUNT_ERROR_NONE;
1516 ret = account_get_user_int(NULL, 0, 100);
1517 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1519 ret = account_get_user_int(account, 100, 100);
1520 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1522 ret = account_get_user_int(account, 0, NULL);
1523 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1528 static bool capability_call_back(const char* capability_type, account_capability_state_e capability_state, void *user_data)
1531 int ret = ACCOUNT_ERROR_NONE;
1532 check_fail(user_data!=NULL);
1533 check_fail(capability_type!=NULL);
1534 account_capability_state_e _capability_state = ACCOUNT_CAPABILITY_ENABLED;
1535 account_h account_data = *((account_h*)user_data);
1536 const char* capability = contact_capability;
1538 ret = account_get_package_name(account_data, &str);
1539 check_fail(ret == ACCOUNT_ERROR_NONE);
1540 check_fail(strcmp(str, package_name)==0);
1542 ret = account_get_user_name(account_data, &str);
1543 check_fail(ret == ACCOUNT_ERROR_NONE);
1544 check_fail(strcmp(str, user_name)==0);
1546 check_fail(strcmp(capability_type, capability)==0);
1547 ret = account_get_capability(account_data, capability, &_capability_state);
1548 check_fail(ret == ACCOUNT_ERROR_NONE);
1549 check_fail(_capability_state == capability_state);
1553 // g_main_loop_quit(mainloop);
1559 int utc_account_get_capability_p(void)
1563 int ret = ACCOUNT_ERROR_NONE;
1564 account_capability_state_e value;
1566 ret = account_set_capability(account, contact_capability, ACCOUNT_CAPABILITY_ENABLED);
1567 assert_eq(ret, ACCOUNT_ERROR_NONE);
1569 ret = account_get_capability(account, contact_capability, &value);
1570 assert_eq(ret, ACCOUNT_ERROR_NONE);
1571 assert_eq(value, ACCOUNT_CAPABILITY_ENABLED);
1576 int utc_account_get_capability_n(void)
1578 int ret = ACCOUNT_ERROR_NONE;
1579 account_capability_state_e value;
1581 ret = account_get_capability(NULL, contact_capability, &value);
1582 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1584 ret = account_get_capability(account, NULL, &value);
1585 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1587 ret = account_get_capability(account, contact_capability, NULL);
1588 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1593 static bool account_call_back(account_h account, void *user_data)
1595 const char* key = "key";
1597 char* comparison_str = NULL;
1599 int comparison_value = -1;
1600 int ret = ACCOUNT_ERROR_NONE;
1602 check_fail(user_data!=NULL);
1603 account_h _account = *((account_h*)user_data);
1605 ret = account_get_package_name(_account, &str);
1606 check_fail(ret == ACCOUNT_ERROR_NONE);
1607 ret = account_get_package_name(account, &comparison_str);
1608 check_fail(ret == ACCOUNT_ERROR_NONE);
1609 check_fail(strcmp(str, comparison_str)==0);
1610 _account_free_text(str);
1611 _account_free_text(comparison_str);
1613 ret = account_get_user_name(_account, &str);
1614 check_fail(ret == ACCOUNT_ERROR_NONE);
1615 ret = account_get_user_name(account, &comparison_str);
1616 check_fail(ret == ACCOUNT_ERROR_NONE);
1617 check_fail(strcmp(str, comparison_str)==0);
1618 _account_free_text(str);
1619 _account_free_text(comparison_str);
1621 ret = account_get_display_name(_account, &str);
1622 check_fail(ret == ACCOUNT_ERROR_NONE);
1623 ret = account_get_display_name(account, &comparison_str);
1624 check_fail(ret == ACCOUNT_ERROR_NONE);
1625 check_fail(strcmp(str, comparison_str)==0);
1626 _account_free_text(str);
1627 _account_free_text(comparison_str);
1629 ret = account_get_icon_path(_account, &str);
1630 check_fail(ret == ACCOUNT_ERROR_NONE);
1631 ret = account_get_icon_path(account, &comparison_str);
1632 check_fail(ret == ACCOUNT_ERROR_NONE);
1633 check_fail(strcmp(str, comparison_str)==0);
1634 _account_free_text(str);
1635 _account_free_text(comparison_str);
1637 ret = account_get_domain_name(_account, &str);
1638 check_fail(ret == ACCOUNT_ERROR_NONE);
1639 ret = account_get_domain_name(account, &comparison_str);
1640 check_fail(ret == ACCOUNT_ERROR_NONE);
1641 check_fail(strcmp(str, comparison_str)==0);
1642 _account_free_text(str);
1643 _account_free_text(comparison_str);
1645 ret = account_get_email_address(_account, &str);
1646 check_fail(ret == ACCOUNT_ERROR_NONE);
1647 ret = account_get_email_address(account, &comparison_str);
1648 check_fail(ret == ACCOUNT_ERROR_NONE);
1649 check_fail(strcmp(str, comparison_str)==0);
1650 _account_free_text(str);
1651 _account_free_text(comparison_str);
1653 ret = account_get_email_address(_account, &str);
1654 check_fail(ret == ACCOUNT_ERROR_NONE);
1655 ret = account_get_email_address(account, &comparison_str);
1656 check_fail(ret == ACCOUNT_ERROR_NONE);
1657 check_fail(strcmp(str, comparison_str)==0);
1658 _account_free_text(str);
1659 _account_free_text(comparison_str);
1661 ret = account_get_source(_account, &str);
1662 check_fail(ret == ACCOUNT_ERROR_NONE);
1663 ret = account_get_source(account, &comparison_str);
1664 check_fail(ret == ACCOUNT_ERROR_NONE);
1665 check_fail(strcmp(str, comparison_str)==0);
1666 _account_free_text(str);
1667 _account_free_text(comparison_str);
1669 ret = account_get_custom(_account, key, &str);
1670 check_fail(ret == ACCOUNT_ERROR_NONE);
1671 ret = account_get_custom(account, key, &comparison_str);
1672 check_fail_eq(ret, ACCOUNT_ERROR_NONE);
1673 check_fail(strcmp(str, comparison_str)==0);
1674 _account_free_text(str);
1675 _account_free_text(comparison_str);
1677 ret = account_get_capability(_account, contact_capability, &value);
1678 check_fail(ret == ACCOUNT_ERROR_NONE);
1679 ret = account_get_capability(account, contact_capability, &comparison_value);
1680 check_fail(ret == ACCOUNT_ERROR_NONE);
1681 check_fail(value == comparison_value);
1683 ret = account_get_access_token(_account, &str);
1684 check_fail(ret == ACCOUNT_ERROR_NONE);
1685 ret = account_get_access_token(account, &comparison_str);
1686 check_fail(ret == ACCOUNT_ERROR_NONE);
1687 check_fail(strcmp(str, comparison_str)==0);
1688 _account_free_text(str);
1689 _account_free_text(comparison_str);
1691 for (i = 0; i < 5; i++){
1692 ret = account_get_user_text(_account, i, &str);
1693 check_fail(ret == ACCOUNT_ERROR_NONE);
1694 ret = account_get_user_text(account, i, &comparison_str);
1695 check_fail(ret == ACCOUNT_ERROR_NONE);
1696 check_fail(strcmp(str, comparison_str)==0);
1697 _account_free_text(str);
1698 _account_free_text(comparison_str);
1701 for (i = 0; i < 5; i++){
1702 ret = account_get_user_int(_account, i, &value);
1703 check_fail(ret == ACCOUNT_ERROR_NONE);
1704 ret = account_get_user_int(account, i, &comparison_value);
1705 check_fail(ret == ACCOUNT_ERROR_NONE);
1706 check_fail(value == comparison_value);
1709 ret = account_get_auth_type(_account, &value);
1710 check_fail(ret == ACCOUNT_ERROR_NONE);
1711 ret = account_get_auth_type(account, &comparison_value);
1712 check_fail(ret == ACCOUNT_ERROR_NONE);
1713 check_fail(value == comparison_value);
1715 ret = account_get_secret(_account, &value);
1716 check_fail(ret == ACCOUNT_ERROR_NONE);
1717 ret = account_get_secret(account, &comparison_value);
1718 check_fail(ret == ACCOUNT_ERROR_NONE);
1719 check_fail(value == comparison_value);
1721 ret = account_get_sync_support(_account, &value);
1722 check_fail(ret == ACCOUNT_ERROR_NONE);
1723 ret = account_get_sync_support(account, &comparison_value);
1724 check_fail(ret == ACCOUNT_ERROR_NONE);
1725 check_fail(value == comparison_value);
1729 // g_main_loop_quit(mainloop);
1735 int utc_account_foreach_account_from_db_p(void)
1738 int ret = ACCOUNT_ERROR_NONE;
1739 int account_id = -1;
1740 char* ret_user_name = NULL;
1741 const char* display_name = "display_name";
1742 const char* icon_path = "icon_path";
1743 const char* domain_name = "domain_name";
1744 const char* email_address = "email_address";
1745 const char* source = "source";
1746 const char* key = "key";
1747 const char* value = "value";
1748 const char* user_text = "user_text";
1749 const char* access_token = "access_token";
1750 const account_auth_type_e auth_type = ACCOUNT_AUTH_TYPE_OAUTH;
1751 const account_capability_state_e capability_state = ACCOUNT_CAPABILITY_ENABLED;
1752 const account_secrecy_state_e secrecy_state = ACCOUNT_SECRECY_VISIBLE;
1753 const account_sync_state_e sync_state = ACCOUNT_SYNC_STATUS_OFF;
1756 ret = account_set_user_name(account, user_name);
1757 assert_eq(ret, ACCOUNT_ERROR_NONE);
1759 ret = account_set_package_name(account, package_name);
1760 assert_eq(ret, ACCOUNT_ERROR_NONE);
1762 ret = account_set_display_name(account, display_name);
1763 assert_eq(ret, ACCOUNT_ERROR_NONE);
1765 ret = account_set_icon_path(account, icon_path);
1766 assert_eq(ret, ACCOUNT_ERROR_NONE);
1768 ret = account_set_domain_name(account, domain_name);
1769 assert_eq(ret, ACCOUNT_ERROR_NONE);
1771 ret = account_set_email_address(account, email_address);
1772 assert_eq(ret, ACCOUNT_ERROR_NONE);
1774 ret = account_set_source(account, source);
1775 assert_eq(ret, ACCOUNT_ERROR_NONE);
1777 ret = account_set_custom(account, key, value);
1778 assert_eq(ret, ACCOUNT_ERROR_NONE);
1780 ret = account_set_capability(account, contact_capability, capability_state);
1781 assert_eq(ret, ACCOUNT_ERROR_NONE);
1783 ret = account_set_access_token(account, access_token);
1784 assert_eq(ret, ACCOUNT_ERROR_NONE);
1786 for (i = 0; i < 5; i++){
1787 ret = account_set_user_text(account, i, user_text);
1788 assert_eq(ret, ACCOUNT_ERROR_NONE);
1791 for (i = 0; i < 5; i++){
1792 ret = account_set_user_int(account, i, i*10);
1793 assert_eq(ret, ACCOUNT_ERROR_NONE);
1796 ret = account_set_auth_type(account, auth_type);
1797 assert_eq(ret, ACCOUNT_ERROR_NONE);
1799 ret = account_set_secret(account, secrecy_state);
1800 assert_eq(ret, ACCOUNT_ERROR_NONE);
1802 ret = account_set_sync_support(account, sync_state);
1803 assert_eq(ret, ACCOUNT_ERROR_NONE);
1805 ret = account_insert_to_db(account, &account_id);
1806 assert_eq(ret, ACCOUNT_ERROR_NONE);
1808 // mainloop = g_main_loop_new(NULL, FALSE);
1809 // assert(mainloop);
1811 ret = account_foreach_account_from_db(account_call_back, &account);
1812 // assert_eq(_is_fail, false);
1814 assert_eq(ret, ACCOUNT_ERROR_NONE);
1816 ret = account_delete_from_db_by_id(account_id);
1817 assert_eq(ret, ACCOUNT_ERROR_NONE);
1819 // int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
1820 // g_main_loop_run(mainloop);
1821 // g_source_remove(timeout_id);
1827 int utc_account_foreach_account_from_db_n(void)
1830 int ret = ACCOUNT_ERROR_NONE;
1832 ret = account_foreach_account_from_db(NULL, NULL);
1833 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1838 int utc_account_query_account_by_account_id_p(void)
1842 int ret = ACCOUNT_ERROR_NONE;
1843 int account_id = -1;
1844 account_h ret_account = NULL;
1845 char* ret_user_name = NULL;
1846 char* ret_package_name = NULL;
1847 account_capability_state_e ret_capability_type = 0;
1849 ret = account_set_user_name(account, user_name);
1850 assert_eq(ret, ACCOUNT_ERROR_NONE);
1852 ret = account_set_package_name(account, package_name);
1853 assert_eq(ret, ACCOUNT_ERROR_NONE);
1855 ret = account_set_capability(account, contact_capability, ACCOUNT_CAPABILITY_ENABLED);
1856 assert_eq(ret, ACCOUNT_ERROR_NONE);
1858 ret = account_insert_to_db(account, &account_id);
1859 assert_eq(ret, ACCOUNT_ERROR_NONE);
1861 ret = account_create(&ret_account);
1862 assert_eq(ret, ACCOUNT_ERROR_NONE);
1864 ret = account_query_account_by_account_id(account_id, &ret_account);
1865 assert_eq(ret, ACCOUNT_ERROR_NONE);
1866 ret = account_get_user_name(ret_account, &ret_user_name);
1867 assert_eq(ret, ACCOUNT_ERROR_NONE);
1868 ret = account_get_package_name(ret_account, &ret_package_name);
1869 assert_eq(ret, ACCOUNT_ERROR_NONE);
1870 ret = account_get_capability(ret_account, contact_capability, &ret_capability_type);
1871 assert_eq(ret, ACCOUNT_ERROR_NONE);
1872 assert_eq(strcmp(ret_user_name, user_name), 0);
1873 assert_eq(strcmp(ret_package_name, package_name), 0);
1874 assert_eq(ret_capability_type, ACCOUNT_CAPABILITY_ENABLED);
1875 _account_free_text(ret_user_name);
1876 _account_free_text(ret_package_name);
1877 ret = account_destroy(ret_account);
1878 assert_eq(ret, ACCOUNT_ERROR_NONE);
1880 ret = account_delete_from_db_by_id(account_id);
1881 assert_eq(ret, ACCOUNT_ERROR_NONE);
1886 int utc_account_query_account_by_account_id_n(void)
1890 int ret = ACCOUNT_ERROR_NONE;
1892 ret = account_query_account_by_account_id(-999, NULL);
1893 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1898 int utc_account_query_account_by_user_name_p(void)
1901 int ret = ACCOUNT_ERROR_NONE;
1902 int account_id = -1;
1903 char* ret_user_name = NULL;
1904 const char* display_name = "display_name";
1905 const char* icon_path = "icon_path";
1906 const char* domain_name = "domain_name";
1907 const char* email_address = "email_address";
1908 const char* source = "source";
1909 const char* key = "key";
1910 const char* value = "value";
1911 const char* user_text = "user_text";
1912 const char* access_token = "access_token";
1913 const account_auth_type_e auth_type = ACCOUNT_AUTH_TYPE_OAUTH;
1914 const account_capability_state_e capability_state = ACCOUNT_CAPABILITY_ENABLED;
1915 const account_secrecy_state_e secrecy_state = ACCOUNT_SECRECY_VISIBLE;
1916 const account_sync_state_e sync_state = ACCOUNT_SYNC_STATUS_OFF;
1919 ret = account_set_user_name(account, user_name);
1920 assert_eq(ret, ACCOUNT_ERROR_NONE);
1922 ret = account_set_package_name(account, package_name);
1923 assert_eq(ret, ACCOUNT_ERROR_NONE);
1925 ret = account_set_display_name(account, display_name);
1926 assert_eq(ret, ACCOUNT_ERROR_NONE);
1928 ret = account_set_icon_path(account, icon_path);
1929 assert_eq(ret, ACCOUNT_ERROR_NONE);
1931 ret = account_set_domain_name(account, domain_name);
1932 assert_eq(ret, ACCOUNT_ERROR_NONE);
1934 ret = account_set_email_address(account, email_address);
1935 assert_eq(ret, ACCOUNT_ERROR_NONE);
1937 ret = account_set_source(account, source);
1938 assert_eq(ret, ACCOUNT_ERROR_NONE);
1940 ret = account_set_custom(account, key, value);
1941 assert_eq(ret, ACCOUNT_ERROR_NONE);
1943 ret = account_set_capability(account, contact_capability, capability_state);
1944 assert_eq(ret, ACCOUNT_ERROR_NONE);
1946 ret = account_set_access_token(account, access_token);
1947 assert_eq(ret, ACCOUNT_ERROR_NONE);
1949 for (i = 0; i < 5; i++){
1950 ret = account_set_user_text(account, i, user_text);
1951 assert_eq(ret, ACCOUNT_ERROR_NONE);
1954 for (i = 0; i < 5; i++){
1955 ret = account_set_user_int(account, i, i*10);
1956 assert_eq(ret, ACCOUNT_ERROR_NONE);
1959 ret = account_set_auth_type(account, auth_type);
1960 assert_eq(ret, ACCOUNT_ERROR_NONE);
1962 ret = account_set_secret(account, secrecy_state);
1963 assert_eq(ret, ACCOUNT_ERROR_NONE);
1965 ret = account_set_sync_support(account, sync_state);
1966 assert_eq(ret, ACCOUNT_ERROR_NONE);
1968 ret = account_insert_to_db(account, &account_id);
1969 assert_eq(ret, ACCOUNT_ERROR_NONE);
1971 // mainloop = g_main_loop_new(NULL, FALSE);
1972 // assert(mainloop);
1974 ret = account_query_account_by_user_name(account_call_back, user_name, &account);
1975 // assert_eq(_is_fail, false);
1977 assert_eq(ret, ACCOUNT_ERROR_NONE);
1979 // int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
1980 // g_main_loop_run(mainloop);
1981 // g_source_remove(timeout_id);
1984 ret = account_delete_from_db_by_id(account_id);
1985 assert_eq(ret, ACCOUNT_ERROR_NONE);
1990 int utc_account_query_account_by_user_name_n(void)
1993 int ret = ACCOUNT_ERROR_NONE;
1995 ret = account_query_account_by_user_name(account_call_back, NULL, NULL);
1996 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1998 ret = account_query_account_by_user_name(NULL, user_name, NULL);
1999 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2004 int utc_account_query_account_by_package_name_p(void)
2007 int ret = ACCOUNT_ERROR_NONE;
2008 int account_id = -1;
2009 char* ret_user_name = NULL;
2010 const char* display_name = "display_name";
2011 const char* icon_path = "icon_path";
2012 const char* domain_name = "domain_name";
2013 const char* email_address = "email_address";
2014 const char* source = "source";
2015 const char* key = "key";
2016 const char* value = "value";
2017 const char* user_text = "user_text";
2018 const char* access_token = "access_token";
2019 const account_auth_type_e auth_type = ACCOUNT_AUTH_TYPE_OAUTH;
2020 const account_capability_state_e capability_state = ACCOUNT_CAPABILITY_ENABLED;
2021 const account_secrecy_state_e secrecy_state = ACCOUNT_SECRECY_VISIBLE;
2022 const account_sync_state_e sync_state = ACCOUNT_SYNC_STATUS_OFF;
2025 ret = account_set_user_name(account, user_name);
2026 assert_eq(ret, ACCOUNT_ERROR_NONE);
2028 ret = account_set_package_name(account, package_name);
2029 assert_eq(ret, ACCOUNT_ERROR_NONE);
2031 ret = account_set_display_name(account, display_name);
2032 assert_eq(ret, ACCOUNT_ERROR_NONE);
2034 ret = account_set_icon_path(account, icon_path);
2035 assert_eq(ret, ACCOUNT_ERROR_NONE);
2037 ret = account_set_domain_name(account, domain_name);
2038 assert_eq(ret, ACCOUNT_ERROR_NONE);
2040 ret = account_set_email_address(account, email_address);
2041 assert_eq(ret, ACCOUNT_ERROR_NONE);
2043 ret = account_set_source(account, source);
2044 assert_eq(ret, ACCOUNT_ERROR_NONE);
2046 ret = account_set_custom(account, key, value);
2047 assert_eq(ret, ACCOUNT_ERROR_NONE);
2049 ret = account_set_capability(account, contact_capability, capability_state);
2050 assert_eq(ret, ACCOUNT_ERROR_NONE);
2052 ret = account_set_access_token(account, access_token);
2053 assert_eq(ret, ACCOUNT_ERROR_NONE);
2055 for (i = 0; i < 5; i++){
2056 ret = account_set_user_text(account, i, user_text);
2057 assert_eq(ret, ACCOUNT_ERROR_NONE);
2060 for (i = 0; i < 5; i++){
2061 ret = account_set_user_int(account, i, i*10);
2062 assert_eq(ret, ACCOUNT_ERROR_NONE);
2065 ret = account_set_auth_type(account, auth_type);
2066 assert_eq(ret, ACCOUNT_ERROR_NONE);
2068 ret = account_set_secret(account, secrecy_state);
2069 assert_eq(ret, ACCOUNT_ERROR_NONE);
2071 ret = account_set_sync_support(account, sync_state);
2072 assert_eq(ret, ACCOUNT_ERROR_NONE);
2074 ret = account_insert_to_db(account, &account_id);
2075 assert_eq(ret, ACCOUNT_ERROR_NONE);
2077 // mainloop = g_main_loop_new(NULL, FALSE);
2078 // assert(mainloop);
2080 ret = account_query_account_by_package_name(account_call_back, package_name, &account);
2081 // assert_eq(_is_fail, false);
2083 assert_eq(ret, ACCOUNT_ERROR_NONE);
2085 // int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
2086 // g_main_loop_run(mainloop);
2087 // g_source_remove(timeout_id);
2090 ret = account_delete_from_db_by_id(account_id);
2091 assert_eq(ret, ACCOUNT_ERROR_NONE);
2096 int utc_account_query_account_by_package_name_n(void)
2099 int ret = ACCOUNT_ERROR_NONE;
2101 ret = account_query_account_by_package_name(account_call_back, NULL, NULL);
2102 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2104 ret = account_query_account_by_package_name(NULL, package_name, NULL);
2105 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2110 int utc_account_query_account_by_capability_p(void)
2113 int ret = ACCOUNT_ERROR_NONE;
2114 int account_id = -1;
2115 char* ret_user_name = NULL;
2116 const char* display_name = "display_name";
2117 const char* icon_path = "icon_path";
2118 const char* domain_name = "domain_name";
2119 const char* email_address = "email_address";
2120 const char* source = "source";
2121 const char* key = "key";
2122 const char* value = "value";
2123 const char* user_text = "user_text";
2124 const char* access_token = "access_token";
2125 const account_auth_type_e auth_type = ACCOUNT_AUTH_TYPE_OAUTH;
2126 const account_capability_state_e capability_state = ACCOUNT_CAPABILITY_ENABLED;
2127 const account_secrecy_state_e secrecy_state = ACCOUNT_SECRECY_VISIBLE;
2128 const account_sync_state_e sync_state = ACCOUNT_SYNC_STATUS_OFF;
2131 ret = account_set_user_name(account, user_name);
2132 assert_eq(ret, ACCOUNT_ERROR_NONE);
2134 ret = account_set_package_name(account, package_name);
2135 assert_eq(ret, ACCOUNT_ERROR_NONE);
2137 ret = account_set_display_name(account, display_name);
2138 assert_eq(ret, ACCOUNT_ERROR_NONE);
2140 ret = account_set_icon_path(account, icon_path);
2141 assert_eq(ret, ACCOUNT_ERROR_NONE);
2143 ret = account_set_domain_name(account, domain_name);
2144 assert_eq(ret, ACCOUNT_ERROR_NONE);
2146 ret = account_set_email_address(account, email_address);
2147 assert_eq(ret, ACCOUNT_ERROR_NONE);
2149 ret = account_set_source(account, source);
2150 assert_eq(ret, ACCOUNT_ERROR_NONE);
2152 ret = account_set_custom(account, key, value);
2153 assert_eq(ret, ACCOUNT_ERROR_NONE);
2155 ret = account_set_capability(account, contact_capability, capability_state);
2156 assert_eq(ret, ACCOUNT_ERROR_NONE);
2158 ret = account_set_access_token(account, access_token);
2159 assert_eq(ret, ACCOUNT_ERROR_NONE);
2161 for (i = 0; i < 5; i++){
2162 ret = account_set_user_text(account, i, user_text);
2163 assert_eq(ret, ACCOUNT_ERROR_NONE);
2166 for (i = 0; i < 5; i++){
2167 ret = account_set_user_int(account, i, i*10);
2168 assert_eq(ret, ACCOUNT_ERROR_NONE);
2171 ret = account_set_auth_type(account, auth_type);
2172 assert_eq(ret, ACCOUNT_ERROR_NONE);
2174 ret = account_set_secret(account, secrecy_state);
2175 assert_eq(ret, ACCOUNT_ERROR_NONE);
2177 ret = account_set_sync_support(account, sync_state);
2178 assert_eq(ret, ACCOUNT_ERROR_NONE);
2180 ret = account_insert_to_db(account, &account_id);
2181 assert_eq(ret, ACCOUNT_ERROR_NONE);
2183 // mainloop = g_main_loop_new(NULL, FALSE);
2184 // assert(mainloop);
2186 ret = account_query_account_by_capability(account_call_back, contact_capability, capability_state, &account);
2187 // assert_eq(_is_fail, false);
2189 assert_eq(ret, ACCOUNT_ERROR_NONE);
2191 // int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
2192 // g_main_loop_run(mainloop);
2193 // g_source_remove(timeout_id);
2196 ret = account_delete_from_db_by_id(account_id);
2197 assert_eq(ret, ACCOUNT_ERROR_NONE);
2202 int utc_account_query_account_by_capability_n(void)
2204 int ret = ACCOUNT_ERROR_NONE;
2206 ret = account_query_account_by_capability(NULL, contact_capability, ACCOUNT_CAPABILITY_ENABLED, NULL);
2207 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2209 ret = account_query_account_by_capability(account_call_back, NULL, ACCOUNT_CAPABILITY_ENABLED, NULL);
2210 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2212 ret = account_query_account_by_capability(account_call_back, contact_capability, -1, NULL);
2213 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2218 static bool account_cb_func(account_h account, void *user_data) {
2220 char* comparison_str = NULL;
2222 int comparison_value = -1;
2223 int ret = ACCOUNT_ERROR_NONE;
2224 check_fail(user_data!=NULL);
2225 account_h _account = *((account_h*)user_data);
2227 ret = account_get_package_name(_account, &str);
2228 check_fail(ret == ACCOUNT_ERROR_NONE);
2229 ret = account_get_package_name(account, &comparison_str);
2230 check_fail(ret == ACCOUNT_ERROR_NONE);
2231 check_fail(strcmp(str, comparison_str)==0);
2232 _account_free_text(str);
2233 _account_free_text(comparison_str);
2235 ret = account_get_user_name(_account, &str);
2236 check_fail(ret == ACCOUNT_ERROR_NONE);
2237 ret = account_get_user_name(account, &comparison_str);
2238 check_fail(ret == ACCOUNT_ERROR_NONE);
2239 check_fail(strcmp(str, comparison_str)==0);
2240 _account_free_text(str);
2241 _account_free_text(comparison_str);
2243 ret = account_get_capability(_account, contact_capability, &value);
2244 check_fail(ret == ACCOUNT_ERROR_NONE);
2245 ret = account_get_capability(account, contact_capability, &comparison_value);
2246 check_fail_eq(ret, ACCOUNT_ERROR_NONE);
2247 check_fail(value == comparison_value);
2250 // g_main_loop_quit(mainloop);
2256 int utc_account_query_account_by_capability_type_p(void)
2260 int ret = ACCOUNT_ERROR_NONE;
2261 int account_id = -1;
2263 ret = account_set_user_name(account, user_name);
2264 assert_eq(ret, ACCOUNT_ERROR_NONE);
2266 ret = account_set_package_name(account, package_name);
2267 assert_eq(ret, ACCOUNT_ERROR_NONE);
2269 ret = account_set_capability(account, contact_capability, ACCOUNT_CAPABILITY_ENABLED);
2270 assert_eq(ret, ACCOUNT_ERROR_NONE);
2272 ret = account_insert_to_db(account, &account_id);
2273 assert_eq(ret, ACCOUNT_ERROR_NONE);
2275 // mainloop = g_main_loop_new(NULL, FALSE);
2276 // assert(mainloop);
2278 ret = account_query_account_by_capability_type(account_cb_func, contact_capability, &account);
2279 // assert_eq(_is_fail, false);
2281 assert_eq(ret, ACCOUNT_ERROR_NONE);
2283 // int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
2284 // g_main_loop_run(mainloop);
2285 // g_source_remove(timeout_id);
2288 ret = account_delete_from_db_by_id(account_id);
2289 assert_eq(ret, ACCOUNT_ERROR_NONE);
2294 int utc_account_query_account_by_capability_type_n(void)
2296 int ret = ACCOUNT_ERROR_NONE;
2297 const char* type = "type";
2299 ret = account_query_account_by_capability_type(NULL, type, NULL);
2300 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2302 ret = account_query_account_by_capability_type(account_cb_func, NULL, NULL);
2303 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2308 int utc_account_query_capability_by_account_id_p(void)
2312 int ret = ACCOUNT_ERROR_NONE;
2313 int account_id = -1;
2314 account_capability_state_e capability_state = ACCOUNT_CAPABILITY_ENABLED;
2316 ret = account_set_user_name(account, user_name);
2317 assert_eq(ret, ACCOUNT_ERROR_NONE);
2319 ret = account_set_package_name(account, package_name);
2320 assert_eq(ret, ACCOUNT_ERROR_NONE);
2322 ret = account_set_capability(account, contact_capability, capability_state);
2323 assert_eq(ret, ACCOUNT_ERROR_NONE);
2325 ret = account_insert_to_db(account, &account_id);
2326 assert_eq(ret, ACCOUNT_ERROR_NONE);
2328 // mainloop = g_main_loop_new(NULL, FALSE);
2329 // assert(mainloop);
2331 ret = account_query_capability_by_account_id(capability_call_back, account_id, &account);
2332 // assert_eq(_is_fail, false);
2334 assert_eq(ret, ACCOUNT_ERROR_NONE);
2336 // int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
2337 // g_main_loop_run(mainloop);
2338 // g_source_remove(timeout_id);
2341 ret = account_delete_from_db_by_id(account_id);
2342 assert_eq(ret, ACCOUNT_ERROR_NONE);
2347 int utc_account_query_capability_by_account_id_n(void)
2350 int ret = ACCOUNT_ERROR_NONE;
2352 ret = account_query_capability_by_account_id(capability_call_back, -1, NULL);
2353 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2355 ret = account_query_capability_by_account_id(NULL, 1, NULL);
2356 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2361 int utc_account_get_total_count_from_db_p(void)
2365 int ret = ACCOUNT_ERROR_NONE;
2367 ret = account_get_total_count_from_db(&count);
2368 assert_eq(ret, ACCOUNT_ERROR_NONE);
2373 int utc_account_get_total_count_from_db_n(void)
2376 int ret = ACCOUNT_ERROR_NONE;
2378 ret = account_get_total_count_from_db(NULL);
2379 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2384 int utc_account_update_sync_status_by_id_p(void)
2387 int ret = ACCOUNT_ERROR_NONE;
2388 int account_id = -1;
2389 account_h ret_account = NULL;
2390 account_sync_state_e sync_state = -1;
2392 ret = account_set_user_name(account, user_name);
2393 assert_eq(ret, ACCOUNT_ERROR_NONE);
2395 ret = account_set_package_name(account, package_name);
2396 assert_eq(ret, ACCOUNT_ERROR_NONE);
2398 ret = account_insert_to_db(account, &account_id);
2399 assert_eq(ret, ACCOUNT_ERROR_NONE);
2401 ret = account_update_sync_status_by_id(account_id, ACCOUNT_SYNC_STATUS_IDLE);
2402 assert_eq(ret, ACCOUNT_ERROR_NONE);
2404 ret = account_create(&ret_account);
2405 assert_eq(ret, ACCOUNT_ERROR_NONE);
2407 ret = account_query_account_by_account_id(account_id, &ret_account);
2408 assert_eq(ret, ACCOUNT_ERROR_NONE);
2410 ret = account_get_sync_support(ret_account, &sync_state);
2411 assert_eq(ret, ACCOUNT_ERROR_NONE);
2412 assert_eq(sync_state, ACCOUNT_SYNC_STATUS_IDLE);
2414 ret = account_destroy(ret_account);
2415 assert_eq(ret, ACCOUNT_ERROR_NONE);
2417 ret = account_delete_from_db_by_id(account_id);
2418 assert_eq(ret, ACCOUNT_ERROR_NONE);
2423 int utc_account_update_sync_status_by_id_n(void)
2426 int ret = ACCOUNT_ERROR_NONE;
2428 ret = account_update_sync_status_by_id(-1, ACCOUNT_SYNC_STATUS_IDLE);
2429 assert_neq(ret, ACCOUNT_ERROR_NONE);
2434 int utc_account_delete_from_db_by_id_p(void)
2438 int account_id = -1;
2439 int ret = ACCOUNT_ERROR_NONE;
2441 ret = account_set_user_name(account, user_name);
2442 assert_eq(ret, ACCOUNT_ERROR_NONE);
2444 ret = account_set_package_name(account, package_name);
2445 assert_eq(ret, ACCOUNT_ERROR_NONE);
2447 ret = account_insert_to_db(account, &account_id);
2448 assert_eq(ret, ACCOUNT_ERROR_NONE);
2450 ret = account_delete_from_db_by_id(account_id);
2451 assert_eq(ret, ACCOUNT_ERROR_NONE);
2456 int utc_account_delete_from_db_by_id_n(void)
2459 int ret = ACCOUNT_ERROR_NONE;
2461 ret = account_delete_from_db_by_id(-1);
2462 assert_neq(ret, ACCOUNT_ERROR_NONE);
2467 int utc_account_delete_from_db_by_user_name_p(void)
2471 int account_id = -1;
2472 int ret = ACCOUNT_ERROR_NONE;
2474 ret = account_set_user_name(account, user_name);
2475 assert_eq(ret, ACCOUNT_ERROR_NONE);
2477 ret = account_insert_to_db(account, &account_id);
2478 assert_eq(ret, ACCOUNT_ERROR_NONE);
2480 ret = account_delete_from_db_by_user_name(user_name, package_name);
2481 assert_eq(ret, ACCOUNT_ERROR_NONE);
2486 int utc_account_delete_from_db_by_user_name_n(void)
2489 int ret = ACCOUNT_ERROR_NONE;
2491 ret = account_delete_from_db_by_user_name(NULL, package_name);
2492 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2497 int utc_account_delete_from_db_by_package_name_p(void)
2502 int account_id = -1;
2503 int ret = ACCOUNT_ERROR_NONE;
2505 ret = account_set_user_name(account, user_name);
2506 assert_eq(ret, ACCOUNT_ERROR_NONE);
2508 ret = account_set_package_name(account, package_name);
2509 assert_eq(ret, ACCOUNT_ERROR_NONE);
2511 ret = account_insert_to_db(account, &account_id);
2512 assert_eq(ret, ACCOUNT_ERROR_NONE);
2514 ret = account_delete_from_db_by_package_name(package_name);
2515 assert_eq(ret, ACCOUNT_ERROR_NONE);
2520 int utc_account_delete_from_db_by_package_name_n(void)
2523 int ret = ACCOUNT_ERROR_NONE;
2525 ret = account_delete_from_db_by_package_name(NULL);
2526 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2531 int utc_account_delete_from_db_by_package_name_without_permission_p(void)
2536 int account_id = -1;
2537 int ret = ACCOUNT_ERROR_NONE;
2539 ret = account_set_user_name(account, user_name);
2540 assert_eq(ret, ACCOUNT_ERROR_NONE);
2542 ret = account_set_package_name(account, package_name);
2543 assert_eq(ret, ACCOUNT_ERROR_NONE);
2545 ret = account_insert_to_db(account, &account_id);
2546 assert_eq(ret, ACCOUNT_ERROR_NONE);
2548 ret = account_delete_from_db_by_package_name_without_permission(package_name);
2549 assert_eq(ret, ACCOUNT_ERROR_NONE);
2554 int utc_account_delete_from_db_by_package_name_without_permission_n(void)
2557 int ret = ACCOUNT_ERROR_NONE;
2559 ret = account_delete_from_db_by_package_name_without_permission(NULL);
2560 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2565 int utc_account_update_to_db_by_id_p(void)
2569 int account_id = -1;
2570 int ret = ACCOUNT_ERROR_NONE;
2571 char* update_user_name = "update_user_name";
2572 char* ret_user_name = NULL;
2573 account_h ret_account = NULL;
2575 ret = account_set_user_name(account, user_name);
2576 assert_eq(ret, ACCOUNT_ERROR_NONE);
2578 ret = account_set_package_name(account, package_name);
2579 assert_eq(ret, ACCOUNT_ERROR_NONE);
2581 ret = account_insert_to_db(account, &account_id);
2582 assert_eq(ret, ACCOUNT_ERROR_NONE);
2584 ret = account_set_user_name(account, update_user_name);
2585 assert_eq(ret, ACCOUNT_ERROR_NONE);
2587 ret = account_update_to_db_by_id(account, account_id);
2588 assert_eq(ret, ACCOUNT_ERROR_NONE);
2590 ret = account_create(&ret_account);
2591 assert_eq(ret, ACCOUNT_ERROR_NONE);
2593 ret = account_query_account_by_account_id(account_id, &ret_account);
2594 assert_eq(ret, ACCOUNT_ERROR_NONE);
2596 ret = account_get_user_name(account, &ret_user_name);
2597 assert_eq(ret, ACCOUNT_ERROR_NONE);
2598 assert_eq(strcmp(ret_user_name, update_user_name), 0);
2600 _account_free_text(ret_user_name);
2601 ret = account_destroy(ret_account);
2602 assert_eq(ret, ACCOUNT_ERROR_NONE);
2604 ret = account_delete_from_db_by_id(account_id);
2605 assert_eq(ret, ACCOUNT_ERROR_NONE);
2610 int utc_account_update_to_db_by_id_n(void)
2614 int ret = ACCOUNT_ERROR_NONE;
2616 ret = account_update_to_db_by_id(account, -1);
2617 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2622 int utc_account_update_to_db_by_user_name_p(void)
2626 int account_id = -1;
2627 int ret = ACCOUNT_ERROR_NONE;
2629 char* ret_user_name = NULL;
2630 account_h ret_account = NULL;
2631 account_capability_state_e capability_state = ACCOUNT_CAPABILITY_ENABLED;
2633 ret = account_set_user_name(account, user_name);
2634 assert_eq(ret, ACCOUNT_ERROR_NONE);
2636 ret = account_set_package_name(account, package_name);
2637 assert_eq(ret, ACCOUNT_ERROR_NONE);
2639 ret = account_insert_to_db(account, &account_id);
2640 assert_eq(ret, ACCOUNT_ERROR_NONE);
2642 ret = account_set_capability(account, contact_capability, capability_state);
2643 assert_eq(ret, ACCOUNT_ERROR_NONE);
2645 ret = account_update_to_db_by_user_name(account, user_name, package_name);
2646 assert_eq(ret, ACCOUNT_ERROR_NONE);
2648 ret = account_create(&ret_account);
2649 assert_eq(ret, ACCOUNT_ERROR_NONE);
2651 ret = account_query_account_by_account_id(account_id, &ret_account);
2652 assert_eq(ret, ACCOUNT_ERROR_NONE);
2654 ret = account_get_user_name(account, &ret_user_name);
2655 assert_eq(ret, ACCOUNT_ERROR_NONE);
2656 assert_eq(strcmp(ret_user_name, user_name), 0);
2657 _account_free_text(ret_user_name);
2659 ret = account_get_capability(account, contact_capability, &value);
2660 assert_eq(ret, ACCOUNT_ERROR_NONE);
2661 assert_eq(value, ACCOUNT_CAPABILITY_ENABLED);
2663 ret = account_destroy(ret_account);
2664 assert_eq(ret, ACCOUNT_ERROR_NONE);
2666 ret = account_delete_from_db_by_id(account_id);
2667 assert_eq(ret, ACCOUNT_ERROR_NONE);
2672 int utc_account_update_to_db_by_user_name_n(void)
2676 int ret = ACCOUNT_ERROR_NONE;
2678 ret = account_update_to_db_by_user_name(account, NULL, package_name);
2679 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2686 int utc_account_subscribe_create_p(void)
2689 account_subscribe_h account_subscribe;
2690 int ret = ACCOUNT_ERROR_NONE;
2692 ret = account_subscribe_create(&account_subscribe);
2693 assert_eq(ret, ACCOUNT_ERROR_NONE);
2695 ret = account_subscribe_notification(account_subscribe, NULL, NULL);
2696 assert_eq(ret, ACCOUNT_ERROR_NONE);
2698 ret = account_unsubscribe_notification(account_subscribe);
2699 assert_eq(ret, ACCOUNT_ERROR_NONE);
2705 int utc_account_subscribe_create_n(void)
2708 int ret = ACCOUNT_ERROR_NONE;
2710 ret = account_subscribe_create(NULL);
2711 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2717 int utc_account_subscribe_notification_p(void)
2720 account_subscribe_h account_subscribe;
2721 int ret = ACCOUNT_ERROR_NONE;
2723 ret = account_subscribe_create(&account_subscribe);
2724 assert_eq(ret, ACCOUNT_ERROR_NONE);
2726 ret = account_subscribe_notification(account_subscribe, NULL, NULL);
2727 assert_eq(ret, ACCOUNT_ERROR_NONE);
2729 ret = account_unsubscribe_notification(account_subscribe);
2730 assert_eq(ret, ACCOUNT_ERROR_NONE);
2736 int utc_account_subscribe_notification_n(void)
2739 account_subscribe_h account_subscribe;
2740 int ret = ACCOUNT_ERROR_NONE;
2742 ret = account_subscribe_create(&account_subscribe);
2743 assert_eq(ret, ACCOUNT_ERROR_NONE);
2745 ret = account_subscribe_notification(NULL, NULL, NULL);
2746 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2748 ret = account_subscribe_notification(account_subscribe, NULL, NULL);
2749 assert_eq(ret, ACCOUNT_ERROR_NONE);
2751 ret = account_unsubscribe_notification(account_subscribe);
2752 assert_eq(ret, ACCOUNT_ERROR_NONE);
2757 int utc_account_unsubscribe_notification_p(void)
2760 account_subscribe_h account_subscribe;
2761 int ret = ACCOUNT_ERROR_NONE;
2763 ret = account_subscribe_create(&account_subscribe);
2764 assert_eq(ret, ACCOUNT_ERROR_NONE);
2766 ret = account_subscribe_notification(account_subscribe, NULL, NULL);
2767 assert_eq(ret, ACCOUNT_ERROR_NONE);
2769 ret = account_unsubscribe_notification(account_subscribe);
2770 assert_eq(ret, ACCOUNT_ERROR_NONE);
2776 int utc_account_unsubscribe_notification_n(void)
2779 int ret = ACCOUNT_ERROR_NONE;
2781 ret = account_unsubscribe_notification(NULL);
2782 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2787 int utc_account_type_create_p(void)
2789 account_type_h account_type = NULL;
2790 int ret = ACCOUNT_ERROR_NONE;
2792 ret = account_type_create(&account_type);
2793 assert_eq(ret, ACCOUNT_ERROR_NONE);
2795 ret = account_type_destroy(account_type);
2796 assert_eq(ret, ACCOUNT_ERROR_NONE);
2801 int utc_account_type_create_n(void)
2803 int ret = ACCOUNT_ERROR_NONE;
2805 ret = account_type_create(NULL);
2806 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2811 int utc_account_type_destroy_p(void)
2813 account_type_h account_type = NULL;
2814 int ret = ACCOUNT_ERROR_NONE;
2816 ret = account_type_create(&account_type);
2817 assert_eq(ret, ACCOUNT_ERROR_NONE);
2819 ret = account_type_destroy(account_type);
2820 assert_eq(ret, ACCOUNT_ERROR_NONE);
2825 int utc_account_type_destroy_n(void)
2827 int ret = ACCOUNT_ERROR_NONE;
2829 ret = account_type_destroy(NULL);
2830 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2835 int utc_account_type_set_app_id_p(void)
2837 int ret = account_type_set_app_id(NULL, NULL);
2838 assert_eq(ret, ACCOUNT_ERROR_NONE);
2843 int utc_account_type_set_app_id_n(void)
2845 int ret = account_type_set_app_id(NULL, NULL);
2846 assert_eq(ret, ACCOUNT_ERROR_NONE);
2851 int utc_account_type_set_app_id_internal_p(void)
2853 account_type_h account_type = NULL;
2854 int ret = ACCOUNT_ERROR_NONE;
2855 const char* app_id = "application_id";
2857 ret = account_type_create(&account_type);
2858 assert_eq(ret, ACCOUNT_ERROR_NONE);
2860 ret = account_type_set_app_id_internal(account_type, app_id);
2861 assert_eq(ret, ACCOUNT_ERROR_NONE);
2863 ret = account_type_destroy(account_type);
2864 assert_eq(ret, ACCOUNT_ERROR_NONE);
2869 int utc_account_type_set_app_id_internal_n(void)
2871 account_type_h account_type = NULL;
2872 int ret = ACCOUNT_ERROR_NONE;
2873 const char* app_id = "application_id";
2875 ret = account_type_create(&account_type);
2876 assert_eq(ret, ACCOUNT_ERROR_NONE);
2878 ret = account_type_set_app_id_internal(NULL, app_id);
2879 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2881 ret = account_type_set_app_id_internal(account_type, NULL);
2882 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2884 ret = account_type_destroy(account_type);
2885 assert_eq(ret, ACCOUNT_ERROR_NONE);
2890 int utc_account_type_get_app_id_p(void)
2892 account_type_h account_type = NULL;
2893 int ret = ACCOUNT_ERROR_NONE;
2894 const char* app_id = "application_id";
2895 char* ret_app_id = NULL;
2897 ret = account_type_create(&account_type);
2898 assert_eq(ret, ACCOUNT_ERROR_NONE);
2900 ret = account_type_set_app_id_internal(account_type, app_id);
2901 assert_eq(ret, ACCOUNT_ERROR_NONE);
2903 ret = account_type_get_app_id(account_type, &ret_app_id);
2904 assert_eq(ret, ACCOUNT_ERROR_NONE);
2905 assert_eq(strcmp(ret_app_id, app_id), 0);
2906 _account_free_text(ret_app_id);
2908 ret = account_type_destroy(account_type);
2909 assert_eq(ret, ACCOUNT_ERROR_NONE);
2914 int utc_account_type_get_app_id_n(void)
2916 account_type_h account_type = NULL;
2917 int ret = ACCOUNT_ERROR_NONE;
2918 char* ret_app_id = NULL;
2920 ret = account_type_create(&account_type);
2921 assert_eq(ret, ACCOUNT_ERROR_NONE);
2923 ret = account_type_get_app_id(NULL, &ret_app_id);
2924 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2926 ret = account_type_get_app_id(account_type, NULL);
2927 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2929 ret = account_type_destroy(account_type);
2930 assert_eq(ret, ACCOUNT_ERROR_NONE);
2935 int utc_account_type_set_icon_path_p(void)
2937 int ret = account_type_set_icon_path(NULL, NULL);
2938 assert_eq(ret, ACCOUNT_ERROR_NONE);
2943 int utc_account_type_set_icon_path_n(void)
2945 int ret = account_type_set_icon_path(NULL, NULL);
2946 assert_eq(ret, ACCOUNT_ERROR_NONE);
2951 int utc_account_type_set_icon_path_internal_p(void)
2953 account_type_h account_type = NULL;
2954 int ret = ACCOUNT_ERROR_NONE;
2955 const char* icon_path = "icon_path";
2957 ret = account_type_create(&account_type);
2958 assert_eq(ret, ACCOUNT_ERROR_NONE);
2960 ret = account_type_set_icon_path_internal(account_type, icon_path);
2961 assert_eq(ret, ACCOUNT_ERROR_NONE);
2963 ret = account_type_destroy(account_type);
2964 assert_eq(ret, ACCOUNT_ERROR_NONE);
2969 int utc_account_type_set_icon_path_internal_n(void)
2971 account_type_h account_type = NULL;
2972 int ret = ACCOUNT_ERROR_NONE;
2973 const char* icon_path = "icon_path";
2975 ret = account_type_create(&account_type);
2976 assert_eq(ret, ACCOUNT_ERROR_NONE);
2978 ret = account_type_set_icon_path_internal(NULL, icon_path);
2979 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2981 ret = account_type_set_icon_path_internal(account_type, NULL);
2982 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2984 ret = account_type_destroy(account_type);
2985 assert_eq(ret, ACCOUNT_ERROR_NONE);
2990 int utc_account_type_get_icon_path_p(void)
2992 account_type_h account_type = NULL;
2993 int ret = ACCOUNT_ERROR_NONE;
2994 char* ret_icon_path = NULL;
2995 const char* icon_path = "icon_path";
2997 ret = account_type_create(&account_type);
2998 assert_eq(ret, ACCOUNT_ERROR_NONE);
3000 ret = account_type_set_icon_path_internal(account_type, icon_path);
3001 assert_eq(ret, ACCOUNT_ERROR_NONE);
3003 ret = account_type_get_icon_path(account_type, &ret_icon_path);
3004 assert_eq(ret, ACCOUNT_ERROR_NONE);
3005 assert_eq(strcmp(ret_icon_path, icon_path), 0);
3006 _account_free_text(ret_icon_path);
3008 ret = account_type_destroy(account_type);
3009 assert_eq(ret, ACCOUNT_ERROR_NONE);
3014 int utc_account_type_get_icon_path_n(void)
3016 account_type_h account_type = NULL;
3017 int ret = ACCOUNT_ERROR_NONE;
3018 char* ret_icon_path = NULL;
3020 ret = account_type_create(&account_type);
3021 assert_eq(ret, ACCOUNT_ERROR_NONE);
3023 ret = account_type_get_icon_path(NULL, &ret_icon_path);
3024 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3026 ret = account_type_get_icon_path(account_type, NULL);
3027 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3029 ret = account_type_destroy(account_type);
3030 assert_eq(ret, ACCOUNT_ERROR_NONE);
3035 int utc_account_type_set_label_p(void)
3037 int ret = account_type_set_label(NULL, NULL, NULL);
3038 assert_eq(ret, ACCOUNT_ERROR_NONE);
3043 int utc_account_type_set_label_n(void)
3045 int ret = account_type_set_label(NULL, NULL, NULL);
3046 assert_eq(ret, ACCOUNT_ERROR_NONE);
3051 int utc_account_type_set_label_internal_p(void)
3053 account_type_h account_type = NULL;
3054 int ret = ACCOUNT_ERROR_NONE;
3055 const char* label = "label";
3056 const char* locale = "locale";
3057 char* ret_label = NULL;
3059 ret = account_type_create(&account_type);
3060 assert_eq(ret, ACCOUNT_ERROR_NONE);
3062 ret = account_type_set_label_internal(account_type, label, locale);
3063 assert_eq(ret, ACCOUNT_ERROR_NONE);
3065 ret = account_type_destroy(account_type);
3066 assert_eq(ret, ACCOUNT_ERROR_NONE);
3071 int utc_account_type_set_label_internal_n(void)
3073 account_type_h account_type = NULL;
3074 int ret = ACCOUNT_ERROR_NONE;
3075 const char* label = "label";
3076 const char* locale = "locale";
3078 ret = account_type_create(&account_type);
3079 assert_eq(ret, ACCOUNT_ERROR_NONE);
3081 ret = account_type_set_label_internal(NULL, label, locale);
3082 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3084 ret = account_type_set_label_internal(account_type, NULL, locale);
3085 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3087 ret = account_type_set_label_internal(account_type, label, NULL);
3088 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3090 ret = account_type_destroy(account_type);
3091 assert_eq(ret, ACCOUNT_ERROR_NONE);
3096 int utc_account_type_get_label_by_locale_p(void)
3098 account_type_h account_type = NULL;
3099 int ret = ACCOUNT_ERROR_NONE;
3100 const char* label = "label";
3101 const char* locale = "locale";
3102 char* ret_label = NULL;
3104 ret = account_type_create(&account_type);
3105 assert_eq(ret, ACCOUNT_ERROR_NONE);
3107 ret = account_type_set_label_internal(account_type, label, locale);
3108 assert_eq(ret, ACCOUNT_ERROR_NONE);
3110 ret = account_type_get_label_by_locale(account_type, locale, &ret_label);
3111 assert_eq(ret, ACCOUNT_ERROR_NONE);
3112 assert_eq(strcmp(ret_label, label), 0);
3113 _account_free_text(ret_label);
3115 ret = account_type_destroy(account_type);
3116 assert_eq(ret, ACCOUNT_ERROR_NONE);
3121 int utc_account_type_get_label_by_locale_n(void)
3123 account_type_h account_type = NULL;
3124 int ret = ACCOUNT_ERROR_NONE;
3125 char* ret_label = NULL;
3126 const char* locale = "locale";
3128 ret = account_type_create(&account_type);
3129 assert_eq(ret, ACCOUNT_ERROR_NONE);
3131 ret = account_type_get_label_by_locale(NULL, locale, &ret_label);
3132 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3134 ret = account_type_get_label_by_locale(account_type, locale, NULL);
3135 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3137 ret = account_type_destroy(account_type);
3138 assert_eq(ret, ACCOUNT_ERROR_NONE);
3143 static bool account_label_cb_func(char* app_id, char* label, char* locale, void *user_data) {
3144 //this callback function checks that query function implements normally through confirmming whether same labels or not.
3145 if(user_data != NULL)
3147 const char* _label = (const char*)user_data;
3148 if(strcmp(label, _label)==0)
3152 // g_main_loop_quit(mainloop);
3157 int utc_account_type_get_label_p(void)
3159 account_type_h account_type = NULL;
3160 int ret = ACCOUNT_ERROR_NONE;
3161 const char* label = "label";
3162 const char* locale = "locale";
3164 ret = account_type_create(&account_type);
3165 assert_eq(ret, ACCOUNT_ERROR_NONE);
3167 ret = account_type_set_label_internal(account_type, label, locale);
3168 assert_eq(ret, ACCOUNT_ERROR_NONE);
3170 // mainloop = g_main_loop_new(NULL, FALSE);
3171 // assert(mainloop);
3173 ret = account_type_get_label(account_type, account_label_cb_func, (void*)label);
3174 // assert_eq(_is_fail, false);
3176 assert_eq(ret, ACCOUNT_ERROR_NONE);
3177 // int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
3178 // g_main_loop_run(mainloop);
3179 // g_source_remove(timeout_id);
3182 ret = account_type_destroy(account_type);
3183 assert_eq(ret, ACCOUNT_ERROR_NONE);
3188 int utc_account_type_get_label_n(void)
3190 account_type_h account_type = NULL;
3191 int ret = ACCOUNT_ERROR_NONE;
3193 ret = account_type_create(&account_type);
3194 assert_eq(ret, ACCOUNT_ERROR_NONE);
3196 ret = account_type_get_label(NULL, account_label_cb_func, NULL);
3197 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3199 ret = account_type_get_label(account_type, NULL, NULL);
3200 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3202 ret = account_type_destroy(account_type);
3203 assert_eq(ret, ACCOUNT_ERROR_NONE);
3208 int utc_account_type_set_multiple_account_support_p(void)
3210 int ret = account_type_set_multiple_account_support(NULL, true);
3211 assert_eq(ret, ACCOUNT_ERROR_NONE);
3216 int utc_account_type_set_multiple_account_support_n(void)
3218 int ret = account_type_set_multiple_account_support(NULL, true);
3219 assert_eq(ret, ACCOUNT_ERROR_NONE);
3224 int utc_account_type_set_multiple_account_support_internal_p(void)
3226 account_type_h account_type = NULL;
3227 int ret = ACCOUNT_ERROR_NONE;
3230 ret = account_type_create(&account_type);
3231 assert_eq(ret, ACCOUNT_ERROR_NONE);
3233 ret = account_type_set_multiple_account_support_internal(account_type, true);
3234 assert_eq(ret, ACCOUNT_ERROR_NONE);
3236 ret = account_type_destroy(account_type);
3237 assert_eq(ret, ACCOUNT_ERROR_NONE);
3242 int utc_account_type_set_multiple_account_support_internal_n(void)
3244 int ret = ACCOUNT_ERROR_NONE;
3246 ret = account_type_set_multiple_account_support_internal(NULL, true);
3247 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3252 int utc_account_type_get_multiple_account_support_p(void)
3254 account_type_h account_type = NULL;
3255 int ret = ACCOUNT_ERROR_NONE;
3258 ret = account_type_create(&account_type);
3259 assert_eq(ret, ACCOUNT_ERROR_NONE);
3261 ret = account_type_set_multiple_account_support_internal(account_type, true);
3262 assert_eq(ret, ACCOUNT_ERROR_NONE);
3264 ret = account_type_get_multiple_account_support(account_type, &ret_val);
3265 assert_eq(ret, ACCOUNT_ERROR_NONE);
3266 assert_eq(ret_val, true);
3268 ret = account_type_destroy(account_type);
3269 assert_eq(ret, ACCOUNT_ERROR_NONE);
3274 int utc_account_type_get_multiple_account_support_n(void)
3276 account_type_h account_type = NULL;
3277 int ret = ACCOUNT_ERROR_NONE;
3278 bool ret_val = true;
3280 ret = account_type_create(&account_type);
3281 assert_eq(ret, ACCOUNT_ERROR_NONE);
3283 ret = account_type_get_multiple_account_support(NULL, &ret_val);
3284 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3286 ret = account_type_get_multiple_account_support(account_type, NULL);
3287 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3289 ret = account_type_destroy(account_type);
3290 assert_eq(ret, ACCOUNT_ERROR_NONE);
3295 static bool provider_feature_cb_func(char* app_id, char* key, void* user_data) {
3296 //this callback function checks that query function implements normally through confirmming whether same provider feature or not.
3297 if(user_data != NULL)
3299 const char* _capability = (const char*)user_data;
3300 check_fail(strcmp(key, _capability)==0)
3302 // g_main_loop_quit(mainloop);
3309 int utc_account_type_set_provider_feature_p(void)
3311 int ret = account_type_set_provider_feature(NULL, NULL);
3312 assert_eq(ret, ACCOUNT_ERROR_NONE);
3317 int utc_account_type_set_provider_feature_n(void)
3319 int ret = account_type_set_provider_feature(NULL, NULL);
3320 assert_eq(ret, ACCOUNT_ERROR_NONE);
3325 int utc_account_type_set_provider_feature_internal_p(void)
3327 account_type_h account_type = NULL;
3328 int ret = ACCOUNT_ERROR_NONE;
3329 const char* provider_feature = "provider_feature";
3331 ret = account_type_create(&account_type);
3332 assert_eq(ret, ACCOUNT_ERROR_NONE);
3334 ret = account_type_set_provider_feature_internal(account_type, provider_feature);
3335 assert_eq(ret, ACCOUNT_ERROR_NONE);
3337 ret = account_type_destroy(account_type);
3338 assert_eq(ret, ACCOUNT_ERROR_NONE);
3343 int utc_account_type_set_provider_feature_internal_n(void)
3345 account_type_h account_type = NULL;
3346 int ret = ACCOUNT_ERROR_NONE;
3347 const char* provider_feature = "provider_feature";
3349 ret = account_type_create(&account_type);
3350 assert_eq(ret, ACCOUNT_ERROR_NONE);
3352 ret = account_type_set_provider_feature_internal(NULL, provider_feature);
3353 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3355 ret = account_type_set_provider_feature_internal(account_type, NULL);
3356 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3358 ret = account_type_destroy(account_type);
3359 assert_eq(ret, ACCOUNT_ERROR_NONE);
3364 int utc_account_type_get_provider_feature_all_p(void)
3366 account_type_h account_type = NULL;
3367 int ret = ACCOUNT_ERROR_NONE;
3368 const char* provider_feature = "provider_feature";
3370 ret = account_type_create(&account_type);
3371 assert_eq(ret, ACCOUNT_ERROR_NONE);
3373 ret = account_type_set_provider_feature_internal(account_type, provider_feature);
3374 assert_eq(ret, ACCOUNT_ERROR_NONE);
3376 // mainloop = g_main_loop_new(NULL, FALSE);
3377 // assert(mainloop);
3379 ret = account_type_get_provider_feature_all(account_type, provider_feature_cb_func, (void *)provider_feature);
3380 // assert_eq(_is_fail, false);
3382 assert_eq(ret, ACCOUNT_ERROR_NONE);
3383 // int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
3384 // g_main_loop_run(mainloop);
3385 // g_source_remove(timeout_id);
3388 ret = account_type_destroy(account_type);
3389 assert_eq(ret, ACCOUNT_ERROR_NONE);
3394 int utc_account_type_get_provider_feature_all_n(void)
3396 account_type_h account_type = NULL;
3397 int ret = ACCOUNT_ERROR_NONE;
3399 ret = account_type_create(&account_type);
3400 assert_eq(ret, ACCOUNT_ERROR_NONE);
3402 ret = account_type_get_provider_feature_all(NULL, provider_feature_cb_func, NULL);
3403 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3405 ret = account_type_get_provider_feature_all(account_type, NULL, NULL);
3406 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3408 ret = account_type_destroy(account_type);
3409 assert_eq(ret, ACCOUNT_ERROR_NONE);
3414 int utc_account_type_set_service_provider_id_p(void)
3416 int ret = account_type_set_service_provider_id(NULL, NULL);
3417 assert_eq(ret, ACCOUNT_ERROR_NONE);
3422 int utc_account_type_set_service_provider_id_n(void)
3424 int ret = account_type_set_service_provider_id(NULL, NULL);
3425 assert_eq(ret, ACCOUNT_ERROR_NONE);
3430 int utc_account_type_set_service_provider_id_internal_p(void)
3432 account_type_h account_type = NULL;
3433 int ret = ACCOUNT_ERROR_NONE;
3434 const char* service_provider_id = "service_provider_id";
3435 char* ret_service_provider_id = NULL;
3437 ret = account_type_create(&account_type);
3438 assert_eq(ret, ACCOUNT_ERROR_NONE);
3440 ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
3441 assert_eq(ret, ACCOUNT_ERROR_NONE);
3443 ret = account_type_destroy(account_type);
3444 assert_eq(ret, ACCOUNT_ERROR_NONE);
3449 int utc_account_type_set_service_provider_id_internal_n(void)
3451 account_type_h account_type = NULL;
3452 int ret = ACCOUNT_ERROR_NONE;
3453 const char* service_provider_id = "service_provider_id";
3455 ret = account_type_create(&account_type);
3456 assert_eq(ret, ACCOUNT_ERROR_NONE);
3458 ret = account_type_set_service_provider_id_internal(NULL, service_provider_id);
3459 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3461 ret = account_type_set_service_provider_id_internal(account_type, NULL);
3462 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3464 ret = account_type_destroy(account_type);
3465 assert_eq(ret, ACCOUNT_ERROR_NONE);
3470 int utc_account_type_get_service_provider_id_p(void)
3472 account_type_h account_type = NULL;
3473 int ret = ACCOUNT_ERROR_NONE;
3474 const char* service_provider_id = "service_provider_id";
3475 char* ret_service_provider_id = NULL;
3477 ret = account_type_create(&account_type);
3478 assert_eq(ret, ACCOUNT_ERROR_NONE);
3480 ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
3481 assert_eq(ret, ACCOUNT_ERROR_NONE);
3483 ret = account_type_get_service_provider_id(account_type, &ret_service_provider_id);
3484 assert_eq(ret, ACCOUNT_ERROR_NONE);
3485 assert_eq(strcmp(ret_service_provider_id, service_provider_id), 0);
3486 _account_free_text(ret_service_provider_id);
3488 ret = account_type_destroy(account_type);
3489 assert_eq(ret, ACCOUNT_ERROR_NONE);
3494 int utc_account_type_get_service_provider_id_n(void)
3496 account_type_h account_type = NULL;
3497 int ret = ACCOUNT_ERROR_NONE;
3498 char* ret_service_provider_id = NULL;
3500 ret = account_type_create(&account_type);
3501 assert_eq(ret, ACCOUNT_ERROR_NONE);
3503 ret = account_type_get_service_provider_id(account_type, NULL);
3504 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3506 ret = account_type_get_service_provider_id(NULL, &ret_service_provider_id);
3507 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3509 ret = account_type_destroy(account_type);
3510 assert_eq(ret, ACCOUNT_ERROR_NONE);
3515 int utc_account_type_set_small_icon_path_p(void)
3517 int ret = account_type_set_small_icon_path(NULL, NULL);
3518 assert_eq(ret, ACCOUNT_ERROR_NONE);
3523 int utc_account_type_set_small_icon_path_n(void)
3525 int ret = account_type_set_small_icon_path(NULL, NULL);
3526 assert_eq(ret, ACCOUNT_ERROR_NONE);
3531 int utc_account_type_set_small_icon_path_internal_p(void)
3533 account_type_h account_type = NULL;
3534 int ret = ACCOUNT_ERROR_NONE;
3535 const char* small_icon_path = "small_icon_path";
3537 ret = account_type_create(&account_type);
3538 assert_eq(ret, ACCOUNT_ERROR_NONE);
3540 ret = account_type_set_small_icon_path_internal(account_type, small_icon_path);
3541 assert_eq(ret, ACCOUNT_ERROR_NONE);
3543 ret = account_type_destroy(account_type);
3544 assert_eq(ret, ACCOUNT_ERROR_NONE);
3549 int utc_account_type_set_small_icon_path_internal_n(void)
3551 account_type_h account_type = NULL;
3552 int ret = ACCOUNT_ERROR_NONE;
3553 const char* small_icon_path = "small_icon_path";
3555 ret = account_type_create(&account_type);
3556 assert_eq(ret, ACCOUNT_ERROR_NONE);
3558 ret = account_type_set_small_icon_path_internal(NULL, small_icon_path);
3559 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3561 ret = account_type_set_small_icon_path_internal(account_type, NULL);
3562 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3564 ret = account_type_destroy(account_type);
3565 assert_eq(ret, ACCOUNT_ERROR_NONE);
3570 int utc_account_type_get_small_icon_path_p(void)
3572 account_type_h account_type = NULL;
3573 int ret = ACCOUNT_ERROR_NONE;
3574 char* ret_small_icon_path = NULL;
3575 const char* small_icon_path = "small_icon_path";
3577 ret = account_type_create(&account_type);
3578 assert_eq(ret, ACCOUNT_ERROR_NONE);
3580 ret = account_type_set_small_icon_path_internal(account_type, small_icon_path);
3581 assert_eq(ret, ACCOUNT_ERROR_NONE);
3583 ret = account_type_get_small_icon_path(account_type, &ret_small_icon_path);
3584 assert_eq(ret, ACCOUNT_ERROR_NONE);
3585 assert_eq(strcmp(ret_small_icon_path, small_icon_path), 0);
3586 _account_free_text(ret_small_icon_path);
3588 ret = account_type_destroy(account_type);
3589 assert_eq(ret, ACCOUNT_ERROR_NONE);
3594 int utc_account_type_get_small_icon_path_n(void)
3596 account_type_h account_type = NULL;
3597 int ret = ACCOUNT_ERROR_NONE;
3598 char* ret_small_icon_path = NULL;
3600 ret = account_type_create(&account_type);
3601 assert_eq(ret, ACCOUNT_ERROR_NONE);
3603 ret = account_type_get_small_icon_path(NULL, &ret_small_icon_path);
3604 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3606 ret = account_type_get_small_icon_path(account_type, NULL);
3607 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3609 ret = account_type_destroy(account_type);
3610 assert_eq(ret, ACCOUNT_ERROR_NONE);
3615 int utc_account_type_insert_to_db_p(void)
3617 int ret = account_type_insert_to_db(NULL, NULL);
3618 assert_eq(ret, ACCOUNT_ERROR_NONE);
3623 int utc_account_type_insert_to_db_n(void)
3625 int ret = account_type_insert_to_db(NULL, NULL);
3626 assert_eq(ret, ACCOUNT_ERROR_NONE);
3631 int utc_account_type_insert_to_db_internal_p(void)
3633 account_type_h account_type = NULL;
3634 account_type_h ret_account_type = NULL;
3635 int ret = ACCOUNT_ERROR_NONE;
3636 int account_type_id = -1;
3637 const char* app_id = "app_id_insert_test";
3638 char* ret_app_id = NULL;
3639 const char* service_provider_id = TEST_PACKAGE_NAME;
3640 char* ret_service_provider_id = NULL;
3641 const char* icon_path = "icon_path";
3642 char* ret_icon_path = NULL;
3643 const char* small_icon_path = "small_icon_path";
3644 char* ret_small_icon_path = NULL;
3645 const bool multi_account_support = true;
3646 bool ret_multi_account_support = false;
3647 const char* label = "label";
3648 char* ret_label = NULL;
3649 const char* locale = "locale";
3650 char* ret_capability = NULL;
3652 ret = account_type_create(&account_type);
3653 assert_eq(ret, ACCOUNT_ERROR_NONE);
3655 ret = account_type_set_app_id_internal(account_type, app_id);
3656 assert_eq(ret, ACCOUNT_ERROR_NONE);
3658 ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
3659 assert_eq(ret, ACCOUNT_ERROR_NONE);
3661 ret = account_type_set_icon_path_internal(account_type, icon_path);
3662 assert_eq(ret, ACCOUNT_ERROR_NONE);
3664 ret = account_type_set_small_icon_path_internal(account_type, small_icon_path);
3665 assert_eq(ret, ACCOUNT_ERROR_NONE);
3667 ret = account_type_set_multiple_account_support_internal(account_type, multi_account_support);
3668 assert_eq(ret, ACCOUNT_ERROR_NONE);
3670 ret = account_type_set_label_internal(account_type, label, locale);
3671 assert_eq(ret, ACCOUNT_ERROR_NONE);
3673 ret = account_type_set_provider_feature_internal(account_type, contact_capability);
3674 assert_eq(ret, ACCOUNT_ERROR_NONE);
3676 ret = account_type_insert_to_db_internal(account_type, &account_type_id);
3677 assert_eq(ret, ACCOUNT_ERROR_NONE);
3679 ret = account_type_destroy(account_type);
3680 assert_eq(ret, ACCOUNT_ERROR_NONE);
3682 ret = account_type_create(&ret_account_type);
3683 assert_eq(ret, ACCOUNT_ERROR_NONE);
3685 ret = account_type_query_by_app_id(app_id, &ret_account_type);
3686 assert_eq(ret, ACCOUNT_ERROR_NONE);
3688 ret = account_type_get_app_id(ret_account_type, &ret_app_id);
3689 assert_eq(ret, ACCOUNT_ERROR_NONE);
3690 assert_eq(strcmp(ret_app_id, app_id), 0);
3691 _account_free_text(ret_app_id);
3693 ret = account_type_get_service_provider_id(ret_account_type, &ret_service_provider_id);
3694 assert_eq(ret, ACCOUNT_ERROR_NONE);
3695 assert_eq(strcmp(ret_service_provider_id, service_provider_id), 0);
3696 _account_free_text(ret_service_provider_id);
3698 ret = account_type_get_icon_path(ret_account_type, &ret_icon_path);
3699 assert_eq(ret, ACCOUNT_ERROR_NONE);
3700 assert_eq(strcmp(ret_icon_path, icon_path), 0);
3701 _account_free_text(ret_icon_path);
3703 ret = account_type_get_small_icon_path(account_type, &small_icon_path);
3704 assert_eq(ret, ACCOUNT_ERROR_NONE);
3705 assert_eq(strcmp(ret_small_icon_path, small_icon_path), 0);
3706 _account_free_text(ret_small_icon_path);
3708 ret = account_type_get_multiple_account_support(account_type, &ret_multi_account_support);
3709 assert_eq(ret, ACCOUNT_ERROR_NONE);
3710 assert_eq(ret_multi_account_support, multi_account_support);
3712 ret = account_type_get_label_by_locale(account_type, locale, &ret_label);
3713 assert_eq(ret, ACCOUNT_ERROR_NONE);
3714 assert_eq(strcmp(ret_label, label), 0);
3715 _account_free_text(ret_label);
3717 ret = account_type_get_provider_feature_all(account_type, provider_feature_cb_func, (void *)contact_capability);
3718 // assert_eq(_is_fail, false);
3720 assert_eq(ret, ACCOUNT_ERROR_NONE);
3723 ret = account_type_destroy(ret_account_type);
3724 assert_eq(ret, ACCOUNT_ERROR_NONE);
3726 ret = account_type_delete_by_app_id_internal(app_id);
3727 assert_eq(ret, ACCOUNT_ERROR_NONE);
3732 int utc_account_type_insert_to_db_internal_n(void)
3734 account_type_h account_type = NULL;
3735 int ret = ACCOUNT_ERROR_NONE;
3736 int account_type_id = 0;
3738 ret = account_type_create(&account_type);
3739 assert_eq(ret, ACCOUNT_ERROR_NONE);
3741 ret = account_type_insert_to_db_internal(NULL, &account_type_id);
3742 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3744 ret = account_type_insert_to_db_internal(account_type, NULL);
3745 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3747 ret = account_type_destroy(account_type);
3748 assert_eq(ret, ACCOUNT_ERROR_NONE);
3753 int utc_account_type_update_to_db_by_app_id_p(void)
3755 int ret = account_type_update_to_db_by_app_id(NULL, NULL);
3756 assert_eq(ret, ACCOUNT_ERROR_NONE);
3761 int utc_account_type_update_to_db_by_app_id_n(void)
3763 int ret = account_type_update_to_db_by_app_id(NULL, NULL);
3764 assert_eq(ret, ACCOUNT_ERROR_NONE);
3769 int utc_account_type_update_to_db_by_app_id_internal_p(void)
3771 account_type_h account_type = NULL;
3772 account_type_h ret_account_type = NULL;
3773 int ret = ACCOUNT_ERROR_NONE;
3774 int account_type_id = 0;
3775 const char* app_id = "account_type_update_by_app_id";
3776 char* ret_app_id = NULL;
3777 const char* service_provider_id = TEST_PACKAGE_NAME;
3778 char* ret_service_provider_id = NULL;
3779 const char* icon_path = "icon_path";
3780 const char* update_icon_path = "update_icon_path";
3781 char* ret_icon_path = NULL;
3782 const char* small_icon_path = "small_icon_path";
3783 const char* update_small_icon_path = "update_small_icon_path";
3784 char* ret_small_icon_path = NULL;
3785 const bool multi_account_support = true;
3786 const bool update_multi_account_support = false;
3787 bool ret_multi_account_support = true;
3788 const char* label = "label";
3789 const char* update_label = "update_label";
3790 char* ret_label = NULL;
3791 const char* locale = "locale";
3792 char* ret_capability = NULL;
3794 ret = account_type_create(&account_type);
3795 assert_eq(ret, ACCOUNT_ERROR_NONE);
3797 ret = account_type_create(&ret_account_type);
3798 assert_eq(ret, ACCOUNT_ERROR_NONE);
3800 ret = account_type_set_app_id_internal(account_type, app_id);
3801 assert_eq(ret, ACCOUNT_ERROR_NONE);
3803 ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
3804 assert_eq(ret, ACCOUNT_ERROR_NONE);
3806 ret = account_type_set_icon_path_internal(account_type, icon_path);
3807 assert_eq(ret, ACCOUNT_ERROR_NONE);
3809 ret = account_type_set_small_icon_path_internal(account_type, small_icon_path);
3810 assert_eq(ret, ACCOUNT_ERROR_NONE);
3812 ret = account_type_set_multiple_account_support_internal(account_type, multi_account_support);
3813 assert_eq(ret, ACCOUNT_ERROR_NONE);
3815 ret = account_type_set_label_internal(account_type, label, locale);
3816 assert_eq(ret, ACCOUNT_ERROR_NONE);
3818 ret = account_type_set_provider_feature_internal(account_type, contact_capability);
3819 assert_eq(ret, ACCOUNT_ERROR_NONE);
3821 ret = account_type_insert_to_db_internal(account_type, &account_type_id);
3822 assert_eq(ret, ACCOUNT_ERROR_NONE);
3824 ret = account_type_destroy(account_type);
3825 assert_eq(ret, ACCOUNT_ERROR_NONE);
3827 ret = account_type_create(&account_type);
3828 assert_eq(ret, ACCOUNT_ERROR_NONE);
3830 ret = account_type_query_by_app_id(app_id, &account_type);
3831 assert_eq(ret, ACCOUNT_ERROR_NONE);
3833 ret = account_type_set_icon_path_internal(account_type, update_icon_path);
3834 assert_eq(ret, ACCOUNT_ERROR_NONE);
3836 ret = account_type_set_small_icon_path_internal(account_type, update_small_icon_path);
3837 assert_eq(ret, ACCOUNT_ERROR_NONE);
3839 ret = account_type_set_multiple_account_support_internal(account_type, update_multi_account_support);
3840 assert_eq(ret, ACCOUNT_ERROR_NONE);
3842 ret = account_type_set_label_internal(account_type, update_label, locale);
3843 assert_eq(ret, ACCOUNT_ERROR_NONE);
3845 ret = account_type_set_provider_feature_internal(account_type, calendar_capability);
3846 assert_eq(ret, ACCOUNT_ERROR_NONE);
3848 ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
3849 assert_eq(ret, ACCOUNT_ERROR_NONE);
3851 ret = account_type_update_to_db_by_app_id_internal(account_type, app_id);
3852 assert_eq(ret, ACCOUNT_ERROR_NONE);
3854 ret = account_type_query_by_app_id(app_id, &ret_account_type);
3855 assert_eq(ret, ACCOUNT_ERROR_NONE);
3857 ret = account_type_get_app_id(ret_account_type, &ret_app_id);
3858 assert_eq(ret, ACCOUNT_ERROR_NONE);
3859 assert_eq(strcmp(ret_app_id, app_id), 0);
3860 _account_free_text(ret_app_id);
3862 ret = account_type_get_service_provider_id(ret_account_type, &ret_service_provider_id);
3863 assert_eq(ret, ACCOUNT_ERROR_NONE);
3864 assert_eq(strcmp(ret_service_provider_id, service_provider_id), 0);
3865 _account_free_text(ret_service_provider_id);
3867 ret = account_type_get_icon_path(ret_account_type, &ret_icon_path);
3868 assert_eq(ret, ACCOUNT_ERROR_NONE);
3869 assert_eq(strcmp(ret_icon_path, update_icon_path), 0);
3870 _account_free_text(ret_icon_path);
3872 ret = account_type_get_small_icon_path(ret_account_type, &ret_small_icon_path);
3873 assert_eq(ret, ACCOUNT_ERROR_NONE);
3874 assert_eq(strcmp(ret_small_icon_path, update_small_icon_path), 0);
3875 _account_free_text(ret_small_icon_path);
3877 ret = account_type_get_multiple_account_support(ret_account_type, &ret_multi_account_support);
3878 assert_eq(ret, ACCOUNT_ERROR_NONE);
3879 assert_eq(ret_multi_account_support, update_multi_account_support);
3881 ret = account_type_get_label_by_locale(account_type, locale, &ret_label);
3882 assert_eq(ret, ACCOUNT_ERROR_NONE);
3883 assert_eq(strcmp(ret_label, update_label), 0);
3884 _account_free_text(ret_label);
3886 ret = account_type_get_provider_feature_all(ret_account_type, provider_feature_cb_func, (void *)calendar_capability);
3887 // assert_eq(_is_fail, false);
3889 assert_eq(ret, ACCOUNT_ERROR_NONE);
3892 ret = account_type_destroy(account_type);
3893 assert_eq(ret, ACCOUNT_ERROR_NONE);
3895 ret = account_type_destroy(ret_account_type);
3896 assert_eq(ret, ACCOUNT_ERROR_NONE);
3898 ret = account_type_delete_by_app_id_internal(app_id);
3899 assert_eq(ret, ACCOUNT_ERROR_NONE);
3904 int utc_account_type_update_to_db_by_app_id_internal_n(void)
3906 account_type_h account_type = NULL;
3907 int ret = ACCOUNT_ERROR_NONE;
3908 const char* app_id = "small_icon_path";
3910 ret = account_type_create(&account_type);
3911 assert_eq(ret, ACCOUNT_ERROR_NONE);
3913 ret = account_type_update_to_db_by_app_id_internal(NULL, app_id);
3914 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3916 ret = account_type_update_to_db_by_app_id_internal(account_type, NULL);
3917 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3919 ret = account_type_destroy(account_type);
3920 assert_eq(ret, ACCOUNT_ERROR_NONE);
3925 int utc_account_type_query_by_app_id_p(void)
3927 account_type_h account_type = NULL;
3928 account_type_h ret_account_type = NULL;
3929 int ret = ACCOUNT_ERROR_NONE;
3930 const char* app_id = "account_type_query_by_app_id";
3931 char* ret_app_id = NULL;
3932 const char* service_provider_id = TEST_PACKAGE_NAME;
3933 char* ret_service_provider_id = NULL;
3934 int account_type_id = 0;
3936 ret = account_type_create(&account_type);
3937 assert_eq(ret, ACCOUNT_ERROR_NONE);
3939 ret = account_type_create(&ret_account_type);
3940 assert_eq(ret, ACCOUNT_ERROR_NONE);
3942 ret = account_type_set_app_id_internal(account_type, app_id);
3943 assert_eq(ret, ACCOUNT_ERROR_NONE);
3945 ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
3946 assert_eq(ret, ACCOUNT_ERROR_NONE);
3948 ret = account_type_insert_to_db_internal(account_type, &account_type_id);
3949 assert_eq(ret, ACCOUNT_ERROR_NONE);
3951 ret = account_type_query_by_app_id(app_id, &ret_account_type);
3952 assert_eq(ret, ACCOUNT_ERROR_NONE);
3954 ret = account_type_get_app_id(ret_account_type, &ret_app_id);
3955 assert_eq(ret, ACCOUNT_ERROR_NONE);
3956 assert_eq(strcmp(ret_app_id, app_id), 0);
3957 _account_free_text(ret_app_id);
3959 ret = account_type_get_service_provider_id(ret_account_type, &ret_service_provider_id);
3960 assert_eq(ret, ACCOUNT_ERROR_NONE);
3961 assert_eq(strcmp(ret_service_provider_id, service_provider_id), 0);
3962 _account_free_text(ret_service_provider_id);
3964 ret = account_type_destroy(account_type);
3965 assert_eq(ret, ACCOUNT_ERROR_NONE);
3967 ret = account_type_destroy(ret_account_type);
3968 assert_eq(ret, ACCOUNT_ERROR_NONE);
3970 ret = account_type_delete_by_app_id_internal(app_id);
3971 assert_eq(ret, ACCOUNT_ERROR_NONE);
3977 int utc_account_type_query_by_app_id_n(void)
3979 account_type_h account_type = NULL;
3980 int ret = ACCOUNT_ERROR_NONE;
3981 const char* app_id = "account_type_query_by_app_id";
3983 ret = account_type_query_by_app_id(app_id, &account_type);
3984 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3986 ret = account_type_create(&account_type);
3987 assert_eq(ret, ACCOUNT_ERROR_NONE);
3989 ret = account_type_query_by_app_id(NULL, &account_type);
3990 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3992 ret = account_type_query_by_app_id(app_id, NULL);
3993 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3995 ret = account_type_destroy(account_type);
3996 assert_eq(ret, ACCOUNT_ERROR_NONE);
4002 int utc_account_type_query_app_id_exist_p(void)
4004 account_type_h account_type = NULL;
4005 int ret = ACCOUNT_ERROR_NONE;
4006 const char* app_id = "account_type_query_app_id_exist";
4009 ret = account_type_query_app_id_exist(app_id);
4010 assert_eq(ret, ACCOUNT_ERROR_RECORD_NOT_FOUND);
4012 ret = account_type_create(&account_type);
4013 assert_eq(ret, ACCOUNT_ERROR_NONE);
4015 ret = account_type_set_app_id_internal(account_type, app_id);
4016 assert_eq(ret, ACCOUNT_ERROR_NONE);
4018 ret = account_type_insert_to_db_internal(account_type, &a_type_id);
4019 assert_eq(ret, ACCOUNT_ERROR_NONE);
4021 ret = account_type_query_app_id_exist(app_id);
4022 assert_eq(ret, ACCOUNT_ERROR_NONE);
4024 account_type_destroy(account_type);
4025 assert_eq(ret, ACCOUNT_ERROR_NONE);
4027 account_type_delete_by_app_id_internal(app_id);
4028 assert_eq(ret, ACCOUNT_ERROR_NONE);
4033 int utc_account_type_query_app_id_exist_n(void)
4035 int ret = ACCOUNT_ERROR_NONE;
4037 ret = account_type_query_app_id_exist(NULL);
4038 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4043 static bool account_type_for_query_by_provider_cb(account_type_h account_type, void *user_data)
4045 //this callback function checks that query function implements normally through confirmming whether same app_id or not.
4046 int ret = ACCOUNT_ERROR_NONE;
4047 account_type_h ret_account_type = NULL;
4048 char* app_id = NULL;
4049 char* ret_app_id = NULL;
4050 char* service_provider_id = NULL;
4051 char* ret_service_provider_id = NULL;
4052 char* icon_path = NULL;
4053 char* ret_icon_path = NULL;
4054 char* small_icon_path = NULL;
4055 char* ret_small_icon_path = NULL;
4056 bool multi_account_support = true;
4058 char* ret_label = NULL;
4059 const char* locale = "locale";
4060 char* capability = "capability";
4061 bool ret_multi_account_support = false;
4063 check_fail(account_type != NULL && user_data != NULL && user_data != NULL);
4065 ret_account_type = *((account_type_h*)user_data);
4067 ret = account_type_get_app_id(account_type, &app_id);
4068 check_fail(ret == ACCOUNT_ERROR_NONE);
4069 ret = account_type_get_app_id(ret_account_type, &ret_app_id);
4070 check_fail(ret == ACCOUNT_ERROR_NONE);
4071 check_fail(strcmp(ret_app_id, app_id)==0);
4072 _account_free_text(app_id);
4073 _account_free_text(ret_app_id);
4075 ret = account_type_get_service_provider_id(account_type, &service_provider_id);
4076 check_fail(ret == ACCOUNT_ERROR_NONE);
4077 ret = account_type_get_service_provider_id(ret_account_type, &ret_service_provider_id);
4078 check_fail(ret == ACCOUNT_ERROR_NONE);
4079 check_fail(strcmp(ret_service_provider_id, service_provider_id)==0);
4080 _account_free_text(service_provider_id);
4081 _account_free_text(ret_service_provider_id);
4083 ret = account_type_get_icon_path(account_type, &icon_path);
4084 check_fail(ret == ACCOUNT_ERROR_NONE);
4085 ret = account_type_get_icon_path(ret_account_type, &ret_icon_path);
4086 check_fail(ret == ACCOUNT_ERROR_NONE);
4087 check_fail(strcmp(ret_icon_path, icon_path)==0);
4088 _account_free_text(icon_path);
4089 _account_free_text(ret_icon_path);
4091 ret = account_type_get_small_icon_path(account_type, &small_icon_path);
4092 check_fail(ret == ACCOUNT_ERROR_NONE);
4093 ret = account_type_get_small_icon_path(ret_account_type, &ret_small_icon_path);
4094 check_fail(ret == ACCOUNT_ERROR_NONE);
4095 check_fail(strcmp(ret_small_icon_path, small_icon_path)==0);
4096 _account_free_text(small_icon_path);
4097 _account_free_text(ret_small_icon_path);
4099 ret = account_type_get_multiple_account_support(account_type, &multi_account_support);
4100 check_fail(ret == ACCOUNT_ERROR_NONE);
4101 ret = account_type_get_multiple_account_support(ret_account_type, &ret_multi_account_support);
4102 check_fail(ret == ACCOUNT_ERROR_NONE);
4103 check_fail(ret_multi_account_support == multi_account_support);
4105 ret = account_type_get_label_by_locale(account_type, locale, &label);
4106 check_fail(ret == ACCOUNT_ERROR_NONE);
4107 ret = account_type_get_label_by_locale(account_type, locale, &ret_label);
4108 check_fail(ret == ACCOUNT_ERROR_NONE);
4109 check_fail(strcmp(ret_label, label) == 0);
4110 _account_free_text(label);
4111 _account_free_text(ret_label);
4114 ret = account_type_get_provider_feature_all(account_type, provider_feature_cb_func, capability);
4115 check_fail(_is_fail == false);
4116 check_fail(ret == ACCOUNT_ERROR_NONE);
4119 ret = account_type_get_provider_feature_all(ret_account_type, provider_feature_cb_func, capability);
4120 check_fail(_is_fail == false);
4121 check_fail(ret == ACCOUNT_ERROR_NONE);
4125 // g_main_loop_quit(mainloop);
4132 int utc_account_type_query_by_provider_feature_p(void)
4134 account_type_h account_type = NULL;
4135 int ret = ACCOUNT_ERROR_NONE;
4136 const char* app_id = "account_type_query_by_provider_feature";
4137 const char* service_provider_id = TEST_PACKAGE_NAME;
4138 const char* icon_path = "icon_path";
4139 const char* small_icon_path = "small_icon_path";
4140 const char* capability = "capability";
4141 const bool multi_account_support = true;
4142 const char* label = "label";
4143 const char* locale = "locale";
4147 ret = account_type_create(&account_type);
4148 assert_eq(ret, ACCOUNT_ERROR_NONE);
4150 ret = account_type_set_app_id_internal(account_type, app_id);
4151 assert_eq(ret, ACCOUNT_ERROR_NONE);
4153 ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
4154 assert_eq(ret, ACCOUNT_ERROR_NONE);
4156 ret = account_type_set_icon_path_internal(account_type, icon_path);
4157 assert_eq(ret, ACCOUNT_ERROR_NONE);
4159 ret = account_type_set_small_icon_path_internal(account_type, small_icon_path);
4160 assert_eq(ret, ACCOUNT_ERROR_NONE);
4162 ret = account_type_set_multiple_account_support_internal(account_type, multi_account_support);
4163 assert_eq(ret, ACCOUNT_ERROR_NONE);
4165 ret = account_type_set_label_internal(account_type, label, locale);
4166 assert_eq(ret, ACCOUNT_ERROR_NONE);
4168 ret = account_type_set_provider_feature_internal(account_type, capability);
4169 assert_eq(ret, ACCOUNT_ERROR_NONE);
4171 ret = account_type_insert_to_db_internal(account_type, &a_type_id);
4172 assert_eq(ret, ACCOUNT_ERROR_NONE);
4174 ret = account_type_query_by_provider_feature(account_type_for_query_by_provider_cb, capability, &account_type);
4175 // assert_eq(_is_fail, false);
4177 assert_eq(ret, ACCOUNT_ERROR_NONE);
4181 account_type_destroy(account_type);
4182 assert_eq(ret, ACCOUNT_ERROR_NONE);
4184 account_type_delete_by_app_id_internal(app_id);
4185 assert_eq(ret, ACCOUNT_ERROR_NONE);
4191 int utc_account_type_query_by_provider_feature_n(void)
4193 int ret = ACCOUNT_ERROR_NONE;
4194 const char* key = contact_capability;
4196 ret = account_type_query_by_provider_feature(account_type_for_query_by_provider_cb, NULL, NULL);
4197 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4199 ret = account_type_query_by_provider_feature(NULL, key, NULL);
4200 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4205 static bool account_type_for_query_by_app_id_cb(char* app_id, char* label, char* locale, void *user_data)
4207 //this callback function checks that query function implements normally through confirmming whether same label or not.
4208 int ret = ACCOUNT_ERROR_NONE;
4209 account_type_h account_type = NULL;
4210 char* ret_label = NULL;
4212 check_fail( app_id!=NULL && label!=NULL && locale!=NULL && user_data!=NULL );
4213 account_type = *((account_type_h*)user_data);
4215 ret = account_type_get_label_by_locale(account_type, locale, &ret_label);
4216 check_fail(ret == ACCOUNT_ERROR_NONE);
4217 check_fail(strcmp(ret_label, label) == 0);
4218 _account_free_text(ret_label);
4225 int utc_account_type_query_label_by_app_id_p(void)
4227 account_type_h account_type = NULL;
4228 int ret = ACCOUNT_ERROR_NONE;
4231 const char* label_t = "label_test";
4232 const char* locale_t = "locale_test";
4233 const char* app_id = "account_type_query_label_by_app_id";
4234 const char* service_provider_id = TEST_PACKAGE_NAME;
4236 ret = account_type_create(&account_type);
4237 assert_eq(ret, ACCOUNT_ERROR_NONE);
4239 ret = account_type_set_label_internal(account_type, label_t, locale_t);
4240 assert_eq(ret, ACCOUNT_ERROR_NONE);
4242 ret = account_type_set_app_id_internal(account_type, app_id);
4243 assert_eq(ret, ACCOUNT_ERROR_NONE);
4245 ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
4246 assert_eq(ret, ACCOUNT_ERROR_NONE);
4248 ret = account_type_insert_to_db_internal(account_type, &a_type_id);
4249 assert_eq(ret, ACCOUNT_ERROR_NONE);
4251 ret = account_type_query_label_by_app_id(account_type_for_query_by_app_id_cb, app_id, &account_type);
4252 // assert_eq(_is_fail, false);
4254 assert_eq(ret, ACCOUNT_ERROR_NONE);
4257 account_type_destroy(account_type);
4258 assert_eq(ret, ACCOUNT_ERROR_NONE);
4260 account_type_delete_by_app_id_internal(app_id);
4261 assert_eq(ret, ACCOUNT_ERROR_NONE);
4266 int utc_account_type_query_label_by_app_id_n(void)
4268 int ret = ACCOUNT_ERROR_NONE;
4269 const char* app_id = "account_type_query_label_by_app_id";
4271 ret = account_type_query_label_by_app_id(NULL, app_id, NULL);
4272 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4274 ret = account_type_query_label_by_app_id(account_type_for_query_by_app_id_cb, NULL, NULL);
4275 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4280 int utc_account_type_query_label_by_locale_p(void)
4282 account_type_h account_type = NULL;
4283 int ret = ACCOUNT_ERROR_NONE;
4284 const char* label = "label";
4285 const char* locale = "locale";
4286 const char* app_id = "account_type_query_label_by_locale";
4287 char* ret_label = NULL;
4290 ret = account_type_create(&account_type);
4291 assert_eq(ret, ACCOUNT_ERROR_NONE);
4293 ret = account_type_set_label_internal(account_type, label, locale);
4294 assert_eq(ret, ACCOUNT_ERROR_NONE);
4296 ret = account_type_set_app_id_internal(account_type, app_id);
4297 assert_eq(ret, ACCOUNT_ERROR_NONE);
4299 ret = account_type_insert_to_db_internal(account_type, &a_type_id);
4300 assert_eq(ret, ACCOUNT_ERROR_NONE);
4302 ret = account_type_query_label_by_locale(app_id, locale, &ret_label);
4303 assert_eq(ret, ACCOUNT_ERROR_NONE);
4304 assert_eq(strcmp(ret_label, label), 0);
4305 _account_free_text(ret_label);
4307 ret = account_type_destroy(account_type);
4308 assert_eq(ret, ACCOUNT_ERROR_NONE);
4310 account_type_delete_by_app_id_internal(app_id);
4311 assert_eq(ret, ACCOUNT_ERROR_NONE);
4316 int utc_account_type_query_label_by_locale_n(void)
4318 int ret = ACCOUNT_ERROR_NONE;
4319 const char* app_id = "account_type_query_label_by_locale";
4320 const char* locale = "locale";
4321 char* ret_label = NULL;
4323 ret = account_type_get_label_by_locale(NULL, locale, &ret_label);
4324 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4326 ret = account_type_get_label_by_locale(app_id, locale, NULL);
4327 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4332 int utc_account_type_query_provider_feature_by_app_id_p(void)
4334 int ret = ACCOUNT_ERROR_NONE;
4335 account_type_h account_type = NULL;
4336 const char* app_id = "application_id";
4337 const char* provider_feature = "provider_feature";
4338 int account_type_id = -1;
4340 ret = account_type_create(&account_type);
4341 assert_eq(ret, ACCOUNT_ERROR_NONE);
4343 ret = account_type_set_app_id_internal(account_type, app_id);
4344 assert_eq(ret, ACCOUNT_ERROR_NONE);
4346 ret = account_type_set_provider_feature_internal(account_type, provider_feature);
4347 assert_eq(ret, ACCOUNT_ERROR_NONE);
4349 ret = account_type_insert_to_db_internal(account_type, &account_type_id);
4350 assert_eq(ret, ACCOUNT_ERROR_NONE);
4352 ret = account_type_query_provider_feature_by_app_id(provider_feature_cb_func, app_id, (void *)provider_feature);
4353 // assert_eq(_is_fail, false);
4355 assert_eq(ret, ACCOUNT_ERROR_NONE);
4358 ret = account_type_destroy(account_type);
4359 assert_eq(ret, ACCOUNT_ERROR_NONE);
4361 account_type_delete_by_app_id_internal(app_id);
4362 assert_eq(ret, ACCOUNT_ERROR_NONE);
4367 int utc_account_type_query_provider_feature_by_app_id_n(void)
4369 int ret = ACCOUNT_ERROR_NONE;
4370 const char* app_id = "application_id";
4372 ret = account_type_query_provider_feature_by_app_id(NULL, app_id, NULL);
4373 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4375 ret = account_type_query_provider_feature_by_app_id(provider_feature_cb_func, NULL, NULL);
4376 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4381 int utc_account_type_query_supported_feature_p(void)
4383 account_type_h account_type = NULL;
4385 int account_type_id = -1;
4386 const char* app_id = "application_id";
4387 const char* capability = "capability";
4389 ret = account_type_create(&account_type);
4390 assert_eq(ret, ACCOUNT_ERROR_NONE);
4392 ret = account_type_set_app_id_internal(account_type, app_id);
4393 assert_eq(ret, ACCOUNT_ERROR_NONE);
4395 ret = account_type_set_provider_feature_internal(account_type, capability);
4396 assert_eq(ret, ACCOUNT_ERROR_NONE);
4398 ret = account_type_insert_to_db_internal(account_type, &account_type_id);
4399 assert_eq(ret, ACCOUNT_ERROR_NONE);
4401 ret = account_type_query_supported_feature(app_id, capability);
4402 assert_eq(ret, true);
4404 ret = account_type_destroy(account_type);
4405 assert_eq(ret, ACCOUNT_ERROR_NONE);
4407 account_type_delete_by_app_id_internal(app_id);
4408 assert_eq(ret, ACCOUNT_ERROR_NONE);
4413 int utc_account_type_query_supported_feature_n(void)
4416 const char* app_id = "application_id";
4417 const char* capability = "capability";
4419 ret = account_type_query_supported_feature(NULL, capability);
4420 assert_eq(ret, FALSE);
4421 assert_eq(get_last_result(), ACCOUNT_ERROR_INVALID_PARAMETER);
4423 ret = account_type_query_supported_feature(app_id, NULL);
4424 assert_eq(ret, FALSE);
4429 int utc_account_update_to_db_by_id_ex_p(void)
4433 int account_id = -1;
4434 int ret = ACCOUNT_ERROR_NONE;
4435 char* update_user_name = "update_user_name";
4436 char* ret_user_name = NULL;
4437 account_h ret_account = NULL;
4439 ret = account_set_user_name(account, user_name);
4440 assert_eq(ret, ACCOUNT_ERROR_NONE);
4442 ret = account_set_package_name(account, package_name);
4443 assert_eq(ret, ACCOUNT_ERROR_NONE);
4445 ret = account_insert_to_db(account, &account_id);
4446 assert_eq(ret, ACCOUNT_ERROR_NONE);
4448 ret = account_set_user_name(account, update_user_name);
4449 assert_eq(ret, ACCOUNT_ERROR_NONE);
4451 ret = account_update_to_db_by_id_ex(account, account_id);
4452 assert_eq(ret, ACCOUNT_ERROR_NONE);
4454 ret = account_create(&ret_account);
4455 assert_eq(ret, ACCOUNT_ERROR_NONE);
4457 ret = account_query_account_by_account_id(account_id, &ret_account);
4458 assert_eq(ret, ACCOUNT_ERROR_NONE);
4460 ret = account_get_user_name(account, &ret_user_name);
4461 assert_eq(ret, ACCOUNT_ERROR_NONE);
4462 assert_eq(strcmp(ret_user_name, update_user_name), 0);
4464 _account_free_text(ret_user_name);
4465 ret = account_destroy(ret_account);
4466 assert_eq(ret, ACCOUNT_ERROR_NONE);
4468 ret = account_delete_from_db_by_id(account_id);
4469 assert_eq(ret, ACCOUNT_ERROR_NONE);
4474 int utc_account_update_to_db_by_id_ex_n(void)
4478 int ret = ACCOUNT_ERROR_NONE;
4480 ret = account_update_to_db_by_id_ex(account, -1);
4481 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4486 int utc_account_update_to_db_by_id_without_permission_p(void)
4490 account_h ret_account = NULL;
4491 int account_id = -1;
4492 int ret = ACCOUNT_ERROR_NONE;
4493 const char* update_user_name = "update_user_name";
4494 char* ret_user_name = NULL;
4496 ret = account_set_user_name(account, user_name);
4497 assert_eq(ret, ACCOUNT_ERROR_NONE);
4499 ret = account_set_package_name(account, package_name);
4500 assert_eq(ret, ACCOUNT_ERROR_NONE);
4502 ret = account_insert_to_db(account, &account_id);
4503 assert_eq(ret, ACCOUNT_ERROR_NONE);
4505 ret = account_set_user_name(account, update_user_name);
4506 assert_eq(ret, ACCOUNT_ERROR_NONE);
4508 ret = account_set_package_name(account, package_name);
4509 assert_eq(ret, ACCOUNT_ERROR_NONE);
4511 ret = account_update_to_db_by_id_without_permission(account, account_id);
4512 assert_eq(ret, ACCOUNT_ERROR_NONE);
4514 ret = account_create(&ret_account);
4515 assert_eq(ret, ACCOUNT_ERROR_NONE);
4517 ret = account_query_account_by_account_id(account_id, &ret_account);
4518 assert_eq(ret, ACCOUNT_ERROR_NONE);
4520 ret = account_get_user_name(ret_account, &ret_user_name);
4521 assert_eq(ret, ACCOUNT_ERROR_NONE);
4522 assert_eq(strcmp(ret_user_name, update_user_name), 0);
4523 _account_free_text(ret_user_name);
4525 ret = account_destroy(ret_account);
4526 assert_eq(ret, ACCOUNT_ERROR_NONE);
4528 ret = account_delete_from_db_by_id(account_id);
4529 assert_eq(ret, ACCOUNT_ERROR_NONE);
4534 int utc_account_update_to_db_by_id_without_permission_n(void)
4538 int ret = ACCOUNT_ERROR_NONE;
4541 ret = account_update_to_db_by_id_without_permission(NULL, account_id);
4542 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4544 ret = account_update_to_db_by_id_without_permission(account, NULL);
4545 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4550 int utc_account_type_delete_by_app_id_p(void)
4552 int ret = account_type_delete_by_app_id(NULL);
4553 assert_eq(ret, ACCOUNT_ERROR_NONE);
4558 int utc_account_type_delete_by_app_id_n(void)
4560 int ret = account_type_delete_by_app_id(NULL);
4561 assert_eq(ret, ACCOUNT_ERROR_NONE);
4566 int utc_account_type_delete_by_app_id_internal_p(void)
4568 account_type_h account_type = NULL;
4569 const char* app_id = "app_id_delete_test";
4570 int ret = ACCOUNT_ERROR_NONE;
4571 int account_type_id = -1;
4573 ret = account_type_create(&account_type);
4574 assert_eq(ret, ACCOUNT_ERROR_NONE);
4576 ret = account_type_set_app_id_internal(account_type, app_id);
4577 assert_eq(ret, ACCOUNT_ERROR_NONE);
4579 ret = account_type_insert_to_db_internal(account_type, &account_type_id);
4580 assert_eq(ret, ACCOUNT_ERROR_NONE);
4582 ret = account_type_query_app_id_exist(app_id);
4583 assert_eq(ret, ACCOUNT_ERROR_NONE);
4585 ret = account_type_destroy(account_type);
4586 assert_eq(ret, ACCOUNT_ERROR_NONE);
4588 ret = account_type_delete_by_app_id_internal(app_id);
4589 assert_eq(ret, ACCOUNT_ERROR_NONE);
4591 ret = account_type_query_app_id_exist(app_id);
4592 assert_eq(ret, ACCOUNT_ERROR_RECORD_NOT_FOUND);
4597 int utc_account_type_delete_by_app_id_internal_n(void)
4599 int ret = ACCOUNT_ERROR_NONE;
4601 ret = account_type_delete_by_app_id_internal(NULL);
4602 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4607 static bool account_type_cb_func(account_type_h account_type, void *user_data) {
4608 //this callback function checks that query function implements normally through confirmming whether same app_id or not.
4609 int ret = ACCOUNT_ERROR_NONE;
4610 account_type_h ret_account_type = NULL;
4611 char* app_id = NULL;
4612 char* ret_app_id = NULL;
4613 char* service_provider_id = NULL;
4614 char* ret_service_provider_id = NULL;
4615 char* icon_path = NULL;
4616 char* ret_icon_path = NULL;
4617 char* small_icon_path = NULL;
4618 char* ret_small_icon_path = NULL;
4619 bool multi_account_support = true;
4621 char* ret_label = NULL;
4622 const char* locale = "locale";
4623 char* capability = NULL;
4624 char* ret_capability = NULL;
4625 bool ret_multi_account_support = false;
4627 check_fail(account_type != NULL && user_data != NULL && user_data != NULL);
4629 ret_account_type = *((account_type_h*)user_data);
4631 ret = account_type_get_app_id(account_type, &app_id);
4632 check_fail(ret == ACCOUNT_ERROR_NONE);
4633 if( strcmp(app_id, TEST_PACKAGE_NAME)==0 )
4638 ret = account_type_get_app_id(ret_account_type, &ret_app_id);
4639 check_fail(ret == ACCOUNT_ERROR_NONE);
4640 check_fail(strcmp(ret_app_id, app_id)==0);
4641 _account_free_text(app_id);
4642 _account_free_text(ret_app_id);
4644 ret = account_type_get_service_provider_id(account_type, &service_provider_id);
4645 check_fail(ret == ACCOUNT_ERROR_NONE);
4646 ret = account_type_get_service_provider_id(ret_account_type, &ret_service_provider_id);
4647 check_fail(ret == ACCOUNT_ERROR_NONE);
4648 check_fail(strcmp(ret_service_provider_id, service_provider_id)==0);
4649 _account_free_text(service_provider_id);
4650 _account_free_text(ret_service_provider_id);
4652 ret = account_type_get_icon_path(account_type, &icon_path);
4653 check_fail(ret == ACCOUNT_ERROR_NONE);
4654 ret = account_type_get_icon_path(ret_account_type, &ret_icon_path);
4655 check_fail(ret == ACCOUNT_ERROR_NONE);
4656 check_fail(strcmp(ret_icon_path, icon_path)==0);
4657 _account_free_text(icon_path);
4658 _account_free_text(ret_icon_path);
4660 ret = account_type_get_small_icon_path(account_type, &small_icon_path);
4661 check_fail(ret == ACCOUNT_ERROR_NONE);
4662 ret = account_type_get_small_icon_path(ret_account_type, &ret_small_icon_path);
4663 check_fail(ret == ACCOUNT_ERROR_NONE);
4664 check_fail(strcmp(ret_small_icon_path, small_icon_path)==0);
4665 _account_free_text(small_icon_path);
4666 _account_free_text(ret_small_icon_path);
4668 ret = account_type_get_multiple_account_support(account_type, &multi_account_support);
4669 check_fail(ret == ACCOUNT_ERROR_NONE);
4670 ret = account_type_get_multiple_account_support(ret_account_type, &ret_multi_account_support);
4671 check_fail(ret == ACCOUNT_ERROR_NONE);
4672 check_fail(ret_multi_account_support == multi_account_support);
4674 ret = account_type_get_label_by_locale(account_type, locale, &label);
4675 check_fail(ret == ACCOUNT_ERROR_NONE);
4676 ret = account_type_get_label_by_locale(account_type, locale, &ret_label);
4677 check_fail(ret == ACCOUNT_ERROR_NONE);
4678 check_fail(strcmp(ret_label, label) == 0);
4679 _account_free_text(label);
4680 _account_free_text(ret_label);
4683 ret = account_type_get_provider_feature_all(account_type, provider_feature_cb_func, (void *)contact_capability);
4685 check_fail(ret == ACCOUNT_ERROR_NONE);
4686 check_fail(_is_fail == false);
4689 ret = account_type_get_provider_feature_all(account_type, provider_feature_cb_func, (void *)contact_capability);
4690 check_fail(ret == ACCOUNT_ERROR_NONE);
4691 check_fail(_is_fail == false);
4695 // g_main_loop_quit(mainloop);
4701 int utc_account_type_foreach_account_type_from_db_p(void)
4704 int ret = ACCOUNT_ERROR_NONE;
4705 int account_type_id = -1;
4706 account_type_h account_type = NULL;
4707 const char* app_id = "account_type_foreach_account_type_from_db";
4708 char* ret_app_id = NULL;
4709 const char* service_provider_id = TEST_PACKAGE_NAME;
4710 char* ret_service_provider_id = NULL;
4711 const char* icon_path = "icon_path";
4712 char* ret_icon_path = NULL;
4713 const char* small_icon_path = "small_icon_path";
4714 char* ret_small_icon_path = NULL;
4715 const bool multi_account_support = true;
4716 bool ret_multi_account_support = true;
4717 const char* label = "label";
4718 char* ret_label = NULL;
4719 const char* locale = "locale";
4720 char* ret_capability = NULL;
4722 ret = account_type_create(&account_type);
4723 assert_eq(ret, ACCOUNT_ERROR_NONE);
4725 ret = account_type_set_app_id_internal(account_type, app_id);
4726 assert_eq(ret, ACCOUNT_ERROR_NONE);
4728 ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
4729 assert_eq(ret, ACCOUNT_ERROR_NONE);
4731 ret = account_type_set_icon_path_internal(account_type, icon_path);
4732 assert_eq(ret, ACCOUNT_ERROR_NONE);
4734 ret = account_type_set_small_icon_path_internal(account_type, small_icon_path);
4735 assert_eq(ret, ACCOUNT_ERROR_NONE);
4737 ret = account_type_set_multiple_account_support_internal(account_type, multi_account_support);
4738 assert_eq(ret, ACCOUNT_ERROR_NONE);
4740 ret = account_type_set_label_internal(account_type, label, locale);
4741 assert_eq(ret, ACCOUNT_ERROR_NONE);
4743 ret = account_type_set_provider_feature_internal(account_type, contact_capability);
4744 assert_eq(ret, ACCOUNT_ERROR_NONE);
4746 ret = account_type_insert_to_db_internal(account_type, &account_type_id);
4747 assert_eq(ret, ACCOUNT_ERROR_NONE);
4751 ret = account_type_foreach_account_type_from_db(account_type_cb_func, &account_type);
4752 // assert_eq(_is_fail, false);
4754 assert_eq(ret, ACCOUNT_ERROR_NONE);
4758 ret = account_type_destroy(account_type);
4759 assert_eq(ret, ACCOUNT_ERROR_NONE);
4761 account_type_delete_by_app_id_internal(app_id);
4762 assert_eq(ret, ACCOUNT_ERROR_NONE);
4767 int utc_account_type_foreach_account_type_from_db_n(void)
4769 int ret = ACCOUNT_ERROR_NONE;
4771 ret = account_type_foreach_account_type_from_db(NULL, NULL);
4772 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);