tizen 2.4 release
[framework/account/libaccounts-svc.git] / TC / utc-accounts-svc.c
1 #include "assert.h"
2 #include <account.h>
3 #include <account_internal.h>
4 #include <account-types.h>
5 #include <account-error.h>
6 #include <string.h>
7 #include <glib.h>
8
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"
12
13 #define check_fail(exp) \
14         if (!(exp)) { \
15                 _is_fail = true; \
16                 FILE *fp = fopen(ERR_LOG,"w"); \
17                         fprintf(fp, \
18                                 "Assert fail in %s:%d\n", __FILE__, __LINE__); \
19                         fprintf(fp, \
20                                 "Following expression is not true:\n" \
21                                 "%s\n", #exp); \
22                         fclose(fp); \
23                 return false; \
24         }
25
26 #define check_fail_eq(var, ref) \
27         if (var != ref) { \
28                 FILE *fp = fopen(ERR_LOG,"w"); \
29                         fprintf(fp, \
30                                 "Assert fail in %s:%d\n", __FILE__, __LINE__); \
31                         fprintf(fp, \
32                                 "Values \"%s\" and \"%s\" are not equal:\n" \
33                                 "%s == %d, %s == %d\n", \
34                                 #var, #ref, #var, (int)var, #ref, (int)ref); \
35                         fclose(fp); \
36                 return false; \
37         }
38
39
40 #define is_callback_fail() \
41         if (_is_fail == true) \
42                 return 1;
43
44 //& set: AccountsSvc
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;
58
59 static gboolean timeout_cb(gpointer data) {
60         printf("timeout!\n");
61         _is_fail = true;
62         g_main_loop_quit((GMainLoop*)data);
63         return FALSE;
64 }
65
66 void utc_account_startup(void)
67 {
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) {
73                 connected = true;
74                 ret2 = account_create(&account);
75                 if (ACCOUNT_ERROR_NONE == ret2) {
76                         created = true;
77                 }
78         }
79
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);
83
84                 ret1 = account_type_set_app_id_internal(account_type, package_name);
85                 assert_eq(ret1, ACCOUNT_ERROR_NONE);
86
87                 ret1 = account_type_set_service_provider_id_internal(account_type, "http://www.samsung.com/");
88                 assert_eq(ret1, ACCOUNT_ERROR_NONE);
89
90                 ret1 = account_type_set_multiple_account_support_internal(account_type, true);
91                 assert_eq(ret1, ACCOUNT_ERROR_NONE);
92
93                 ret1 = account_type_set_label_internal(account_type, label_default, NULL);
94                 assert_eq(ret1, ACCOUNT_ERROR_NONE);
95
96                 ret1 = account_type_set_label_internal(account_type, label_en_gb, "en_GB");
97                 assert_eq(ret1, ACCOUNT_ERROR_NONE);
98
99                 ret1 = account_type_set_icon_path_internal(account_type, icon_path);
100                 assert_eq(ret1, ACCOUNT_ERROR_NONE);
101
102                 ret1 = account_type_set_small_icon_path_internal(account_type, icon_path);
103                 assert_eq(ret1, ACCOUNT_ERROR_NONE);
104
105                 ret1 = account_type_set_provider_feature_internal(account_type, contact_capability);
106                 assert_eq(ret1, ACCOUNT_ERROR_NONE);
107
108                 ret1 = account_type_set_provider_feature_internal(account_type, calendar_capability);
109                 assert_eq(ret1, ACCOUNT_ERROR_NONE);
110
111                 ret1 = account_type_insert_to_db_internal(account_type, &account_type_id);
112                 assert_eq(ret1, ACCOUNT_ERROR_NONE);
113
114                 ret1 = account_type_destroy(account_type);
115                 assert_eq(ret1, ACCOUNT_ERROR_NONE);
116         }
117 }
118
119 void utc_account_cleanup(void)
120 {
121         int ret1 = ACCOUNT_ERROR_NONE, ret2 = ACCOUNT_ERROR_NONE;
122         ret1 = account_destroy(account);
123         if (ACCOUNT_ERROR_NONE == ret1) {
124                 created = false;
125                 ret2 = account_disconnect();
126                 if (ACCOUNT_ERROR_NONE == ret2) {
127                         connected = false;
128                 }
129         }
130 }
131
132 static void _account_free_text(char *text)
133 {
134         if (text != NULL) {
135                 free(text);
136                 text = NULL;
137         }
138 }
139
140 int utc_account_connect_p(void)
141 {
142         assert(connected);
143
144         return 0;
145 }
146
147
148 int utc_account_connect_n(void)
149 {
150         /*
151            There is no way to test account_connect_n().
152          */
153         return 0;
154 }
155
156 int utc_account_connect_readonly_p(void)
157 {
158         int ret = ACCOUNT_ERROR_NONE;
159         if(connected)
160         {
161                 ret = account_disconnect();
162                 assert_eq(ret, ACCOUNT_ERROR_NONE);
163         }
164
165         ret = account_connect_readonly();
166         assert_eq(ret, ACCOUNT_ERROR_NONE);
167
168         return 0;
169 }
170
171 int utc_account_connect_readonly_n(void)
172 {
173         /*
174            There is no way to test account_connect_readonly_n().
175          */
176         return 0;
177 }
178
179 int utc_account_disconnect_p(void)
180 {
181         assert(connected);
182         assert(created);
183         int ret = ACCOUNT_ERROR_NONE;
184         ret = account_disconnect();
185         assert_eq(ret, ACCOUNT_ERROR_NONE);
186
187         ret = account_connect();
188         assert_eq(ret, ACCOUNT_ERROR_NONE);
189
190         return 0;
191 }
192
193 int utc_account_disconnect_n(void)
194 {
195         /*
196            There is no way to test account_disconnect_n().
197          */
198         return 0;
199 }
200
201 int utc_account_destroy_p(void)
202 {
203         int ret = ACCOUNT_ERROR_NONE;
204         account_h account_data = NULL;
205         assert(connected);
206
207         ret = account_create(&account_data);
208         assert_eq(ret, ACCOUNT_ERROR_NONE);
209
210         ret = account_destroy(account_data);
211         assert_eq(ret, ACCOUNT_ERROR_NONE);
212
213         return 0;
214 }
215
216
217 int utc_account_destroy_n(void)
218 {
219         assert(connected);
220         assert(created);
221         utc_account_cleanup();
222         int ret = ACCOUNT_ERROR_NONE;
223
224         ret = rename("/opt/usr/dbspace/.account.db", "/opt/usr/dbspace/.account-tmp.db");
225
226         ret = rename("/opt/usr/dbspace/.account.db-journal", "/opt/usr/dbspace/.account-tmp.db-journal");
227
228         ret = account_destroy(NULL);
229
230         assert_neq(ret, ACCOUNT_ERROR_NONE);
231
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");
234
235         utc_account_startup();
236
237         return 0;
238 }
239
240
241 int utc_account_create_p(void)
242 {
243         assert(connected);
244         assert(created);
245
246         return 0;
247 }
248
249 int utc_account_create_n(void)
250 {
251         assert(connected);
252         int ret = ACCOUNT_ERROR_NONE;
253
254         ret = account_create(NULL);
255         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
256
257         return 0;
258 }
259
260 int utc_account_insert_to_db_p(void)
261 {
262         assert(connected);
263         assert(created);
264         int account_id = -1;
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;
294         int i = -1;
295
296         ret = account_set_user_name(account, user_name);
297         assert_eq(ret, ACCOUNT_ERROR_NONE);
298
299         ret = account_set_package_name(account, package_name);
300         assert_eq(ret, ACCOUNT_ERROR_NONE);
301
302         ret = account_set_display_name(account, display_name);
303         assert_eq(ret, ACCOUNT_ERROR_NONE);
304
305         ret = account_set_icon_path(account, icon_path);
306         assert_eq(ret, ACCOUNT_ERROR_NONE);
307
308         ret = account_set_domain_name(account, domain_name);
309         assert_eq(ret, ACCOUNT_ERROR_NONE);
310
311         ret = account_set_email_address(account, email_address);
312         assert_eq(ret, ACCOUNT_ERROR_NONE);
313
314         ret = account_set_source(account, source);
315         assert_eq(ret, ACCOUNT_ERROR_NONE);
316
317         ret = account_set_custom(account, key, value);
318         assert_eq(ret, ACCOUNT_ERROR_NONE);
319
320         ret = account_set_capability(account, contact_capability, capability_state);
321         assert_eq(ret, ACCOUNT_ERROR_NONE);
322
323         ret = account_set_access_token(account, access_token);
324         assert_eq(ret, ACCOUNT_ERROR_NONE);
325
326         for (i = 0; i < 5; i++){
327                 ret = account_set_user_text(account, i, user_text);
328                 assert_eq(ret, ACCOUNT_ERROR_NONE);
329         }
330
331         for (i = 0; i < 5; i++){
332                 ret = account_set_user_int(account, i, i*10);
333                 assert_eq(ret, ACCOUNT_ERROR_NONE);
334         }
335
336         ret = account_set_auth_type(account, auth_type);
337         assert_eq(ret, ACCOUNT_ERROR_NONE);
338
339         ret = account_set_secret(account, secrecy_state);
340         assert_eq(ret, ACCOUNT_ERROR_NONE);
341
342         ret = account_set_sync_support(account, sync_state);
343         assert_eq(ret, ACCOUNT_ERROR_NONE);
344
345         ret = account_insert_to_db(account, &account_id);
346         assert_eq(ret, ACCOUNT_ERROR_NONE);
347
348         ret = account_destroy(account);
349         assert_eq(ret, ACCOUNT_ERROR_NONE);
350
351         ret = account_create(&ret_account);
352         assert_eq(ret, ACCOUNT_ERROR_NONE);
353
354         ret = account_query_account_by_account_id(account_id, &ret_account);
355         assert_eq(ret, ACCOUNT_ERROR_NONE);
356
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);
361
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);
366
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);
371
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);
376
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);
381
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);
386
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);
391
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);
396
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);
400
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);
405
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);
411         }
412
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);
418         }
419
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);
423
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);
427
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);
431
432         ret = account_delete_from_db_by_id(account_id);
433         assert_eq(ret, ACCOUNT_ERROR_NONE);
434
435         return 0;
436 }
437
438 int utc_account_insert_to_db_n(void)
439 {
440         assert(connected);
441         assert(created);
442         int account_id = -1;
443         int ret = ACCOUNT_ERROR_NONE;
444
445         ret = account_insert_to_db(NULL, &account_id);
446         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
447
448         ret = account_insert_to_db(account, NULL);
449         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
450
451         return 0;
452 }
453
454 int utc_account_set_display_name_p(void)
455 {
456         assert(connected);
457         assert(created);
458         int ret = ACCOUNT_ERROR_NONE;
459         const char* display_name = "display_name";
460
461         ret = account_set_display_name(account, display_name);
462         assert_eq(ret, ACCOUNT_ERROR_NONE);
463
464         return 0;
465 }
466
467 int utc_account_set_display_name_n(void)
468 {
469         assert(connected);
470         assert(created);
471         int ret = ACCOUNT_ERROR_NONE;
472         const char* display_name = "display_name";
473
474         ret = account_set_display_name(account, NULL);
475         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
476
477         ret = account_set_display_name(NULL, display_name);
478         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
479
480         return 0;
481 }
482
483 int utc_account_set_user_name_p(void)
484 {
485         assert(connected);
486         assert(created);
487         int ret = ACCOUNT_ERROR_NONE;
488
489         ret = account_set_user_name(account, user_name);
490         assert_eq(ret, ACCOUNT_ERROR_NONE);
491
492         return 0;
493 }
494
495 int utc_account_set_user_name_n(void)
496 {
497         assert(connected);
498         assert(created);
499         int ret = ACCOUNT_ERROR_NONE;
500
501         ret = account_set_user_name(account, NULL);
502         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
503
504         ret = account_set_user_name(NULL, user_name);
505         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
506
507         return 0;
508 }
509
510 int utc_account_set_icon_path_p(void)
511 {
512         assert(connected);
513         assert(created);
514         int ret = ACCOUNT_ERROR_NONE;
515         const char* icon_path = "icon_path";
516
517         ret = account_set_icon_path(account, icon_path);
518         assert_eq(ret, ACCOUNT_ERROR_NONE);
519
520         return 0;
521 }
522
523 int utc_account_set_icon_path_n(void)
524 {
525         assert(connected);
526         assert(created);
527         int ret = ACCOUNT_ERROR_NONE;
528         const char* icon_path = "icon_path";
529
530         ret = account_set_icon_path(account, NULL);
531         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
532
533         ret = account_set_icon_path(NULL, icon_path);
534         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
535
536         return 0;
537 }
538
539 int utc_account_set_domain_name_p(void)
540 {
541         assert(connected);
542         assert(created);
543         int ret = ACCOUNT_ERROR_NONE;
544         const char* domain_name = "domain_name";
545
546         ret = account_set_domain_name(account, domain_name);
547         assert_eq(ret, ACCOUNT_ERROR_NONE);
548
549         return 0;
550 }
551
552 int utc_account_set_domain_name_n(void)
553 {
554         assert(connected);
555         assert(created);
556         int ret = ACCOUNT_ERROR_NONE;
557         const char* domain_name = "domain_name";
558
559         ret = account_set_domain_name(account, NULL);
560         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
561
562         ret = account_set_domain_name(NULL, domain_name);
563         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
564
565         return 0;
566 }
567
568 int utc_account_set_email_address_p(void)
569 {
570         assert(connected);
571         assert(created);
572         int ret = ACCOUNT_ERROR_NONE;
573         const char* email_address = "email_address";
574
575         ret = account_set_email_address(account, email_address);
576         assert_eq(ret, ACCOUNT_ERROR_NONE);
577
578         return 0;
579 }
580
581 int utc_account_set_email_address_n(void)
582 {
583         assert(connected);
584         assert(created);
585         int ret = ACCOUNT_ERROR_NONE;
586         const char* email_address = "email_address";
587
588         ret = account_set_email_address(account, NULL);
589         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
590
591         ret = account_set_email_address(NULL, email_address);
592         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
593
594         return 0;
595 }
596
597 int utc_account_set_source_p(void)
598 {
599         assert(connected);
600         assert(created);
601         int ret = ACCOUNT_ERROR_NONE;
602         const char* source = "source";
603
604         ret = account_set_source(account, source);
605         assert_eq(ret, ACCOUNT_ERROR_NONE);
606
607         return 0;
608 }
609
610 int utc_account_set_source_n(void)
611 {
612         assert(connected);
613         assert(created);
614         int ret = ACCOUNT_ERROR_NONE;
615         const char* source = "source";
616
617         ret = account_set_source(account, NULL);
618         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
619
620         ret = account_set_source(NULL, source);
621         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
622
623         return 0;
624 }
625
626 int utc_account_set_custom_p(void)
627 {
628         assert(connected);
629         assert(created);
630         int ret = ACCOUNT_ERROR_NONE;
631         const char* key = "key";
632         const char* value = "value";
633
634         ret = account_set_custom(account, key, value);
635         assert_eq(ret, ACCOUNT_ERROR_NONE);
636
637         return 0;
638 }
639
640 int utc_account_set_custom_n(void)
641 {
642         assert(connected);
643         assert(created);
644         int ret = ACCOUNT_ERROR_NONE;
645         const char* key = "key";
646         const char* value = "value";
647
648         ret = account_set_custom(account, NULL, value);
649         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
650
651         ret = account_set_custom(account, key, NULL);
652         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
653
654         ret = account_set_custom(NULL, key, value);
655         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
656
657         return 0;
658 }
659
660 int utc_account_get_custom_p(void)
661 {
662         assert(connected);
663         assert(created);
664         int ret = ACCOUNT_ERROR_NONE;
665         const char* key = "key";
666         const char* value = "value";
667         char* ret_value = NULL;
668
669         ret = account_set_custom(account, key, value);
670         assert_eq(ret, ACCOUNT_ERROR_NONE);
671
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);
676
677     return 0;
678 }
679
680 int utc_account_get_custom_n(void)
681 {
682         assert(connected);
683         assert(created);
684         int ret = ACCOUNT_ERROR_NONE;
685         char* returned_val = NULL;
686
687         ret = account_get_custom(account, NULL, &returned_val);
688         free(returned_val);
689         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
690
691         return 0;
692 }
693
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) {
697                 _is_fail = false;
698         }
699 //      g_main_loop_quit(mainloop);
700 //      mainloop = NULL;
701
702         return true;
703 }
704
705 int utc_account_get_custom_all_p(void)
706 {
707         assert(connected);
708         assert(created);
709         int ret = ACCOUNT_ERROR_NONE;
710         const char* key = "key";
711         const char* value = "value";
712
713         ret = account_set_custom(account, key, value);
714         assert_eq(ret, ACCOUNT_ERROR_NONE);
715
716 //      mainloop = g_main_loop_new(NULL, FALSE);
717 //      assert(mainloop);
718         ret = account_get_custom_all(account, account_custom_cb_func, value);
719 //      assert_eq(_is_fail, false);
720         is_callback_fail();
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);
725         _is_fail = true;
726
727         return 0;
728 }
729
730 int utc_account_get_custom_all_n(void)
731 {
732         assert(connected);
733         assert(created);
734         int ret = ACCOUNT_ERROR_NONE;
735
736         ret = account_get_custom_all(account, NULL, NULL);
737         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
738
739         ret = account_get_custom_all(NULL, account_custom_cb_func, NULL);
740         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
741
742         return 0;
743 }
744
745 int utc_account_set_package_name_p(void)
746 {
747         assert(connected);
748         assert(created);
749         int ret = ACCOUNT_ERROR_NONE;
750
751         ret = account_set_package_name(account, package_name);
752         assert_eq(ret, ACCOUNT_ERROR_NONE);
753
754         return 0;
755 }
756
757 int utc_account_set_package_name_n(void)
758 {
759         assert(connected);
760         assert(created);
761         int ret = ACCOUNT_ERROR_NONE;
762
763         ret = account_set_package_name(account, NULL);
764         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
765
766         ret = account_set_package_name(NULL, package_name);
767         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
768
769         return 0;
770 }
771
772 int utc_account_set_access_token_p(void)
773 {
774         assert(connected);
775         assert(created);
776         int ret = ACCOUNT_ERROR_NONE;
777         const char* access_token = "access_token";
778
779         ret = account_set_access_token(account, access_token);
780         assert_eq(ret, ACCOUNT_ERROR_NONE);
781
782         return 0;
783 }
784
785 int utc_account_set_access_token_n(void)
786 {
787         assert(connected);
788         assert(created);
789         int ret = ACCOUNT_ERROR_NONE;
790
791         ret = account_set_access_token(account, NULL);
792         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
793
794         return 0;
795 }
796
797 int utc_account_set_auth_type_p(void)
798 {
799         assert(connected);
800         assert(created);
801         int ret = ACCOUNT_ERROR_NONE;
802
803         ret = account_set_auth_type(account, ACCOUNT_AUTH_TYPE_OAUTH);
804         assert_eq(ret, ACCOUNT_ERROR_NONE);
805
806         return 0;
807 }
808
809 int utc_account_set_auth_type_n(void)
810 {
811         assert(connected);
812         assert(created);
813         int ret = ACCOUNT_ERROR_NONE;
814
815         ret = account_set_auth_type(account, -999);
816         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
817
818         ret = account_set_auth_type(NULL, ACCOUNT_AUTH_TYPE_OAUTH);
819         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
820
821         return 0;
822 }
823
824 int utc_account_set_secret_p(void)
825 {
826         assert(connected);
827         assert(created);
828         int ret = ACCOUNT_ERROR_NONE;
829
830         ret = account_set_secret(account, ACCOUNT_SECRECY_INVISIBLE);
831         assert_eq(ret, ACCOUNT_ERROR_NONE);
832
833         return 0;
834 }
835
836 int utc_account_set_secret_n(void)
837 {
838         assert(connected);
839         assert(created);
840         int ret = ACCOUNT_ERROR_NONE;
841
842         ret = account_set_secret(account, -999);
843         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
844
845         ret = account_set_secret(NULL, ACCOUNT_SECRECY_INVISIBLE);
846         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
847
848         return 0;
849 }
850
851 int utc_account_set_sync_support_p(void)
852 {
853         assert(connected);
854         assert(created);
855         int ret = ACCOUNT_ERROR_NONE;
856
857         ret = account_set_sync_support(account, ACCOUNT_SYNC_STATUS_IDLE);
858         assert_eq(ret, ACCOUNT_ERROR_NONE);
859
860         return 0;
861 }
862
863 int utc_account_set_sync_support_n(void)
864 {
865         assert(connected);
866         assert(created);
867         int ret = ACCOUNT_ERROR_NONE;
868
869         ret = account_set_sync_support(account, -999);
870         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
871
872         ret = account_set_sync_support(NULL, ACCOUNT_SYNC_STATUS_IDLE);
873         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
874
875         return 0;
876 }
877
878 int utc_account_set_user_text_p(void)
879 {
880         assert(connected);
881         assert(created);
882         int ret = ACCOUNT_ERROR_NONE;
883         const char* user_text = "user_text";
884
885         int i;
886         for ( i = 0; i < 5; i++){
887                 ret = account_set_user_text(account, i, user_text);
888                 assert_eq(ret, ACCOUNT_ERROR_NONE);
889         }
890
891         return 0;
892 }
893
894 int utc_account_set_user_text_n(void)
895 {
896         assert(connected);
897         assert(created);
898         int ret = ACCOUNT_ERROR_NONE;
899         const char* user_text = "user_text";
900
901         int i;
902         for (i = 0; i < 5; i++){
903                 ret = account_set_user_text(account, i, NULL);
904                 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
905         }
906         ret = account_set_user_text(account, 100, user_text);
907         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
908
909         ret = account_set_user_text(NULL, 1, user_text);
910         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
911
912         return 0;
913 }
914
915 int utc_account_set_user_int_p(void)
916 {
917         assert(connected);
918         assert(created);
919         int ret = ACCOUNT_ERROR_NONE;
920
921         int i;
922         for (i = 0; i < 5; i++){
923                 ret = account_set_user_int(account, i, 999);
924                 assert_eq(ret, ACCOUNT_ERROR_NONE);
925         }
926
927         return 0;
928 }
929
930 int utc_account_set_user_int_n(void)
931 {
932         assert(connected);
933         assert(created);
934         int ret = ACCOUNT_ERROR_NONE;
935
936         int i;
937         for (i = 0; i < 5; i++){
938                 ret = account_set_user_int(NULL, i, 999);
939                 assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
940         }
941         ret = account_set_user_int(account, 100, 999);
942         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
943
944         return 0;
945 }
946
947 int utc_account_set_capability_p(void)
948 {
949         assert(connected);
950         assert(created);
951         int ret = ACCOUNT_ERROR_NONE;
952
953         ret = account_set_capability(account, contact_capability, ACCOUNT_CAPABILITY_ENABLED);
954         assert_eq(ret, ACCOUNT_ERROR_NONE);
955
956         return 0;
957 }
958
959
960 int utc_account_set_capability_n(void)
961 {
962         assert(connected);
963         assert(created);
964         int ret = ACCOUNT_ERROR_NONE;
965
966         ret = account_set_capability(NULL, contact_capability, ACCOUNT_CAPABILITY_ENABLED);
967         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
968
969         ret = account_set_capability(account, NULL, ACCOUNT_CAPABILITY_ENABLED);
970         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
971
972         ret = account_set_capability(account, contact_capability, -1);
973         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
974
975         return 0;
976 }
977
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)
981                 _is_fail = false;
982 //      g_main_loop_quit(mainloop);
983 //      mainloop = NULL;
984
985         return true;
986 }
987
988 int utc_account_get_capability_all_p(void)
989 {
990         assert(connected);
991         assert(created);
992         int ret = ACCOUNT_ERROR_NONE;
993         const account_capability_state_e capability_state = ACCOUNT_CAPABILITY_ENABLED;
994
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);
998 //      assert(mainloop);
999         ret = account_get_capability_all(account, capability_cb_func, &capability_state);
1000 //      assert_eq(_is_fail, false);
1001         is_callback_fail();
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);
1006         _is_fail = true;
1007
1008         return 0;
1009 }
1010
1011 int utc_account_get_capability_all_n(void)
1012 {
1013         assert(connected);
1014         assert(created);
1015         int ret = ACCOUNT_ERROR_NONE;
1016
1017         ret = account_get_capability_all(NULL, capability_cb_func, NULL);
1018         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1019
1020         ret = account_get_capability_all(account, NULL, NULL);
1021         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1022
1023         return 0;
1024 }
1025
1026 int utc_account_get_display_name_p(void)
1027 {
1028         assert(connected);
1029         assert(created);
1030         const char* display_name = "display_name";
1031         char * ret_display_name = NULL;
1032         int ret = ACCOUNT_ERROR_NONE;
1033
1034         ret = account_set_display_name(account, display_name);
1035         assert_eq(ret, ACCOUNT_ERROR_NONE);
1036
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);
1041
1042         return 0;
1043 }
1044
1045 int utc_account_get_display_name_n(void)
1046 {
1047         assert(connected);
1048         assert(created);
1049         int ret = ACCOUNT_ERROR_NONE;
1050         char * display_name;
1051
1052         ret = account_get_display_name(NULL, &display_name);
1053         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1054
1055         ret = account_get_display_name(account, NULL);
1056         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1057
1058         return 0;
1059 }
1060
1061 int utc_account_get_account_id_p(void)
1062 {
1063         assert(connected);
1064         assert(created);
1065         int account_id = -1;
1066         int ret_account_id = -2;
1067         int ret = ACCOUNT_ERROR_NONE;
1068
1069         ret = account_set_user_name(account, user_name);
1070         assert_eq(ret, ACCOUNT_ERROR_NONE);
1071
1072         ret = account_insert_to_db(account, &account_id);
1073         assert_eq(ret, ACCOUNT_ERROR_NONE);
1074
1075         ret = account_query_account_by_account_id(account_id, &account);
1076         assert_eq(ret, ACCOUNT_ERROR_NONE);
1077
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);
1081
1082         ret = account_delete_from_db_by_id(account_id);
1083         assert_eq(ret, ACCOUNT_ERROR_NONE);
1084
1085         return 0;
1086 }
1087
1088 int utc_account_get_account_id_n(void)
1089 {
1090         assert(connected);
1091         assert(created);
1092         int ret = ACCOUNT_ERROR_NONE;
1093         int account_id = -1;
1094
1095         ret = account_get_account_id(NULL, &account_id);
1096         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1097
1098         ret = account_get_account_id(account, NULL);
1099         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1100
1101         return 0;
1102 }
1103
1104 int utc_account_get_user_name_p(void)
1105 {
1106         assert(connected);
1107         assert(created);
1108         char *ret_user_name;
1109         int ret = ACCOUNT_ERROR_NONE;
1110
1111         ret = account_set_user_name(account, user_name);
1112         assert_eq(ret, ACCOUNT_ERROR_NONE);
1113
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);
1118
1119         return 0;
1120 }
1121
1122 int utc_account_get_user_name_n(void)
1123 {
1124         assert(connected);
1125         assert(created);
1126         char *get_user_name;
1127         int ret = ACCOUNT_ERROR_NONE;
1128
1129         ret = account_get_user_name(NULL, &get_user_name);
1130         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1131
1132         ret = account_get_user_name(account, NULL);
1133         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1134
1135         return 0;
1136 }
1137
1138 int utc_account_get_icon_path_p(void)
1139 {
1140         assert(connected);
1141         assert(created);
1142         char *ret_icon_path = NULL;
1143         const char* icon_path = "icon_path";
1144         int ret = ACCOUNT_ERROR_NONE;
1145
1146         ret = account_set_icon_path(account, icon_path);
1147         assert_eq(ret, ACCOUNT_ERROR_NONE);
1148
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);
1153
1154         return 0;
1155 }
1156
1157 int utc_account_get_icon_path_n(void)
1158 {
1159         assert(connected);
1160         assert(created);
1161         char *ret_icon_path;
1162         int ret = ACCOUNT_ERROR_NONE;
1163
1164         ret = account_get_icon_path(NULL, &ret_icon_path);
1165         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1166
1167         ret = account_get_icon_path(account, NULL);
1168         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1169
1170         return 0;
1171 }
1172
1173 int utc_account_get_domain_name_p(void)
1174 {
1175         assert(connected);
1176         assert(created);
1177         char *ret_domain_name;
1178         const char* domain_name = "domain_name";
1179         int ret = ACCOUNT_ERROR_NONE;
1180
1181         ret = account_set_domain_name(account, domain_name);
1182         assert_eq(ret, ACCOUNT_ERROR_NONE);
1183
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);
1188
1189         return 0;
1190 }
1191
1192 int utc_account_get_domain_name_n(void)
1193 {
1194         assert(connected);
1195         assert(created);
1196         char *domain_name;
1197         int ret = ACCOUNT_ERROR_NONE;
1198
1199         ret = account_get_domain_name(NULL, &domain_name);
1200         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1201
1202         ret = account_get_domain_name(account, NULL);
1203         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1204
1205         return 0;
1206 }
1207
1208 int utc_account_get_email_address_p(void)
1209 {
1210         assert(connected);
1211         assert(created);
1212         char *ret_email_address;
1213         const char* email_address = "email_address";
1214         int ret = ACCOUNT_ERROR_NONE;
1215
1216         ret = account_set_email_address(account, email_address);
1217         assert_eq(ret, ACCOUNT_ERROR_NONE);
1218
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);
1223
1224         return 0;
1225 }
1226
1227 int utc_account_get_email_address_n(void)
1228 {
1229         assert(connected);
1230         assert(created);
1231         char *ret_email_address;
1232         int ret = ACCOUNT_ERROR_NONE;
1233
1234         ret = account_get_email_address(NULL, &ret_email_address);
1235         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1236
1237         ret = account_get_email_address(account, NULL);
1238         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1239
1240         return 0;
1241 }
1242
1243 int utc_account_get_source_p(void)
1244 {
1245         assert(connected);
1246         assert(created);
1247         char *ret_source = NULL;
1248         const char* source = "source";
1249         int ret = ACCOUNT_ERROR_NONE;
1250
1251         ret = account_set_source(account, source);
1252         assert_eq(ret, ACCOUNT_ERROR_NONE);
1253
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);
1258
1259         return 0;
1260 }
1261
1262 int utc_account_get_source_n(void)
1263 {
1264         assert(connected);
1265         assert(created);
1266         char *ret_source = NULL;
1267         int ret = ACCOUNT_ERROR_NONE;
1268
1269         ret = account_get_source(NULL, &ret_source);
1270         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1271
1272         ret = account_get_source(account, NULL);
1273         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1274
1275         return 0;
1276 }
1277
1278 int utc_account_get_package_name_p(void)
1279 {
1280         assert(connected);
1281         assert(created);
1282         char *ret_package_name = NULL;
1283         int ret = ACCOUNT_ERROR_NONE;
1284
1285         ret = account_set_package_name(account, package_name);
1286         assert_eq(ret, ACCOUNT_ERROR_NONE);
1287
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);
1292
1293         return 0;
1294 }
1295
1296 int utc_account_get_package_name_n(void)
1297 {
1298         assert(connected);
1299         assert(created);
1300         char *ret_package_name = NULL;
1301         int ret = ACCOUNT_ERROR_NONE;
1302
1303         ret = account_get_package_name(NULL, &ret_package_name);
1304         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1305
1306         ret = account_get_package_name(account, NULL);
1307         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1308
1309         return 0;
1310 }
1311
1312 int utc_account_get_access_token_p(void)
1313 {
1314         assert(connected);
1315         assert(created);
1316         char *ret_access_token = NULL;
1317         const char* access_token = "access_token";
1318         int ret = ACCOUNT_ERROR_NONE;
1319
1320         ret = account_set_access_token(account, access_token);
1321         assert_eq(ret, ACCOUNT_ERROR_NONE);
1322
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);
1327
1328         return 0;
1329 }
1330
1331 int utc_account_get_access_token_n(void)
1332 {
1333         assert(connected);
1334         assert(created);
1335         int ret = ACCOUNT_ERROR_NONE;
1336         char *ret_access_token = NULL;
1337
1338         ret = account_get_access_token(NULL, &ret_access_token);
1339         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1340
1341         ret = account_get_access_token(account, NULL);
1342         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1343
1344         return 0;
1345 }
1346
1347 int utc_account_get_auth_type_p(void)
1348 {
1349         assert(connected);
1350         assert(created);
1351         account_auth_type_e auth_type;
1352         int ret = ACCOUNT_ERROR_NONE;
1353
1354         ret = account_set_auth_type(account, ACCOUNT_AUTH_TYPE_XAUTH);
1355         assert_eq(ret, ACCOUNT_ERROR_NONE);
1356
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);
1360
1361         return 0;
1362 }
1363
1364 int utc_account_get_auth_type_n(void)
1365 {
1366         assert(connected);
1367         assert(created);
1368         account_auth_type_e auth_type;
1369         int ret = ACCOUNT_ERROR_NONE;
1370
1371         ret = account_get_auth_type(NULL, &auth_type);
1372         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1373
1374         ret = account_get_auth_type(account, NULL);
1375         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1376
1377         return 0;
1378 }
1379
1380 int utc_account_get_secret_p(void)
1381 {
1382         assert(connected);
1383         assert(created);
1384         account_secrecy_state_e secret;
1385         int ret = ACCOUNT_ERROR_NONE;
1386
1387         ret = account_set_secret(account, ACCOUNT_SECRECY_INVISIBLE);
1388         assert_eq(ret, ACCOUNT_ERROR_NONE);
1389
1390         ret = account_get_secret(account, &secret);
1391         assert_eq(ret, ACCOUNT_ERROR_NONE);
1392         assert_eq(secret, ACCOUNT_SECRECY_INVISIBLE);
1393
1394         return 0;
1395 }
1396
1397 int utc_account_get_sync_support_p(void)
1398 {
1399         assert(connected);
1400         assert(created);
1401         account_sync_state_e sync_support;
1402         int ret = ACCOUNT_ERROR_NONE;
1403
1404         ret = account_set_sync_support(account, ACCOUNT_SYNC_STATUS_IDLE);
1405         assert_eq(ret, ACCOUNT_ERROR_NONE);
1406
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);
1410
1411         return 0;
1412 }
1413
1414 int utc_account_get_secret_n(void)
1415 {
1416         assert(connected);
1417         assert(created);
1418         int ret = ACCOUNT_ERROR_NONE;
1419         account_secrecy_state_e secret;
1420
1421         ret = account_get_secret(NULL, &secret);
1422         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1423
1424         ret = account_get_secret(account, NULL);
1425         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1426
1427         return 0;
1428 }
1429
1430 int utc_account_get_sync_support_n(void)
1431 {
1432         assert(connected);
1433         assert(created);
1434         account_sync_state_e sync_support;
1435         int ret = ACCOUNT_ERROR_NONE;
1436
1437         ret = account_get_sync_support(NULL, &sync_support);
1438         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1439
1440         ret = account_get_sync_support(account, NULL);
1441         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1442
1443         return 0;
1444 }
1445
1446 int utc_account_get_user_text_p(void)
1447 {
1448         assert(connected);
1449         assert(created);
1450         char *ret_user_text = NULL;
1451         const char* user_text = "user_text";
1452         int ret = ACCOUNT_ERROR_NONE;
1453
1454         int i;
1455         for ( i = 0; i < 5; i++){
1456                 ret = account_set_user_text(account, i, user_text);
1457                 assert_eq(ret, ACCOUNT_ERROR_NONE);
1458         }
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);
1464         }
1465
1466         return 0;
1467 }
1468
1469 int utc_account_get_user_text_n(void)
1470 {
1471         assert(connected);
1472         assert(created);
1473         char *ret_user_text = NULL;
1474         int ret = ACCOUNT_ERROR_NONE;
1475
1476         ret = account_get_user_text(NULL, 0, &ret_user_text);
1477         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1478
1479         ret = account_get_user_text(account, 100, &ret_user_text);
1480         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1481
1482         ret = account_get_user_text(account, 0, NULL);
1483         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1484
1485         return 0;
1486 }
1487
1488 int utc_account_get_user_int_p(void)
1489 {
1490         assert(connected);
1491         assert(created);
1492         int user_int;
1493         int ret = ACCOUNT_ERROR_NONE;
1494
1495         int i;
1496         for (i = 0; i < 5; i++){
1497                 ret = account_set_user_int(account, i, i*10);
1498                 assert_eq(ret, ACCOUNT_ERROR_NONE);
1499         }
1500
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);
1505         }
1506
1507         return 0;
1508 }
1509
1510 int utc_account_get_user_int_n(void)
1511 {
1512         assert(connected);
1513         assert(created);
1514         int ret = ACCOUNT_ERROR_NONE;
1515
1516         ret = account_get_user_int(NULL, 0, 100);
1517         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1518
1519         ret = account_get_user_int(account, 100, 100);
1520         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1521
1522         ret = account_get_user_int(account, 0, NULL);
1523         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1524
1525         return 0;
1526 }
1527
1528 static bool capability_call_back(const char* capability_type, account_capability_state_e capability_state, void *user_data)
1529 {
1530         char* str = NULL;
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;
1537
1538         ret = account_get_package_name(account_data, &str);
1539         check_fail(ret == ACCOUNT_ERROR_NONE);
1540         check_fail(strcmp(str, package_name)==0);
1541
1542         ret = account_get_user_name(account_data, &str);
1543         check_fail(ret == ACCOUNT_ERROR_NONE);
1544         check_fail(strcmp(str, user_name)==0);
1545
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);
1550
1551         _is_fail = false;
1552
1553 //      g_main_loop_quit(mainloop);
1554 //      mainloop = NULL;
1555
1556         return 0;
1557 }
1558
1559 int utc_account_get_capability_p(void)
1560 {
1561         assert(connected);
1562         assert(created);
1563         int ret = ACCOUNT_ERROR_NONE;
1564         account_capability_state_e value;
1565
1566         ret = account_set_capability(account, contact_capability, ACCOUNT_CAPABILITY_ENABLED);
1567         assert_eq(ret, ACCOUNT_ERROR_NONE);
1568
1569         ret = account_get_capability(account, contact_capability, &value);
1570         assert_eq(ret, ACCOUNT_ERROR_NONE);
1571         assert_eq(value, ACCOUNT_CAPABILITY_ENABLED);
1572
1573         return 0;
1574 }
1575
1576 int utc_account_get_capability_n(void)
1577 {
1578         int ret = ACCOUNT_ERROR_NONE;
1579         account_capability_state_e value;
1580
1581         ret = account_get_capability(NULL, contact_capability, &value);
1582         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1583
1584         ret = account_get_capability(account, NULL, &value);
1585         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1586
1587         ret = account_get_capability(account, contact_capability, NULL);
1588         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1589
1590         return 0;
1591 }
1592
1593 static bool account_call_back(account_h account, void *user_data)
1594 {
1595         const char* key = "key";
1596         char* str = NULL;
1597         char* comparison_str = NULL;
1598         int value = -1;
1599         int comparison_value = -1;
1600         int ret = ACCOUNT_ERROR_NONE;
1601         int i = -1;
1602         check_fail(user_data!=NULL);
1603         account_h _account = *((account_h*)user_data);
1604
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);
1612
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);
1620
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);
1628
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);
1636
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);
1644
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);
1652
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);
1660
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);
1668
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);
1676
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);
1682
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);
1690
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);
1699         }
1700
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);
1707         }
1708
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);
1714
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);
1720
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);
1726
1727         _is_fail = false;
1728
1729 //      g_main_loop_quit(mainloop);
1730 //      mainloop = NULL;
1731
1732         return true;
1733 }
1734
1735 int utc_account_foreach_account_from_db_p(void)
1736 {
1737         assert(connected);
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;
1754         int i = -1;
1755
1756         ret = account_set_user_name(account, user_name);
1757         assert_eq(ret, ACCOUNT_ERROR_NONE);
1758
1759         ret = account_set_package_name(account, package_name);
1760         assert_eq(ret, ACCOUNT_ERROR_NONE);
1761
1762         ret = account_set_display_name(account, display_name);
1763         assert_eq(ret, ACCOUNT_ERROR_NONE);
1764
1765         ret = account_set_icon_path(account, icon_path);
1766         assert_eq(ret, ACCOUNT_ERROR_NONE);
1767
1768         ret = account_set_domain_name(account, domain_name);
1769         assert_eq(ret, ACCOUNT_ERROR_NONE);
1770
1771         ret = account_set_email_address(account, email_address);
1772         assert_eq(ret, ACCOUNT_ERROR_NONE);
1773
1774         ret = account_set_source(account, source);
1775         assert_eq(ret, ACCOUNT_ERROR_NONE);
1776
1777         ret = account_set_custom(account, key, value);
1778         assert_eq(ret, ACCOUNT_ERROR_NONE);
1779
1780         ret = account_set_capability(account, contact_capability, capability_state);
1781         assert_eq(ret, ACCOUNT_ERROR_NONE);
1782
1783         ret = account_set_access_token(account, access_token);
1784         assert_eq(ret, ACCOUNT_ERROR_NONE);
1785
1786         for (i = 0; i < 5; i++){
1787                 ret = account_set_user_text(account, i, user_text);
1788                 assert_eq(ret, ACCOUNT_ERROR_NONE);
1789         }
1790
1791         for (i = 0; i < 5; i++){
1792                 ret = account_set_user_int(account, i, i*10);
1793                 assert_eq(ret, ACCOUNT_ERROR_NONE);
1794         }
1795
1796         ret = account_set_auth_type(account, auth_type);
1797         assert_eq(ret, ACCOUNT_ERROR_NONE);
1798
1799         ret = account_set_secret(account, secrecy_state);
1800         assert_eq(ret, ACCOUNT_ERROR_NONE);
1801
1802         ret = account_set_sync_support(account, sync_state);
1803         assert_eq(ret, ACCOUNT_ERROR_NONE);
1804
1805         ret = account_insert_to_db(account, &account_id);
1806         assert_eq(ret, ACCOUNT_ERROR_NONE);
1807
1808 //      mainloop = g_main_loop_new(NULL, FALSE);
1809 //      assert(mainloop);
1810
1811         ret = account_foreach_account_from_db(account_call_back, &account);
1812 //      assert_eq(_is_fail, false);
1813         is_callback_fail();
1814         assert_eq(ret, ACCOUNT_ERROR_NONE);
1815
1816         ret = account_delete_from_db_by_id(account_id);
1817         assert_eq(ret, ACCOUNT_ERROR_NONE);
1818
1819 //      int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
1820 //      g_main_loop_run(mainloop);
1821 //      g_source_remove(timeout_id);
1822         _is_fail = true;
1823
1824         return 0;
1825 }
1826
1827 int utc_account_foreach_account_from_db_n(void)
1828 {
1829         assert(connected);
1830         int ret = ACCOUNT_ERROR_NONE;
1831
1832         ret = account_foreach_account_from_db(NULL, NULL);
1833         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1834
1835         return 0;
1836 }
1837
1838 int utc_account_query_account_by_account_id_p(void)
1839 {
1840         assert(connected);
1841         assert(created);
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;
1848
1849         ret = account_set_user_name(account, user_name);
1850         assert_eq(ret, ACCOUNT_ERROR_NONE);
1851
1852         ret = account_set_package_name(account, package_name);
1853         assert_eq(ret, ACCOUNT_ERROR_NONE);
1854
1855         ret = account_set_capability(account, contact_capability, ACCOUNT_CAPABILITY_ENABLED);
1856         assert_eq(ret, ACCOUNT_ERROR_NONE);
1857
1858         ret = account_insert_to_db(account, &account_id);
1859         assert_eq(ret, ACCOUNT_ERROR_NONE);
1860
1861         ret = account_create(&ret_account);
1862         assert_eq(ret, ACCOUNT_ERROR_NONE);
1863
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);
1879
1880         ret = account_delete_from_db_by_id(account_id);
1881         assert_eq(ret, ACCOUNT_ERROR_NONE);
1882
1883         return 0;
1884 }
1885
1886 int utc_account_query_account_by_account_id_n(void)
1887 {
1888         assert(connected);
1889         assert(created);
1890         int ret = ACCOUNT_ERROR_NONE;
1891
1892         ret = account_query_account_by_account_id(-999, NULL);
1893         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1894
1895         return 0;
1896 }
1897
1898 int utc_account_query_account_by_user_name_p(void)
1899 {
1900         assert(connected);
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;
1917         int i = -1;
1918
1919         ret = account_set_user_name(account, user_name);
1920         assert_eq(ret, ACCOUNT_ERROR_NONE);
1921
1922         ret = account_set_package_name(account, package_name);
1923         assert_eq(ret, ACCOUNT_ERROR_NONE);
1924
1925         ret = account_set_display_name(account, display_name);
1926         assert_eq(ret, ACCOUNT_ERROR_NONE);
1927
1928         ret = account_set_icon_path(account, icon_path);
1929         assert_eq(ret, ACCOUNT_ERROR_NONE);
1930
1931         ret = account_set_domain_name(account, domain_name);
1932         assert_eq(ret, ACCOUNT_ERROR_NONE);
1933
1934         ret = account_set_email_address(account, email_address);
1935         assert_eq(ret, ACCOUNT_ERROR_NONE);
1936
1937         ret = account_set_source(account, source);
1938         assert_eq(ret, ACCOUNT_ERROR_NONE);
1939
1940         ret = account_set_custom(account, key, value);
1941         assert_eq(ret, ACCOUNT_ERROR_NONE);
1942
1943         ret = account_set_capability(account, contact_capability, capability_state);
1944         assert_eq(ret, ACCOUNT_ERROR_NONE);
1945
1946         ret = account_set_access_token(account, access_token);
1947         assert_eq(ret, ACCOUNT_ERROR_NONE);
1948
1949         for (i = 0; i < 5; i++){
1950                 ret = account_set_user_text(account, i, user_text);
1951                 assert_eq(ret, ACCOUNT_ERROR_NONE);
1952         }
1953
1954         for (i = 0; i < 5; i++){
1955                 ret = account_set_user_int(account, i, i*10);
1956                 assert_eq(ret, ACCOUNT_ERROR_NONE);
1957         }
1958
1959         ret = account_set_auth_type(account, auth_type);
1960         assert_eq(ret, ACCOUNT_ERROR_NONE);
1961
1962         ret = account_set_secret(account, secrecy_state);
1963         assert_eq(ret, ACCOUNT_ERROR_NONE);
1964
1965         ret = account_set_sync_support(account, sync_state);
1966         assert_eq(ret, ACCOUNT_ERROR_NONE);
1967
1968         ret = account_insert_to_db(account, &account_id);
1969         assert_eq(ret, ACCOUNT_ERROR_NONE);
1970
1971 //      mainloop = g_main_loop_new(NULL, FALSE);
1972 //      assert(mainloop);
1973
1974         ret = account_query_account_by_user_name(account_call_back, user_name, &account);
1975 //      assert_eq(_is_fail, false);
1976         is_callback_fail();
1977         assert_eq(ret, ACCOUNT_ERROR_NONE);
1978
1979 //      int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
1980 //      g_main_loop_run(mainloop);
1981 //      g_source_remove(timeout_id);
1982         _is_fail = true;
1983
1984         ret = account_delete_from_db_by_id(account_id);
1985         assert_eq(ret, ACCOUNT_ERROR_NONE);
1986
1987         return 0;
1988 }
1989
1990 int utc_account_query_account_by_user_name_n(void)
1991 {
1992         assert(connected);
1993         int ret = ACCOUNT_ERROR_NONE;
1994
1995         ret = account_query_account_by_user_name(account_call_back, NULL, NULL);
1996         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
1997
1998         ret = account_query_account_by_user_name(NULL, user_name, NULL);
1999         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2000
2001         return 0;
2002 }
2003
2004 int utc_account_query_account_by_package_name_p(void)
2005 {
2006         assert(connected);
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;
2023         int i = -1;
2024
2025         ret = account_set_user_name(account, user_name);
2026         assert_eq(ret, ACCOUNT_ERROR_NONE);
2027
2028         ret = account_set_package_name(account, package_name);
2029         assert_eq(ret, ACCOUNT_ERROR_NONE);
2030
2031         ret = account_set_display_name(account, display_name);
2032         assert_eq(ret, ACCOUNT_ERROR_NONE);
2033
2034         ret = account_set_icon_path(account, icon_path);
2035         assert_eq(ret, ACCOUNT_ERROR_NONE);
2036
2037         ret = account_set_domain_name(account, domain_name);
2038         assert_eq(ret, ACCOUNT_ERROR_NONE);
2039
2040         ret = account_set_email_address(account, email_address);
2041         assert_eq(ret, ACCOUNT_ERROR_NONE);
2042
2043         ret = account_set_source(account, source);
2044         assert_eq(ret, ACCOUNT_ERROR_NONE);
2045
2046         ret = account_set_custom(account, key, value);
2047         assert_eq(ret, ACCOUNT_ERROR_NONE);
2048
2049         ret = account_set_capability(account, contact_capability, capability_state);
2050         assert_eq(ret, ACCOUNT_ERROR_NONE);
2051
2052         ret = account_set_access_token(account, access_token);
2053         assert_eq(ret, ACCOUNT_ERROR_NONE);
2054
2055         for (i = 0; i < 5; i++){
2056                 ret = account_set_user_text(account, i, user_text);
2057                 assert_eq(ret, ACCOUNT_ERROR_NONE);
2058         }
2059
2060         for (i = 0; i < 5; i++){
2061                 ret = account_set_user_int(account, i, i*10);
2062                 assert_eq(ret, ACCOUNT_ERROR_NONE);
2063         }
2064
2065         ret = account_set_auth_type(account, auth_type);
2066         assert_eq(ret, ACCOUNT_ERROR_NONE);
2067
2068         ret = account_set_secret(account, secrecy_state);
2069         assert_eq(ret, ACCOUNT_ERROR_NONE);
2070
2071         ret = account_set_sync_support(account, sync_state);
2072         assert_eq(ret, ACCOUNT_ERROR_NONE);
2073
2074         ret = account_insert_to_db(account, &account_id);
2075         assert_eq(ret, ACCOUNT_ERROR_NONE);
2076
2077 //      mainloop = g_main_loop_new(NULL, FALSE);
2078 //      assert(mainloop);
2079
2080         ret = account_query_account_by_package_name(account_call_back, package_name, &account);
2081 //      assert_eq(_is_fail, false);
2082         is_callback_fail();
2083         assert_eq(ret, ACCOUNT_ERROR_NONE);
2084
2085 //      int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
2086 //      g_main_loop_run(mainloop);
2087 //      g_source_remove(timeout_id);
2088         _is_fail = true;
2089
2090         ret = account_delete_from_db_by_id(account_id);
2091         assert_eq(ret, ACCOUNT_ERROR_NONE);
2092
2093         return 0;
2094 }
2095
2096 int utc_account_query_account_by_package_name_n(void)
2097 {
2098         assert(connected);
2099         int ret = ACCOUNT_ERROR_NONE;
2100
2101         ret = account_query_account_by_package_name(account_call_back, NULL, NULL);
2102         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2103
2104         ret = account_query_account_by_package_name(NULL, package_name, NULL);
2105         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2106
2107         return 0;
2108 }
2109
2110 int utc_account_query_account_by_capability_p(void)
2111 {
2112         assert(connected);
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;
2129         int i = -1;
2130
2131         ret = account_set_user_name(account, user_name);
2132         assert_eq(ret, ACCOUNT_ERROR_NONE);
2133
2134         ret = account_set_package_name(account, package_name);
2135         assert_eq(ret, ACCOUNT_ERROR_NONE);
2136
2137         ret = account_set_display_name(account, display_name);
2138         assert_eq(ret, ACCOUNT_ERROR_NONE);
2139
2140         ret = account_set_icon_path(account, icon_path);
2141         assert_eq(ret, ACCOUNT_ERROR_NONE);
2142
2143         ret = account_set_domain_name(account, domain_name);
2144         assert_eq(ret, ACCOUNT_ERROR_NONE);
2145
2146         ret = account_set_email_address(account, email_address);
2147         assert_eq(ret, ACCOUNT_ERROR_NONE);
2148
2149         ret = account_set_source(account, source);
2150         assert_eq(ret, ACCOUNT_ERROR_NONE);
2151
2152         ret = account_set_custom(account, key, value);
2153         assert_eq(ret, ACCOUNT_ERROR_NONE);
2154
2155         ret = account_set_capability(account, contact_capability, capability_state);
2156         assert_eq(ret, ACCOUNT_ERROR_NONE);
2157
2158         ret = account_set_access_token(account, access_token);
2159         assert_eq(ret, ACCOUNT_ERROR_NONE);
2160
2161         for (i = 0; i < 5; i++){
2162                 ret = account_set_user_text(account, i, user_text);
2163                 assert_eq(ret, ACCOUNT_ERROR_NONE);
2164         }
2165
2166         for (i = 0; i < 5; i++){
2167                 ret = account_set_user_int(account, i, i*10);
2168                 assert_eq(ret, ACCOUNT_ERROR_NONE);
2169         }
2170
2171         ret = account_set_auth_type(account, auth_type);
2172         assert_eq(ret, ACCOUNT_ERROR_NONE);
2173
2174         ret = account_set_secret(account, secrecy_state);
2175         assert_eq(ret, ACCOUNT_ERROR_NONE);
2176
2177         ret = account_set_sync_support(account, sync_state);
2178         assert_eq(ret, ACCOUNT_ERROR_NONE);
2179
2180         ret = account_insert_to_db(account, &account_id);
2181         assert_eq(ret, ACCOUNT_ERROR_NONE);
2182
2183 //      mainloop = g_main_loop_new(NULL, FALSE);
2184 //      assert(mainloop);
2185
2186         ret = account_query_account_by_capability(account_call_back, contact_capability, capability_state, &account);
2187 //      assert_eq(_is_fail, false);
2188         is_callback_fail();
2189         assert_eq(ret, ACCOUNT_ERROR_NONE);
2190
2191 //      int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
2192 //      g_main_loop_run(mainloop);
2193 //      g_source_remove(timeout_id);
2194         _is_fail = true;
2195
2196         ret = account_delete_from_db_by_id(account_id);
2197         assert_eq(ret, ACCOUNT_ERROR_NONE);
2198
2199         return 0;
2200 }
2201
2202 int utc_account_query_account_by_capability_n(void)
2203 {
2204         int ret = ACCOUNT_ERROR_NONE;
2205
2206         ret = account_query_account_by_capability(NULL, contact_capability, ACCOUNT_CAPABILITY_ENABLED, NULL);
2207         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2208
2209         ret = account_query_account_by_capability(account_call_back, NULL, ACCOUNT_CAPABILITY_ENABLED, NULL);
2210         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2211
2212         ret = account_query_account_by_capability(account_call_back, contact_capability, -1, NULL);
2213         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2214
2215         return 0;
2216 }
2217
2218 static bool account_cb_func(account_h account, void *user_data) {
2219         char* str = NULL;
2220         char* comparison_str = NULL;
2221         int value = -1;
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);
2226
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);
2234
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);
2242
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);
2248
2249         _is_fail = false;
2250 //      g_main_loop_quit(mainloop);
2251 //      mainloop = NULL;
2252
2253         return true;
2254 }
2255
2256 int utc_account_query_account_by_capability_type_p(void)
2257 {
2258         assert(connected);
2259         assert(created);
2260         int ret = ACCOUNT_ERROR_NONE;
2261         int account_id = -1;
2262
2263         ret = account_set_user_name(account, user_name);
2264         assert_eq(ret, ACCOUNT_ERROR_NONE);
2265
2266         ret = account_set_package_name(account, package_name);
2267         assert_eq(ret, ACCOUNT_ERROR_NONE);
2268
2269         ret = account_set_capability(account, contact_capability, ACCOUNT_CAPABILITY_ENABLED);
2270         assert_eq(ret, ACCOUNT_ERROR_NONE);
2271
2272         ret = account_insert_to_db(account, &account_id);
2273         assert_eq(ret, ACCOUNT_ERROR_NONE);
2274
2275 //      mainloop = g_main_loop_new(NULL, FALSE);
2276 //      assert(mainloop);
2277
2278         ret = account_query_account_by_capability_type(account_cb_func, contact_capability, &account);
2279 //      assert_eq(_is_fail, false);
2280         is_callback_fail();
2281         assert_eq(ret, ACCOUNT_ERROR_NONE);
2282
2283 //      int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
2284 //      g_main_loop_run(mainloop);
2285 //      g_source_remove(timeout_id);
2286         _is_fail = true;
2287
2288         ret = account_delete_from_db_by_id(account_id);
2289         assert_eq(ret, ACCOUNT_ERROR_NONE);
2290
2291         return 0;
2292 }
2293
2294 int utc_account_query_account_by_capability_type_n(void)
2295 {
2296         int ret = ACCOUNT_ERROR_NONE;
2297         const char* type = "type";
2298
2299         ret = account_query_account_by_capability_type(NULL, type, NULL);
2300         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2301
2302         ret = account_query_account_by_capability_type(account_cb_func, NULL, NULL);
2303         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2304
2305         return 0;
2306 }
2307
2308 int utc_account_query_capability_by_account_id_p(void)
2309 {
2310         assert(connected);
2311         assert(created);
2312         int ret = ACCOUNT_ERROR_NONE;
2313         int account_id = -1;
2314         account_capability_state_e capability_state = ACCOUNT_CAPABILITY_ENABLED;
2315
2316         ret = account_set_user_name(account, user_name);
2317         assert_eq(ret, ACCOUNT_ERROR_NONE);
2318
2319         ret = account_set_package_name(account, package_name);
2320         assert_eq(ret, ACCOUNT_ERROR_NONE);
2321
2322         ret = account_set_capability(account, contact_capability, capability_state);
2323         assert_eq(ret, ACCOUNT_ERROR_NONE);
2324
2325         ret = account_insert_to_db(account, &account_id);
2326         assert_eq(ret, ACCOUNT_ERROR_NONE);
2327
2328 //      mainloop = g_main_loop_new(NULL, FALSE);
2329 //      assert(mainloop);
2330
2331         ret = account_query_capability_by_account_id(capability_call_back, account_id, &account);
2332 //      assert_eq(_is_fail, false);
2333         is_callback_fail();
2334         assert_eq(ret, ACCOUNT_ERROR_NONE);
2335
2336 //      int timeout_id = g_timeout_add(3000, timeout_cb, mainloop);
2337 //      g_main_loop_run(mainloop);
2338 //      g_source_remove(timeout_id);
2339         _is_fail = true;
2340
2341         ret = account_delete_from_db_by_id(account_id);
2342         assert_eq(ret, ACCOUNT_ERROR_NONE);
2343
2344         return 0;
2345 }
2346
2347 int utc_account_query_capability_by_account_id_n(void)
2348 {
2349         assert(connected);
2350         int ret = ACCOUNT_ERROR_NONE;
2351
2352         ret = account_query_capability_by_account_id(capability_call_back, -1, NULL);
2353         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2354
2355         ret = account_query_capability_by_account_id(NULL, 1, NULL);
2356         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2357
2358         return 0;
2359 }
2360
2361 int utc_account_get_total_count_from_db_p(void)
2362 {
2363         assert(connected);
2364         int count = -1;
2365         int ret = ACCOUNT_ERROR_NONE;
2366
2367         ret = account_get_total_count_from_db(&count);
2368         assert_eq(ret, ACCOUNT_ERROR_NONE);
2369
2370         return 0;
2371 }
2372
2373 int utc_account_get_total_count_from_db_n(void)
2374 {
2375         assert(connected);
2376         int ret = ACCOUNT_ERROR_NONE;
2377
2378         ret = account_get_total_count_from_db(NULL);
2379         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2380
2381         return 0;
2382 }
2383
2384 int utc_account_update_sync_status_by_id_p(void)
2385 {
2386         assert(connected);
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;
2391
2392         ret = account_set_user_name(account, user_name);
2393         assert_eq(ret, ACCOUNT_ERROR_NONE);
2394
2395         ret = account_set_package_name(account, package_name);
2396         assert_eq(ret, ACCOUNT_ERROR_NONE);
2397
2398         ret = account_insert_to_db(account, &account_id);
2399         assert_eq(ret, ACCOUNT_ERROR_NONE);
2400
2401         ret = account_update_sync_status_by_id(account_id, ACCOUNT_SYNC_STATUS_IDLE);
2402         assert_eq(ret, ACCOUNT_ERROR_NONE);
2403
2404         ret = account_create(&ret_account);
2405         assert_eq(ret, ACCOUNT_ERROR_NONE);
2406
2407         ret = account_query_account_by_account_id(account_id, &ret_account);
2408         assert_eq(ret, ACCOUNT_ERROR_NONE);
2409
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);
2413
2414         ret = account_destroy(ret_account);
2415         assert_eq(ret, ACCOUNT_ERROR_NONE);
2416
2417         ret = account_delete_from_db_by_id(account_id);
2418         assert_eq(ret, ACCOUNT_ERROR_NONE);
2419
2420         return 0;
2421 }
2422
2423 int utc_account_update_sync_status_by_id_n(void)
2424 {
2425         assert(connected);
2426         int ret = ACCOUNT_ERROR_NONE;
2427
2428         ret = account_update_sync_status_by_id(-1, ACCOUNT_SYNC_STATUS_IDLE);
2429         assert_neq(ret, ACCOUNT_ERROR_NONE);
2430
2431         return 0;
2432 }
2433
2434 int utc_account_delete_from_db_by_id_p(void)
2435 {
2436         assert(connected);
2437         assert(created);
2438         int account_id = -1;
2439         int ret = ACCOUNT_ERROR_NONE;
2440
2441         ret = account_set_user_name(account, user_name);
2442         assert_eq(ret, ACCOUNT_ERROR_NONE);
2443
2444         ret = account_set_package_name(account, package_name);
2445         assert_eq(ret, ACCOUNT_ERROR_NONE);
2446
2447         ret = account_insert_to_db(account, &account_id);
2448         assert_eq(ret, ACCOUNT_ERROR_NONE);
2449
2450         ret = account_delete_from_db_by_id(account_id);
2451         assert_eq(ret, ACCOUNT_ERROR_NONE);
2452
2453         return 0;
2454 }
2455
2456 int utc_account_delete_from_db_by_id_n(void)
2457 {
2458         assert(connected);
2459         int ret = ACCOUNT_ERROR_NONE;
2460
2461         ret = account_delete_from_db_by_id(-1);
2462         assert_neq(ret, ACCOUNT_ERROR_NONE);
2463
2464         return 0;
2465 }
2466
2467 int utc_account_delete_from_db_by_user_name_p(void)
2468 {
2469         assert(connected);
2470         assert(created);
2471         int account_id = -1;
2472         int ret = ACCOUNT_ERROR_NONE;
2473
2474         ret = account_set_user_name(account, user_name);
2475         assert_eq(ret, ACCOUNT_ERROR_NONE);
2476
2477         ret = account_insert_to_db(account, &account_id);
2478         assert_eq(ret, ACCOUNT_ERROR_NONE);
2479
2480         ret = account_delete_from_db_by_user_name(user_name, package_name);
2481         assert_eq(ret, ACCOUNT_ERROR_NONE);
2482
2483         return 0;
2484 }
2485
2486 int utc_account_delete_from_db_by_user_name_n(void)
2487 {
2488         assert(connected);
2489         int ret = ACCOUNT_ERROR_NONE;
2490
2491         ret = account_delete_from_db_by_user_name(NULL, package_name);
2492         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2493
2494         return 0;
2495 }
2496
2497 int utc_account_delete_from_db_by_package_name_p(void)
2498 {
2499         assert(connected);
2500         assert(created);
2501
2502         int account_id = -1;
2503         int ret = ACCOUNT_ERROR_NONE;
2504
2505         ret = account_set_user_name(account, user_name);
2506         assert_eq(ret, ACCOUNT_ERROR_NONE);
2507
2508         ret = account_set_package_name(account, package_name);
2509         assert_eq(ret, ACCOUNT_ERROR_NONE);
2510
2511         ret = account_insert_to_db(account, &account_id);
2512         assert_eq(ret, ACCOUNT_ERROR_NONE);
2513
2514         ret = account_delete_from_db_by_package_name(package_name);
2515         assert_eq(ret, ACCOUNT_ERROR_NONE);
2516
2517         return 0;
2518 }
2519
2520 int utc_account_delete_from_db_by_package_name_n(void)
2521 {
2522         assert(connected);
2523         int ret = ACCOUNT_ERROR_NONE;
2524
2525         ret = account_delete_from_db_by_package_name(NULL);
2526         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2527
2528         return 0;
2529 }
2530
2531 int utc_account_delete_from_db_by_package_name_without_permission_p(void)
2532 {
2533         assert(connected);
2534         assert(created);
2535
2536         int account_id = -1;
2537         int ret = ACCOUNT_ERROR_NONE;
2538
2539         ret = account_set_user_name(account, user_name);
2540         assert_eq(ret, ACCOUNT_ERROR_NONE);
2541
2542         ret = account_set_package_name(account, package_name);
2543         assert_eq(ret, ACCOUNT_ERROR_NONE);
2544
2545         ret = account_insert_to_db(account, &account_id);
2546         assert_eq(ret, ACCOUNT_ERROR_NONE);
2547
2548         ret = account_delete_from_db_by_package_name_without_permission(package_name);
2549         assert_eq(ret, ACCOUNT_ERROR_NONE);
2550
2551         return 0;
2552 }
2553
2554 int utc_account_delete_from_db_by_package_name_without_permission_n(void)
2555 {
2556         assert(connected);
2557         int ret = ACCOUNT_ERROR_NONE;
2558
2559         ret = account_delete_from_db_by_package_name_without_permission(NULL);
2560         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2561
2562         return 0;
2563 }
2564
2565 int utc_account_update_to_db_by_id_p(void)
2566 {
2567         assert(connected);
2568         assert(created);
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;
2574
2575         ret = account_set_user_name(account, user_name);
2576         assert_eq(ret, ACCOUNT_ERROR_NONE);
2577
2578         ret = account_set_package_name(account, package_name);
2579         assert_eq(ret, ACCOUNT_ERROR_NONE);
2580
2581         ret = account_insert_to_db(account, &account_id);
2582         assert_eq(ret, ACCOUNT_ERROR_NONE);
2583
2584         ret = account_set_user_name(account, update_user_name);
2585         assert_eq(ret, ACCOUNT_ERROR_NONE);
2586
2587         ret = account_update_to_db_by_id(account, account_id);
2588         assert_eq(ret, ACCOUNT_ERROR_NONE);
2589
2590         ret = account_create(&ret_account);
2591         assert_eq(ret, ACCOUNT_ERROR_NONE);
2592
2593         ret = account_query_account_by_account_id(account_id, &ret_account);
2594         assert_eq(ret, ACCOUNT_ERROR_NONE);
2595
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);
2599
2600         _account_free_text(ret_user_name);
2601         ret = account_destroy(ret_account);
2602         assert_eq(ret, ACCOUNT_ERROR_NONE);
2603
2604         ret = account_delete_from_db_by_id(account_id);
2605         assert_eq(ret, ACCOUNT_ERROR_NONE);
2606
2607         return 0;
2608 }
2609
2610 int utc_account_update_to_db_by_id_n(void)
2611 {
2612         assert(connected);
2613         assert(created);
2614         int ret = ACCOUNT_ERROR_NONE;
2615
2616         ret = account_update_to_db_by_id(account, -1);
2617         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2618
2619         return 0;
2620 }
2621
2622 int utc_account_update_to_db_by_user_name_p(void)
2623 {
2624         assert(connected);
2625         assert(created);
2626         int account_id = -1;
2627         int ret = ACCOUNT_ERROR_NONE;
2628         int value = -1;
2629         char* ret_user_name = NULL;
2630         account_h ret_account = NULL;
2631         account_capability_state_e capability_state = ACCOUNT_CAPABILITY_ENABLED;
2632
2633         ret = account_set_user_name(account, user_name);
2634         assert_eq(ret, ACCOUNT_ERROR_NONE);
2635
2636         ret = account_set_package_name(account, package_name);
2637         assert_eq(ret, ACCOUNT_ERROR_NONE);
2638
2639         ret = account_insert_to_db(account, &account_id);
2640         assert_eq(ret, ACCOUNT_ERROR_NONE);
2641
2642         ret = account_set_capability(account, contact_capability, capability_state);
2643         assert_eq(ret, ACCOUNT_ERROR_NONE);
2644
2645         ret = account_update_to_db_by_user_name(account, user_name, package_name);
2646         assert_eq(ret, ACCOUNT_ERROR_NONE);
2647
2648         ret = account_create(&ret_account);
2649         assert_eq(ret, ACCOUNT_ERROR_NONE);
2650
2651         ret = account_query_account_by_account_id(account_id, &ret_account);
2652         assert_eq(ret, ACCOUNT_ERROR_NONE);
2653
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);
2658
2659         ret = account_get_capability(account, contact_capability, &value);
2660         assert_eq(ret, ACCOUNT_ERROR_NONE);
2661         assert_eq(value, ACCOUNT_CAPABILITY_ENABLED);
2662
2663         ret = account_destroy(ret_account);
2664         assert_eq(ret, ACCOUNT_ERROR_NONE);
2665
2666         ret = account_delete_from_db_by_id(account_id);
2667         assert_eq(ret, ACCOUNT_ERROR_NONE);
2668
2669         return 0;
2670 }
2671
2672 int utc_account_update_to_db_by_user_name_n(void)
2673 {
2674         assert(connected);
2675         assert(created);
2676         int ret = ACCOUNT_ERROR_NONE;
2677
2678         ret = account_update_to_db_by_user_name(account, NULL, package_name);
2679         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2680
2681         return 0;
2682 }
2683
2684
2685
2686 int utc_account_subscribe_create_p(void)
2687 {
2688         assert(connected);
2689         account_subscribe_h account_subscribe;
2690         int ret = ACCOUNT_ERROR_NONE;
2691
2692         ret = account_subscribe_create(&account_subscribe);
2693         assert_eq(ret, ACCOUNT_ERROR_NONE);
2694
2695         ret = account_subscribe_notification(account_subscribe, NULL, NULL);
2696         assert_eq(ret, ACCOUNT_ERROR_NONE);
2697
2698         ret = account_unsubscribe_notification(account_subscribe);
2699         assert_eq(ret, ACCOUNT_ERROR_NONE);
2700
2701         return 0;
2702 }
2703
2704
2705 int utc_account_subscribe_create_n(void)
2706 {
2707         assert(connected);
2708         int ret = ACCOUNT_ERROR_NONE;
2709
2710         ret = account_subscribe_create(NULL);
2711         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2712
2713         return 0;
2714 }
2715
2716
2717 int utc_account_subscribe_notification_p(void)
2718 {
2719         assert(connected);
2720         account_subscribe_h account_subscribe;
2721         int ret = ACCOUNT_ERROR_NONE;
2722
2723         ret = account_subscribe_create(&account_subscribe);
2724         assert_eq(ret, ACCOUNT_ERROR_NONE);
2725
2726         ret = account_subscribe_notification(account_subscribe, NULL, NULL);
2727         assert_eq(ret, ACCOUNT_ERROR_NONE);
2728
2729         ret = account_unsubscribe_notification(account_subscribe);
2730         assert_eq(ret, ACCOUNT_ERROR_NONE);
2731
2732         return 0;
2733 }
2734
2735
2736 int utc_account_subscribe_notification_n(void)
2737 {
2738         assert(connected);
2739         account_subscribe_h account_subscribe;
2740         int ret = ACCOUNT_ERROR_NONE;
2741
2742         ret = account_subscribe_create(&account_subscribe);
2743         assert_eq(ret, ACCOUNT_ERROR_NONE);
2744
2745         ret = account_subscribe_notification(NULL, NULL, NULL);
2746         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2747
2748         ret = account_subscribe_notification(account_subscribe, NULL, NULL);
2749         assert_eq(ret, ACCOUNT_ERROR_NONE);
2750
2751         ret = account_unsubscribe_notification(account_subscribe);
2752         assert_eq(ret, ACCOUNT_ERROR_NONE);
2753
2754         return 0;
2755 }
2756
2757 int utc_account_unsubscribe_notification_p(void)
2758 {
2759         assert(connected);
2760         account_subscribe_h account_subscribe;
2761         int ret = ACCOUNT_ERROR_NONE;
2762
2763         ret = account_subscribe_create(&account_subscribe);
2764         assert_eq(ret, ACCOUNT_ERROR_NONE);
2765
2766         ret = account_subscribe_notification(account_subscribe, NULL, NULL);
2767         assert_eq(ret, ACCOUNT_ERROR_NONE);
2768
2769         ret = account_unsubscribe_notification(account_subscribe);
2770         assert_eq(ret, ACCOUNT_ERROR_NONE);
2771
2772         return 0;
2773 }
2774
2775
2776 int utc_account_unsubscribe_notification_n(void)
2777 {
2778         assert(connected);
2779         int ret = ACCOUNT_ERROR_NONE;
2780
2781         ret = account_unsubscribe_notification(NULL);
2782         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2783
2784         return 0;
2785 }
2786
2787 int utc_account_type_create_p(void)
2788 {
2789         account_type_h account_type = NULL;
2790         int ret = ACCOUNT_ERROR_NONE;
2791
2792         ret = account_type_create(&account_type);
2793         assert_eq(ret, ACCOUNT_ERROR_NONE);
2794
2795         ret = account_type_destroy(account_type);
2796         assert_eq(ret, ACCOUNT_ERROR_NONE);
2797
2798         return 0;
2799 }
2800
2801 int utc_account_type_create_n(void)
2802 {
2803         int ret = ACCOUNT_ERROR_NONE;
2804
2805         ret = account_type_create(NULL);
2806         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2807
2808         return 0;
2809 }
2810
2811 int utc_account_type_destroy_p(void)
2812 {
2813         account_type_h account_type = NULL;
2814         int ret = ACCOUNT_ERROR_NONE;
2815
2816         ret = account_type_create(&account_type);
2817         assert_eq(ret, ACCOUNT_ERROR_NONE);
2818
2819         ret = account_type_destroy(account_type);
2820         assert_eq(ret, ACCOUNT_ERROR_NONE);
2821
2822         return 0;
2823 }
2824
2825 int utc_account_type_destroy_n(void)
2826 {
2827         int ret = ACCOUNT_ERROR_NONE;
2828
2829         ret = account_type_destroy(NULL);
2830         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2831
2832         return 0;
2833 }
2834
2835 int utc_account_type_set_app_id_p(void)
2836 {
2837         int ret = account_type_set_app_id(NULL, NULL);
2838         assert_eq(ret, ACCOUNT_ERROR_NONE);
2839
2840         return 0;
2841 }
2842
2843 int utc_account_type_set_app_id_n(void)
2844 {
2845         int ret = account_type_set_app_id(NULL, NULL);
2846         assert_eq(ret, ACCOUNT_ERROR_NONE);
2847
2848         return 0;
2849 }
2850
2851 int utc_account_type_set_app_id_internal_p(void)
2852 {
2853         account_type_h account_type = NULL;
2854         int ret = ACCOUNT_ERROR_NONE;
2855         const char* app_id = "application_id";
2856
2857         ret = account_type_create(&account_type);
2858         assert_eq(ret, ACCOUNT_ERROR_NONE);
2859
2860         ret = account_type_set_app_id_internal(account_type, app_id);
2861         assert_eq(ret, ACCOUNT_ERROR_NONE);
2862
2863         ret = account_type_destroy(account_type);
2864         assert_eq(ret, ACCOUNT_ERROR_NONE);
2865
2866         return 0;
2867 }
2868
2869 int utc_account_type_set_app_id_internal_n(void)
2870 {
2871         account_type_h account_type = NULL;
2872         int ret = ACCOUNT_ERROR_NONE;
2873         const char* app_id = "application_id";
2874
2875         ret = account_type_create(&account_type);
2876         assert_eq(ret, ACCOUNT_ERROR_NONE);
2877
2878         ret = account_type_set_app_id_internal(NULL, app_id);
2879         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2880
2881         ret = account_type_set_app_id_internal(account_type, NULL);
2882         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2883
2884         ret = account_type_destroy(account_type);
2885         assert_eq(ret, ACCOUNT_ERROR_NONE);
2886
2887         return 0;
2888 }
2889
2890 int utc_account_type_get_app_id_p(void)
2891 {
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;
2896
2897         ret = account_type_create(&account_type);
2898         assert_eq(ret, ACCOUNT_ERROR_NONE);
2899
2900         ret = account_type_set_app_id_internal(account_type, app_id);
2901         assert_eq(ret, ACCOUNT_ERROR_NONE);
2902
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);
2907
2908         ret = account_type_destroy(account_type);
2909         assert_eq(ret, ACCOUNT_ERROR_NONE);
2910
2911         return 0;
2912 }
2913
2914 int utc_account_type_get_app_id_n(void)
2915 {
2916         account_type_h account_type = NULL;
2917         int ret = ACCOUNT_ERROR_NONE;
2918         char* ret_app_id = NULL;
2919
2920         ret = account_type_create(&account_type);
2921         assert_eq(ret, ACCOUNT_ERROR_NONE);
2922
2923         ret = account_type_get_app_id(NULL, &ret_app_id);
2924         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2925
2926         ret = account_type_get_app_id(account_type, NULL);
2927         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2928
2929         ret = account_type_destroy(account_type);
2930         assert_eq(ret, ACCOUNT_ERROR_NONE);
2931
2932         return 0;
2933 }
2934
2935 int utc_account_type_set_icon_path_p(void)
2936 {
2937         int ret = account_type_set_icon_path(NULL, NULL);
2938         assert_eq(ret, ACCOUNT_ERROR_NONE);
2939
2940         return 0;
2941 }
2942
2943 int utc_account_type_set_icon_path_n(void)
2944 {
2945         int ret = account_type_set_icon_path(NULL, NULL);
2946         assert_eq(ret, ACCOUNT_ERROR_NONE);
2947
2948         return 0;
2949 }
2950
2951 int utc_account_type_set_icon_path_internal_p(void)
2952 {
2953         account_type_h account_type = NULL;
2954         int ret = ACCOUNT_ERROR_NONE;
2955         const char* icon_path = "icon_path";
2956
2957         ret = account_type_create(&account_type);
2958         assert_eq(ret, ACCOUNT_ERROR_NONE);
2959
2960         ret = account_type_set_icon_path_internal(account_type, icon_path);
2961         assert_eq(ret, ACCOUNT_ERROR_NONE);
2962
2963         ret = account_type_destroy(account_type);
2964         assert_eq(ret, ACCOUNT_ERROR_NONE);
2965
2966         return 0;
2967 }
2968
2969 int utc_account_type_set_icon_path_internal_n(void)
2970 {
2971         account_type_h account_type = NULL;
2972         int ret = ACCOUNT_ERROR_NONE;
2973         const char* icon_path = "icon_path";
2974
2975         ret = account_type_create(&account_type);
2976         assert_eq(ret, ACCOUNT_ERROR_NONE);
2977
2978         ret = account_type_set_icon_path_internal(NULL, icon_path);
2979         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2980
2981         ret = account_type_set_icon_path_internal(account_type, NULL);
2982         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
2983
2984         ret = account_type_destroy(account_type);
2985         assert_eq(ret, ACCOUNT_ERROR_NONE);
2986
2987         return 0;
2988 }
2989
2990 int utc_account_type_get_icon_path_p(void)
2991 {
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";
2996
2997         ret = account_type_create(&account_type);
2998         assert_eq(ret, ACCOUNT_ERROR_NONE);
2999
3000         ret = account_type_set_icon_path_internal(account_type, icon_path);
3001         assert_eq(ret, ACCOUNT_ERROR_NONE);
3002
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);
3007
3008         ret = account_type_destroy(account_type);
3009         assert_eq(ret, ACCOUNT_ERROR_NONE);
3010
3011         return 0;
3012 }
3013
3014 int utc_account_type_get_icon_path_n(void)
3015 {
3016         account_type_h account_type = NULL;
3017         int ret = ACCOUNT_ERROR_NONE;
3018         char* ret_icon_path = NULL;
3019
3020         ret = account_type_create(&account_type);
3021         assert_eq(ret, ACCOUNT_ERROR_NONE);
3022
3023         ret = account_type_get_icon_path(NULL, &ret_icon_path);
3024         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3025
3026         ret = account_type_get_icon_path(account_type, NULL);
3027         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3028
3029         ret = account_type_destroy(account_type);
3030         assert_eq(ret, ACCOUNT_ERROR_NONE);
3031
3032         return 0;
3033 }
3034
3035 int utc_account_type_set_label_p(void)
3036 {
3037         int ret = account_type_set_label(NULL, NULL, NULL);
3038         assert_eq(ret, ACCOUNT_ERROR_NONE);
3039
3040         return 0;
3041 }
3042
3043 int utc_account_type_set_label_n(void)
3044 {
3045         int ret = account_type_set_label(NULL, NULL, NULL);
3046         assert_eq(ret, ACCOUNT_ERROR_NONE);
3047
3048         return 0;
3049 }
3050
3051 int utc_account_type_set_label_internal_p(void)
3052 {
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;
3058
3059         ret = account_type_create(&account_type);
3060         assert_eq(ret, ACCOUNT_ERROR_NONE);
3061
3062         ret = account_type_set_label_internal(account_type, label, locale);
3063         assert_eq(ret, ACCOUNT_ERROR_NONE);
3064
3065         ret = account_type_destroy(account_type);
3066         assert_eq(ret, ACCOUNT_ERROR_NONE);
3067
3068         return 0;
3069 }
3070
3071 int utc_account_type_set_label_internal_n(void)
3072 {
3073         account_type_h account_type = NULL;
3074         int ret = ACCOUNT_ERROR_NONE;
3075         const char* label = "label";
3076         const char* locale = "locale";
3077
3078         ret = account_type_create(&account_type);
3079         assert_eq(ret, ACCOUNT_ERROR_NONE);
3080
3081         ret = account_type_set_label_internal(NULL, label, locale);
3082         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3083
3084         ret = account_type_set_label_internal(account_type, NULL, locale);
3085         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3086
3087         ret = account_type_set_label_internal(account_type, label, NULL);
3088         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3089
3090         ret = account_type_destroy(account_type);
3091         assert_eq(ret, ACCOUNT_ERROR_NONE);
3092
3093         return 0;
3094 }
3095
3096 int utc_account_type_get_label_by_locale_p(void)
3097 {
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;
3103
3104         ret = account_type_create(&account_type);
3105         assert_eq(ret, ACCOUNT_ERROR_NONE);
3106
3107         ret = account_type_set_label_internal(account_type, label, locale);
3108         assert_eq(ret, ACCOUNT_ERROR_NONE);
3109
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);
3114
3115         ret = account_type_destroy(account_type);
3116         assert_eq(ret, ACCOUNT_ERROR_NONE);
3117
3118         return 0;
3119 }
3120
3121 int utc_account_type_get_label_by_locale_n(void)
3122 {
3123         account_type_h account_type = NULL;
3124         int ret = ACCOUNT_ERROR_NONE;
3125         char* ret_label = NULL;
3126         const char* locale = "locale";
3127
3128         ret = account_type_create(&account_type);
3129         assert_eq(ret, ACCOUNT_ERROR_NONE);
3130
3131         ret = account_type_get_label_by_locale(NULL, locale, &ret_label);
3132         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3133
3134         ret = account_type_get_label_by_locale(account_type, locale, NULL);
3135         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3136
3137         ret = account_type_destroy(account_type);
3138         assert_eq(ret, ACCOUNT_ERROR_NONE);
3139
3140         return 0;
3141 }
3142
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)
3146         {
3147                 const char* _label = (const char*)user_data;
3148                 if(strcmp(label, _label)==0)
3149                         _is_fail = false;
3150         }
3151
3152 //      g_main_loop_quit(mainloop);
3153 //      mainloop = NULL;
3154         return TRUE;
3155 }
3156
3157 int utc_account_type_get_label_p(void)
3158 {
3159         account_type_h account_type = NULL;
3160         int ret = ACCOUNT_ERROR_NONE;
3161         const char* label = "label";
3162         const char* locale = "locale";
3163
3164         ret = account_type_create(&account_type);
3165         assert_eq(ret, ACCOUNT_ERROR_NONE);
3166
3167         ret = account_type_set_label_internal(account_type, label, locale);
3168         assert_eq(ret, ACCOUNT_ERROR_NONE);
3169
3170 //      mainloop = g_main_loop_new(NULL, FALSE);
3171 //      assert(mainloop);
3172
3173         ret = account_type_get_label(account_type, account_label_cb_func, (void*)label);
3174 //      assert_eq(_is_fail, false);
3175         is_callback_fail();
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);
3180         _is_fail = true;
3181
3182         ret = account_type_destroy(account_type);
3183         assert_eq(ret, ACCOUNT_ERROR_NONE);
3184
3185         return 0;
3186 }
3187
3188 int utc_account_type_get_label_n(void)
3189 {
3190         account_type_h account_type = NULL;
3191         int ret = ACCOUNT_ERROR_NONE;
3192
3193         ret = account_type_create(&account_type);
3194         assert_eq(ret, ACCOUNT_ERROR_NONE);
3195
3196         ret = account_type_get_label(NULL, account_label_cb_func, NULL);
3197         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3198
3199         ret = account_type_get_label(account_type, NULL, NULL);
3200         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3201
3202         ret = account_type_destroy(account_type);
3203         assert_eq(ret, ACCOUNT_ERROR_NONE);
3204
3205         return 0;
3206 }
3207
3208 int utc_account_type_set_multiple_account_support_p(void)
3209 {
3210         int ret = account_type_set_multiple_account_support(NULL, true);
3211         assert_eq(ret, ACCOUNT_ERROR_NONE);
3212
3213         return 0;
3214 }
3215
3216 int utc_account_type_set_multiple_account_support_n(void)
3217 {
3218         int ret = account_type_set_multiple_account_support(NULL, true);
3219         assert_eq(ret, ACCOUNT_ERROR_NONE);
3220
3221         return 0;
3222 }
3223
3224 int utc_account_type_set_multiple_account_support_internal_p(void)
3225 {
3226         account_type_h account_type = NULL;
3227         int ret = ACCOUNT_ERROR_NONE;
3228         int ret_val = -1;
3229
3230         ret = account_type_create(&account_type);
3231         assert_eq(ret, ACCOUNT_ERROR_NONE);
3232
3233         ret = account_type_set_multiple_account_support_internal(account_type, true);
3234         assert_eq(ret, ACCOUNT_ERROR_NONE);
3235
3236         ret = account_type_destroy(account_type);
3237         assert_eq(ret, ACCOUNT_ERROR_NONE);
3238
3239         return 0;
3240 }
3241
3242 int utc_account_type_set_multiple_account_support_internal_n(void)
3243 {
3244         int ret = ACCOUNT_ERROR_NONE;
3245
3246         ret = account_type_set_multiple_account_support_internal(NULL, true);
3247         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3248
3249         return 0;
3250 }
3251
3252 int utc_account_type_get_multiple_account_support_p(void)
3253 {
3254         account_type_h account_type = NULL;
3255         int ret = ACCOUNT_ERROR_NONE;
3256         int ret_val = 0;
3257
3258         ret = account_type_create(&account_type);
3259         assert_eq(ret, ACCOUNT_ERROR_NONE);
3260
3261         ret = account_type_set_multiple_account_support_internal(account_type, true);
3262         assert_eq(ret, ACCOUNT_ERROR_NONE);
3263
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);
3267
3268         ret = account_type_destroy(account_type);
3269         assert_eq(ret, ACCOUNT_ERROR_NONE);
3270
3271         return 0;
3272 }
3273
3274 int utc_account_type_get_multiple_account_support_n(void)
3275 {
3276         account_type_h account_type = NULL;
3277         int ret = ACCOUNT_ERROR_NONE;
3278         bool ret_val = true;
3279
3280         ret = account_type_create(&account_type);
3281         assert_eq(ret, ACCOUNT_ERROR_NONE);
3282
3283         ret = account_type_get_multiple_account_support(NULL, &ret_val);
3284         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3285
3286         ret = account_type_get_multiple_account_support(account_type, NULL);
3287         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3288
3289         ret = account_type_destroy(account_type);
3290         assert_eq(ret, ACCOUNT_ERROR_NONE);
3291
3292         return 0;
3293 }
3294
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)
3298         {
3299                 const char* _capability = (const char*)user_data;
3300                 check_fail(strcmp(key, _capability)==0)
3301         }
3302 //      g_main_loop_quit(mainloop);
3303 //      mainloop = NULL;
3304         _is_fail = false;
3305
3306         return TRUE;
3307 }
3308
3309 int utc_account_type_set_provider_feature_p(void)
3310 {
3311         int ret = account_type_set_provider_feature(NULL, NULL);
3312         assert_eq(ret, ACCOUNT_ERROR_NONE);
3313
3314         return TRUE;
3315 }
3316
3317 int utc_account_type_set_provider_feature_n(void)
3318 {
3319         int ret = account_type_set_provider_feature(NULL, NULL);
3320         assert_eq(ret, ACCOUNT_ERROR_NONE);
3321
3322         return TRUE;
3323 }
3324
3325 int utc_account_type_set_provider_feature_internal_p(void)
3326 {
3327         account_type_h account_type = NULL;
3328         int ret = ACCOUNT_ERROR_NONE;
3329         const char* provider_feature = "provider_feature";
3330
3331         ret = account_type_create(&account_type);
3332         assert_eq(ret, ACCOUNT_ERROR_NONE);
3333
3334         ret = account_type_set_provider_feature_internal(account_type, provider_feature);
3335         assert_eq(ret, ACCOUNT_ERROR_NONE);
3336
3337         ret = account_type_destroy(account_type);
3338         assert_eq(ret, ACCOUNT_ERROR_NONE);
3339
3340         return 0;
3341 }
3342
3343 int utc_account_type_set_provider_feature_internal_n(void)
3344 {
3345         account_type_h account_type = NULL;
3346         int ret = ACCOUNT_ERROR_NONE;
3347         const char* provider_feature = "provider_feature";
3348
3349         ret = account_type_create(&account_type);
3350         assert_eq(ret, ACCOUNT_ERROR_NONE);
3351
3352         ret = account_type_set_provider_feature_internal(NULL, provider_feature);
3353         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3354
3355         ret = account_type_set_provider_feature_internal(account_type, NULL);
3356         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3357
3358         ret = account_type_destroy(account_type);
3359         assert_eq(ret, ACCOUNT_ERROR_NONE);
3360
3361         return 0;
3362 }
3363
3364 int utc_account_type_get_provider_feature_all_p(void)
3365 {
3366         account_type_h account_type = NULL;
3367         int ret = ACCOUNT_ERROR_NONE;
3368         const char* provider_feature = "provider_feature";
3369
3370         ret = account_type_create(&account_type);
3371         assert_eq(ret, ACCOUNT_ERROR_NONE);
3372
3373         ret = account_type_set_provider_feature_internal(account_type, provider_feature);
3374         assert_eq(ret, ACCOUNT_ERROR_NONE);
3375
3376 //      mainloop = g_main_loop_new(NULL, FALSE);
3377 //      assert(mainloop);
3378
3379         ret = account_type_get_provider_feature_all(account_type, provider_feature_cb_func, (void *)provider_feature);
3380 //      assert_eq(_is_fail, false);
3381         is_callback_fail();
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);
3386         _is_fail = true;
3387
3388         ret = account_type_destroy(account_type);
3389         assert_eq(ret, ACCOUNT_ERROR_NONE);
3390
3391         return 0;
3392 }
3393
3394 int utc_account_type_get_provider_feature_all_n(void)
3395 {
3396         account_type_h account_type = NULL;
3397         int ret = ACCOUNT_ERROR_NONE;
3398
3399         ret = account_type_create(&account_type);
3400         assert_eq(ret, ACCOUNT_ERROR_NONE);
3401
3402         ret = account_type_get_provider_feature_all(NULL, provider_feature_cb_func, NULL);
3403         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3404
3405         ret = account_type_get_provider_feature_all(account_type, NULL, NULL);
3406         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3407
3408         ret = account_type_destroy(account_type);
3409         assert_eq(ret, ACCOUNT_ERROR_NONE);
3410
3411         return 0;
3412 }
3413
3414 int utc_account_type_set_service_provider_id_p(void)
3415 {
3416         int ret = account_type_set_service_provider_id(NULL, NULL);
3417         assert_eq(ret, ACCOUNT_ERROR_NONE);
3418
3419         return 0;
3420 }
3421
3422 int utc_account_type_set_service_provider_id_n(void)
3423 {
3424         int ret = account_type_set_service_provider_id(NULL, NULL);
3425         assert_eq(ret, ACCOUNT_ERROR_NONE);
3426
3427         return 0;
3428 }
3429
3430 int utc_account_type_set_service_provider_id_internal_p(void)
3431 {
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;
3436
3437         ret = account_type_create(&account_type);
3438         assert_eq(ret, ACCOUNT_ERROR_NONE);
3439
3440         ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
3441         assert_eq(ret, ACCOUNT_ERROR_NONE);
3442
3443         ret = account_type_destroy(account_type);
3444         assert_eq(ret, ACCOUNT_ERROR_NONE);
3445
3446         return 0;
3447 }
3448
3449 int utc_account_type_set_service_provider_id_internal_n(void)
3450 {
3451         account_type_h account_type = NULL;
3452         int ret = ACCOUNT_ERROR_NONE;
3453         const char* service_provider_id = "service_provider_id";
3454
3455         ret = account_type_create(&account_type);
3456         assert_eq(ret, ACCOUNT_ERROR_NONE);
3457
3458         ret = account_type_set_service_provider_id_internal(NULL, service_provider_id);
3459         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3460
3461         ret = account_type_set_service_provider_id_internal(account_type, NULL);
3462         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3463
3464         ret = account_type_destroy(account_type);
3465         assert_eq(ret, ACCOUNT_ERROR_NONE);
3466
3467         return 0;
3468 }
3469
3470 int utc_account_type_get_service_provider_id_p(void)
3471 {
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;
3476
3477         ret = account_type_create(&account_type);
3478         assert_eq(ret, ACCOUNT_ERROR_NONE);
3479
3480         ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
3481         assert_eq(ret, ACCOUNT_ERROR_NONE);
3482
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);
3487
3488         ret = account_type_destroy(account_type);
3489         assert_eq(ret, ACCOUNT_ERROR_NONE);
3490
3491         return 0;
3492 }
3493
3494 int utc_account_type_get_service_provider_id_n(void)
3495 {
3496         account_type_h account_type = NULL;
3497         int ret = ACCOUNT_ERROR_NONE;
3498         char* ret_service_provider_id = NULL;
3499
3500         ret = account_type_create(&account_type);
3501         assert_eq(ret, ACCOUNT_ERROR_NONE);
3502
3503         ret = account_type_get_service_provider_id(account_type, NULL);
3504         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3505
3506         ret = account_type_get_service_provider_id(NULL, &ret_service_provider_id);
3507         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3508
3509         ret = account_type_destroy(account_type);
3510         assert_eq(ret, ACCOUNT_ERROR_NONE);
3511
3512         return 0;
3513 }
3514
3515 int utc_account_type_set_small_icon_path_p(void)
3516 {
3517         int ret = account_type_set_small_icon_path(NULL, NULL);
3518         assert_eq(ret, ACCOUNT_ERROR_NONE);
3519
3520         return 0;
3521 }
3522
3523 int utc_account_type_set_small_icon_path_n(void)
3524 {
3525         int ret = account_type_set_small_icon_path(NULL, NULL);
3526         assert_eq(ret, ACCOUNT_ERROR_NONE);
3527
3528         return 0;
3529 }
3530
3531 int utc_account_type_set_small_icon_path_internal_p(void)
3532 {
3533         account_type_h account_type = NULL;
3534         int ret = ACCOUNT_ERROR_NONE;
3535         const char* small_icon_path = "small_icon_path";
3536
3537         ret = account_type_create(&account_type);
3538         assert_eq(ret, ACCOUNT_ERROR_NONE);
3539
3540         ret = account_type_set_small_icon_path_internal(account_type, small_icon_path);
3541         assert_eq(ret, ACCOUNT_ERROR_NONE);
3542
3543         ret = account_type_destroy(account_type);
3544         assert_eq(ret, ACCOUNT_ERROR_NONE);
3545
3546         return 0;
3547 }
3548
3549 int utc_account_type_set_small_icon_path_internal_n(void)
3550 {
3551         account_type_h account_type = NULL;
3552         int ret = ACCOUNT_ERROR_NONE;
3553         const char* small_icon_path = "small_icon_path";
3554
3555         ret = account_type_create(&account_type);
3556         assert_eq(ret, ACCOUNT_ERROR_NONE);
3557
3558         ret = account_type_set_small_icon_path_internal(NULL, small_icon_path);
3559         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3560
3561         ret = account_type_set_small_icon_path_internal(account_type, NULL);
3562         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3563
3564         ret = account_type_destroy(account_type);
3565         assert_eq(ret, ACCOUNT_ERROR_NONE);
3566
3567         return 0;
3568 }
3569
3570 int utc_account_type_get_small_icon_path_p(void)
3571 {
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";
3576
3577         ret = account_type_create(&account_type);
3578         assert_eq(ret, ACCOUNT_ERROR_NONE);
3579
3580         ret = account_type_set_small_icon_path_internal(account_type, small_icon_path);
3581         assert_eq(ret, ACCOUNT_ERROR_NONE);
3582
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);
3587
3588         ret = account_type_destroy(account_type);
3589         assert_eq(ret, ACCOUNT_ERROR_NONE);
3590
3591         return 0;
3592 }
3593
3594 int utc_account_type_get_small_icon_path_n(void)
3595 {
3596         account_type_h account_type = NULL;
3597         int ret = ACCOUNT_ERROR_NONE;
3598         char* ret_small_icon_path = NULL;
3599
3600         ret = account_type_create(&account_type);
3601         assert_eq(ret, ACCOUNT_ERROR_NONE);
3602
3603         ret = account_type_get_small_icon_path(NULL, &ret_small_icon_path);
3604         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3605
3606         ret = account_type_get_small_icon_path(account_type, NULL);
3607         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3608
3609         ret = account_type_destroy(account_type);
3610         assert_eq(ret, ACCOUNT_ERROR_NONE);
3611
3612         return 0;
3613 }
3614
3615 int utc_account_type_insert_to_db_p(void)
3616 {
3617         int ret = account_type_insert_to_db(NULL, NULL);
3618         assert_eq(ret, ACCOUNT_ERROR_NONE);
3619
3620         return 0;
3621 }
3622
3623 int utc_account_type_insert_to_db_n(void)
3624 {
3625         int ret = account_type_insert_to_db(NULL, NULL);
3626         assert_eq(ret, ACCOUNT_ERROR_NONE);
3627
3628         return 0;
3629 }
3630
3631 int utc_account_type_insert_to_db_internal_p(void)
3632 {
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;
3651
3652         ret = account_type_create(&account_type);
3653         assert_eq(ret, ACCOUNT_ERROR_NONE);
3654
3655         ret = account_type_set_app_id_internal(account_type, app_id);
3656         assert_eq(ret, ACCOUNT_ERROR_NONE);
3657
3658         ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
3659         assert_eq(ret, ACCOUNT_ERROR_NONE);
3660
3661         ret = account_type_set_icon_path_internal(account_type, icon_path);
3662         assert_eq(ret, ACCOUNT_ERROR_NONE);
3663
3664         ret = account_type_set_small_icon_path_internal(account_type, small_icon_path);
3665         assert_eq(ret, ACCOUNT_ERROR_NONE);
3666
3667         ret = account_type_set_multiple_account_support_internal(account_type, multi_account_support);
3668         assert_eq(ret, ACCOUNT_ERROR_NONE);
3669
3670         ret = account_type_set_label_internal(account_type, label, locale);
3671         assert_eq(ret, ACCOUNT_ERROR_NONE);
3672
3673         ret = account_type_set_provider_feature_internal(account_type, contact_capability);
3674         assert_eq(ret, ACCOUNT_ERROR_NONE);
3675
3676         ret = account_type_insert_to_db_internal(account_type, &account_type_id);
3677         assert_eq(ret, ACCOUNT_ERROR_NONE);
3678
3679         ret = account_type_destroy(account_type);
3680         assert_eq(ret, ACCOUNT_ERROR_NONE);
3681
3682         ret = account_type_create(&ret_account_type);
3683         assert_eq(ret, ACCOUNT_ERROR_NONE);
3684
3685         ret = account_type_query_by_app_id(app_id, &ret_account_type);
3686         assert_eq(ret, ACCOUNT_ERROR_NONE);
3687
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);
3692
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);
3697
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);
3702
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);
3707
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);
3711
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);
3716
3717         ret = account_type_get_provider_feature_all(account_type, provider_feature_cb_func, (void *)contact_capability);
3718 //      assert_eq(_is_fail, false);
3719         is_callback_fail();
3720         assert_eq(ret, ACCOUNT_ERROR_NONE);
3721         _is_fail = true;
3722
3723         ret = account_type_destroy(ret_account_type);
3724         assert_eq(ret, ACCOUNT_ERROR_NONE);
3725
3726         ret = account_type_delete_by_app_id_internal(app_id);
3727         assert_eq(ret, ACCOUNT_ERROR_NONE);
3728
3729         return 0;
3730 }
3731
3732 int utc_account_type_insert_to_db_internal_n(void)
3733 {
3734         account_type_h account_type = NULL;
3735         int ret = ACCOUNT_ERROR_NONE;
3736         int account_type_id = 0;
3737
3738         ret = account_type_create(&account_type);
3739         assert_eq(ret, ACCOUNT_ERROR_NONE);
3740
3741         ret = account_type_insert_to_db_internal(NULL, &account_type_id);
3742         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3743
3744         ret = account_type_insert_to_db_internal(account_type, NULL);
3745         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3746
3747         ret = account_type_destroy(account_type);
3748         assert_eq(ret, ACCOUNT_ERROR_NONE);
3749
3750         return 0;
3751 }
3752
3753 int utc_account_type_update_to_db_by_app_id_p(void)
3754 {
3755         int ret = account_type_update_to_db_by_app_id(NULL, NULL);
3756         assert_eq(ret, ACCOUNT_ERROR_NONE);
3757
3758         return 0;
3759 }
3760
3761 int utc_account_type_update_to_db_by_app_id_n(void)
3762 {
3763         int ret = account_type_update_to_db_by_app_id(NULL, NULL);
3764         assert_eq(ret, ACCOUNT_ERROR_NONE);
3765
3766         return 0;
3767 }
3768
3769 int utc_account_type_update_to_db_by_app_id_internal_p(void)
3770 {
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;
3793
3794         ret = account_type_create(&account_type);
3795         assert_eq(ret, ACCOUNT_ERROR_NONE);
3796
3797         ret = account_type_create(&ret_account_type);
3798         assert_eq(ret, ACCOUNT_ERROR_NONE);
3799
3800         ret = account_type_set_app_id_internal(account_type, app_id);
3801         assert_eq(ret, ACCOUNT_ERROR_NONE);
3802
3803         ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
3804         assert_eq(ret, ACCOUNT_ERROR_NONE);
3805
3806         ret = account_type_set_icon_path_internal(account_type, icon_path);
3807         assert_eq(ret, ACCOUNT_ERROR_NONE);
3808
3809         ret = account_type_set_small_icon_path_internal(account_type, small_icon_path);
3810         assert_eq(ret, ACCOUNT_ERROR_NONE);
3811
3812         ret = account_type_set_multiple_account_support_internal(account_type, multi_account_support);
3813         assert_eq(ret, ACCOUNT_ERROR_NONE);
3814
3815         ret = account_type_set_label_internal(account_type, label, locale);
3816         assert_eq(ret, ACCOUNT_ERROR_NONE);
3817
3818         ret = account_type_set_provider_feature_internal(account_type, contact_capability);
3819         assert_eq(ret, ACCOUNT_ERROR_NONE);
3820
3821         ret = account_type_insert_to_db_internal(account_type, &account_type_id);
3822         assert_eq(ret, ACCOUNT_ERROR_NONE);
3823
3824         ret = account_type_destroy(account_type);
3825         assert_eq(ret, ACCOUNT_ERROR_NONE);
3826
3827         ret = account_type_create(&account_type);
3828         assert_eq(ret, ACCOUNT_ERROR_NONE);
3829
3830         ret = account_type_query_by_app_id(app_id, &account_type);
3831         assert_eq(ret, ACCOUNT_ERROR_NONE);
3832
3833         ret = account_type_set_icon_path_internal(account_type, update_icon_path);
3834         assert_eq(ret, ACCOUNT_ERROR_NONE);
3835
3836         ret = account_type_set_small_icon_path_internal(account_type, update_small_icon_path);
3837         assert_eq(ret, ACCOUNT_ERROR_NONE);
3838
3839         ret = account_type_set_multiple_account_support_internal(account_type, update_multi_account_support);
3840         assert_eq(ret, ACCOUNT_ERROR_NONE);
3841
3842         ret = account_type_set_label_internal(account_type, update_label, locale);
3843         assert_eq(ret, ACCOUNT_ERROR_NONE);
3844
3845         ret = account_type_set_provider_feature_internal(account_type, calendar_capability);
3846         assert_eq(ret, ACCOUNT_ERROR_NONE);
3847
3848         ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
3849         assert_eq(ret, ACCOUNT_ERROR_NONE);
3850
3851         ret = account_type_update_to_db_by_app_id_internal(account_type, app_id);
3852         assert_eq(ret, ACCOUNT_ERROR_NONE);
3853
3854         ret = account_type_query_by_app_id(app_id, &ret_account_type);
3855         assert_eq(ret, ACCOUNT_ERROR_NONE);
3856
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);
3861
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);
3866
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);
3871
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);
3876
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);
3880
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);
3885
3886         ret = account_type_get_provider_feature_all(ret_account_type, provider_feature_cb_func, (void *)calendar_capability);
3887 //      assert_eq(_is_fail, false);
3888         is_callback_fail();
3889         assert_eq(ret, ACCOUNT_ERROR_NONE);
3890         _is_fail = true;
3891
3892         ret = account_type_destroy(account_type);
3893         assert_eq(ret, ACCOUNT_ERROR_NONE);
3894
3895         ret = account_type_destroy(ret_account_type);
3896         assert_eq(ret, ACCOUNT_ERROR_NONE);
3897
3898         ret = account_type_delete_by_app_id_internal(app_id);
3899         assert_eq(ret, ACCOUNT_ERROR_NONE);
3900
3901         return 0;
3902 }
3903
3904 int utc_account_type_update_to_db_by_app_id_internal_n(void)
3905 {
3906         account_type_h account_type = NULL;
3907         int ret = ACCOUNT_ERROR_NONE;
3908         const char* app_id = "small_icon_path";
3909
3910         ret = account_type_create(&account_type);
3911         assert_eq(ret, ACCOUNT_ERROR_NONE);
3912
3913         ret = account_type_update_to_db_by_app_id_internal(NULL, app_id);
3914         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3915
3916         ret = account_type_update_to_db_by_app_id_internal(account_type, NULL);
3917         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3918
3919         ret = account_type_destroy(account_type);
3920         assert_eq(ret, ACCOUNT_ERROR_NONE);
3921
3922         return 0;
3923 }
3924
3925 int utc_account_type_query_by_app_id_p(void)
3926 {
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;
3935
3936         ret = account_type_create(&account_type);
3937         assert_eq(ret, ACCOUNT_ERROR_NONE);
3938
3939         ret = account_type_create(&ret_account_type);
3940         assert_eq(ret, ACCOUNT_ERROR_NONE);
3941
3942         ret = account_type_set_app_id_internal(account_type, app_id);
3943         assert_eq(ret, ACCOUNT_ERROR_NONE);
3944
3945         ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
3946         assert_eq(ret, ACCOUNT_ERROR_NONE);
3947
3948         ret = account_type_insert_to_db_internal(account_type, &account_type_id);
3949         assert_eq(ret, ACCOUNT_ERROR_NONE);
3950
3951         ret = account_type_query_by_app_id(app_id, &ret_account_type);
3952         assert_eq(ret, ACCOUNT_ERROR_NONE);
3953
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);
3958
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);
3963
3964         ret = account_type_destroy(account_type);
3965         assert_eq(ret, ACCOUNT_ERROR_NONE);
3966
3967         ret = account_type_destroy(ret_account_type);
3968         assert_eq(ret, ACCOUNT_ERROR_NONE);
3969
3970         ret = account_type_delete_by_app_id_internal(app_id);
3971         assert_eq(ret, ACCOUNT_ERROR_NONE);
3972
3973         return 0;
3974 }
3975
3976
3977 int utc_account_type_query_by_app_id_n(void)
3978 {
3979         account_type_h account_type = NULL;
3980         int ret = ACCOUNT_ERROR_NONE;
3981         const char* app_id = "account_type_query_by_app_id";
3982
3983         ret = account_type_query_by_app_id(app_id, &account_type);
3984         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3985
3986         ret = account_type_create(&account_type);
3987         assert_eq(ret, ACCOUNT_ERROR_NONE);
3988
3989         ret = account_type_query_by_app_id(NULL, &account_type);
3990         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3991
3992         ret = account_type_query_by_app_id(app_id, NULL);
3993         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
3994
3995         ret = account_type_destroy(account_type);
3996         assert_eq(ret, ACCOUNT_ERROR_NONE);
3997
3998         return 0;
3999 }
4000
4001
4002 int utc_account_type_query_app_id_exist_p(void)
4003 {
4004         account_type_h account_type = NULL;
4005         int ret = ACCOUNT_ERROR_NONE;
4006         const char* app_id = "account_type_query_app_id_exist";
4007         int a_type_id = -1;
4008
4009         ret = account_type_query_app_id_exist(app_id);
4010         assert_eq(ret, ACCOUNT_ERROR_RECORD_NOT_FOUND);
4011
4012         ret = account_type_create(&account_type);
4013         assert_eq(ret, ACCOUNT_ERROR_NONE);
4014
4015         ret = account_type_set_app_id_internal(account_type, app_id);
4016         assert_eq(ret, ACCOUNT_ERROR_NONE);
4017
4018         ret = account_type_insert_to_db_internal(account_type, &a_type_id);
4019         assert_eq(ret, ACCOUNT_ERROR_NONE);
4020
4021         ret = account_type_query_app_id_exist(app_id);
4022         assert_eq(ret, ACCOUNT_ERROR_NONE);
4023
4024         account_type_destroy(account_type);
4025         assert_eq(ret, ACCOUNT_ERROR_NONE);
4026
4027         account_type_delete_by_app_id_internal(app_id);
4028         assert_eq(ret, ACCOUNT_ERROR_NONE);
4029
4030         return 0;
4031 }
4032
4033 int utc_account_type_query_app_id_exist_n(void)
4034 {
4035         int ret = ACCOUNT_ERROR_NONE;
4036
4037         ret = account_type_query_app_id_exist(NULL);
4038         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4039
4040         return 0;
4041 }
4042
4043 static bool account_type_for_query_by_provider_cb(account_type_h account_type, void *user_data)
4044 {
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;
4057         char* label = NULL;
4058         char* ret_label = NULL;
4059         const char* locale = "locale";
4060         char* capability = "capability";
4061         bool ret_multi_account_support = false;
4062
4063         check_fail(account_type != NULL && user_data != NULL && user_data != NULL);
4064
4065         ret_account_type = *((account_type_h*)user_data);
4066
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);
4074
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);
4082
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);
4090
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);
4098
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);
4104
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);
4112
4113         _is_fail = true;
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);
4117
4118         _is_fail = true;
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);
4122
4123         _is_fail = false;
4124
4125 //      g_main_loop_quit(mainloop);
4126 //      mainloop = NULL;
4127
4128     return true;
4129 }
4130
4131
4132 int utc_account_type_query_by_provider_feature_p(void)
4133 {
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";
4144
4145         int a_type_id = -1;
4146
4147         ret = account_type_create(&account_type);
4148         assert_eq(ret, ACCOUNT_ERROR_NONE);
4149
4150         ret = account_type_set_app_id_internal(account_type, app_id);
4151         assert_eq(ret, ACCOUNT_ERROR_NONE);
4152
4153         ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
4154         assert_eq(ret, ACCOUNT_ERROR_NONE);
4155
4156         ret = account_type_set_icon_path_internal(account_type, icon_path);
4157         assert_eq(ret, ACCOUNT_ERROR_NONE);
4158
4159         ret = account_type_set_small_icon_path_internal(account_type, small_icon_path);
4160         assert_eq(ret, ACCOUNT_ERROR_NONE);
4161
4162         ret = account_type_set_multiple_account_support_internal(account_type, multi_account_support);
4163         assert_eq(ret, ACCOUNT_ERROR_NONE);
4164
4165         ret = account_type_set_label_internal(account_type, label, locale);
4166         assert_eq(ret, ACCOUNT_ERROR_NONE);
4167
4168         ret = account_type_set_provider_feature_internal(account_type, capability);
4169         assert_eq(ret, ACCOUNT_ERROR_NONE);
4170
4171         ret = account_type_insert_to_db_internal(account_type, &a_type_id);
4172         assert_eq(ret, ACCOUNT_ERROR_NONE);
4173
4174         ret = account_type_query_by_provider_feature(account_type_for_query_by_provider_cb, capability, &account_type);
4175 //      assert_eq(_is_fail, false);
4176         is_callback_fail();
4177         assert_eq(ret, ACCOUNT_ERROR_NONE);
4178
4179         _is_fail = true;
4180
4181         account_type_destroy(account_type);
4182         assert_eq(ret, ACCOUNT_ERROR_NONE);
4183
4184         account_type_delete_by_app_id_internal(app_id);
4185         assert_eq(ret, ACCOUNT_ERROR_NONE);
4186
4187         return 0;
4188 }
4189
4190
4191 int utc_account_type_query_by_provider_feature_n(void)
4192 {
4193         int ret = ACCOUNT_ERROR_NONE;
4194         const char* key = contact_capability;
4195
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);
4198
4199         ret = account_type_query_by_provider_feature(NULL, key, NULL);
4200         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4201
4202         return 0;
4203 }
4204
4205 static bool account_type_for_query_by_app_id_cb(char* app_id, char* label, char* locale, void *user_data)
4206 {
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;
4211
4212         check_fail( app_id!=NULL && label!=NULL && locale!=NULL && user_data!=NULL );
4213         account_type = *((account_type_h*)user_data);
4214
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);
4219
4220         _is_fail = false;
4221
4222         return TRUE;
4223 }
4224
4225 int utc_account_type_query_label_by_app_id_p(void)
4226 {
4227         account_type_h account_type = NULL;
4228         int ret = ACCOUNT_ERROR_NONE;
4229         int a_type_id = -1;
4230
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;
4235
4236         ret = account_type_create(&account_type);
4237         assert_eq(ret, ACCOUNT_ERROR_NONE);
4238
4239         ret = account_type_set_label_internal(account_type, label_t, locale_t);
4240         assert_eq(ret, ACCOUNT_ERROR_NONE);
4241
4242         ret = account_type_set_app_id_internal(account_type, app_id);
4243         assert_eq(ret, ACCOUNT_ERROR_NONE);
4244
4245         ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
4246         assert_eq(ret, ACCOUNT_ERROR_NONE);
4247
4248         ret = account_type_insert_to_db_internal(account_type, &a_type_id);
4249         assert_eq(ret, ACCOUNT_ERROR_NONE);
4250
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);
4253         is_callback_fail();
4254         assert_eq(ret, ACCOUNT_ERROR_NONE);
4255         _is_fail = true;
4256
4257         account_type_destroy(account_type);
4258         assert_eq(ret, ACCOUNT_ERROR_NONE);
4259
4260         account_type_delete_by_app_id_internal(app_id);
4261         assert_eq(ret, ACCOUNT_ERROR_NONE);
4262
4263         return 0;
4264 }
4265
4266 int utc_account_type_query_label_by_app_id_n(void)
4267 {
4268         int ret = ACCOUNT_ERROR_NONE;
4269         const char* app_id = "account_type_query_label_by_app_id";
4270
4271         ret = account_type_query_label_by_app_id(NULL, app_id, NULL);
4272         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4273
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);
4276
4277         return 0;
4278 }
4279
4280 int utc_account_type_query_label_by_locale_p(void)
4281 {
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;
4288         int a_type_id = -1;
4289
4290         ret = account_type_create(&account_type);
4291         assert_eq(ret, ACCOUNT_ERROR_NONE);
4292
4293         ret = account_type_set_label_internal(account_type, label, locale);
4294         assert_eq(ret, ACCOUNT_ERROR_NONE);
4295
4296         ret = account_type_set_app_id_internal(account_type, app_id);
4297         assert_eq(ret, ACCOUNT_ERROR_NONE);
4298
4299         ret = account_type_insert_to_db_internal(account_type, &a_type_id);
4300         assert_eq(ret, ACCOUNT_ERROR_NONE);
4301
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);
4306
4307         ret = account_type_destroy(account_type);
4308         assert_eq(ret, ACCOUNT_ERROR_NONE);
4309
4310         account_type_delete_by_app_id_internal(app_id);
4311         assert_eq(ret, ACCOUNT_ERROR_NONE);
4312
4313         return 0;
4314 }
4315
4316 int utc_account_type_query_label_by_locale_n(void)
4317 {
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;
4322
4323         ret = account_type_get_label_by_locale(NULL, locale, &ret_label);
4324         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4325
4326         ret = account_type_get_label_by_locale(app_id, locale, NULL);
4327         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4328
4329         return 0;
4330 }
4331
4332 int utc_account_type_query_provider_feature_by_app_id_p(void)
4333 {
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;
4339
4340         ret = account_type_create(&account_type);
4341         assert_eq(ret, ACCOUNT_ERROR_NONE);
4342
4343         ret = account_type_set_app_id_internal(account_type, app_id);
4344         assert_eq(ret, ACCOUNT_ERROR_NONE);
4345
4346         ret = account_type_set_provider_feature_internal(account_type, provider_feature);
4347         assert_eq(ret, ACCOUNT_ERROR_NONE);
4348
4349         ret = account_type_insert_to_db_internal(account_type, &account_type_id);
4350         assert_eq(ret, ACCOUNT_ERROR_NONE);
4351
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);
4354         is_callback_fail();
4355         assert_eq(ret, ACCOUNT_ERROR_NONE);
4356         _is_fail = true;
4357
4358         ret = account_type_destroy(account_type);
4359         assert_eq(ret, ACCOUNT_ERROR_NONE);
4360
4361         account_type_delete_by_app_id_internal(app_id);
4362         assert_eq(ret, ACCOUNT_ERROR_NONE);
4363
4364         return 0;
4365 }
4366
4367 int utc_account_type_query_provider_feature_by_app_id_n(void)
4368 {
4369         int ret = ACCOUNT_ERROR_NONE;
4370         const char* app_id = "application_id";
4371
4372         ret = account_type_query_provider_feature_by_app_id(NULL, app_id, NULL);
4373         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4374
4375         ret = account_type_query_provider_feature_by_app_id(provider_feature_cb_func, NULL, NULL);
4376         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4377
4378         return 0;
4379 }
4380
4381 int utc_account_type_query_supported_feature_p(void)
4382 {
4383         account_type_h account_type = NULL;
4384         bool ret = true;
4385         int account_type_id = -1;
4386         const char* app_id = "application_id";
4387         const char* capability = "capability";
4388
4389         ret = account_type_create(&account_type);
4390         assert_eq(ret, ACCOUNT_ERROR_NONE);
4391
4392         ret = account_type_set_app_id_internal(account_type, app_id);
4393         assert_eq(ret, ACCOUNT_ERROR_NONE);
4394
4395         ret = account_type_set_provider_feature_internal(account_type, capability);
4396         assert_eq(ret, ACCOUNT_ERROR_NONE);
4397
4398         ret = account_type_insert_to_db_internal(account_type, &account_type_id);
4399         assert_eq(ret, ACCOUNT_ERROR_NONE);
4400
4401         ret = account_type_query_supported_feature(app_id, capability);
4402         assert_eq(ret, true);
4403
4404         ret = account_type_destroy(account_type);
4405         assert_eq(ret, ACCOUNT_ERROR_NONE);
4406
4407         account_type_delete_by_app_id_internal(app_id);
4408         assert_eq(ret, ACCOUNT_ERROR_NONE);
4409
4410         return 0;
4411 }
4412
4413 int utc_account_type_query_supported_feature_n(void)
4414 {
4415         bool ret = true;
4416         const char* app_id = "application_id";
4417         const char* capability = "capability";
4418
4419         ret = account_type_query_supported_feature(NULL, capability);
4420         assert_eq(ret, FALSE);
4421         assert_eq(get_last_result(), ACCOUNT_ERROR_INVALID_PARAMETER);
4422
4423         ret = account_type_query_supported_feature(app_id, NULL);
4424         assert_eq(ret, FALSE);
4425
4426         return 0;
4427 }
4428
4429 int utc_account_update_to_db_by_id_ex_p(void)
4430 {
4431         assert(connected);
4432         assert(created);
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;
4438
4439         ret = account_set_user_name(account, user_name);
4440         assert_eq(ret, ACCOUNT_ERROR_NONE);
4441
4442         ret = account_set_package_name(account, package_name);
4443         assert_eq(ret, ACCOUNT_ERROR_NONE);
4444
4445         ret = account_insert_to_db(account, &account_id);
4446         assert_eq(ret, ACCOUNT_ERROR_NONE);
4447
4448         ret = account_set_user_name(account, update_user_name);
4449         assert_eq(ret, ACCOUNT_ERROR_NONE);
4450
4451         ret = account_update_to_db_by_id_ex(account, account_id);
4452         assert_eq(ret, ACCOUNT_ERROR_NONE);
4453
4454         ret = account_create(&ret_account);
4455         assert_eq(ret, ACCOUNT_ERROR_NONE);
4456
4457         ret = account_query_account_by_account_id(account_id, &ret_account);
4458         assert_eq(ret, ACCOUNT_ERROR_NONE);
4459
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);
4463
4464         _account_free_text(ret_user_name);
4465         ret = account_destroy(ret_account);
4466         assert_eq(ret, ACCOUNT_ERROR_NONE);
4467
4468         ret = account_delete_from_db_by_id(account_id);
4469         assert_eq(ret, ACCOUNT_ERROR_NONE);
4470
4471         return 0;
4472 }
4473
4474 int utc_account_update_to_db_by_id_ex_n(void)
4475 {
4476         assert(connected);
4477         assert(created);
4478         int ret = ACCOUNT_ERROR_NONE;
4479
4480         ret = account_update_to_db_by_id_ex(account, -1);
4481         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4482
4483         return 0;
4484 }
4485
4486 int utc_account_update_to_db_by_id_without_permission_p(void)
4487 {
4488         assert(connected);
4489         assert(created);
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;
4495
4496         ret = account_set_user_name(account, user_name);
4497         assert_eq(ret, ACCOUNT_ERROR_NONE);
4498
4499         ret = account_set_package_name(account, package_name);
4500         assert_eq(ret, ACCOUNT_ERROR_NONE);
4501
4502         ret = account_insert_to_db(account, &account_id);
4503         assert_eq(ret, ACCOUNT_ERROR_NONE);
4504
4505         ret = account_set_user_name(account, update_user_name);
4506         assert_eq(ret, ACCOUNT_ERROR_NONE);
4507
4508         ret = account_set_package_name(account, package_name);
4509         assert_eq(ret, ACCOUNT_ERROR_NONE);
4510
4511         ret = account_update_to_db_by_id_without_permission(account, account_id);
4512         assert_eq(ret, ACCOUNT_ERROR_NONE);
4513
4514         ret = account_create(&ret_account);
4515         assert_eq(ret, ACCOUNT_ERROR_NONE);
4516
4517         ret = account_query_account_by_account_id(account_id, &ret_account);
4518         assert_eq(ret, ACCOUNT_ERROR_NONE);
4519
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);
4524
4525         ret = account_destroy(ret_account);
4526         assert_eq(ret, ACCOUNT_ERROR_NONE);
4527
4528         ret = account_delete_from_db_by_id(account_id);
4529         assert_eq(ret, ACCOUNT_ERROR_NONE);
4530
4531         return 0;
4532 }
4533
4534 int utc_account_update_to_db_by_id_without_permission_n(void)
4535 {
4536         assert(connected);
4537         assert(created);
4538         int ret = ACCOUNT_ERROR_NONE;
4539         int account_id = 2;
4540
4541         ret = account_update_to_db_by_id_without_permission(NULL, account_id);
4542         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4543
4544         ret = account_update_to_db_by_id_without_permission(account, NULL);
4545         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4546
4547         return 0;
4548 }
4549
4550 int utc_account_type_delete_by_app_id_p(void)
4551 {
4552         int ret = account_type_delete_by_app_id(NULL);
4553         assert_eq(ret, ACCOUNT_ERROR_NONE);
4554
4555         return 0;
4556 }
4557
4558 int utc_account_type_delete_by_app_id_n(void)
4559 {
4560         int ret = account_type_delete_by_app_id(NULL);
4561         assert_eq(ret, ACCOUNT_ERROR_NONE);
4562
4563         return 0;
4564 }
4565
4566 int utc_account_type_delete_by_app_id_internal_p(void)
4567 {
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;
4572
4573         ret = account_type_create(&account_type);
4574         assert_eq(ret, ACCOUNT_ERROR_NONE);
4575
4576         ret = account_type_set_app_id_internal(account_type, app_id);
4577         assert_eq(ret, ACCOUNT_ERROR_NONE);
4578
4579         ret = account_type_insert_to_db_internal(account_type, &account_type_id);
4580         assert_eq(ret, ACCOUNT_ERROR_NONE);
4581
4582         ret = account_type_query_app_id_exist(app_id);
4583         assert_eq(ret, ACCOUNT_ERROR_NONE);
4584
4585         ret = account_type_destroy(account_type);
4586         assert_eq(ret, ACCOUNT_ERROR_NONE);
4587
4588         ret = account_type_delete_by_app_id_internal(app_id);
4589         assert_eq(ret, ACCOUNT_ERROR_NONE);
4590
4591         ret = account_type_query_app_id_exist(app_id);
4592         assert_eq(ret, ACCOUNT_ERROR_RECORD_NOT_FOUND);
4593
4594         return 0;
4595 }
4596
4597 int utc_account_type_delete_by_app_id_internal_n(void)
4598 {
4599         int ret = ACCOUNT_ERROR_NONE;
4600
4601         ret = account_type_delete_by_app_id_internal(NULL);
4602         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4603
4604         return 0;
4605 }
4606
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;
4620         char* label = NULL;
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;
4626
4627         check_fail(account_type != NULL && user_data != NULL && user_data != NULL);
4628
4629         ret_account_type = *((account_type_h*)user_data);
4630
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 )
4634         {
4635                 _is_fail=false;
4636                 return true;
4637         }
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);
4643
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);
4651
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);
4659
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);
4667
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);
4673
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);
4681
4682         _is_fail = true;
4683         ret = account_type_get_provider_feature_all(account_type, provider_feature_cb_func, (void *)contact_capability);
4684
4685         check_fail(ret == ACCOUNT_ERROR_NONE);
4686         check_fail(_is_fail == false);
4687
4688         _is_fail = true;
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);
4692
4693         _is_fail = false;
4694
4695 //      g_main_loop_quit(mainloop);
4696 //      mainloop = NULL;
4697
4698     return true;
4699 }
4700
4701 int utc_account_type_foreach_account_type_from_db_p(void)
4702 {
4703         assert(connected);
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;
4721
4722         ret = account_type_create(&account_type);
4723         assert_eq(ret, ACCOUNT_ERROR_NONE);
4724
4725         ret = account_type_set_app_id_internal(account_type, app_id);
4726         assert_eq(ret, ACCOUNT_ERROR_NONE);
4727
4728         ret = account_type_set_service_provider_id_internal(account_type, service_provider_id);
4729         assert_eq(ret, ACCOUNT_ERROR_NONE);
4730
4731         ret = account_type_set_icon_path_internal(account_type, icon_path);
4732         assert_eq(ret, ACCOUNT_ERROR_NONE);
4733
4734         ret = account_type_set_small_icon_path_internal(account_type, small_icon_path);
4735         assert_eq(ret, ACCOUNT_ERROR_NONE);
4736
4737         ret = account_type_set_multiple_account_support_internal(account_type, multi_account_support);
4738         assert_eq(ret, ACCOUNT_ERROR_NONE);
4739
4740         ret = account_type_set_label_internal(account_type, label, locale);
4741         assert_eq(ret, ACCOUNT_ERROR_NONE);
4742
4743         ret = account_type_set_provider_feature_internal(account_type, contact_capability);
4744         assert_eq(ret, ACCOUNT_ERROR_NONE);
4745
4746         ret = account_type_insert_to_db_internal(account_type, &account_type_id);
4747         assert_eq(ret, ACCOUNT_ERROR_NONE);
4748
4749         _is_fail = true;
4750
4751         ret = account_type_foreach_account_type_from_db(account_type_cb_func, &account_type);
4752 //      assert_eq(_is_fail, false);
4753         is_callback_fail();
4754         assert_eq(ret, ACCOUNT_ERROR_NONE);
4755
4756         _is_fail = true;
4757
4758         ret = account_type_destroy(account_type);
4759         assert_eq(ret, ACCOUNT_ERROR_NONE);
4760
4761         account_type_delete_by_app_id_internal(app_id);
4762         assert_eq(ret, ACCOUNT_ERROR_NONE);
4763
4764         return 0;
4765 }
4766
4767 int utc_account_type_foreach_account_type_from_db_n(void)
4768 {
4769         int ret = ACCOUNT_ERROR_NONE;
4770
4771         ret = account_type_foreach_account_type_from_db(NULL, NULL);
4772         assert_eq(ret, ACCOUNT_ERROR_INVALID_PARAMETER);
4773
4774         return 0;
4775 }
4776