[ACR-1643] Add to search ebooks with keywords
[platform/core/api/media-content.git] / test / media-content_test.c
1 /*
2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <sys/time.h>
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <unistd.h>
21 #include <media_content.h>
22 #include <media_info_private.h>
23 #include <dlog.h>
24 #include <pthread.h>
25 #include <glib.h>
26 #include <tzplatform_config.h>
27 #include <media_content_internal.h>
28
29
30 filter_h g_filter = NULL;
31 filter_h g_filter_g = NULL;     /*filter for group like folder, tag, playlist, album, year ... */
32
33 GMainLoop *g_loop = NULL;
34 static int g_cnt = 0;
35 static int g_media_cnt = 0;
36
37 #define test_audio_id   "3304285f-1070-41af-8b4e-f0086cc768f3"
38 #define test_video_id   "53c43e7e-53d2-4194-80a6-55d5dcde0def"
39 #define test_image_id "db1c184c-6f31-43b4-b924-8c00ac5b6197"
40 media_folder_h g_folder = NULL;
41
42 static void get_audio_meta(audio_meta_h audio)
43 {
44         char *c_value = NULL;
45         int i_value = 0;
46         int ret = MEDIA_CONTENT_ERROR_NONE;
47
48         content_debug("=== audio meta ===");
49
50         ret = audio_meta_get_media_id(audio, &c_value);
51         if (ret != MEDIA_CONTENT_ERROR_NONE)
52                 content_error("error when get meta : [%d]", ret);
53
54         if (c_value)
55                 content_debug("audio_id : [%s]", c_value);
56         SAFE_FREE(c_value);
57
58         ret = audio_meta_get_album(audio, &c_value);
59         if (ret != MEDIA_CONTENT_ERROR_NONE)
60                 content_error("error when get meta : [%d]", ret);
61
62         if (c_value)
63                 content_debug("album : [%s]", c_value);
64         SAFE_FREE(c_value);
65
66         ret = audio_meta_get_artist(audio, &c_value);
67         if (ret != MEDIA_CONTENT_ERROR_NONE)
68                 content_error("error when get meta : [%d]", ret);
69
70         if (c_value)
71                 content_debug("artist : [%s]", c_value);
72         SAFE_FREE(c_value);
73
74         ret = audio_meta_get_album_artist(audio, &c_value);
75         if (ret != MEDIA_CONTENT_ERROR_NONE)
76                 content_error("error when get meta : [%d]", ret);
77
78         if (c_value)
79                 content_debug("album_artist : [%s]", c_value);
80         SAFE_FREE(c_value);
81
82         ret = audio_meta_get_genre(audio, &c_value);
83         if (ret != MEDIA_CONTENT_ERROR_NONE)
84                 content_error("error when get meta : [%d]", ret);
85
86         if (c_value)
87                 content_debug("genre : [%s]", c_value);
88         SAFE_FREE(c_value);
89
90         ret = audio_meta_get_composer(audio, &c_value);
91         if (ret != MEDIA_CONTENT_ERROR_NONE)
92                 content_error("error when get meta : [%d]", ret);
93
94         if (c_value)
95                 content_debug("composer : [%s]", c_value);
96         SAFE_FREE(c_value);
97
98         ret = audio_meta_get_year(audio, &c_value);
99         if (ret != MEDIA_CONTENT_ERROR_NONE)
100                 content_error("error when get meta : [%d]", ret);
101
102         if (c_value)
103                 content_debug("year : [%s]", c_value);
104         SAFE_FREE(c_value);
105
106         ret = audio_meta_get_recorded_date(audio, &c_value);
107         if (ret != MEDIA_CONTENT_ERROR_NONE)
108                 content_error("error when get meta : [%d]", ret);
109
110         if (c_value)
111                 content_debug("recorded_date : [%s]", c_value);
112         SAFE_FREE(c_value);
113
114         ret = audio_meta_get_copyright(audio, &c_value);
115         if (ret != MEDIA_CONTENT_ERROR_NONE)
116                 content_error("error when get meta : [%d]", ret);
117
118         if (c_value)
119                 content_debug("copyright : [%s]", c_value);
120         SAFE_FREE(c_value);
121
122         ret = audio_meta_get_track_num(audio, &c_value);
123         if (ret != MEDIA_CONTENT_ERROR_NONE)
124                 content_error("error when get meta : [%d]", ret);
125
126         if (c_value)
127                 content_debug("track_num : [%s]", c_value);
128         SAFE_FREE(c_value);
129
130         ret = audio_meta_get_bit_rate(audio, &i_value);
131         if (ret != MEDIA_CONTENT_ERROR_NONE)
132                 content_error("error when get meta : [%d]", ret);
133         else
134                 content_debug("bitrate : [%d]", i_value);
135
136         ret = audio_meta_get_sample_rate(audio, &i_value);
137         if (ret != MEDIA_CONTENT_ERROR_NONE)
138                 content_error("error when get meta : [%d]", ret);
139         else
140                 content_debug("samplerate : [%d]", i_value);
141
142         ret = audio_meta_get_channel(audio, &i_value);
143         if (ret != MEDIA_CONTENT_ERROR_NONE)
144                 content_error("error when get meta : [%d]", ret);
145         else
146                 content_debug("channel : [%d]", i_value);
147
148         ret = audio_meta_get_duration(audio, &i_value);
149         if (ret != MEDIA_CONTENT_ERROR_NONE)
150                 content_error("error when get meta : [%d]", ret);
151         else
152                 content_debug("duration : [%d]", i_value);
153
154 }
155
156 static void get_video_meta(video_meta_h video)
157 {
158         char *c_value = NULL;
159         int i_value = 0;
160         int ret = MEDIA_CONTENT_ERROR_NONE;
161
162         content_debug("=== video meta ===");
163
164         ret = video_meta_get_media_id(video, &c_value);
165         if (ret != MEDIA_CONTENT_ERROR_NONE)
166                 content_error("error when get meta : [%d]", ret);
167
168         if (c_value)
169                 content_debug("video_id : [%s]", c_value);
170         SAFE_FREE(c_value);
171
172         ret = video_meta_get_album(video, &c_value);
173         if (ret != MEDIA_CONTENT_ERROR_NONE)
174                 content_error("error when get meta : [%d]", ret);
175
176         if (c_value)
177                 content_debug("album : [%s]", c_value);
178         SAFE_FREE(c_value);
179
180         ret = video_meta_get_artist(video, &c_value);
181         if (ret != MEDIA_CONTENT_ERROR_NONE)
182                 content_error("error when get meta : [%d]", ret);
183
184         if (c_value)
185                 content_debug("artist : [%s]", c_value);
186         SAFE_FREE(c_value);
187
188         ret = video_meta_get_album_artist(video, &c_value);
189         if (ret != MEDIA_CONTENT_ERROR_NONE)
190                 content_error("error when get meta : [%d]", ret);
191
192         if (c_value)
193                 content_debug("album_artist : [%s]", c_value);
194         SAFE_FREE(c_value);
195
196         ret = video_meta_get_genre(video, &c_value);
197         if (ret != MEDIA_CONTENT_ERROR_NONE)
198                 content_error("error when get meta : [%d]", ret);
199
200         if (c_value)
201                 content_debug("genre : [%s]", c_value);
202         SAFE_FREE(c_value);
203
204         ret = video_meta_get_composer(video, &c_value);
205         if (ret != MEDIA_CONTENT_ERROR_NONE)
206                 content_error("error when get meta : [%d]", ret);
207
208         if (c_value)
209                 content_debug("omposer : [%s]", c_value);
210         SAFE_FREE(c_value);
211
212         ret = video_meta_get_year(video, &c_value);
213         if (ret != MEDIA_CONTENT_ERROR_NONE)
214                 content_error("error when get meta : [%d]", ret);
215
216         if (c_value)
217                 content_debug("year : [%s]", c_value);
218         SAFE_FREE(c_value);
219
220         ret = video_meta_get_recorded_date(video, &c_value);
221         if (ret != MEDIA_CONTENT_ERROR_NONE)
222                 content_error("error when get meta : [%d]", ret);
223
224         if (c_value)
225                 content_debug("recorded_date : [%s]", c_value);
226         SAFE_FREE(c_value);
227
228         ret = video_meta_get_copyright(video, &c_value);
229         if (ret != MEDIA_CONTENT_ERROR_NONE)
230                 content_error("error when get meta : [%d]", ret);
231
232         if (c_value)
233                 content_debug("copyright : [%s]", c_value);
234         SAFE_FREE(c_value);
235
236         ret = video_meta_get_track_num(video, &c_value);
237         if (ret != MEDIA_CONTENT_ERROR_NONE)
238                 content_error("error when get meta : [%d]", ret);
239
240         if (c_value)
241                 content_debug("track_num : [%s]", c_value);
242         SAFE_FREE(c_value);
243
244         ret = video_meta_get_bit_rate(video, &i_value);
245         if (ret != MEDIA_CONTENT_ERROR_NONE)
246                 content_error("error when get meta : [%d]", ret);
247         else
248                 content_debug("bitrate : [%d]", i_value);
249
250         ret = video_meta_get_duration(video, &i_value);
251         if (ret != MEDIA_CONTENT_ERROR_NONE)
252                 content_error("error when get meta : [%d]", ret);
253         else
254                 content_debug("duration : [%d]", i_value);
255
256         ret = video_meta_get_width(video, &i_value);
257         if (ret != MEDIA_CONTENT_ERROR_NONE)
258                 content_error("error when get meta : [%d]", ret);
259         else
260                 content_debug("width : [%d]", i_value);
261
262         ret = video_meta_get_height(video, &i_value);
263         if (ret != MEDIA_CONTENT_ERROR_NONE)
264                 content_error("error when get meta : [%d]", ret);
265         else
266                 content_debug("height : [%d]", i_value);
267
268 }
269
270 static void get_image_meta(image_meta_h image)
271 {
272         char *c_value = NULL;
273         int i_value = 0;
274         media_content_orientation_e orientation;
275         int ret = MEDIA_CONTENT_ERROR_NONE;
276
277         content_debug("=== image meta ===");
278
279         ret = image_meta_get_width(image, &i_value);
280         if (ret != MEDIA_CONTENT_ERROR_NONE)
281                 content_error("error image_meta_get_width : [%d]", ret);
282         else
283                 content_debug("width : [%d]", i_value);
284
285         ret = image_meta_get_height(image, &i_value);
286         if (ret != MEDIA_CONTENT_ERROR_NONE)
287                 content_error("error image_meta_get_height : [%d]", ret);
288         else
289                 content_debug("height : [%d]", i_value);
290
291         ret = image_meta_get_orientation(image, &orientation);
292         if (ret != MEDIA_CONTENT_ERROR_NONE)
293                 content_error("error image_meta_get_orientation : [%d]", ret);
294         else
295                 content_debug("orientation : [%d]", orientation);
296
297         ret = image_meta_get_date_taken(image, &c_value);
298         if (ret != MEDIA_CONTENT_ERROR_NONE)
299                 content_error("error image_meta_get_date_taken : [%d]", ret);
300
301         if (c_value)
302                 content_debug("date_taken : [%s]", c_value);
303         SAFE_FREE(c_value);
304
305 }
306
307 static void get_album_meta(media_album_h album)
308 {
309         char *c_value = NULL;
310         int i_value = 0;
311         int ret = MEDIA_CONTENT_ERROR_NONE;
312
313         content_debug("=== album meta ===");
314
315         ret = media_album_get_album_id(album, &i_value);
316         if (ret != MEDIA_CONTENT_ERROR_NONE)
317                 content_error("error media_album_get_album_id : [%d]", ret);
318         else
319                 content_debug("album_id : [%d]", i_value);
320
321         ret = media_album_get_name(album, &c_value);
322         if (ret != MEDIA_CONTENT_ERROR_NONE)
323                 content_error("error media_album_get_name : [%d]", ret);
324
325         if (c_value)
326                 content_debug("album_name : [%s]", c_value);
327         SAFE_FREE(c_value);
328
329         ret = media_album_get_artist(album, &c_value);
330         if (ret != MEDIA_CONTENT_ERROR_NONE)
331                 content_error("error media_album_get_artist : [%d]", ret);
332
333         if (c_value)
334                 content_debug("album_artist : [%s]", c_value);
335         SAFE_FREE(c_value);
336
337 }
338
339 static void get_bookmark_meta(media_bookmark_h bookmark)
340 {
341         char *c_value = NULL;
342         int i_value = 0;
343         time_t time = 0;
344         int ret = MEDIA_CONTENT_ERROR_NONE;
345
346         content_debug("=== bookmark meta ===");
347
348         ret = media_bookmark_get_bookmark_id(bookmark, &i_value);
349         if (ret != MEDIA_CONTENT_ERROR_NONE)
350                 content_error("error media_bookmark_get_bookmark_id : [%d]", ret);
351         else
352                 content_debug("bookmark_id : %d", i_value);
353
354         ret = media_bookmark_get_thumbnail_path(bookmark, &c_value);
355         if (ret != MEDIA_CONTENT_ERROR_NONE)
356                 content_error("error media_bookmark_get_thumbnail_path : [%d]", ret);
357
358         if (c_value)
359                 content_debug("bookmark thumbnail_path : %s", c_value);
360         SAFE_FREE(c_value);
361
362         ret = media_bookmark_get_marked_time(bookmark, &time);
363         if (ret != MEDIA_CONTENT_ERROR_NONE)
364                 content_error("error media_bookmark_get_marked_time : [%d]", ret);
365         else
366                 content_debug("bookmark marked_time : %ld", time);
367
368         ret = media_bookmark_get_name(bookmark, &c_value);
369         if (ret != MEDIA_CONTENT_ERROR_NONE)
370                 content_error("error media_bookmark_get_name : [%d]", ret);
371
372         if (c_value)
373                 content_debug("bookmark name : %s", c_value);
374         SAFE_FREE(c_value);
375
376 }
377
378 static void get_tag_meta(media_tag_h tag)
379 {
380         char *c_value = NULL;
381         int i_value = 0;
382         int ret = MEDIA_CONTENT_ERROR_NONE;
383
384         content_debug("=== tag meta ===");
385
386         ret = media_tag_get_tag_id(tag, &i_value);
387         if (ret != MEDIA_CONTENT_ERROR_NONE)
388                 content_error("error media_tag_get_tag_id : [%d]", ret);
389         else
390                 content_debug("tag_id : %d", i_value);
391
392         ret = media_tag_get_name(tag, &c_value);
393         if (ret != MEDIA_CONTENT_ERROR_NONE)
394                 content_error("error media_tag_get_name : [%d]", ret);
395
396         if (c_value)
397                 content_debug("tag_name : %s", c_value);
398         SAFE_FREE(c_value);
399
400 }
401
402 static void get_face_meta(media_face_h face)
403 {
404         char *c_value = NULL;
405         unsigned int rect_x = 0;
406         unsigned int rect_y = 0;
407         unsigned int rect_w = 0;
408         unsigned int rect_h = 0;
409         media_content_orientation_e orientation = 0;
410         int ret = MEDIA_CONTENT_ERROR_NONE;
411
412         content_debug("=== face meta ===");
413
414         ret = media_face_get_face_id(face, &c_value);
415         if (ret != MEDIA_CONTENT_ERROR_NONE)
416                 content_error("error media_face_get_face_id : [%d]", ret);
417
418         if (c_value)
419                 content_debug("face_id : %s", c_value);
420         SAFE_FREE(c_value);
421
422         ret = media_face_get_media_id(face, &c_value);
423         if (ret != MEDIA_CONTENT_ERROR_NONE)
424                 content_error("error media_face_get_media_id : [%d]", ret);
425
426         if (c_value)
427                 content_debug("media_id : %s", c_value);
428         SAFE_FREE(c_value);
429
430         ret = media_face_get_face_rect(face, &rect_x, &rect_y, &rect_w, &rect_h);
431         if (ret != MEDIA_CONTENT_ERROR_NONE)
432                 content_error("error media_face_get_face_rect : [%d]", ret);
433         else
434                 content_debug("face_rect x[%d] y[%d] w[%d] h[%d]", rect_x, rect_y, rect_w, rect_h);
435
436         ret = media_face_get_orientation(face, &orientation);
437         if (ret != MEDIA_CONTENT_ERROR_NONE)
438                 content_error("error media_face_get_orientation : [%d]", ret);
439         else
440                 content_debug("orientation : %d", orientation);
441
442         ret = media_face_get_tag(face, &c_value);
443         if (ret != MEDIA_CONTENT_ERROR_NONE)
444                 content_error("error media_face_get_tag : [%d]", ret);
445
446         if (c_value)
447                 content_debug("tag : %s", c_value);
448         SAFE_FREE(c_value);
449
450 }
451
452 static void get_folder_meta(media_folder_h folder, char **folder_id)
453 {
454         char *c_value = NULL;
455         media_content_storage_e storage_type;
456         int ret = MEDIA_CONTENT_ERROR_NONE;
457
458         content_debug("=== folder meta ===");
459
460         ret = media_folder_get_folder_id(folder, &c_value);
461         if (ret != MEDIA_CONTENT_ERROR_NONE)
462                 content_error("error media_folder_get_folder_id : [%d]", ret);
463
464         if (c_value) {
465                 content_debug("folder_id : %s", c_value);
466                 *folder_id = c_value;
467         }
468
469         ret = media_folder_get_path(folder, &c_value);
470         if (ret != MEDIA_CONTENT_ERROR_NONE)
471                 content_error("error media_folder_get_path : [%d]", ret);
472
473         if (c_value)
474                 content_debug("folder_path : %s", c_value);
475         SAFE_FREE(c_value);
476
477         ret = media_folder_get_name(folder, &c_value);
478         if (ret != MEDIA_CONTENT_ERROR_NONE)
479                 content_error("error media_folder_get_name : [%d]", ret);
480
481         if (c_value)
482                 content_debug("folder_name : %s", c_value);
483         SAFE_FREE(c_value);
484
485         ret = media_folder_get_storage_type(folder, &storage_type);
486         if (ret != MEDIA_CONTENT_ERROR_NONE)
487                 content_error("error media_folder_get_storage_type : [%d]", ret);
488         else
489                 content_debug("storage_type : [%d]", storage_type);
490
491         ret = media_folder_get_storage_id(folder, &c_value);
492         if (ret != MEDIA_CONTENT_ERROR_NONE)
493                 content_error("error media_folder_get_storage_id : [%d]", ret);
494
495         if (c_value)
496                 content_debug("storage_id : %s", c_value);
497         SAFE_FREE(c_value);
498
499 }
500
501 static void get_media_meta(media_info_h media)
502 {
503         char *c_value = NULL;
504         int i_value = 0;
505         time_t t_value = 0;
506         bool b_value = false;
507         unsigned long long size = 0;
508         media_content_type_e media_type = 0;
509         int ret = MEDIA_CONTENT_ERROR_NONE;
510
511         content_debug("=== media meta ===");
512
513         ret = media_info_get_media_type(media, &media_type);
514         if (ret != MEDIA_CONTENT_ERROR_NONE)
515                 content_error("error media_info_get_media_type : [%d]", ret);
516         else
517                 content_debug("media_type : [%d]", media_type);
518
519         ret = media_info_get_media_id(media, &c_value);
520         if (ret != MEDIA_CONTENT_ERROR_NONE)
521                 content_error("error media_info_get_media_id : [%d]", ret);
522
523         if (c_value)
524                 content_debug("media_id : [%s]", c_value);
525         SAFE_FREE(c_value);
526
527         ret = media_info_get_file_path(media, &c_value);
528         if (ret != MEDIA_CONTENT_ERROR_NONE)
529                 content_error("error media_info_get_file_path : [%d]", ret);
530
531         if (c_value)
532                 content_debug("file_path : [%s]", c_value);
533         SAFE_FREE(c_value);
534
535         ret = media_info_get_display_name(media, &c_value);
536         if (ret != MEDIA_CONTENT_ERROR_NONE)
537                 content_error("error media_info_get_display_name : [%d]", ret);
538
539         if (c_value)
540                 content_debug("display_name : [%s]", c_value);
541         SAFE_FREE(c_value);
542
543         ret = media_info_get_mime_type(media, &c_value);
544         if (ret != MEDIA_CONTENT_ERROR_NONE)
545                 content_error("error media_info_get_mime_type : [%d]", ret);
546
547         if (c_value)
548                 content_debug("mime_type : [%s]", c_value);
549         SAFE_FREE(c_value);
550
551         ret = media_info_get_thumbnail_path(media, &c_value);
552         if (ret != MEDIA_CONTENT_ERROR_NONE)
553                 content_error("error media_info_get_thumbnail_path : [%d]", ret);
554
555         if (c_value)
556                 content_debug("thumbnail_path : [%s]", c_value);
557         SAFE_FREE(c_value);
558
559         ret = media_info_get_description(media, &c_value);
560         if (ret != MEDIA_CONTENT_ERROR_NONE)
561                 content_error("error media_info_get_description : [%d]", ret);
562
563         if (c_value)
564                 content_debug("description : [%s]", c_value);
565         SAFE_FREE(c_value);
566
567         ret = media_info_get_size(media, &size);
568         if (ret != MEDIA_CONTENT_ERROR_NONE)
569                 content_error("error media_info_get_size : [%d]", ret);
570         else
571                 content_debug("size : [%lld]", size);
572
573         ret = media_info_get_added_time(media, &t_value);
574         if (ret != MEDIA_CONTENT_ERROR_NONE)
575                 content_error("error media_info_get_added_time : [%d]", ret);
576         else
577                 content_debug("added_time : [%ld]", t_value);
578
579         ret = media_info_get_modified_time(media, &t_value);
580         if (ret != MEDIA_CONTENT_ERROR_NONE)
581                 content_error("error media_info_get_modified_time : [%d]", ret);
582         else
583                 content_debug("modified_time : [%ld]", t_value);
584
585         ret = media_info_get_timeline(media, &t_value);
586         if (ret != MEDIA_CONTENT_ERROR_NONE)
587                 content_error("error media_info_get_timeline : [%d]", ret);
588         else
589                 content_debug("timeline : [%ld]", t_value);
590
591         ret = media_info_get_rating(media, &i_value);
592         if (ret != MEDIA_CONTENT_ERROR_NONE)
593                 content_error("error media_info_get_rating : [%d]", ret);
594         else
595                 content_debug("rating : [%d]", i_value);
596
597         ret = media_info_get_favorite(media, &b_value);
598         if (ret != MEDIA_CONTENT_ERROR_NONE)
599                 content_error("error media_info_get_favorite : [%d]", ret);
600         else
601                 content_debug("favorite : [%d]", b_value);
602
603         ret = media_info_is_drm(media, &b_value);
604         if (ret != MEDIA_CONTENT_ERROR_NONE)
605                 content_error("error media_info_is_drm : [%d]", ret);
606         else
607                 content_debug("is_drm : [%d]", b_value);
608
609         ret = media_info_is_360_content(media, &b_value);
610         if (ret != MEDIA_CONTENT_ERROR_NONE)
611                 content_error("error media_info_is_360_content : [%d]", ret);
612         else
613                 content_debug("is_360 : [%d]", b_value);
614
615 #ifdef _USE_TVPD_MODE
616         ret = media_info_get_stitched_state(media, &i_value);
617         if (ret != MEDIA_CONTENT_ERROR_NONE)
618                 content_error("error media_info_get_stitched_state : [%d]", ret);
619         else
620                 content_debug("360 stitched : [%d]", i_value);
621
622         ret = media_info_get_stitched_engine(media, &i_value);
623         if (ret != MEDIA_CONTENT_ERROR_NONE)
624                 content_error("error media_info_get_stitched_engine : [%d]", ret);
625         else
626                 content_debug("360 engine : [%d]", i_value);
627 #endif
628
629         if (media_type == MEDIA_CONTENT_TYPE_MUSIC) {
630                 audio_meta_h audio;
631
632                 ret = media_info_get_audio(media, &audio);
633                 if (ret != MEDIA_CONTENT_ERROR_NONE)
634                         content_error("error media_info_get_audio : [%d]", ret);
635                 else
636                         get_audio_meta(audio);
637
638                 ret = audio_meta_destroy(audio);
639                 if (ret != MEDIA_CONTENT_ERROR_NONE)
640                         content_error("error audio_meta_destroy : [%d]", ret);
641
642         } else if (media_type == MEDIA_CONTENT_TYPE_IMAGE) {
643                 image_meta_h image;
644
645                 ret = media_info_get_image(media, &image);
646                 if (ret != MEDIA_CONTENT_ERROR_NONE)
647                         content_error("error media_info_get_image : [%d]", ret);
648                 else
649                         get_image_meta(image);
650
651                 ret = image_meta_destroy(image);
652                 if (ret != MEDIA_CONTENT_ERROR_NONE)
653                         content_error("error image_meta_destroy : [%d]", ret);
654
655         } else if (media_type == MEDIA_CONTENT_TYPE_VIDEO) {
656                 video_meta_h video;
657
658                 ret = media_info_get_video(media, &video);
659                 if (ret != MEDIA_CONTENT_ERROR_NONE)
660                         content_error("error media_info_get_video : [%d]", ret);
661                 else
662                         get_video_meta(video);
663
664                 ret = video_meta_destroy(video);
665                 if (ret != MEDIA_CONTENT_ERROR_NONE)
666                         content_error("error video_meta_destroy : [%d]", ret);
667
668         } else {
669                 content_debug("Other Content");
670         }
671
672 }
673
674 bool media_item_cb(media_info_h media, void *user_data)
675 {
676         if (!media) {
677                 content_debug("NO Item");
678                 return true;
679         }
680
681         get_media_meta(media);
682
683         return true;
684 }
685
686 bool gallery_folder_list_cb(media_folder_h folder, void *user_data)
687 {
688         media_folder_h new_folder = NULL;
689         media_folder_clone(&new_folder, folder);
690
691         GList **list = (GList**)user_data;
692         *list = g_list_append(*list, new_folder);
693
694         return true;
695 }
696
697 bool gallery_media_item_cb(media_info_h media, void *user_data)
698 {
699         media_info_h new_media = NULL;
700         int ret = MEDIA_CONTENT_ERROR_NONE;
701
702         ret = media_info_clone(&new_media, media);
703
704         if (ret != MEDIA_CONTENT_ERROR_NONE) {
705                 GList **list = (GList**)user_data;
706                 *list = g_list_append(*list, new_media);
707         }
708
709         return true;
710 }
711
712 bool gallery_tag_item_cb(media_tag_h tag, void *user_data)
713 {
714         media_tag_h new_tag = NULL;
715         media_tag_clone(&new_tag, tag);
716
717         GList **list = (GList**)user_data;
718         *list = g_list_append(*list, new_tag);
719
720         return true;
721 }
722
723 bool gallery_bookmarks_cb(media_bookmark_h bookmark, void *user_data)
724 {
725         media_bookmark_h new_bm = NULL;
726         int ret = MEDIA_CONTENT_ERROR_NONE;
727
728         ret = media_bookmark_clone(&new_bm, bookmark);
729         if (ret != MEDIA_CONTENT_ERROR_NONE)
730                 content_error("error media_bookmark_clone : [%d]", ret);
731
732         GList **list = (GList**)user_data;
733         *list = g_list_append(*list, new_bm);
734
735         return true;
736 }
737
738 bool folder_list_cb(media_folder_h folder, void *user_data)
739 {
740         int item_count = 0;
741         char *folder_id = NULL;
742         media_folder_h *_folder = (media_folder_h*)user_data;
743
744         content_debug("===========================");
745         if (folder != NULL) {
746                 if (_folder != NULL)
747                         media_folder_clone(_folder, folder);
748
749                 get_folder_meta(folder, &folder_id);
750
751                 if (media_folder_get_media_count_from_db(folder_id, g_filter, &item_count) != MEDIA_CONTENT_ERROR_NONE) {
752                         SAFE_FREE(folder_id);
753                         content_error("[ERROR] media_folder_get_media_count_from_db is failed");
754                         return false;
755                 }
756
757                 if (media_folder_foreach_media_from_db(folder_id, g_filter, media_item_cb, NULL) != MEDIA_CONTENT_ERROR_NONE) {
758                         SAFE_FREE(folder_id);
759                         content_error("[ERROR] media_folder_foreach_media_from_db is failed");
760                         return false;
761                 }
762
763                 SAFE_FREE(folder_id);
764                 return true;
765         } else {
766                 return false;
767         }
768
769 }
770
771 bool playlist_list_cb(media_playlist_h playlist, void *user_data)
772 {
773         int ret = MEDIA_CONTENT_ERROR_NONE;
774         int playlist_id = 0;
775         char *playlist_name = NULL;
776         media_playlist_h playlist_h;
777         char *playlist_thumbnail_path = NULL;
778
779         content_debug("playlist_list_cb ======");
780 #if 0
781         GList **list = (GList**)user_data;
782 #endif
783
784         if (playlist == NULL) {
785                 content_debug(" playlist handle is NULL");
786                 return false;
787         }
788
789         ret = media_playlist_get_playlist_id(playlist, &playlist_id);
790         if (ret != MEDIA_CONTENT_ERROR_NONE)
791                 content_error("error media_playlist_get_playlist_id : [%d]", ret);
792
793         content_debug("playlist_id : %d", playlist_id);
794         /* 64bit build issue */
795 #if 0
796         if (user_data != NULL)
797                 *list = g_list_append(*list, (gpointer)playlist_id);
798 #endif
799         ret = media_playlist_get_name(playlist, &playlist_name);
800         if (ret != MEDIA_CONTENT_ERROR_NONE)
801                 content_error("error media_playlist_get_name : [%d]", ret);
802
803         content_debug("playlist_name : %s", playlist_name);
804         SAFE_FREE(playlist_name);
805
806         ret = media_playlist_get_thumbnail_path(playlist, &playlist_thumbnail_path);
807         if (ret != MEDIA_CONTENT_ERROR_NONE)
808                 content_error("error media_playlist_get_thumbnail_path : [%d]", ret);
809
810         content_debug("playlist_thumbnail_path : %s", playlist_thumbnail_path);
811         SAFE_FREE(playlist_thumbnail_path);
812
813         ret = media_playlist_get_playlist_from_db(playlist_id, &playlist_h);
814         if (ret != MEDIA_CONTENT_ERROR_NONE)
815                 content_error("error media_playlist_get_playlist_from_db : [%d]", ret);
816
817         ret = media_playlist_destroy(playlist_h);
818         if (ret != MEDIA_CONTENT_ERROR_NONE)
819                 content_error("error media_playlist_destroy : [%d]", ret);
820
821         return true;
822 }
823
824 bool tag_list_cb(media_tag_h tag, void *user_data)
825 {
826         if (!tag) {
827                 content_debug(" tag handle is NULL");
828                 return false;
829         }
830
831         get_tag_meta(tag);
832
833         return true;
834 }
835
836 bool bookmarks_cb(media_bookmark_h bookmark, void *user_data)
837 {
838         if (bookmark != NULL && user_data != NULL) {
839                 media_bookmark_h new_bookmark;
840
841                 media_bookmark_clone(&new_bookmark, bookmark);
842                 GList **list = (GList**)user_data;
843                 *list = g_list_append(*list, new_bookmark);
844         }
845
846         get_bookmark_meta(bookmark);
847
848         return true;
849 }
850
851 bool album_list_cb(media_album_h album, void *user_data)
852 {
853         int album_id = 0;
854         int media_count = 0;
855         int ret = MEDIA_CONTENT_ERROR_NONE;
856
857         if (album != NULL) {
858                 get_album_meta(album);
859                 media_album_get_album_id(album, &album_id);
860
861                 ret = media_album_get_media_count_from_db(album_id, NULL, &media_count);
862                 if (ret != MEDIA_CONTENT_ERROR_NONE)
863                         content_error("error media_album_get_media_count_from_db : [%d]", ret);
864
865                 content_debug("media_count : [%d]", media_count);
866
867                 ret = media_album_foreach_media_from_db(album_id, NULL, media_item_cb, NULL);
868                 if (ret != MEDIA_CONTENT_ERROR_NONE) {
869                         content_error("error media_album_foreach_media_from_db : [%d]", ret);
870                         return false;
871                 }
872
873         } else {
874                 content_error("album item not Found!!");
875         }
876
877         return true;
878 }
879
880 bool group_list_cb(const char *group_name, void *user_data)
881 {
882         int media_count = 0;
883         int *idx = user_data;
884
885         content_debug("group item : [%s] [%d]", group_name, *idx);
886
887         if (media_group_get_media_count_from_db(group_name, *idx, g_filter, &media_count) != MEDIA_CONTENT_ERROR_NONE)
888                 return false;
889
890         content_debug("media_count : [%d]", media_count);
891
892         if (media_group_foreach_media_from_db(group_name, *idx, g_filter, media_item_cb, NULL) != MEDIA_CONTENT_ERROR_NONE)
893                 return false;
894
895         return true;
896 }
897
898 bool playlist_item_cb(int playlist_member_id, media_info_h media, void *user_data)
899 {
900         content_debug("playlist_member_id : [%d]", playlist_member_id);
901         /* 64bit build issue */
902 #if 0
903         GList **list = (GList**)user_data;
904
905         *list = g_list_append(*list, (gpointer)playlist_member_id);
906 #endif
907         /*media_item_cb(media, user_data);*/
908
909         return true;
910 }
911
912 int test_filter_create(void)
913 {
914         content_debug("\n============Filter Create============\n\n");
915
916         int ret = MEDIA_CONTENT_ERROR_NONE;
917
918         /* Filter for media */
919         const char *condition = "MEDIA_TYPE=3"; /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
920         /*const char *condition = "MEDIA_TYPE IS NOT 0 AND MEDIA_DESCRIPTION IS NOT NULL"; */   /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
921
922         ret = media_filter_create(&g_filter);
923
924         /* Set condition and collate
925          * Condition string : You can make where statement of sql.
926          * Colation : You can use collation when comparing.
927          * Ex) In case of FILE_NAME='Samsung' as condition string,
928          *      if you want to compare with NOCASE collation,
929          *      call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_NOCASE);
930          *      if you want to compare in case-sensitive,
931          *      call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
932          */
933         ret = media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
934
935         /* Collation of ordering
936          * If you want to get list, which is sorted by NOCASE,
937          * call media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_NOCASE);
938          * Or,
939          * call media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
940          */
941         /* Able to set multi column to set order */
942 #if 0
943         ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, "MEDIA_MODIFIED_TIME, MEDIA_DISPLAY_NAME", MEDIA_CONTENT_COLLATE_DEFAULT);
944         ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
945         ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TRACK_NUM_INT, MEDIA_CONTENT_COLLATE_DEFAULT);
946         ret = media_filter_set_storage(g_filter, "cfbf3d2c-71c5-4611-bccc-7cbac890146e");
947
948         /* Filter for group */
949         const char *g_condition = "TAG_NAME like \"\%my\%\"";
950         const char *g_condition = "BOOKMARK_MARKED_TIME > 300";
951 #endif
952         ret = media_filter_create(&g_filter_g);
953
954         ret = media_filter_set_order(g_filter_g, MEDIA_CONTENT_ORDER_DESC, TAG_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
955
956         return ret;
957 }
958
959 int test_filter_destroy(void)
960 {
961         content_debug("\n============Filter Create============\n\n");
962
963         int ret = MEDIA_CONTENT_ERROR_NONE;
964
965         ret = media_filter_destroy(g_filter);
966
967         return ret;
968 }
969
970 int test_connect_database(void)
971 {
972         int ret = MEDIA_CONTENT_ERROR_NONE;
973
974         content_debug("\n============DB Connection Test============\n\n");
975
976         ret = media_content_connect();
977
978         if (ret == MEDIA_CONTENT_ERROR_NONE)
979                 content_debug("connection is success\n\n");
980         else
981                 content_error("connection is failed\n\n");
982
983         return ret;
984 }
985
986 int test_gallery_scenario(void)
987 {
988         int ret = MEDIA_CONTENT_ERROR_NONE;
989         unsigned int i = 0;
990         filter_h filter = NULL;
991
992         int count;
993         GList *folder_list = NULL;
994         media_folder_h folder_handle = NULL;
995
996         /* First, Get folder list */
997         ret = media_folder_foreach_folder_from_db(filter, gallery_folder_list_cb, &folder_list);
998         if (ret != MEDIA_CONTENT_ERROR_NONE) {
999                 content_error("media_folder_foreach_folder_from_db failed: %d", ret);
1000                 return -1;
1001         } else {
1002                 content_debug("media_folder_foreach_folder_from_db success!!");
1003                 char *folder_id = NULL;
1004
1005                 for (i = 0; i < g_list_length(folder_list); i++) {
1006                         folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
1007
1008                         get_folder_meta(folder_handle, &folder_id);
1009
1010                         ret = media_folder_get_media_count_from_db(folder_id, filter, &count);
1011                         SAFE_FREE(folder_id);
1012                         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1013                                 content_error("media_folder_get_media_count_from_db failed: %d", ret);
1014                                 return -1;
1015                         } else {
1016                                 content_debug("media count [%d] : %d", i, count);
1017                         }
1018                 }
1019         }
1020
1021         /* To check performance */
1022         struct timeval start, end;
1023         gettimeofday(&start, NULL);
1024
1025         /* Second, Get all item list */
1026         media_info_h media_handle = NULL;
1027         GList *all_item_list = NULL;
1028
1029         media_content_collation_e collate_type = MEDIA_CONTENT_COLLATE_NOCASE;
1030         media_content_order_e order_type = MEDIA_CONTENT_ORDER_DESC;
1031         ret = media_filter_create(&filter);
1032         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1033                 content_error("Fail to create filter");
1034                 return ret;
1035         }
1036         ret = media_filter_set_condition(filter, "MEDIA_TYPE = 0", collate_type);
1037         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1038                 media_filter_destroy(filter);
1039                 content_error("Fail to set condition");
1040                 return ret;
1041         }
1042         ret = media_filter_set_order(filter, order_type, MEDIA_DISPLAY_NAME, collate_type);
1043         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1044                 media_filter_destroy(filter);
1045                 content_error("Fail to set order");
1046                 return ret;
1047         }
1048
1049         ret = media_info_foreach_media_from_db(filter, gallery_media_item_cb, &all_item_list);
1050         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1051                 content_error("media_info_foreach_media_from_db failed: %d", ret);
1052                 media_filter_destroy(filter);
1053                 return -1;
1054         } else {
1055                 content_debug("media_info_foreach_media_from_db success");
1056
1057                 for (i = 0; i < g_list_length(all_item_list); i++) {
1058                         media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
1059                         get_media_meta(media_handle);
1060                 }
1061         }
1062
1063         media_filter_destroy(filter);
1064         filter = NULL;
1065
1066         /* To check performance */
1067         gettimeofday(&end, NULL);
1068         long time = (end.tv_sec * 1000000 + end.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec);
1069         content_debug("Time : %ld\n", time);
1070
1071         /* Third, Get item list of a folder */
1072         GList *item_list = NULL;
1073
1074         for (i = 0; i < g_list_length(folder_list); i++) {
1075                 unsigned int j = 0;
1076                 char *folder_id = NULL;
1077                 folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
1078
1079                 get_folder_meta(folder_handle, &folder_id);
1080
1081                 ret = media_folder_foreach_media_from_db(folder_id, filter, gallery_media_item_cb, &item_list);
1082                 SAFE_FREE(folder_id);
1083
1084                 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1085                         content_error("media_folder_foreach_media_from_db failed: %d", ret);
1086                         return -1;
1087                 } else {
1088                         content_error("media_folder_foreach_media_from_db success!");
1089
1090                         for (j = 0; j < g_list_length(item_list); j++) {
1091                                 media_handle = (media_info_h)g_list_nth_data(item_list, j);
1092                                 get_media_meta(media_handle);
1093                         }
1094                 }
1095         }
1096
1097         /* Get tag list */
1098         media_tag_h tag_handle = NULL;
1099         GList *tag_list = NULL;
1100         GList *media_list_in_tag = NULL;
1101         int tag_id = 0;
1102
1103         ret = media_tag_foreach_tag_from_db(filter, gallery_tag_item_cb, &tag_list);
1104
1105         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1106                 content_error("media_tag_foreach_tag_from_db failed: %d", ret);
1107                 return -1;
1108         } else {
1109                 content_error("media_tag_foreach_tag_from_db success");
1110                 for (i = 0; i < g_list_length(tag_list); i++) {
1111                         tag_handle = (media_tag_h)g_list_nth_data(tag_list, i);
1112                         get_tag_meta(tag_handle);
1113
1114                         ret = media_tag_get_tag_id(tag_handle, &tag_id);
1115                         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1116                                 ret = media_tag_foreach_media_from_db(tag_id, filter, gallery_media_item_cb, &media_list_in_tag);
1117                                 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1118                                         content_error("media_tag_foreach_media_from_db failed: %d", ret);
1119                                         return -1;
1120                                 } else {
1121                                         content_error("media_tag_foreach_media_from_db success");
1122                                         unsigned int j = 0;
1123                                         media_info_h tag_media_handle;
1124
1125                                         for (j = 0; j < g_list_length(media_list_in_tag); j++) {
1126                                                 tag_media_handle = (media_info_h)g_list_nth_data(media_list_in_tag, j);
1127                                                 get_media_meta(tag_media_handle);
1128                                         }
1129                                 }
1130                         }
1131                 }
1132         }
1133
1134         /* Remove folder list */
1135         if (folder_list) {
1136                 for (i = 0; i < g_list_length(folder_list); i++) {
1137                         folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
1138                         media_folder_destroy(folder_handle);
1139                 }
1140
1141                 g_list_free(folder_list);
1142         }
1143
1144         /* Remove all items list */
1145         if (all_item_list) {
1146                 for (i = 0; i < g_list_length(all_item_list); i++) {
1147                         media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
1148                         ret = media_info_destroy(media_handle);
1149                         if (ret != MEDIA_CONTENT_ERROR_NONE)
1150                                 content_error("media_info_destroy failed: %d", ret);
1151                 }
1152
1153                 g_list_free(all_item_list);
1154         }
1155
1156         /* Remove items list */
1157         if (item_list) {
1158                 for (i = 0; i < g_list_length(item_list); i++) {
1159                         media_handle = (media_info_h)g_list_nth_data(item_list, i);
1160                         ret = media_info_destroy(media_handle);
1161                         if (ret != MEDIA_CONTENT_ERROR_NONE)
1162                                 content_error("media_info_destroy failed: %d", ret);
1163                 }
1164
1165                 g_list_free(item_list);
1166         }
1167
1168         /* Remove tag list */
1169         if (tag_list) {
1170                 for (i = 0; i < g_list_length(tag_list); i++) {
1171                         tag_handle = (media_tag_h)g_list_nth_data(tag_list, i);
1172                         ret = media_tag_destroy(tag_handle);
1173                         if (ret != MEDIA_CONTENT_ERROR_NONE)
1174                                 content_error("error media_tag_destroy : [%d]", ret);
1175                 }
1176
1177                 g_list_free(tag_list);
1178         }
1179
1180         /* Remove media list in a tag */
1181         if (media_list_in_tag) {
1182                 for (i = 0; i < g_list_length(media_list_in_tag); i++) {
1183                         media_handle = (media_info_h)g_list_nth_data(media_list_in_tag, i);
1184                         ret = media_info_destroy(media_handle);
1185                         if (ret != MEDIA_CONTENT_ERROR_NONE)
1186                                 content_error("media_info_destroy failed: %d", ret);
1187                 }
1188
1189                 g_list_free(media_list_in_tag);
1190         }
1191
1192         return MEDIA_CONTENT_ERROR_NONE;
1193 }
1194
1195 /*Get All Music file. sort by Title and not case sensitive*/
1196 int test_get_all_music_files(void)
1197 {
1198         int ret = MEDIA_CONTENT_ERROR_NONE;
1199         int media_count = 0;
1200         filter_h filter;
1201
1202         /*Set Filter*/
1203         const char *condition = "MEDIA_TYPE=3"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
1204
1205         ret = media_filter_create(&filter);
1206         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1207                 content_error("Fail to create filter");
1208                 return ret;
1209         }
1210         ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_LOCALIZED);
1211         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1212                 media_filter_destroy(filter);
1213                 content_error("Fail to set condition");
1214                 return ret;
1215         }
1216         ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_LOCALIZED);
1217         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1218                 media_filter_destroy(filter);
1219                 content_error("Fail to set order");
1220                 return ret;
1221         }
1222
1223         /*Get Media Count*/
1224         ret = media_info_get_media_count_from_db(filter, &media_count);
1225         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1226                 media_filter_destroy(filter);
1227                 content_error("Fail to get media count");
1228                 return ret;
1229         }
1230
1231         content_debug("media_count : [%d]", media_count);
1232
1233         ret = media_info_foreach_media_from_db(filter, media_item_cb, NULL);
1234         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1235                 media_filter_destroy(filter);
1236                 content_error("Fail to get media");
1237                 return ret;
1238         }
1239
1240         ret = media_filter_destroy(filter);
1241
1242         return ret;
1243 }
1244
1245 int test_media_info_operation(void)
1246 {
1247         int ret = MEDIA_CONTENT_ERROR_NONE;
1248         int media_count = 0;
1249
1250         content_debug("\n============Media info Test============\n\n");
1251
1252         test_filter_create();
1253
1254         ret = media_info_get_media_count_from_db(g_filter, &media_count);
1255         if (ret != MEDIA_CONTENT_ERROR_NONE)
1256                 content_error("media_info_get_media_count_from_db failed: %d", ret);
1257         else
1258                 content_debug("media_count : [%d]", media_count);
1259
1260         ret = media_info_foreach_media_from_db(g_filter, media_item_cb, NULL);
1261         if (ret == MEDIA_CONTENT_ERROR_NONE)
1262                 content_debug("media_info_foreach_media_from_db is success");
1263         else
1264                 content_error("media_info_foreach_media_from_db is failed");
1265
1266         test_filter_destroy();
1267
1268         return ret;
1269 }
1270
1271 int test_media_info_operation_2(void)
1272 {
1273         int ret = MEDIA_CONTENT_ERROR_NONE;
1274         int bookmark_count = 0;
1275
1276         content_debug("\n============Media info Test 2============\n\n");
1277
1278         test_filter_create();
1279
1280 #if 0
1281         /* Bookmark */
1282         char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1283         media_bookmark_insert_to_db(test_video_id, 100, thumbnail_path1);
1284         media_bookmark_insert_to_db(test_video_id, 200, thumbnail_path1);
1285
1286         media_info_get_bookmark_count_from_db(test_video_id, g_filter_g, &bookmark_count);
1287
1288         content_debug("bookmark_count : [%d]", bookmark_count);
1289
1290         ret = media_info_foreach_bookmark_from_db(test_video_id, g_filter_g, bookmarks_cb, NULL);
1291 #endif
1292
1293         /* Tag */
1294         ret = media_info_get_tag_count_from_db(test_audio_id, g_filter_g, &bookmark_count);
1295         if (ret != MEDIA_CONTENT_ERROR_NONE)
1296                 content_error("media_info_get_tag_count_from_db failed: %d", ret);
1297         else
1298                 content_debug("tag_count : [%d]", bookmark_count);
1299
1300         ret = media_info_foreach_tag_from_db(test_audio_id, g_filter_g, tag_list_cb, NULL);
1301         if (ret != MEDIA_CONTENT_ERROR_NONE)
1302                 content_error("media_info_foreach_tag_from_db failed: %d", ret);
1303
1304         test_filter_destroy();
1305
1306         return ret;
1307 }
1308
1309 int test_folder_operation(void)
1310 {
1311         int ret = MEDIA_CONTENT_ERROR_NONE;
1312         filter_h filter = NULL;
1313         media_folder_h folder = NULL;
1314         char *folder_id = NULL;
1315         int count = 0;
1316
1317         content_debug("\n============Folder Test============\n\n");
1318
1319         test_filter_create();
1320
1321         ret = media_filter_create(&filter);
1322         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1323                 content_error("[ERROR] media_folder_filter_create is failed");
1324                 return ret;
1325         }
1326
1327         media_filter_set_condition(filter, "(MEDIA_TYPE = 0 or MEDIA_TYPE = 1) and MEDIA_STORAGE_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);       /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
1328         media_filter_set_offset(filter, 0, 5);
1329         media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE);
1330         media_filter_set_storage(filter, "cfbf3d2c-71c5-4611-bccc-7cbac890146e");
1331
1332         ret = media_folder_get_folder_count_from_db(filter, &count);
1333         content_debug("Folder count : [%d]", count);
1334
1335         ret = media_folder_foreach_folder_from_db(filter, folder_list_cb, &folder);
1336
1337         filter_h m_filter = NULL;
1338
1339         ret = media_filter_create(&m_filter);
1340         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1341                 test_filter_destroy();
1342                 media_filter_destroy(filter);
1343                 content_error("[ERROR] media_info_filter_create is failed");
1344                 return ret;
1345         }
1346
1347         media_filter_set_condition(m_filter, "MEDIA_TYPE=1 and MEDIA_STORAGE_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);   /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
1348         media_filter_set_offset(m_filter, 0, 5);
1349         media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE);
1350
1351         ret = media_folder_foreach_media_from_db(folder_id, m_filter, media_item_cb, NULL);
1352         if (ret != MEDIA_CONTENT_ERROR_NONE)
1353                 content_error("[ERROR] media_folder_foreach_media_from_db is failed, error code : %d", ret);
1354
1355         media_filter_destroy(filter);
1356         media_filter_destroy(m_filter);
1357
1358         test_filter_destroy();
1359
1360         /* fix prevent: Resource Leak */
1361         SAFE_FREE(folder_id);
1362
1363         return ret;
1364 }
1365
1366 int test_playlist_operation(void)
1367 {
1368         int ret = MEDIA_CONTENT_ERROR_NONE;
1369         media_playlist_h playlist_1 = NULL;
1370         media_playlist_h playlist_2 = NULL;
1371         media_playlist_h playlist_3 = NULL;
1372         media_playlist_h playlist_4 = NULL;
1373         int playlist_id_1 = 0;
1374         int playlist_id_2 = 0;
1375         int playlist_id_3 = 0;
1376         const char *playlist_name_1 = "myPlaylist_1";
1377         const char *playlist_name_2 = "myPlaylist_2";
1378         const char *playlist_name_3 = "myPlaylist_3";
1379         int playlist_count = 0;
1380         int media_count = 0;
1381         int order_1 = 0;
1382         int order_2 = 0;
1383         int order_3 = 0;
1384         int order_4 = 0;
1385         int order_5 = 0;
1386         filter_h filter = NULL;
1387         filter_h m_filter = NULL;
1388
1389         content_debug("\n============Playlist Test============\n\n");
1390
1391         /* Filter for playlist */
1392
1393         const char *condition = "(MEDIA_TYPE=1 or MEDIA_TYPE=3)";       /*0-image, 1-video, 2-sound, 3-music, 4-other*/
1394
1395         ret = media_filter_create(&filter);
1396         ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_NOCASE);
1397         ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_NAME, MEDIA_CONTENT_COLLATE_NOCASE);
1398
1399         /* Create Playlist */
1400         media_playlist_insert_to_db(playlist_name_1, &playlist_1);
1401         media_playlist_insert_to_db(playlist_name_2, &playlist_2);
1402         media_playlist_insert_to_db(playlist_name_3, &playlist_3);
1403
1404         if (playlist_1 != NULL) {
1405                 /* Add media to Playlist */
1406                 media_playlist_add_media(playlist_1, test_audio_id);
1407                 media_playlist_add_media(playlist_1, test_audio_id);
1408                 media_playlist_add_media(playlist_1, test_video_id);
1409
1410                 #if 0
1411                 char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg"));
1412                 media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
1413                 #endif
1414
1415                 media_playlist_update_to_db(playlist_1);
1416         }
1417
1418         if (playlist_2 != NULL) {
1419                 media_playlist_add_media(playlist_2, test_audio_id);
1420                 media_playlist_add_media(playlist_2, test_audio_id);
1421                 media_playlist_update_to_db(playlist_2);
1422         }
1423
1424         /* Get Playlist Count*/
1425         ret = media_playlist_get_playlist_count_from_db(filter, &playlist_count);
1426         if (ret == 0)
1427                 content_debug("playlist_count [%d]", playlist_count);
1428
1429         /* Get Playlist*/
1430         GList *playlist_id_list = NULL;
1431         media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, &playlist_id_list);
1432         /* 64bit build issue */
1433 #if 0
1434         /* Get Playlist id*/
1435         playlist_id_1 = (int)g_list_nth_data(playlist_id_list, 0);
1436         playlist_id_2 = (int)g_list_nth_data(playlist_id_list, 1);
1437         playlist_id_3 = (int)g_list_nth_data(playlist_id_list, 2);
1438 #endif
1439         content_debug("playlist_id_1 [%d]", playlist_id_1);
1440         content_debug("playlist_id_2 [%d]", playlist_id_2);
1441         content_debug("playlist_id_3 [%d]", playlist_id_3);
1442
1443         /* Export and import playlist */
1444         media_playlist_export_to_file(playlist_3, tzplatform_mkpath(TZ_USER_MUSIC, "playlist.m3u"));
1445         media_playlist_import_from_file(tzplatform_mkpath(TZ_USER_MUSIC, "playlist.m3u"), "playlist_4", &playlist_4);
1446
1447         /* Filter for media*/
1448         ret = media_filter_create(&m_filter);
1449
1450         ret = media_filter_set_condition(m_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1451
1452         ret = media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_MEMBER_ORDER, MEDIA_CONTENT_COLLATE_DEFAULT);
1453
1454         /* Get media count */
1455         media_playlist_get_media_count_from_db(playlist_id_1, m_filter, &media_count);
1456         content_debug("playlist_1_media_count [%d]", media_count);
1457
1458         media_playlist_get_media_count_from_db(playlist_id_2, m_filter, &media_count);
1459         content_debug("playlist_2_media_count [%d]", media_count);
1460
1461         media_playlist_get_media_count_from_db(playlist_id_3, m_filter, &media_count);
1462         content_debug("playlist_3_media_count [%d]", media_count);
1463
1464         /* Get media of playlist */
1465         GList *playlist_member_id_list = NULL;
1466         GList *playlist_member_id_list_1 = NULL;
1467
1468         media_playlist_foreach_media_from_db(playlist_id_1, m_filter, playlist_item_cb, &playlist_member_id_list);
1469         media_playlist_foreach_media_from_db(playlist_id_2, m_filter, playlist_item_cb, &playlist_member_id_list_1);
1470
1471         int playlist_member_id_1_1 = 0;
1472         int playlist_member_id_1_2 = 0;
1473         int playlist_member_id_1_3 = 0;
1474         int playlist_member_id_2_1 = 0;
1475         int playlist_member_id_2_2 = 0;
1476         /* 64bit build issue */
1477 #if 0
1478         playlist_member_id_1_1 = (int)g_list_nth_data(playlist_member_id_list, 0);
1479         playlist_member_id_1_2 = (int)g_list_nth_data(playlist_member_id_list, 1);
1480         playlist_member_id_1_3 = (int)g_list_nth_data(playlist_member_id_list, 2);
1481         playlist_member_id_2_1 = (int)g_list_nth_data(playlist_member_id_list_1, 0);
1482         playlist_member_id_2_2 = (int)g_list_nth_data(playlist_member_id_list_1, 1);
1483 #endif
1484         content_debug("playlist_member_id_1_1 [%d]", playlist_member_id_1_1);
1485         content_debug("playlist_member_id_1_2 [%d]", playlist_member_id_1_2);
1486         content_debug("playlist_member_id_1_3 [%d]", playlist_member_id_1_3);
1487         content_debug("playlist_member_id_2_1 [%d]", playlist_member_id_2_1);
1488         content_debug("playlist_member_id_2_2 [%d]", playlist_member_id_2_2);
1489
1490         media_playlist_get_play_order(playlist_1, playlist_member_id_1_1, &order_1);
1491         media_playlist_get_play_order(playlist_1, playlist_member_id_1_2, &order_2);
1492         media_playlist_get_play_order(playlist_1, playlist_member_id_1_3, &order_3);
1493         media_playlist_get_play_order(playlist_2, playlist_member_id_2_1, &order_4);
1494         media_playlist_get_play_order(playlist_2, playlist_member_id_2_2, &order_5);
1495         content_debug("order_1 [%d] order_2 [%d] order_3 [%d] order_4 [%d] order_5 [%d]", order_1, order_2, order_3, order_4, order_5);
1496
1497         /* Update Playlist */
1498         media_playlist_remove_media(playlist_2, playlist_member_id_2_1);
1499         media_playlist_add_media(playlist_2, test_video_id);
1500         media_playlist_set_name(playlist_2, "test_playlist");
1501         media_playlist_set_play_order(playlist_2, playlist_member_id_2_2, order_5+100);
1502         media_playlist_update_to_db(playlist_2);
1503
1504         /* Get Updated Playlist*/
1505         media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, NULL);
1506
1507         /* deletes the playlist */
1508 #if 0
1509         media_playlist_delete_from_db(playlist_id_1);
1510         media_playlist_delete_from_db(playlist_id_2);
1511 #endif
1512
1513         if (playlist_1 != NULL)
1514                 media_playlist_destroy(playlist_1);
1515         if (playlist_2 != NULL)
1516                 media_playlist_destroy(playlist_2);
1517         if (playlist_3 != NULL)
1518                 media_playlist_destroy(playlist_3);
1519         if (playlist_4 != NULL)
1520                 media_playlist_destroy(playlist_4);
1521
1522         g_list_free(playlist_id_list);
1523         g_list_free(playlist_member_id_list);
1524         g_list_free(playlist_member_id_list_1);
1525
1526         if (filter != NULL)
1527                 ret = media_filter_destroy(filter);
1528         if (m_filter != NULL)
1529                 ret = media_filter_destroy(m_filter);
1530
1531         return ret;
1532 }
1533
1534 int test_playlist_operation_v2(void)
1535 {
1536         int ret = MEDIA_CONTENT_ERROR_NONE;
1537         media_playlist_h playlist_1 = NULL;
1538         const char *playlist_name_1 = "myPlaylist_1";
1539         const char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg");
1540         int playlist_id = 0;
1541
1542         content_debug("\n============Playlist Test V2============\n\n");
1543
1544         ret = media_playlist_create(&playlist_1);
1545         if (ret != MEDIA_CONTENT_ERROR_NONE)
1546                 content_error("error media_playlist_create : [%d]", ret);
1547
1548         ret = media_playlist_set_name(playlist_1, playlist_name_1);
1549         if (ret != MEDIA_CONTENT_ERROR_NONE)
1550                 content_error("error media_playlist_set_name : [%d]", ret);
1551
1552         ret = media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
1553         if (ret != MEDIA_CONTENT_ERROR_NONE)
1554                 content_error("error media_playlist_set_thumbnail_path : [%d]", ret);
1555
1556         ret = media_playlist_insert_to_db_v2(playlist_1);
1557         if (ret != MEDIA_CONTENT_ERROR_NONE)
1558                 content_error("error media_playlist_insert_to_db_v2 : [%d]", ret);
1559
1560         ret = media_playlist_set_name(playlist_1, "myPlaylist_3");
1561         if (ret != MEDIA_CONTENT_ERROR_NONE)
1562                 content_error("error media_playlist_set_name : [%d]", ret);
1563
1564         ret = media_playlist_get_playlist_id(playlist_1, &playlist_id);
1565         if (ret != MEDIA_CONTENT_ERROR_NONE)
1566                 content_error("error media_playlist_get_playlist_id : [%d]", ret);
1567
1568         ret = media_playlist_update_to_db_v2(playlist_id, playlist_1);
1569         if (ret != MEDIA_CONTENT_ERROR_NONE)
1570                 content_error("error media_playlist_update_to_db_v2 : [%d]", ret);
1571
1572         ret = media_playlist_destroy(playlist_1);
1573         if (ret != MEDIA_CONTENT_ERROR_NONE)
1574                 content_error("error media_playlist_destroy : [%d]", ret);
1575
1576         return ret;
1577 }
1578
1579 int test_tag_operation(void)
1580 {
1581         int ret = MEDIA_CONTENT_ERROR_NONE;
1582         media_tag_h tag_1;
1583         media_tag_h tag_2;
1584         media_tag_h tag_3;
1585         int tag_id_1 = 0;
1586         int tag_id_2 = 0;
1587         int tag_id_3 = 0;
1588         const char *tag_name_1 = "myTag_1";
1589         const char *tag_name_2 = "myTag_2";
1590         const char *tag_name_3 = "myTag_3";
1591         int tag_count = 0;
1592         int media_count = 0;
1593         filter_h filter;
1594
1595         content_debug("\n============Tag Test============\n\n");
1596
1597         const char *g_condition = "TAG_NAME like \"%%my%%\"";
1598
1599         ret = media_filter_create(&filter);
1600
1601         ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1602
1603         ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, TAG_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
1604
1605         /* Create Tag */
1606         ret = media_tag_insert_to_db(tag_name_1, &tag_1);
1607         if (ret != MEDIA_CONTENT_ERROR_NONE)
1608                 content_error("error media_tag_insert_to_db : [%d]", ret);
1609         ret = media_tag_insert_to_db(tag_name_2, &tag_2);
1610         if (ret != MEDIA_CONTENT_ERROR_NONE)
1611                 content_error("error media_tag_insert_to_db : [%d]", ret);
1612         ret = media_tag_insert_to_db(tag_name_3, &tag_3);
1613         if (ret != MEDIA_CONTENT_ERROR_NONE)
1614                 content_error("error media_tag_insert_to_db : [%d]", ret);
1615
1616         /* Add media to Tag */
1617         ret = media_tag_add_media(tag_1, test_audio_id);
1618         if (ret != MEDIA_CONTENT_ERROR_NONE)
1619                 content_error("error media_tag_add_media : [%d]", ret);
1620         ret = media_tag_add_media(tag_1, test_video_id);
1621         if (ret != MEDIA_CONTENT_ERROR_NONE)
1622                 content_error("error media_tag_add_media : [%d]", ret);
1623         ret = media_tag_update_to_db(tag_1);
1624         if (ret != MEDIA_CONTENT_ERROR_NONE)
1625                 content_error("error media_tag_update_to_db : [%d]", ret);
1626
1627         ret = media_tag_add_media(tag_2, test_audio_id);
1628         if (ret != MEDIA_CONTENT_ERROR_NONE)
1629                 content_error("error media_tag_add_media : [%d]", ret);
1630         ret = media_tag_update_to_db(tag_2);
1631         if (ret != MEDIA_CONTENT_ERROR_NONE)
1632                 content_error("error media_tag_update_to_db : [%d]", ret);
1633
1634         /* Get Tag Count*/
1635         ret = media_tag_get_tag_count_from_db(filter, &tag_count);
1636         if (ret != MEDIA_CONTENT_ERROR_NONE)
1637                 content_error("error media_tag_get_tag_count_from_db : [%d]", ret);
1638         else
1639                 content_debug("tag_count [%d]", tag_count);
1640
1641         /* Get Tag*/
1642         ret = media_tag_foreach_tag_from_db(filter, tag_list_cb, NULL);
1643         if (ret != MEDIA_CONTENT_ERROR_NONE)
1644                 content_error("error media_tag_foreach_tag_from_db : [%d]", ret);
1645
1646         /* Get Tag id*/
1647         ret = media_tag_get_tag_id(tag_1, &tag_id_1);
1648         if (ret != MEDIA_CONTENT_ERROR_NONE)
1649                 content_error("error media_tag_get_tag_id : [%d]", ret);
1650         else
1651                 content_debug("tag_id_1 [%d]", tag_id_1);
1652
1653         ret = media_tag_get_tag_id(tag_2, &tag_id_2);
1654         if (ret != MEDIA_CONTENT_ERROR_NONE)
1655                 content_error("error media_tag_get_tag_id : [%d]", ret);
1656         else
1657                 content_debug("tag_id_2 [%d]", tag_id_2);
1658
1659         ret = media_tag_get_tag_id(tag_3, &tag_id_3);
1660         if (ret != MEDIA_CONTENT_ERROR_NONE)
1661                 content_error("error media_tag_get_tag_id : [%d]", ret);
1662         else
1663                 content_debug("tag_id_3 [%d]", tag_id_3);
1664
1665         /* Get media count */
1666         ret = media_tag_get_media_count_from_db(tag_id_1, NULL, &media_count);
1667         if (ret != MEDIA_CONTENT_ERROR_NONE)
1668                 content_error("error media_tag_get_media_count_from_db : [%d]", ret);
1669         else
1670                 content_debug("tag_1_media_count [%d]", media_count);
1671
1672         ret = media_tag_get_media_count_from_db(tag_id_2, NULL, &media_count);
1673         if (ret != MEDIA_CONTENT_ERROR_NONE)
1674                 content_error("error media_tag_get_media_count_from_db : [%d]", ret);
1675         else
1676                 content_debug("tag_2_media_count [%d]", media_count);
1677
1678         /* Get media of Tag */
1679         ret = media_tag_foreach_media_from_db(tag_id_1, NULL, media_item_cb, NULL);
1680         if (ret != MEDIA_CONTENT_ERROR_NONE)
1681                 content_error("error media_tag_foreach_media_from_db : [%d]", ret);
1682
1683         ret = media_tag_foreach_media_from_db(tag_id_2, NULL, media_item_cb, NULL);
1684         if (ret != MEDIA_CONTENT_ERROR_NONE)
1685                 content_error("error media_tag_foreach_media_from_db : [%d]", ret);
1686
1687         /* Update Tag */
1688         ret = media_tag_add_media(tag_2, test_video_id);
1689         if (ret != MEDIA_CONTENT_ERROR_NONE)
1690                 content_error("error media_tag_add_media : [%d]", ret);
1691         ret = media_tag_set_name(tag_2, "test_tag");
1692         if (ret != MEDIA_CONTENT_ERROR_NONE)
1693                 content_error("error media_tag_set_name : [%d]", ret);
1694         ret = media_tag_update_to_db(tag_2);
1695         if (ret != MEDIA_CONTENT_ERROR_NONE)
1696                 content_error("error media_tag_update_to_db : [%d]", ret);
1697
1698         /* Get Updated Tag*/
1699         ret = media_tag_foreach_tag_from_db(filter, tag_list_cb, NULL);
1700         if (ret != MEDIA_CONTENT_ERROR_NONE)
1701                 content_error("error media_tag_foreach_tag_from_db : [%d]", ret);
1702
1703         /* deletes the tag */
1704         ret = media_tag_delete_from_db(tag_id_1);
1705         if (ret != MEDIA_CONTENT_ERROR_NONE)
1706                 content_error("error media_tag_delete_from_db : [%d]", ret);
1707         ret = media_tag_delete_from_db(tag_id_2);
1708         if (ret != MEDIA_CONTENT_ERROR_NONE)
1709                 content_error("error media_tag_delete_from_db : [%d]", ret);
1710
1711         ret = media_tag_destroy(tag_1);
1712         if (ret != MEDIA_CONTENT_ERROR_NONE)
1713                 content_error("error media_tag_destroy : [%d]", ret);
1714         ret = media_tag_destroy(tag_2);
1715         if (ret != MEDIA_CONTENT_ERROR_NONE)
1716                 content_error("error media_tag_destroy : [%d]", ret);
1717         ret = media_tag_destroy(tag_3);
1718         if (ret != MEDIA_CONTENT_ERROR_NONE)
1719                 content_error("error media_tag_destroy : [%d]", ret);
1720         ret = media_filter_destroy(filter);
1721         if (ret != MEDIA_CONTENT_ERROR_NONE)
1722                 content_error("error media_filter_destroy : [%d]", ret);
1723
1724         return ret;
1725 }
1726
1727 int test_tag_operation_v2(void)
1728 {
1729         int ret = MEDIA_CONTENT_ERROR_NONE;
1730         media_tag_h tag_1;
1731         const char *tag_name_1 = "myTag_1";
1732         int tag_id = -1;
1733
1734         content_debug("\n============Tag Test V2============\n\n");
1735
1736         /* Create Tag */
1737         ret = media_tag_create(&tag_1);
1738         if (ret != MEDIA_CONTENT_ERROR_NONE)
1739                 content_error("error media_tag_create : [%d]", ret);
1740
1741         ret = media_tag_set_name(tag_1, tag_name_1);
1742         if (ret != MEDIA_CONTENT_ERROR_NONE)
1743                 content_error("error media_tag_set_name : [%d]", ret);
1744
1745         /* Add media to Tag */
1746         ret = media_tag_add_media(tag_1, test_audio_id);
1747         if (ret != MEDIA_CONTENT_ERROR_NONE)
1748                 content_error("error media_tag_add_media : [%d]", ret);
1749
1750         ret = media_tag_add_media(tag_1, test_video_id);
1751         if (ret != MEDIA_CONTENT_ERROR_NONE)
1752                 content_error("error media_tag_add_media : [%d]", ret);
1753
1754         ret = media_tag_insert_to_db_v2(tag_1);
1755         if (ret != MEDIA_CONTENT_ERROR_NONE)
1756                 content_error("error media_tag_insert_to_db_v2 : [%d]", ret);
1757
1758 #if 1
1759         ret = media_tag_get_tag_id(tag_1, &tag_id);
1760         if (ret != MEDIA_CONTENT_ERROR_NONE)
1761                 content_error("error media_tag_get_tag_id : [%d]", ret);
1762
1763         ret = media_tag_remove_media(tag_1, test_video_id);
1764         if (ret != MEDIA_CONTENT_ERROR_NONE)
1765                 content_error("error media_tag_add_media : [%d]", ret);
1766
1767         ret = media_tag_update_to_db_v2(tag_id, tag_1);
1768         if (ret != MEDIA_CONTENT_ERROR_NONE)
1769                 content_error("error media_tag_update_to_db_v2 : [%d]", ret);
1770 #endif
1771
1772         ret = media_tag_destroy(tag_1);
1773         if (ret != MEDIA_CONTENT_ERROR_NONE)
1774                 content_error("error media_tag_destroy : [%d]", ret);
1775
1776         return ret;
1777 }
1778
1779 int test_bookmark_operation(void)
1780 {
1781         /* bookmark is only supported for video information. */
1782         int ret = MEDIA_CONTENT_ERROR_NONE;
1783         int bookmark_count = 0;
1784         filter_h filter;
1785         GList *all_item_list = NULL;
1786         int idx = 0;
1787
1788         content_debug("\n============Bookmark Test============\n\n");
1789
1790         const char *g_condition = "BOOKMARK_MARKED_TIME > 300";
1791
1792         ret = media_filter_create(&filter);
1793         if (ret != MEDIA_CONTENT_ERROR_NONE)
1794                 content_error("error media_filter_create : [%d]", ret);
1795
1796         ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1797         if (ret != MEDIA_CONTENT_ERROR_NONE)
1798                 content_error("error media_filter_set_condition : [%d]", ret);
1799
1800         ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, BOOKMARK_MARKED_TIME, MEDIA_CONTENT_COLLATE_DEFAULT);
1801         if (ret != MEDIA_CONTENT_ERROR_NONE)
1802                 content_error("error media_filter_set_order : [%d]", ret);
1803
1804         /* insert bookmark to video */
1805         const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1806         ret = media_bookmark_insert_to_db(test_video_id, 400, thumbnail_path1);
1807         if (ret != MEDIA_CONTENT_ERROR_NONE)
1808                 content_error("error media_bookmark_insert_to_db : [%d]", ret);
1809
1810         ret = media_bookmark_insert_to_db(test_video_id, 600, thumbnail_path1);
1811         if (ret != MEDIA_CONTENT_ERROR_NONE)
1812                 content_error("error media_bookmark_insert_to_db : [%d]", ret);
1813
1814         ret = media_bookmark_get_bookmark_count_from_db(filter, &bookmark_count);
1815         if (ret != MEDIA_CONTENT_ERROR_NONE)
1816                 content_error("error media_bookmark_get_bookmark_count_from_db : [%d]", ret);
1817         else
1818                 content_debug("bookmark_count = [%d]", bookmark_count);
1819
1820         ret = media_info_foreach_bookmark_from_db(test_video_id, NULL, bookmarks_cb, &all_item_list);
1821         if (ret != MEDIA_CONTENT_ERROR_NONE)
1822                 content_error("error media_info_foreach_bookmark_from_db : [%d]", ret);
1823
1824         for (idx = 0; idx < g_list_length(all_item_list); idx++) {
1825                 media_bookmark_h bookmark_handle;
1826                 bookmark_handle = (media_bookmark_h)g_list_nth_data(all_item_list, idx);
1827
1828                 ret = media_bookmark_set_name(bookmark_handle, "test 1");
1829                 if (ret != MEDIA_CONTENT_ERROR_NONE)
1830                         content_error("error media_bookmark_set_name : [%d]", ret);
1831
1832                 ret = media_bookmark_update_to_db(bookmark_handle);
1833                 if (ret != MEDIA_CONTENT_ERROR_NONE)
1834                         content_error("error media_bookmark_update_to_db : [%d]", ret);
1835         }
1836
1837         ret = media_info_foreach_bookmark_from_db(test_video_id, NULL, bookmarks_cb, NULL);
1838         if (ret != MEDIA_CONTENT_ERROR_NONE)
1839                 content_error("error media_info_foreach_bookmark_from_db : [%d]", ret);
1840
1841         ret = media_filter_destroy(filter);
1842         if (ret != MEDIA_CONTENT_ERROR_NONE)
1843                 content_error("error media_filter_destroy : [%d]", ret);
1844
1845         return ret;
1846 }
1847
1848 int test_bookmark_operation_v2(void)
1849 {
1850         content_debug("\n============Bookmark Test V2============\n\n");
1851
1852         int ret = MEDIA_CONTENT_ERROR_NONE;
1853         media_bookmark_h bookmark = NULL;
1854         const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1855
1856         ret = media_bookmark_create(test_video_id, 400, &bookmark);
1857         if (ret != MEDIA_CONTENT_ERROR_NONE)
1858                 content_error("error media_bookmark_create : [%d]", ret);
1859
1860         ret = media_bookmark_set_name(bookmark, "test bookmark");
1861         if (ret != MEDIA_CONTENT_ERROR_NONE)
1862                 content_error("error media_bookmark_set_name : [%d]", ret);
1863
1864         ret = media_bookmark_set_thumbnail_path(bookmark, thumbnail_path1);
1865         if (ret != MEDIA_CONTENT_ERROR_NONE)
1866                 content_error("error media_bookmark_set_thumbnail_path : [%d]", ret);
1867
1868         ret = media_bookmark_insert_to_db_v2(bookmark);
1869         if (ret != MEDIA_CONTENT_ERROR_NONE)
1870                 content_error("error media_bookmark_insert_to_db_v2 : [%d]", ret);
1871
1872         ret = media_bookmark_set_name(bookmark, "test bookmark 2");
1873         if (ret != MEDIA_CONTENT_ERROR_NONE)
1874                 content_error("error media_bookmark_set_name : [%d]", ret);
1875
1876         ret = media_bookmark_update_to_db(bookmark);
1877         if (ret != MEDIA_CONTENT_ERROR_NONE)
1878                 content_error("error media_bookmark_update_to_db : [%d]", ret);
1879
1880         ret = media_bookmark_destroy(bookmark);
1881         if (ret != MEDIA_CONTENT_ERROR_NONE)
1882                 content_error("error media_bookmark_destroy : [%d]", ret);
1883
1884         return ret;
1885 }
1886
1887 int test_album_list(void)
1888 {
1889         content_debug("\n============Album Test============\n\n");
1890
1891         int ret = MEDIA_CONTENT_ERROR_NONE;
1892         int album_count = 0;
1893         filter_h filter;
1894
1895         /*Set Filter*/
1896         const char *condition = "MEDIA_TYPE=3"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
1897
1898         ret = media_filter_create(&filter);
1899         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1900                 content_error("Fail to create filter");
1901                 return ret;
1902         }
1903         ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1904         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1905                 media_filter_destroy(filter);
1906                 content_error("Fail to set condition");
1907                 return ret;
1908         }
1909         ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ALBUM, MEDIA_CONTENT_COLLATE_NOCASE);
1910         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1911                 media_filter_destroy(filter);
1912                 content_error("Fail to set order");
1913                 return ret;
1914         }
1915
1916         ret = media_album_get_album_count_from_db(filter, &album_count);
1917         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1918                 media_filter_destroy(filter);
1919                 return ret;
1920         } else {
1921                 content_debug("album_count [%d]", album_count);
1922         }
1923
1924         ret = media_album_foreach_album_from_db(filter, album_list_cb, NULL);
1925         if (ret != MEDIA_CONTENT_ERROR_NONE)
1926                 content_error("error media_album_foreach_album_from_db : [%d]", ret);
1927
1928         ret = media_filter_destroy(filter);
1929         if (ret != MEDIA_CONTENT_ERROR_NONE)
1930                 content_error("error media_filter_destroy : [%d]", ret);
1931
1932         return ret;
1933 }
1934
1935 int test_group_operation(void)
1936 {
1937         content_debug("\n============Group Test============\n\n");
1938
1939         int ret = MEDIA_CONTENT_ERROR_NONE;
1940         int group_count = 0;
1941         int idx = 0;
1942
1943         ret = test_filter_create();
1944         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1945                 content_error("[error(0x%08x)", ret);
1946                 return ret;
1947         }
1948
1949         for (idx = 0; idx < MEDIA_CONTENT_GROUP_MAX; idx++) {
1950                 ret = media_group_get_group_count_from_db(g_filter, idx, &group_count);
1951                 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1952                         test_filter_destroy();
1953                         content_error("media_group_get_group_count_from_db fail. ret=[%d] idx=[%d]", ret, idx);
1954                         return ret;
1955                 } else {
1956                         content_debug("[%2d]group_count [%d]", idx, group_count);
1957                 }
1958
1959                 ret = media_group_foreach_group_from_db(g_filter, idx, group_list_cb, &idx);
1960                 if (ret != MEDIA_CONTENT_ERROR_NONE)
1961                         content_error("media_group_foreach_group_from_db failed: %d", ret);
1962         }
1963         ret = test_filter_destroy();
1964
1965         return ret;
1966 }
1967
1968 int test_update_operation()
1969 {
1970         int ret = MEDIA_CONTENT_ERROR_NONE;
1971         unsigned int i = 0;
1972         media_info_h media_handle = NULL;
1973         GList *all_item_list = NULL;
1974
1975         /* Get all item list */
1976         ret = media_info_foreach_media_from_db(NULL, gallery_media_item_cb, &all_item_list);
1977         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1978                 content_error("media_info_foreach_media_from_db failed: %d", ret);
1979                 return -1;
1980         } else {
1981                 content_debug("media_info_foreach_media_from_db success");
1982
1983                 for (i = 0; i < g_list_length(all_item_list); i++) {
1984                         media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
1985                         get_media_meta(media_handle);
1986                 }
1987         }
1988
1989         return MEDIA_CONTENT_ERROR_NONE;
1990 }
1991
1992 int test_insert(void)
1993 {
1994         int ret = MEDIA_CONTENT_ERROR_NONE;
1995         const char *path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg");
1996 #if 0
1997         const char *path = tzplatform_mkpath(TZ_USER_DOCUMENTS, "other.txt"));
1998         char *path = NULL;
1999 #endif
2000         media_info_h media_item = NULL;
2001         content_debug("\n============DB Insert Test============\n\n");
2002
2003         ret = media_info_insert_to_db(path, &media_item);
2004
2005         if ((ret == MEDIA_CONTENT_ERROR_NONE) && (media_item != NULL)) {
2006                 content_debug("Insertion is success");
2007         } else {
2008                 content_error("Insertion is failed");
2009                 ret = media_info_destroy(media_item);
2010                 return ret;
2011         }
2012
2013         char *media_id = NULL;
2014
2015         ret = media_info_get_media_id(media_item, &media_id);
2016         if (ret != MEDIA_CONTENT_ERROR_NONE)
2017                 content_error("media_info_get_media_id failed: %d", ret);
2018         else
2019                 content_debug("Media ID: %s", media_id);
2020
2021         SAFE_FREE(media_id);
2022
2023         ret = media_info_update_to_db(media_item);
2024         if (ret == MEDIA_CONTENT_ERROR_NONE)
2025                 content_debug("media_info_update_to_db is success");
2026         else
2027                 content_error("media_info_update_to_db is failed");
2028
2029         ret = media_info_destroy(media_item);
2030         if (ret != MEDIA_CONTENT_ERROR_NONE)
2031                 content_error("media_info_destroy failed: %d", ret);
2032
2033         return ret;
2034 }
2035
2036 int test_move(void)
2037 {
2038         int ret = MEDIA_CONTENT_ERROR_NONE;
2039         const char *move_media_id = "60aea677-4742-408e-b5f7-f2628062d06d";
2040         const char *dst_path = tzplatform_mkpath(TZ_USER_IMAGES, "XX/Default1.jpg");
2041         media_info_h move_media = NULL;
2042
2043         ret = media_info_get_media_from_db(move_media_id, &move_media);
2044         if (ret == MEDIA_CONTENT_ERROR_NONE)
2045                 content_debug("media_info_get_media_from_db success");
2046         else
2047                 content_error("media_info_get_media_from_db failed: %d", ret);
2048
2049         content_debug("\n============DB Move Test============\n\n");
2050
2051         if (move_media) {
2052                 ret = media_info_move_to_db(move_media, dst_path);
2053
2054                 if (ret == MEDIA_CONTENT_ERROR_NONE)
2055                         content_debug("Move is success");
2056                 else
2057                         content_error("Move is failed");
2058
2059                 ret = media_info_destroy(move_media);
2060         } else {
2061                 content_debug("There is no item : %s", move_media_id);
2062         }
2063
2064         return ret;
2065 }
2066
2067 void thumbnail_completed_cb(media_content_error_e error, const char *path, void *user_data)
2068 {
2069         char *thumbnail_path = NULL;
2070         int ret = MEDIA_CONTENT_ERROR_NONE;
2071         g_cnt++;
2072
2073         content_debug("=================[%d][%d]", g_media_cnt, g_cnt);
2074         content_debug("error_code [%d]", error);
2075         content_debug("thumbnail_path [%s]", path);
2076         if (user_data != NULL) {
2077                 media_info_h media = (media_info_h)user_data;
2078                 ret = media_info_get_thumbnail_path(media, &thumbnail_path);
2079                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2080                         content_error("media_info_get_thumbnail_path failed: %d", ret);
2081                 else
2082                         content_debug("thumbnail_path get from media[%s]", thumbnail_path);
2083                 SAFE_FREE(thumbnail_path);
2084                 ret = media_info_destroy(media);
2085                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2086                         content_error("media_info_destroy failed: %d", ret);
2087         }
2088
2089         if (g_cnt == g_media_cnt)
2090                 g_main_loop_quit(g_loop);
2091
2092         return;
2093 }
2094
2095 bool thumbnail_create_cb(media_info_h media, void *user_data)
2096 {
2097         char *media_id = NULL;
2098         media_info_h dst = NULL;
2099         int ret = MEDIA_CONTENT_ERROR_NONE;
2100
2101         if (media == NULL) {
2102                 content_debug("NO Item");
2103                 return true;
2104         }
2105
2106         ret = media_info_get_media_id(media, &media_id);
2107         if (ret != MEDIA_CONTENT_ERROR_NONE)
2108                 content_error("media_info_get_media_id failed: %d", ret);
2109         else
2110                 content_debug("media_id : [%s]", media_id);
2111
2112         ret = media_info_clone(&dst, media);
2113         if (ret != MEDIA_CONTENT_ERROR_NONE)
2114                 content_error("media_info_clone failed: %d", ret);
2115         else {
2116                 ret = media_info_create_thumbnail(dst, thumbnail_completed_cb, dst);
2117                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2118                         content_error("media_info_create_thumbnail failed: %d", ret);
2119         }
2120
2121         /* fix prevent: Resource leak */
2122         SAFE_FREE(media_id);
2123
2124         return true;
2125 }
2126
2127 bool thumbnail_cancel_cb(media_info_h media, void *user_data)
2128 {
2129         int ret = MEDIA_CONTENT_ERROR_NONE;
2130
2131         char *media_id = NULL;
2132         media_info_h dst = NULL;
2133
2134         g_cnt++;
2135
2136         if (media == NULL) {
2137                 content_debug("NO Item");
2138                 return true;
2139         }
2140
2141         ret = media_info_get_media_id(media, &media_id);
2142         if (ret != MEDIA_CONTENT_ERROR_NONE)
2143                 content_error("media_info_get_media_id failed: %d", ret);
2144         else
2145                 content_debug("media_id : [%s]", media_id);
2146
2147         ret = media_info_clone(&dst, media);
2148         if (ret != MEDIA_CONTENT_ERROR_NONE)
2149                 content_error("media_info_clone failed: %d", ret);
2150
2151         ret = media_info_cancel_thumbnail(dst);
2152         if (ret != MEDIA_CONTENT_ERROR_NONE)
2153                 content_error("media_info_cancel_thumbnail failed: %d", ret);
2154
2155         ret = media_info_destroy(dst);
2156         if (ret != MEDIA_CONTENT_ERROR_NONE)
2157                         content_error("media_info_destroy failed: %d", ret);
2158
2159         if (g_cnt == g_media_cnt)
2160                 g_main_loop_quit(g_loop);
2161
2162         /* fix prevent: Resource leak */
2163         SAFE_FREE(media_id);
2164
2165         return true;
2166 }
2167
2168 gboolean create_thumbnail_start(gpointer data)
2169 {
2170         int ret = MEDIA_CONTENT_ERROR_NONE;
2171
2172         ret = media_info_foreach_media_from_db(g_filter, thumbnail_create_cb, NULL);
2173
2174         if (ret == MEDIA_CONTENT_ERROR_NONE)
2175                 content_debug("media_info_foreach_media_from_db is success");
2176         else
2177                 content_error("media_info_foreach_media_from_db is failed");
2178
2179         return false;
2180 }
2181
2182 gboolean cancel_thumbnail_start(gpointer data)
2183 {
2184         int ret = MEDIA_CONTENT_ERROR_NONE;
2185
2186         ret = media_info_foreach_media_from_db(g_filter, thumbnail_cancel_cb, NULL);
2187
2188         if (ret == MEDIA_CONTENT_ERROR_NONE)
2189                 content_debug("media_info_foreach_media_from_db is success");
2190         else
2191                 content_error("media_info_foreach_media_from_db is failed");
2192
2193         return false;
2194 }
2195
2196 int test_create_thumbnail(int cancel)
2197 {
2198         int ret = MEDIA_CONTENT_ERROR_NONE;
2199         GSource *source = NULL;
2200         GMainContext *context = NULL;
2201
2202         test_filter_create();
2203
2204         ret = media_info_get_media_count_from_db(g_filter, &g_media_cnt);
2205         if (ret != MEDIA_CONTENT_ERROR_NONE)
2206                 content_error("media_info_get_media_count_from_db failed: %d", ret);
2207         else
2208                 content_debug("media_count : [%d]", g_media_cnt);
2209
2210         g_loop = g_main_loop_new(NULL, FALSE);
2211         context = g_main_loop_get_context(g_loop);
2212         source = g_idle_source_new();
2213         g_source_set_callback(source, create_thumbnail_start, NULL, NULL);
2214         g_source_attach(source, context);
2215
2216         /* Logic to cancel */
2217         if (cancel) {
2218                 GSource *cancel_src = NULL;
2219                 cancel_src = g_idle_source_new();
2220                 g_source_set_callback(cancel_src, cancel_thumbnail_start, NULL, NULL);
2221                 g_source_attach(cancel_src, context);
2222         }
2223
2224         g_main_loop_run(g_loop);
2225         g_main_loop_unref(g_loop);
2226
2227         test_filter_destroy();
2228
2229         return ret;
2230 }
2231
2232 bool face_cb(media_face_h face, void *user_data)
2233 {
2234         get_face_meta(face);
2235
2236         return false;
2237 }
2238
2239 void face_detection_complete_cb(media_content_error_e error, int count, void *user_data)
2240 {
2241         int ret = MEDIA_CONTENT_ERROR_NONE;
2242         g_cnt++;
2243
2244         content_debug("=================[%d][%d]", g_media_cnt, g_cnt);
2245         content_debug("error_code [%d]", error);
2246         content_debug("face_count [%d]", count);
2247         if (count == 0) {
2248                 content_debug("No faces are detected!");
2249         } else if (user_data != NULL) {
2250                 media_info_h media = (media_info_h)user_data;
2251                 char *media_id = NULL;
2252                 ret = media_info_get_media_id(media, &media_id);
2253                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2254                         content_error("media_info_get_media_id failed: %d", ret);
2255                 if (media_id != NULL) {
2256                         ret = media_info_foreach_face_from_db(media_id, NULL, face_cb, NULL);
2257                         SAFE_FREE(media_id);
2258                         if (ret != MEDIA_CONTENT_ERROR_NONE)
2259                                 content_error("media_info_foreach_face_from_db failed: %d", ret);
2260                 }
2261                 ret = media_info_destroy(media);
2262                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2263                         content_error("media_info_destroy failed: %d", ret);
2264         }
2265
2266         if (g_cnt == g_media_cnt)
2267                 g_main_loop_quit(g_loop);
2268
2269         return;
2270 }
2271
2272 bool start_face_detection_cb(media_info_h media, void *user_data)
2273 {
2274         char *media_id = NULL;
2275         media_info_h dst = NULL;
2276         int ret = MEDIA_CONTENT_ERROR_NONE;
2277
2278         if (media == NULL) {
2279                 content_debug("NO Item");
2280                 return true;
2281         }
2282
2283         ret = media_info_get_media_id(media, &media_id);
2284         if (ret != MEDIA_CONTENT_ERROR_NONE)
2285                 content_error("media_info_get_media_id failed: %d", ret);
2286         else
2287                 content_debug("media_id : [%s]", media_id);
2288
2289         ret = media_info_clone(&dst, media);
2290         if (ret != MEDIA_CONTENT_ERROR_NONE)
2291                 content_error("media_info_clone failed: %d", ret);
2292
2293         GList **list = (GList**)user_data;
2294         *list = g_list_append(*list, dst);
2295
2296         /* fix prevent: Resource leak */
2297         SAFE_FREE(media_id);
2298
2299         return true;
2300 }
2301
2302 bool cancel_face_detection_cb(media_info_h media, void *user_data)
2303 {
2304         int ret = MEDIA_CONTENT_ERROR_NONE;
2305
2306         char *media_id = NULL;
2307         media_info_h dst = NULL;
2308
2309         g_cnt++;
2310
2311         if (media == NULL) {
2312                 content_debug("NO Item");
2313                 return true;
2314         }
2315
2316         ret = media_info_get_media_id(media, &media_id);
2317         if (ret != MEDIA_CONTENT_ERROR_NONE)
2318                 content_error("media_info_get_media_id failed: %d", ret);
2319         else
2320                 content_debug("media_id : [%s]", media_id);
2321
2322         ret = media_info_clone(&dst, media);
2323         if (ret != MEDIA_CONTENT_ERROR_NONE)
2324                 content_error("media_info_clone failed: %d", ret);
2325
2326         ret = media_info_cancel_face_detection(dst);
2327         if (ret != MEDIA_CONTENT_ERROR_NONE)
2328                 content_error("media_info_cancel_face_detection failed: %d", ret);
2329
2330         ret = media_info_destroy(dst);
2331         if (ret != MEDIA_CONTENT_ERROR_NONE)
2332                         content_error("media_info_destroy failed: %d", ret);
2333
2334         if (g_cnt == g_media_cnt)
2335                 g_main_loop_quit(g_loop);
2336
2337         /* fix prevent: Resource leak */
2338         SAFE_FREE(media_id);
2339
2340         return true;
2341 }
2342
2343 gboolean face_detection_start(gpointer data)
2344 {
2345         int ret = MEDIA_CONTENT_ERROR_NONE;
2346         GList *all_item_list = NULL;
2347         int idx = 0;
2348
2349         ret = media_info_foreach_media_from_db(g_filter, start_face_detection_cb, &all_item_list);
2350
2351         if (ret == MEDIA_CONTENT_ERROR_NONE)
2352                 content_debug("media_info_foreach_media_from_db is success");
2353         else
2354                 content_error("media_info_foreach_media_from_db is failed");
2355
2356         for (idx = 0; idx < g_list_length(all_item_list); idx++) {
2357                 media_info_h media_handle = NULL;
2358
2359                 media_handle = (media_info_h)g_list_nth_data(all_item_list, idx);
2360
2361                 ret = media_info_start_face_detection(media_handle, face_detection_complete_cb, NULL);
2362                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2363                         content_error("media_info_start_face_detection failed: %d", ret);
2364
2365         }
2366
2367         return false;
2368 }
2369
2370 gboolean face_detection_cancel(gpointer data)
2371 {
2372         int ret = MEDIA_CONTENT_ERROR_NONE;
2373
2374         ret = media_info_foreach_media_from_db(g_filter, cancel_face_detection_cb, NULL);
2375
2376         if (ret == MEDIA_CONTENT_ERROR_NONE)
2377                 content_debug("media_info_foreach_media_from_db is success");
2378         else
2379                 content_error("media_info_foreach_media_from_db is failed");
2380
2381         return false;
2382 }
2383
2384 int test_start_face_detection(int cancel)
2385 {
2386         int ret = MEDIA_CONTENT_ERROR_NONE;
2387         GSource *source = NULL;
2388         GMainContext *context = NULL;
2389
2390         test_filter_create();
2391
2392         ret = media_info_get_media_count_from_db(g_filter, &g_media_cnt);
2393         if (ret != MEDIA_CONTENT_ERROR_NONE)
2394                 content_error("media_info_get_media_count_from_db failed: %d", ret);
2395         else
2396                 content_debug("media_count : [%d]", g_media_cnt);
2397
2398         if (g_media_cnt == 0)
2399                 goto END;
2400
2401         g_loop = g_main_loop_new(NULL, FALSE);
2402         context = g_main_loop_get_context(g_loop);
2403         source = g_idle_source_new();
2404         g_source_set_callback(source, face_detection_start, NULL, NULL);
2405         g_source_attach(source, context);
2406
2407         /* Logic to cancel */
2408         if (cancel) {
2409                 GSource *cancel_src = NULL;
2410                 cancel_src = g_idle_source_new();
2411                 g_source_set_callback(cancel_src, face_detection_cancel, NULL, NULL);
2412                 g_source_attach(cancel_src, context);
2413         }
2414
2415         g_main_loop_run(g_loop);
2416         g_main_loop_unref(g_loop);
2417
2418 END:
2419         test_filter_destroy();
2420
2421         return ret;
2422 }
2423
2424 int test_ebook_text_finder(const char *keyword)
2425 {
2426         int ret = MEDIA_CONTENT_ERROR_NONE;
2427         char **book_path_list = NULL;
2428         unsigned int book_path_len = 0;
2429         unsigned int i = 0;
2430         media_info_h media = NULL;
2431         book_meta_h book = NULL;
2432         char *s_value = NULL;
2433         long long ms_time = 0;
2434         struct timeval start_time;
2435         struct timeval end_time;
2436
2437         gettimeofday(&start_time, NULL);
2438
2439         ret = book_meta_get_path_with_keyword(keyword, &book_path_list, &book_path_len);
2440         if (ret == MEDIA_CONTENT_ERROR_NONE)
2441                 content_debug("book_meta_get_path_with_keyword is success");
2442         else
2443                 content_error("book_meta_get_path_with_keyword is failed");
2444
2445         gettimeofday(&end_time, NULL);
2446
2447         for (i = 0; i < book_path_len; i++) {
2448                 content_debug("=========================== [%d]", i);
2449                 content_debug("%s", book_path_list[i]);
2450                 content_debug("===============================");
2451                 media_info_get_media_from_db_by_path(book_path_list[i], &media);
2452                 media_info_get_title(media, &s_value);
2453                 content_debug("Title  : %s", s_value);
2454                 g_free(s_value);
2455                 media_info_get_book(media, &book);
2456                 book_meta_get_author(book, &s_value);
2457                 content_debug("Author : %s", s_value);
2458                 g_free(s_value);
2459                 book_meta_get_date(book, &s_value);
2460                 content_debug("Date   : %s", s_value);
2461                 g_free(s_value);
2462                 book_meta_destroy(book);
2463                 media_info_destroy(media);
2464                 content_debug("===============================");
2465         }
2466
2467         ms_time = (end_time.tv_sec * 1000LL + end_time.tv_usec / 1000) - (start_time.tv_sec * 1000LL + start_time.tv_usec/ 1000);
2468
2469         content_debug("Search Time [%lld]", ms_time);
2470         return ret;
2471 }
2472 int test_disconnect_database(void)
2473 {
2474         int ret = MEDIA_CONTENT_ERROR_NONE;
2475         content_debug("\n============DB Disconnection Test============\n\n");
2476
2477         ret = media_content_disconnect();
2478
2479         if (ret == MEDIA_CONTENT_ERROR_NONE)
2480                 content_debug("disconnection is success");
2481         else
2482                 content_error("disconnection is failed");
2483
2484         return ret;
2485 }
2486
2487 int test_request_update_db(void)
2488 {
2489         int ret = MEDIA_CONTENT_ERROR_NONE;
2490         media_info_h media = NULL;
2491         bool favorite = FALSE;
2492
2493         ret = media_info_get_media_from_db("71b19196-5b38-4ab1-ab34-bfe05c369614", &media);
2494         if (ret != MEDIA_CONTENT_ERROR_NONE)
2495                 content_error("media_info_get_media_from_db failed: %d", ret);
2496
2497         ret = media_info_set_favorite(media, TRUE);
2498         if (ret != MEDIA_CONTENT_ERROR_NONE)
2499                 content_error("media_info_set_favorite failed: %d", ret);
2500
2501         ret = media_info_update_to_db(media);
2502         if (ret == MEDIA_CONTENT_ERROR_NONE)
2503                 content_debug("media_info_update_to_db is success");
2504         else
2505                 content_error("media_info_update_to_db is failed");
2506
2507         if (media != NULL)
2508                 media_info_destroy(media);
2509
2510         /*get the updated value*/
2511         ret = media_info_get_media_from_db("71b19196-5b38-4ab1-ab34-bfe05c369614", &media);
2512         if (ret != MEDIA_CONTENT_ERROR_NONE)
2513                 content_error("media_info_get_media_from_db failed: %d", ret);
2514
2515         ret = media_info_get_favorite(media, &favorite);
2516         if (ret != MEDIA_CONTENT_ERROR_NONE)
2517                 content_error("media_info_get_favorite failed: %d", ret);
2518         else
2519                 content_debug("favorite [%d]", favorite);
2520
2521         ret = media_info_destroy(media);
2522
2523         return ret;
2524 }
2525
2526 int g_total_photo_size = 0;
2527 int g_total_video_size = 0;
2528 int g_total_mp3_size = 0;
2529 int g_total_voice_memo_size = 0;
2530
2531 bool dft_cb(media_info_h media, void *user_data)
2532 {
2533         unsigned long long file_size = 0;
2534         media_content_type_e media_type = -1;
2535         char *mime_type = NULL;
2536         int ret = MEDIA_CONTENT_ERROR_NONE;
2537
2538         if (media == NULL)
2539                 return true;
2540
2541         ret = media_info_get_media_type(media, &media_type);
2542         if (ret != MEDIA_CONTENT_ERROR_NONE)
2543                 content_error("media_info_get_media_type failed: %d", ret);
2544         ret = media_info_get_size(media, &file_size);
2545         if (ret != MEDIA_CONTENT_ERROR_NONE)
2546                 content_error("media_info_get_size failed: %d", ret);
2547         ret = media_info_get_mime_type(media, &mime_type);
2548         if (ret != MEDIA_CONTENT_ERROR_NONE)
2549                 content_error("media_info_get_mime_type failed: %d", ret);
2550
2551         if (media_type == MEDIA_CONTENT_TYPE_IMAGE)
2552                 g_total_photo_size += file_size;
2553         else if (media_type == MEDIA_CONTENT_TYPE_VIDEO)
2554                 g_total_video_size += file_size;
2555         else if (media_type == MEDIA_CONTENT_TYPE_SOUND)
2556                 g_total_voice_memo_size += file_size;
2557         else if (media_type == MEDIA_CONTENT_TYPE_MUSIC) {
2558                 if ((mime_type != NULL) && (!strcmp("audio/mpeg", mime_type)))
2559                         g_total_mp3_size += file_size;
2560                 else
2561                         g_total_voice_memo_size += file_size;
2562         } else
2563                 content_debug("invalid media_type");
2564
2565         SAFE_FREE(mime_type);
2566
2567         return true;
2568
2569 }
2570
2571 int DFT_test(void)
2572 {
2573         int ret = MEDIA_CONTENT_ERROR_NONE;
2574         content_debug("\n============DFT_test============\n\n");
2575
2576         filter_h filter = NULL;
2577         int media_cnt = 0;
2578
2579         /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
2580
2581         ret = media_filter_create(&filter);
2582
2583 /*Internal Memory*/
2584         content_debug("[Internal Memory]\n");
2585         /*1. Photo ============================================================*/
2586         ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);
2587
2588         /*Get Photo Count*/
2589         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2590         content_debug("Photo count = [%d]\n", media_cnt);
2591
2592         /*Get Photo Size*/
2593         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2594         content_debug("Photo size = [%d]\n", g_total_photo_size);
2595
2596         /*2. Video ============================================================*/
2597         ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT);
2598
2599         /*Get Video Count*/
2600         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2601         content_debug("Video count = [%d]\n", media_cnt);
2602
2603         /*Get Video Size*/
2604         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2605         content_debug("Video size = [%d]\n", g_total_video_size);
2606
2607         /*3. MP3 ============================================================*/
2608         ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT);
2609
2610         /*Get MP3 Count*/
2611         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2612         content_debug("MP3 count = [%d]\n", media_cnt);
2613
2614         /*Get MP3 Size*/
2615         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2616         content_debug("MP3 size = [%d]\n", g_total_mp3_size);
2617
2618         /*4. Voice Memo ============================================================*/
2619         ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND (MEDIA_MIME_TYPE=\"audio/AMR\" OR MEDIA_MIME_TYPE=\"audio/mp4\")", MEDIA_CONTENT_COLLATE_DEFAULT);
2620
2621         /*Get Voice Memo Count*/
2622         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2623         content_debug("Voice Memo count = [%d]\n", media_cnt);
2624
2625         /*Get Voice Memo Size*/
2626         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2627         content_debug("Voice Memo size = [%d]\n", g_total_voice_memo_size);
2628
2629         g_total_photo_size = 0;
2630         g_total_video_size = 0;
2631         g_total_mp3_size = 0;
2632         g_total_voice_memo_size = 0;
2633
2634 /*External Memory*/
2635         content_debug("\n[External Memory]\n");
2636         /*1. Photo ============================================================*/
2637         ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);
2638
2639         /*Get Photo Count*/
2640         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2641         content_debug("Photo count = [%d]\n", media_cnt);
2642
2643         /*Get Photo Size*/
2644         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2645         content_debug("Photo size = [%d]\n", g_total_photo_size);
2646
2647         /*2. Video ============================================================*/
2648         ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT);
2649
2650         /*Get Video Count*/
2651         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2652         content_debug("Video count = [%d]\n", media_cnt);
2653
2654         /*Get Video Size*/
2655         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2656         content_debug("Video size = [%d]\n", g_total_video_size);
2657
2658         /*3. MP3 ============================================================*/
2659         ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT);
2660
2661         /*Get MP3 Count*/
2662         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2663         content_debug("MP3 count = [%d]\n", media_cnt);
2664
2665         /*Get MP3 Size*/
2666         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2667         content_debug("MP3 size = [%d]\n", g_total_mp3_size);
2668
2669         /*4. Voice Memo ============================================================*/
2670         ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND (MEDIA_MIME_TYPE=\"audio/AMR\" OR MEDIA_MIME_TYPE=\"audio/mp4\")", MEDIA_CONTENT_COLLATE_DEFAULT);
2671
2672         /*Get Voice Memo Count*/
2673         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2674         content_debug("Voice Memo count = [%d]\n", media_cnt);
2675
2676         /*Get Voice Memo Size*/
2677         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2678         content_debug("Voice Memo size = [%d]\n", g_total_voice_memo_size);
2679         ret = media_filter_destroy(filter);
2680
2681         return ret;
2682 }
2683
2684 void insert_batch_cb(media_content_error_e error, void * user_data)
2685 {
2686         content_debug("media_info_insert_batch_to_db completed!\n");
2687 }
2688
2689 int test_batch_operations()
2690 {
2691         int ret = -1;
2692         int i = 0;
2693         char *file_list[10];
2694
2695         for (i = 0; i < 10; i++) {
2696                 file_list[i] = g_strdup_printf("%s%d.jpg", tzplatform_mkpath(TZ_USER_CONTENT, "test/image"), i+1);
2697                 content_debug("File : %s\n", file_list[i]);
2698         }
2699
2700         ret = media_info_insert_batch_to_db((const char **)file_list, 10, insert_batch_cb, NULL);
2701         if (ret != MEDIA_CONTENT_ERROR_NONE)
2702                 content_error("media_info_insert_batch_to_db failed : %d\n", ret);
2703
2704         for (i = 0; i < 10; i++)
2705                 g_free(file_list[i]);
2706
2707         return ret;
2708 }
2709
2710 void _scan_cb(media_content_error_e err, void *user_data)
2711 {
2712         content_debug("scan callback is called : %d\n", err);
2713         g_main_loop_quit(g_loop);
2714
2715         return;
2716 }
2717
2718 int test_scan_file()
2719 {
2720         int ret = -1;
2721
2722         const char *file_path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
2723         ret = media_content_scan_file(file_path);
2724         if (ret != MEDIA_CONTENT_ERROR_NONE) {
2725                 content_error("Fail to media_content_scan_file : %d", ret);
2726                 return ret;
2727         }
2728
2729         return 0;
2730 }
2731
2732 gboolean test_scan_dir_start(gpointer data)
2733 {
2734         int ret = -1;
2735
2736         const char *dir_path = tzplatform_getenv(TZ_USER_CONTENT);
2737
2738         ret = media_content_scan_folder(dir_path, TRUE, _scan_cb, NULL);
2739
2740         if (ret != MEDIA_CONTENT_ERROR_NONE) {
2741                 content_error("Fail to test_scan_dir_start : %d", ret);
2742                 return ret;
2743         }
2744
2745         return 0;
2746 }
2747
2748 gboolean cancel_scan_dir_start(gpointer data)
2749 {
2750         int ret = MEDIA_CONTENT_ERROR_NONE;
2751
2752         const char *dir_path = tzplatform_getenv(TZ_USER_IMAGES);
2753
2754         ret = media_content_cancel_scan_folder(dir_path);
2755
2756         if (ret == MEDIA_CONTENT_ERROR_NONE)
2757                 content_debug("media_content_cancel_scan_folder is success");
2758         else
2759                 content_error("media_content_cancel_scan_folder is failed");
2760
2761         return false;
2762 }
2763
2764 int test_scan_dir(int cancel)
2765 {
2766         GSource *source = NULL;
2767         GMainContext *context = NULL;
2768
2769         g_loop = g_main_loop_new(NULL, FALSE);
2770         context = g_main_loop_get_context(g_loop);
2771         source = g_idle_source_new();
2772         g_source_set_callback(source, test_scan_dir_start, NULL, NULL);
2773         g_source_attach(source, context);
2774
2775         if (cancel) {
2776                 GSource *cancel_src = NULL;
2777                 cancel_src = g_idle_source_new();
2778                 g_source_set_callback(cancel_src, cancel_scan_dir_start, NULL, NULL);
2779                 g_source_attach(cancel_src, context);
2780         }
2781
2782         g_main_loop_run(g_loop);
2783         g_main_loop_unref(g_loop);
2784
2785         return 0;
2786 }
2787
2788 void _noti_cb(media_content_error_e error,
2789                                 int pid,
2790                                 media_content_db_update_item_type_e update_item,
2791                                 media_content_db_update_type_e update_type,
2792                                 media_content_type_e media_type,
2793                                 char *uuid,
2794                                 char *path,
2795                                 char *mime_type,
2796                                 void *user_data)
2797 {
2798         if (error == 0)
2799                 content_debug("noti success! : %d\n", error);
2800         else
2801                 content_debug("error occurred! : %d\n", error);
2802
2803         content_debug("Noti from PID(%d)\n", pid);
2804
2805         if (update_item == MEDIA_ITEM_FILE)
2806                 content_debug("Noti item : MEDIA_ITEM_FILE\n");
2807         else if (update_item == MEDIA_ITEM_DIRECTORY)
2808                 content_debug("Noti item : MEDIA_ITEM_DIRECTORY\n");
2809
2810         if (update_type == MEDIA_CONTENT_INSERT)
2811                 content_debug("Noti type : MEDIA_CONTENT_INSERT\n");
2812         else if (update_type == MEDIA_CONTENT_DELETE)
2813                 content_debug("Noti type : MEDIA_CONTENT_DELETE\n");
2814         else if (update_type == MEDIA_CONTENT_UPDATE)
2815                 content_debug("Noti type : MEDIA_CONTENT_UPDATE\n");
2816
2817         content_debug("content type : %d\n", media_type);
2818
2819         if (path)
2820                 content_debug("path : %s\n", path);
2821         else
2822                 content_debug("path not\n");
2823
2824         if (uuid)
2825                 content_debug("uuid : %s\n", uuid);
2826         else
2827                 content_debug("uuid not\n");
2828
2829         if (mime_type)
2830                 content_debug("mime_type : %s\n", mime_type);
2831         else
2832                 content_debug("mime not\n");
2833
2834         if (user_data) content_debug("String : %s\n", (char *)user_data);
2835
2836         return;
2837 }
2838
2839 void _noti_cb_2(media_content_error_e error,
2840                                 int pid,
2841                                 media_content_db_update_item_type_e update_item,
2842                                 media_content_db_update_type_e update_type,
2843                                 media_content_type_e media_type,
2844                                 char *uuid,
2845                                 char *path,
2846                                 char *mime_type,
2847                                 void *user_data)
2848 {
2849         if (error == 0)
2850                 content_debug("noti_2 success! : %d\n", error);
2851         else
2852                 content_debug("error occurred! : %d\n", error);
2853
2854         content_debug("Noti_2 from PID(%d)\n", pid);
2855
2856         g_main_loop_quit(g_loop);
2857         return;
2858 }
2859
2860 static media_content_noti_h noti_h;
2861 static media_content_noti_h noti_h_2;
2862
2863 gboolean _send_noti_operations(gpointer data)
2864 {
2865         int ret = MEDIA_CONTENT_ERROR_NONE;
2866
2867         /* First of all, noti subscription */
2868         char *user_str = strdup("hi");
2869         media_content_add_db_updated_cb(_noti_cb, (void*)user_str, &noti_h);
2870         media_content_add_db_updated_cb(_noti_cb_2, (void*)user_str, &noti_h_2);
2871
2872         /* media_info_insert_to_db */
2873         media_info_h media_item = NULL;
2874         const char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
2875
2876         ret = media_info_insert_to_db(path, &media_item);
2877         if (ret != MEDIA_CONTENT_ERROR_NONE) {
2878                 content_error("media_info_insert_to_db failed : %d", ret);
2879                 media_info_destroy(media_item);
2880                 return FALSE;
2881         }
2882
2883         content_debug("media_info_insert_to_db success");
2884
2885         media_content_remove_db_updated_cb(noti_h);
2886
2887         /* media_info_update_to_db */
2888         ret = media_info_update_to_db(media_item);
2889         if (ret != MEDIA_CONTENT_ERROR_NONE) {
2890                 content_error("media_info_update_to_db failed : %d\n", ret);
2891                 media_info_destroy(media_item);
2892                 return ret;
2893         }
2894
2895         media_info_destroy(media_item);
2896
2897         return FALSE;
2898 }
2899
2900 int test_noti()
2901 {
2902         int ret = MEDIA_CONTENT_ERROR_NONE;
2903         GSource *source = NULL;
2904         GMainContext *context = NULL;
2905
2906         g_loop = g_main_loop_new(NULL, FALSE);
2907         context = g_main_loop_get_context(g_loop);
2908         source = g_idle_source_new();
2909         g_source_set_callback(source, _send_noti_operations, NULL, NULL);
2910         g_source_attach(source, context);
2911
2912         g_main_loop_run(g_loop);
2913         g_main_loop_unref(g_loop);
2914
2915         test_filter_destroy();
2916         media_content_remove_db_updated_cb(noti_h_2);
2917
2918         return ret;
2919 }
2920
2921 bool media_face_test_cb(media_face_h face, void *user_data)
2922 {
2923         get_face_meta(face);
2924
2925         if (user_data != NULL) {
2926                 media_face_h new_face = NULL;
2927                 media_face_clone(&new_face, face);
2928
2929                 GList **list = (GList**)user_data;
2930                 *list = g_list_append(*list, new_face);
2931         }
2932
2933         return true;
2934 }
2935
2936 int test_face(void)
2937 {
2938         int ret = MEDIA_CONTENT_ERROR_NONE;
2939         filter_h filter = NULL;
2940         GList *all_item_list = NULL;
2941         int i = 0;
2942
2943         ret = media_filter_create(&filter);
2944         content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_filter_create");
2945
2946         ret = media_filter_set_condition(filter, "MEDIA_TYPE = 0", MEDIA_CONTENT_COLLATE_DEFAULT);
2947         if (ret != MEDIA_CONTENT_ERROR_NONE) {
2948                 media_filter_destroy(filter);
2949                 content_error("Fail to set condition");
2950                 return ret;
2951         }
2952
2953         ret = media_info_foreach_media_from_db(filter, gallery_media_item_cb, &all_item_list);
2954         if (ret != MEDIA_CONTENT_ERROR_NONE) {
2955                 content_error("media_info_foreach_media_from_db failed: %d", ret);
2956                 media_filter_destroy(filter);
2957                 return ret;
2958         }
2959
2960         for (i = 0; i < g_list_length(all_item_list); i++) {
2961                 media_info_h media_handle = NULL;
2962                 char *media_id = NULL;
2963                 int face_count = 0;
2964
2965                 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
2966
2967                 ret = media_info_get_media_id(media_handle, &media_id);
2968                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2969                         content_error("media_info_get_media_id failed: %d", ret);
2970
2971                 ret = media_info_get_face_count_from_db(media_id, filter, &face_count);
2972                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2973                         content_error("media_info_get_face_count_from_db failed: %d", ret);
2974
2975                 content_error("media_id [%s] face_count [%d]", media_id, face_count);
2976
2977                 ret = media_info_foreach_face_from_db(media_id, filter, media_face_test_cb, NULL);
2978                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2979                         content_error("media_info_foreach_face_from_db failed: %d", ret);
2980
2981                 media_info_destroy(media_handle);
2982         }
2983
2984         media_filter_destroy(filter);
2985
2986         return ret;
2987 }
2988
2989 int test_face_add_del(void)
2990 {
2991         int ret = MEDIA_CONTENT_ERROR_NONE;
2992         char *media_id = "ecca7366-e085-41d8-a12b-cbdfc2b9c5fc";
2993
2994         /* Insert Test */
2995         media_face_h face = NULL;
2996
2997         char *face_tag = "test_face_tag";
2998
2999         ret = media_face_create(media_id, &face);
3000         content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_face_create");
3001
3002         ret = media_face_set_face_rect(face, 10, 12, 50, 100);
3003         if (ret != MEDIA_CONTENT_ERROR_NONE)
3004                 content_error("media_face_set_face_rect failed: %d", ret);
3005
3006         ret = media_face_set_orientation(face, 5);
3007         if (ret != MEDIA_CONTENT_ERROR_NONE)
3008                 content_error("media_face_set_orientation failed: %d", ret);
3009
3010         ret = media_face_set_tag(face, face_tag);
3011         if (ret != MEDIA_CONTENT_ERROR_NONE)
3012                 content_error("media_face_set_tag failed: %d", ret);
3013
3014         ret = media_face_insert_to_db(face);
3015         if (ret != MEDIA_CONTENT_ERROR_NONE)
3016                 content_error("media_face_insert_to_db failed: %d", ret);
3017
3018         ret = media_face_destroy(face);
3019         if (ret != MEDIA_CONTENT_ERROR_NONE)
3020                 content_error("media_face_destroy failed: %d", ret);
3021
3022         /* Update Test */
3023         GList *all_item_list = NULL;
3024         filter_h filter = NULL;
3025         ret = media_filter_create(&filter);
3026         content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_filter_create");
3027
3028         ret = media_filter_set_condition(filter, "MEDIA_FACE_TAG IS NOT NULL", MEDIA_CONTENT_COLLATE_DEFAULT);
3029         if (ret != MEDIA_CONTENT_ERROR_NONE) {
3030                 media_filter_destroy(filter);
3031                 content_error("Fail to set condition");
3032                 return ret;
3033         }
3034
3035         ret = media_info_foreach_face_from_db(media_id, filter, media_face_test_cb, &all_item_list);
3036
3037         if (g_list_length(all_item_list) > 0) {
3038                 media_face_h face_handle = NULL;
3039                 face_handle = (media_face_h)g_list_nth_data(all_item_list, 0);
3040
3041                 ret = media_face_set_face_rect(face_handle, 20, 22, 70, 70);
3042                 if (ret != MEDIA_CONTENT_ERROR_NONE)
3043                         content_error("media_face_set_face_rect failed: %d", ret);
3044                 ret = media_face_set_orientation(face_handle, 3);
3045                 if (ret != MEDIA_CONTENT_ERROR_NONE)
3046                         content_error("media_face_set_orientation failed: %d", ret);
3047                 ret = media_face_set_tag(face_handle, NULL);
3048                 if (ret != MEDIA_CONTENT_ERROR_NONE)
3049                         content_error("media_face_set_tag failed: %d", ret);
3050                 ret = media_face_update_to_db(face_handle);
3051                 if (ret != MEDIA_CONTENT_ERROR_NONE)
3052                         content_error("media_face_update_to_db failed: %d", ret);
3053
3054                 media_face_destroy(face_handle);
3055         }
3056
3057         media_filter_destroy(filter);
3058
3059         /* Delete Test */
3060         char *face_id = "5e58a3a8-f0b2-4c29-b799-b49a70dc2313";
3061
3062         /* Delete Test*/
3063         ret = media_face_delete_from_db(face_id);
3064
3065         return ret;
3066 }
3067
3068 #ifdef _USE_TVPD_MODE
3069 filter_h g_tv_filter = NULL;
3070
3071 int test_tv_filter_create(void)
3072 {
3073         content_debug("\n============Filter Create============\n\n");
3074
3075         int ret = MEDIA_CONTENT_ERROR_NONE;
3076
3077         ret = media_filter_create(&g_tv_filter);
3078
3079         ret = media_filter_set_storage(g_tv_filter, "0a22a163-e634-4a2e-ba14-0469a969eea0");
3080
3081         ret = media_filter_set_order(g_tv_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_STORAGE_ID, MEDIA_CONTENT_COLLATE_DEFAULT);
3082
3083         return ret;
3084 }
3085
3086 int test_tv_filter_destroy(void)
3087 {
3088         content_debug("\n============Filter Destroy============\n\n");
3089
3090         int ret = MEDIA_CONTENT_ERROR_NONE;
3091
3092         ret = media_filter_destroy(g_tv_filter);
3093
3094         return ret;
3095 }
3096
3097 bool pvr_item_cb(media_pvr_h pvr, void *user_data)
3098 {
3099         int ret = MEDIA_CONTENT_ERROR_NONE;
3100         char *c_value = NULL;
3101         int i_value = 0;
3102         bool b_value = false;
3103         unsigned long long l_value = 0;
3104
3105         if (pvr == NULL) {
3106                 content_debug("NO Item");
3107                 return true;
3108         }
3109
3110         ret = media_pvr_get_media_id(pvr, &c_value);
3111         if (ret != MEDIA_CONTENT_ERROR_NONE)
3112                 content_error("Fail to media_pvr_get_media_id");
3113         content_debug("media_id [%s]", c_value);
3114         SAFE_FREE(c_value);
3115
3116         ret = media_pvr_get_channel_name(pvr, &c_value);
3117         if (ret != MEDIA_CONTENT_ERROR_NONE)
3118                 content_error("Fail to media_pvr_get_channel_name");
3119         content_debug("channel_name [%s]", c_value);
3120         SAFE_FREE(c_value);
3121
3122         ret = media_pvr_get_program_title(pvr, &c_value);
3123         if (ret != MEDIA_CONTENT_ERROR_NONE)
3124                 content_error("Fail to media_pvr_get_program_title");
3125         content_debug("program_title [%s]", c_value);
3126         SAFE_FREE(c_value);
3127
3128         ret = media_pvr_get_program_crid(pvr, &c_value);
3129         if (ret != MEDIA_CONTENT_ERROR_NONE)
3130                 content_error("Fail to media_pvr_get_program_crid");
3131         content_debug("program_crid [%s]", c_value);
3132         SAFE_FREE(c_value);
3133
3134         ret = media_pvr_get_guidance(pvr, &c_value);
3135         if (ret != MEDIA_CONTENT_ERROR_NONE)
3136                 content_error("Fail to media_pvr_get_guidance");
3137         content_debug("guidance [%s]", c_value);
3138         SAFE_FREE(c_value);
3139
3140         ret = media_pvr_get_synopsis(pvr, &c_value);
3141         if (ret != MEDIA_CONTENT_ERROR_NONE)
3142                 content_error("Fail to media_pvr_get_synopsis");
3143         content_debug("synopsis [%s]", c_value);
3144         SAFE_FREE(c_value);
3145
3146         ret = media_pvr_get_genre(pvr, &c_value);
3147         if (ret != MEDIA_CONTENT_ERROR_NONE)
3148                 content_error("Fail to media_pvr_get_synopsis");
3149         content_debug("genre [%s]", c_value);
3150         SAFE_FREE(c_value);
3151
3152         ret = media_pvr_get_language(pvr, &c_value);
3153         if (ret != MEDIA_CONTENT_ERROR_NONE)
3154                 content_error("Fail to media_pvr_get_language");
3155         content_debug("language [%s]", c_value);
3156         SAFE_FREE(c_value);
3157
3158         ret = media_pvr_get_path(pvr, &c_value);
3159         if (ret != MEDIA_CONTENT_ERROR_NONE)
3160                 content_error("Fail to media_pvr_get_path");
3161         content_debug("path [%s]", c_value);
3162         SAFE_FREE(c_value);
3163
3164         ret = media_pvr_get_storage_id(pvr, &c_value);
3165         if (ret != MEDIA_CONTENT_ERROR_NONE)
3166                 content_error("Fail to media_pvr_get_storage_id");
3167         content_debug("storage_id [%s]", c_value);
3168         SAFE_FREE(c_value);
3169
3170         ret = media_pvr_get_size(pvr, &l_value);
3171         if (ret != MEDIA_CONTENT_ERROR_NONE)
3172                 content_error("Fail to media_pvr_get_size");
3173         content_debug("size [%lld]", l_value);
3174
3175         ret = media_pvr_get_timezone(pvr, &i_value);
3176         if (ret != MEDIA_CONTENT_ERROR_NONE)
3177                 content_error("Fail to media_pvr_get_timezone");
3178         content_debug("timezone [%d]", i_value);
3179
3180         ret = media_pvr_get_ptc(pvr, &i_value);
3181         if (ret != MEDIA_CONTENT_ERROR_NONE)
3182                 content_error("Fail to media_pvr_get_ptc");
3183         content_debug("ptc [%d]", i_value);
3184
3185         ret = media_pvr_get_major(pvr, &i_value);
3186         if (ret != MEDIA_CONTENT_ERROR_NONE)
3187                 content_error("Fail to media_pvr_get_major");
3188         content_debug("[%d]", i_value);
3189
3190         ret = media_pvr_get_minor(pvr, &i_value);
3191         if (ret != MEDIA_CONTENT_ERROR_NONE)
3192                 content_error("Fail to media_pvr_get_minor");
3193         content_debug("minor [%d]", i_value);
3194
3195         ret = media_pvr_get_channel_type(pvr, &i_value);
3196         if (ret != MEDIA_CONTENT_ERROR_NONE)
3197                 content_error("Fail to media_pvr_get_channel_type");
3198         content_debug("channel_type [%d]", i_value);
3199
3200         ret = media_pvr_get_program_num(pvr, &i_value);
3201         if (ret != MEDIA_CONTENT_ERROR_NONE)
3202                 content_error("Fail to media_pvr_get_program_num");
3203         content_debug("program_num [%d]", i_value);
3204
3205         unsigned int ui_value = 0;
3206         ret = media_pvr_get_service_profile(pvr, &ui_value);
3207         if (ret != MEDIA_CONTENT_ERROR_NONE)
3208                 content_error("Fail to media_pvr_get_service_profile");
3209         content_debug("service_profile [%u]", ui_value);
3210
3211         ret = media_pvr_get_duration(pvr, &i_value);
3212         if (ret != MEDIA_CONTENT_ERROR_NONE)
3213                 content_error("Fail to media_pvr_get_duration");
3214         content_debug("duration [%d]", i_value);
3215
3216         ret = media_pvr_get_embargo_time(pvr, &i_value);
3217         if (ret != MEDIA_CONTENT_ERROR_NONE)
3218                 content_error("Fail to media_pvr_get_embargo_time");
3219         content_debug("embargo_time [%d]", i_value);
3220
3221         ret = media_pvr_get_expiry_time(pvr, &i_value);
3222         if (ret != MEDIA_CONTENT_ERROR_NONE)
3223                 content_error("Fail to media_pvr_get_expiry_time");
3224         content_debug("expiry_time [%d]", i_value);
3225
3226         ret = media_pvr_get_parental_rating(pvr, &i_value);
3227         if (ret != MEDIA_CONTENT_ERROR_NONE)
3228                 content_error("Fail to media_pvr_get_parental_rating");
3229         content_debug("parental_rating [%d]", i_value);
3230
3231         ret = media_pvr_get_start_time(pvr, &i_value);
3232         if (ret != MEDIA_CONTENT_ERROR_NONE)
3233                 content_error("Fail to media_pvr_get_start_time");
3234         content_debug("start_time [%d]", i_value);
3235
3236         ret = media_pvr_get_program_start_time(pvr, &i_value);
3237         if (ret != MEDIA_CONTENT_ERROR_NONE)
3238                 content_error("Fail to media_pvr_get_program_start_time");
3239         content_debug("program_start_time [%d]", i_value);
3240
3241         ret = media_pvr_get_program_end_time(pvr, &i_value);
3242         if (ret != MEDIA_CONTENT_ERROR_NONE)
3243                 content_error("Fail to media_pvr_get_program_end_time");
3244         content_debug("program_end_time [%d]", i_value);
3245
3246         ret = media_pvr_get_program_date(pvr, &i_value);
3247         if (ret != MEDIA_CONTENT_ERROR_NONE)
3248                 content_error("Fail to media_pvr_get_program_date");
3249         content_debug("program_date [%d]", i_value);
3250
3251         ret = media_pvr_get_timer_record(pvr, &b_value);
3252         if (ret != MEDIA_CONTENT_ERROR_NONE)
3253                 content_error("Fail to media_pvr_get_timer_record");
3254         content_debug("timer_record [%d]", b_value);
3255
3256         ret = media_pvr_get_series_record(pvr, &b_value);
3257         if (ret != MEDIA_CONTENT_ERROR_NONE)
3258                 content_error("Fail to media_pvr_get_series_record");
3259         content_debug("series_record [%d]", b_value);
3260
3261         ret = media_pvr_get_hd(pvr, &i_value);
3262         if (ret != MEDIA_CONTENT_ERROR_NONE)
3263                 content_error("Fail to media_pvr_get_hd");
3264         content_debug("hd [%d]", i_value);
3265
3266         ret = media_pvr_get_subtitle(pvr, &b_value);
3267         if (ret != MEDIA_CONTENT_ERROR_NONE)
3268                 content_error("Fail to media_pvr_get_subtitle");
3269         content_debug("subtitle [%d]", b_value);
3270
3271         ret = media_pvr_get_ttx(pvr, &b_value);
3272         if (ret != MEDIA_CONTENT_ERROR_NONE)
3273                 content_error("Fail to media_pvr_get_ttx");
3274         content_debug("ttx [%d]", b_value);
3275
3276         ret = media_pvr_get_ad(pvr, &b_value);
3277         if (ret != MEDIA_CONTENT_ERROR_NONE)
3278                 content_error("Fail to media_pvr_get_ad");
3279         content_debug("ad [%d]", b_value);
3280
3281         ret = media_pvr_get_hard_of_hearing_radio(pvr, &b_value);
3282         if (ret != MEDIA_CONTENT_ERROR_NONE)
3283                 content_error("Fail to media_pvr_get_hard_of_hearing_radio");
3284         content_debug("hard_of_hearing_radio [%d]", b_value);
3285
3286         ret = media_pvr_get_data_service(pvr, &b_value);
3287         if (ret != MEDIA_CONTENT_ERROR_NONE)
3288                 content_error("Fail to media_pvr_get_data_service");
3289         content_debug("data_service [%d]", b_value);
3290
3291         ret = media_pvr_get_content_lock(pvr, &b_value);
3292         if (ret != MEDIA_CONTENT_ERROR_NONE)
3293                 content_error("Fail to media_pvr_get_content_lock");
3294         content_debug("content_lock [%d]", b_value);
3295
3296         ret = media_pvr_get_content_watch(pvr, &b_value);
3297         if (ret != MEDIA_CONTENT_ERROR_NONE)
3298                 content_error("Fail to media_pvr_get_content_watch");
3299         content_debug("content_watch [%d]", b_value);
3300
3301         ret = media_pvr_get_has_audio_only(pvr, &b_value);
3302         if (ret != MEDIA_CONTENT_ERROR_NONE)
3303                 content_error("Fail to media_pvr_get_has_audio_only");
3304         content_debug("has_audio_only [%d]", b_value);
3305
3306         ret = media_pvr_get_is_local_record(pvr, &b_value);
3307         if (ret != MEDIA_CONTENT_ERROR_NONE)
3308                 content_error("Fail to media_pvr_get_is_local_record");
3309         content_debug("is_local_record [%d]", b_value);
3310
3311         ret = media_pvr_get_resolution(pvr, (media_pvr_resolution_e*)&i_value);
3312         if (ret != MEDIA_CONTENT_ERROR_NONE)
3313                 content_error("Fail to media_pvr_get_resolution");
3314         content_debug("resolution [%d]", i_value);
3315
3316         ret = media_pvr_get_aspectratio(pvr, (media_pvr_aspectratio_e*)&i_value);
3317         if (ret != MEDIA_CONTENT_ERROR_NONE)
3318                 content_error("Fail to media_pvr_get_aspectratio");
3319         content_debug("aspectratio [%d]", i_value);
3320
3321         ret = media_pvr_get_highlight(pvr, &b_value);
3322         if (ret != MEDIA_CONTENT_ERROR_NONE)
3323                 content_error("Fail to media_pvr_get_highlight");
3324         content_debug("highlight [%d]", b_value);
3325
3326
3327         return TRUE;
3328 }
3329
3330 int test_pvr()
3331 {
3332         int ret = MEDIA_CONTENT_ERROR_NONE;
3333         int media_count = 0;
3334
3335         content_debug("\n============PVR Test============\n\n");
3336
3337         test_tv_filter_create();
3338
3339         ret = media_pvr_get_media_count_from_db(g_tv_filter, &media_count);
3340         if (ret != MEDIA_CONTENT_ERROR_NONE)
3341                 content_error("media_pvr_get_media_count_from_db failed: %d", ret);
3342         else
3343                 content_debug("media_count : [%d]", media_count);
3344
3345         ret = media_pvr_foreach_media_from_db(g_tv_filter, pvr_item_cb, NULL);
3346         if (ret != MEDIA_CONTENT_ERROR_NONE)
3347                 content_error("media_pvr_foreach_media_from_db is failed");
3348
3349         test_tv_filter_destroy();
3350
3351         return ret;
3352 }
3353
3354 int test_pvr_update_db(void)
3355 {
3356         int ret = MEDIA_CONTENT_ERROR_NONE;
3357         media_pvr_h pvr = NULL;
3358
3359         ret = media_pvr_get_pvr_from_db("ff9b5a9a-a7b4-47f4-8255-84e007e25f13", &pvr);
3360         if (ret != MEDIA_CONTENT_ERROR_NONE)
3361                 content_error("media_pvr_get_pvr_from_db failed: %d", ret);
3362
3363         ret = media_pvr_set_content_lock(pvr, TRUE);
3364         if (ret != MEDIA_CONTENT_ERROR_NONE)
3365                 content_error("Fail to media_pvr_set_content_lock");
3366
3367         ret = media_pvr_set_content_watch(pvr, TRUE);
3368         if (ret != MEDIA_CONTENT_ERROR_NONE)
3369                 content_error("Fail to media_pvr_set_content_watch");
3370
3371         ret = media_pvr_set_program_title(pvr, "TEST TITLE");
3372         if (ret != MEDIA_CONTENT_ERROR_NONE)
3373                 content_error("Fail to media_pvr_set_program_title");
3374
3375         ret = media_pvr_set_highlight(pvr, TRUE);
3376         if (ret != MEDIA_CONTENT_ERROR_NONE)
3377                 content_error("Fail to media_pvr_set_highlight");
3378
3379         ret = media_pvr_update_to_db(pvr);
3380         if (ret != MEDIA_CONTENT_ERROR_NONE)
3381                 content_error("Fail to media_pvr_update_to_db");
3382
3383         if (pvr != NULL)
3384                 media_pvr_destroy(pvr);
3385
3386         return ret;
3387 }
3388 #endif
3389
3390 int main(int argc, char *argv[])
3391 {
3392         int ret = MEDIA_CONTENT_ERROR_NONE;
3393
3394         content_debug("--- content manager test start ---\n\n");
3395
3396         ret = test_connect_database();
3397         if (ret != MEDIA_CONTENT_ERROR_NONE)
3398                 return MEDIA_CONTENT_ERROR_NONE;
3399 #ifdef _USE_TVPD_MODE
3400         test_pvr();
3401
3402         test_pvr_update_db();
3403
3404         test_pvr();
3405 #endif
3406
3407 #if 0
3408         if (argc == 2) {
3409                 ret = test_ebook_text_finder(argv[1]);
3410                 if (ret != MEDIA_CONTENT_ERROR_NONE)
3411                         return ret;
3412         }
3413
3414         ret = test_start_face_detection(FALSE);
3415         if (ret != MEDIA_CONTENT_ERROR_NONE)
3416                 return ret;
3417
3418         ret = test_move();
3419         if (ret != MEDIA_CONTENT_ERROR_NONE)
3420                 return ret;
3421
3422         ret = test_gallery_scenario();
3423         if (ret != MEDIA_CONTENT_ERROR_NONE)
3424                 return ret;
3425
3426         ret = test_get_all_music_files();
3427         if (ret != MEDIA_CONTENT_ERROR_NONE)
3428                 return ret;
3429
3430         ret = test_media_info_operation();
3431         if (ret != MEDIA_CONTENT_ERROR_NONE)
3432                 return ret;
3433
3434         ret = test_folder_operation();
3435         if (ret != MEDIA_CONTENT_ERROR_NONE)
3436                 return ret;
3437
3438         ret = test_playlist_operation();
3439         if (ret != MEDIA_CONTENT_ERROR_NONE)
3440                 return ret;
3441
3442         ret = test_tag_operation();
3443         if (ret != MEDIA_CONTENT_ERROR_NONE)
3444                 return ret;
3445
3446         ret = test_bookmark_operation();
3447         if (ret != MEDIA_CONTENT_ERROR_NONE)
3448                 return ret;
3449
3450         ret = test_album_list();
3451         if (ret != MEDIA_CONTENT_ERROR_NONE)
3452                 return ret;
3453
3454         ret = test_group_operation();
3455         if (ret != MEDIA_CONTENT_ERROR_NONE)
3456                 return ret;
3457
3458         ret = test_update_operation();
3459         if (ret != MEDIA_CONTENT_ERROR_NONE)
3460                 return ret;
3461
3462         ret = test_insert();
3463         if (ret != MEDIA_CONTENT_ERROR_NONE)
3464                 return ret;
3465
3466         ret = test_move();
3467         if (ret != MEDIA_CONTENT_ERROR_NONE)
3468                 return ret;
3469
3470         ret = test_create_thumbnail(TRUE);
3471         if (ret != MEDIA_CONTENT_ERROR_NONE)
3472                 return ret;
3473
3474         ret = test_extrace_face(TRUE);
3475         if (ret != MEDIA_CONTENT_ERROR_NONE)
3476                 return ret;
3477
3478         ret = test_request_update_db();
3479         if (ret != MEDIA_CONTENT_ERROR_NONE)
3480                 return ret;
3481
3482         ret = DFT_test();
3483         if (ret != MEDIA_CONTENT_ERROR_NONE)
3484                 return ret;
3485
3486         ret = test_batch_operations();
3487         if (ret != MEDIA_CONTENT_ERROR_NONE)
3488                 return MEDIA_CONTENT_ERROR_NONE;
3489
3490         ret = test_scan_file();
3491         if (ret != MEDIA_CONTENT_ERROR_NONE)
3492                 return MEDIA_CONTENT_ERROR_NONE;
3493
3494         ret = test_scan_dir(true);
3495         if (ret != MEDIA_CONTENT_ERROR_NONE)
3496                 return MEDIA_CONTENT_ERROR_NONE;
3497
3498         ret = test_noti();
3499         if (ret != MEDIA_CONTENT_ERROR_NONE)
3500                 return MEDIA_CONTENT_ERROR_NONE;
3501
3502         ret = test_face();
3503         if (ret != MEDIA_CONTENT_ERROR_NONE)
3504                 return MEDIA_CONTENT_ERROR_NONE;
3505
3506         ret = test_face_add_del();
3507         if (ret != MEDIA_CONTENT_ERROR_NONE)
3508                 return MEDIA_CONTENT_ERROR_NONE;
3509
3510         ret = test_playlist_operation_v2();
3511         if (ret != MEDIA_CONTENT_ERROR_NONE)
3512                 return MEDIA_CONTENT_ERROR_NONE;
3513
3514         ret = test_bookmark_operation_v2();
3515         if (ret != MEDIA_CONTENT_ERROR_NONE)
3516                 return MEDIA_CONTENT_ERROR_NONE;
3517
3518         ret = test_tag_operation_v2();
3519         if (ret != MEDIA_CONTENT_ERROR_NONE)
3520                 return MEDIA_CONTENT_ERROR_NONE;
3521 #endif
3522
3523         ret = test_disconnect_database();
3524         if (ret != MEDIA_CONTENT_ERROR_NONE)
3525                 return ret;
3526
3527         content_debug("--- content manager test end ---\n");
3528
3529         return ret;
3530 }