Remove deprecated filter keyword from test code
[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
921         ret = media_filter_create(&g_filter);
922
923         /* Set condition and collate
924          * Condition string : You can make where statement of sql.
925          * Colation : You can use collation when comparing.
926          * Ex) In case of FILE_NAME='Samsung' as condition string,
927          *      if you want to compare with NOCASE collation,
928          *      call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_NOCASE);
929          *      if you want to compare in case-sensitive,
930          *      call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
931          */
932         ret = media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
933
934         /* Collation of ordering
935          * If you want to get list, which is sorted by NOCASE,
936          * call media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_NOCASE);
937          * Or,
938          * call media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
939          */
940         /* Able to set multi column to set order */
941 #if 0
942         ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, "MEDIA_MODIFIED_TIME, MEDIA_DISPLAY_NAME", MEDIA_CONTENT_COLLATE_DEFAULT);
943         ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
944         ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TRACK_NUM_INT, MEDIA_CONTENT_COLLATE_DEFAULT);
945         ret = media_filter_set_storage(g_filter, "cfbf3d2c-71c5-4611-bccc-7cbac890146e");
946
947         /* Filter for group */
948         const char *g_condition = "TAG_NAME like \"\%my\%\"";
949         const char *g_condition = "BOOKMARK_MARKED_TIME > 300";
950 #endif
951         ret = media_filter_create(&g_filter_g);
952
953         ret = media_filter_set_order(g_filter_g, MEDIA_CONTENT_ORDER_DESC, TAG_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
954
955         return ret;
956 }
957
958 int test_filter_destroy(void)
959 {
960         content_debug("\n============Filter Create============\n\n");
961
962         int ret = MEDIA_CONTENT_ERROR_NONE;
963
964         ret = media_filter_destroy(g_filter);
965
966         return ret;
967 }
968
969 int test_connect_database(void)
970 {
971         int ret = MEDIA_CONTENT_ERROR_NONE;
972
973         content_debug("\n============DB Connection Test============\n\n");
974
975         ret = media_content_connect();
976
977         if (ret == MEDIA_CONTENT_ERROR_NONE)
978                 content_debug("connection is success\n\n");
979         else
980                 content_error("connection is failed\n\n");
981
982         return ret;
983 }
984
985 int test_gallery_scenario(void)
986 {
987         int ret = MEDIA_CONTENT_ERROR_NONE;
988         unsigned int i = 0;
989         filter_h filter = NULL;
990
991         int count;
992         GList *folder_list = NULL;
993         media_folder_h folder_handle = NULL;
994
995         /* First, Get folder list */
996         ret = media_folder_foreach_folder_from_db(filter, gallery_folder_list_cb, &folder_list);
997         if (ret != MEDIA_CONTENT_ERROR_NONE) {
998                 content_error("media_folder_foreach_folder_from_db failed: %d", ret);
999                 return -1;
1000         } else {
1001                 content_debug("media_folder_foreach_folder_from_db success!!");
1002                 char *folder_id = NULL;
1003
1004                 for (i = 0; i < g_list_length(folder_list); i++) {
1005                         folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
1006
1007                         get_folder_meta(folder_handle, &folder_id);
1008
1009                         ret = media_folder_get_media_count_from_db(folder_id, filter, &count);
1010                         SAFE_FREE(folder_id);
1011                         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1012                                 content_error("media_folder_get_media_count_from_db failed: %d", ret);
1013                                 return -1;
1014                         } else {
1015                                 content_debug("media count [%d] : %d", i, count);
1016                         }
1017                 }
1018         }
1019
1020         /* To check performance */
1021         struct timeval start, end;
1022         gettimeofday(&start, NULL);
1023
1024         /* Second, Get all item list */
1025         media_info_h media_handle = NULL;
1026         GList *all_item_list = NULL;
1027
1028         media_content_collation_e collate_type = MEDIA_CONTENT_COLLATE_NOCASE;
1029         media_content_order_e order_type = MEDIA_CONTENT_ORDER_DESC;
1030         ret = media_filter_create(&filter);
1031         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1032                 content_error("Fail to create filter");
1033                 return ret;
1034         }
1035         ret = media_filter_set_condition(filter, "MEDIA_TYPE = 0", collate_type);
1036         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1037                 media_filter_destroy(filter);
1038                 content_error("Fail to set condition");
1039                 return ret;
1040         }
1041         ret = media_filter_set_order(filter, order_type, MEDIA_DISPLAY_NAME, collate_type);
1042         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1043                 media_filter_destroy(filter);
1044                 content_error("Fail to set order");
1045                 return ret;
1046         }
1047
1048         ret = media_info_foreach_media_from_db(filter, gallery_media_item_cb, &all_item_list);
1049         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1050                 content_error("media_info_foreach_media_from_db failed: %d", ret);
1051                 media_filter_destroy(filter);
1052                 return -1;
1053         } else {
1054                 content_debug("media_info_foreach_media_from_db success");
1055
1056                 for (i = 0; i < g_list_length(all_item_list); i++) {
1057                         media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
1058                         get_media_meta(media_handle);
1059                 }
1060         }
1061
1062         media_filter_destroy(filter);
1063         filter = NULL;
1064
1065         /* To check performance */
1066         gettimeofday(&end, NULL);
1067         long time = (end.tv_sec * 1000000 + end.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec);
1068         content_debug("Time : %ld\n", time);
1069
1070         /* Third, Get item list of a folder */
1071         GList *item_list = NULL;
1072
1073         for (i = 0; i < g_list_length(folder_list); i++) {
1074                 unsigned int j = 0;
1075                 char *folder_id = NULL;
1076                 folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
1077
1078                 get_folder_meta(folder_handle, &folder_id);
1079
1080                 ret = media_folder_foreach_media_from_db(folder_id, filter, gallery_media_item_cb, &item_list);
1081                 SAFE_FREE(folder_id);
1082
1083                 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1084                         content_error("media_folder_foreach_media_from_db failed: %d", ret);
1085                         return -1;
1086                 } else {
1087                         content_error("media_folder_foreach_media_from_db success!");
1088
1089                         for (j = 0; j < g_list_length(item_list); j++) {
1090                                 media_handle = (media_info_h)g_list_nth_data(item_list, j);
1091                                 get_media_meta(media_handle);
1092                         }
1093                 }
1094         }
1095
1096         /* Get tag list */
1097         media_tag_h tag_handle = NULL;
1098         GList *tag_list = NULL;
1099         GList *media_list_in_tag = NULL;
1100         int tag_id = 0;
1101
1102         ret = media_tag_foreach_tag_from_db(filter, gallery_tag_item_cb, &tag_list);
1103
1104         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1105                 content_error("media_tag_foreach_tag_from_db failed: %d", ret);
1106                 return -1;
1107         } else {
1108                 content_error("media_tag_foreach_tag_from_db success");
1109                 for (i = 0; i < g_list_length(tag_list); i++) {
1110                         tag_handle = (media_tag_h)g_list_nth_data(tag_list, i);
1111                         get_tag_meta(tag_handle);
1112
1113                         ret = media_tag_get_tag_id(tag_handle, &tag_id);
1114                         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1115                                 ret = media_tag_foreach_media_from_db(tag_id, filter, gallery_media_item_cb, &media_list_in_tag);
1116                                 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1117                                         content_error("media_tag_foreach_media_from_db failed: %d", ret);
1118                                         return -1;
1119                                 } else {
1120                                         content_error("media_tag_foreach_media_from_db success");
1121                                         unsigned int j = 0;
1122                                         media_info_h tag_media_handle;
1123
1124                                         for (j = 0; j < g_list_length(media_list_in_tag); j++) {
1125                                                 tag_media_handle = (media_info_h)g_list_nth_data(media_list_in_tag, j);
1126                                                 get_media_meta(tag_media_handle);
1127                                         }
1128                                 }
1129                         }
1130                 }
1131         }
1132
1133         /* Remove folder list */
1134         if (folder_list) {
1135                 for (i = 0; i < g_list_length(folder_list); i++) {
1136                         folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
1137                         media_folder_destroy(folder_handle);
1138                 }
1139
1140                 g_list_free(folder_list);
1141         }
1142
1143         /* Remove all items list */
1144         if (all_item_list) {
1145                 for (i = 0; i < g_list_length(all_item_list); i++) {
1146                         media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
1147                         ret = media_info_destroy(media_handle);
1148                         if (ret != MEDIA_CONTENT_ERROR_NONE)
1149                                 content_error("media_info_destroy failed: %d", ret);
1150                 }
1151
1152                 g_list_free(all_item_list);
1153         }
1154
1155         /* Remove items list */
1156         if (item_list) {
1157                 for (i = 0; i < g_list_length(item_list); i++) {
1158                         media_handle = (media_info_h)g_list_nth_data(item_list, i);
1159                         ret = media_info_destroy(media_handle);
1160                         if (ret != MEDIA_CONTENT_ERROR_NONE)
1161                                 content_error("media_info_destroy failed: %d", ret);
1162                 }
1163
1164                 g_list_free(item_list);
1165         }
1166
1167         /* Remove tag list */
1168         if (tag_list) {
1169                 for (i = 0; i < g_list_length(tag_list); i++) {
1170                         tag_handle = (media_tag_h)g_list_nth_data(tag_list, i);
1171                         ret = media_tag_destroy(tag_handle);
1172                         if (ret != MEDIA_CONTENT_ERROR_NONE)
1173                                 content_error("error media_tag_destroy : [%d]", ret);
1174                 }
1175
1176                 g_list_free(tag_list);
1177         }
1178
1179         /* Remove media list in a tag */
1180         if (media_list_in_tag) {
1181                 for (i = 0; i < g_list_length(media_list_in_tag); i++) {
1182                         media_handle = (media_info_h)g_list_nth_data(media_list_in_tag, i);
1183                         ret = media_info_destroy(media_handle);
1184                         if (ret != MEDIA_CONTENT_ERROR_NONE)
1185                                 content_error("media_info_destroy failed: %d", ret);
1186                 }
1187
1188                 g_list_free(media_list_in_tag);
1189         }
1190
1191         return MEDIA_CONTENT_ERROR_NONE;
1192 }
1193
1194 /*Get All Music file. sort by Title and not case sensitive*/
1195 int test_get_all_music_files(void)
1196 {
1197         int ret = MEDIA_CONTENT_ERROR_NONE;
1198         int media_count = 0;
1199         filter_h filter;
1200
1201         /*Set Filter*/
1202         const char *condition = "MEDIA_TYPE=3"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
1203
1204         ret = media_filter_create(&filter);
1205         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1206                 content_error("Fail to create filter");
1207                 return ret;
1208         }
1209         ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_LOCALIZED);
1210         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1211                 media_filter_destroy(filter);
1212                 content_error("Fail to set condition");
1213                 return ret;
1214         }
1215         ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_LOCALIZED);
1216         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1217                 media_filter_destroy(filter);
1218                 content_error("Fail to set order");
1219                 return ret;
1220         }
1221
1222         /*Get Media Count*/
1223         ret = media_info_get_media_count_from_db(filter, &media_count);
1224         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1225                 media_filter_destroy(filter);
1226                 content_error("Fail to get media count");
1227                 return ret;
1228         }
1229
1230         content_debug("media_count : [%d]", media_count);
1231
1232         ret = media_info_foreach_media_from_db(filter, media_item_cb, NULL);
1233         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1234                 media_filter_destroy(filter);
1235                 content_error("Fail to get media");
1236                 return ret;
1237         }
1238
1239         ret = media_filter_destroy(filter);
1240
1241         return ret;
1242 }
1243
1244 int test_media_info_operation(void)
1245 {
1246         int ret = MEDIA_CONTENT_ERROR_NONE;
1247         int media_count = 0;
1248
1249         content_debug("\n============Media info Test============\n\n");
1250
1251         test_filter_create();
1252
1253         ret = media_info_get_media_count_from_db(g_filter, &media_count);
1254         if (ret != MEDIA_CONTENT_ERROR_NONE)
1255                 content_error("media_info_get_media_count_from_db failed: %d", ret);
1256         else
1257                 content_debug("media_count : [%d]", media_count);
1258
1259         ret = media_info_foreach_media_from_db(g_filter, media_item_cb, NULL);
1260         if (ret == MEDIA_CONTENT_ERROR_NONE)
1261                 content_debug("media_info_foreach_media_from_db is success");
1262         else
1263                 content_error("media_info_foreach_media_from_db is failed");
1264
1265         test_filter_destroy();
1266
1267         return ret;
1268 }
1269
1270 int test_media_info_operation_2(void)
1271 {
1272         int ret = MEDIA_CONTENT_ERROR_NONE;
1273         int bookmark_count = 0;
1274
1275         content_debug("\n============Media info Test 2============\n\n");
1276
1277         test_filter_create();
1278
1279 #if 0
1280         /* Bookmark */
1281         char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1282         media_bookmark_insert_to_db(test_video_id, 100, thumbnail_path1);
1283         media_bookmark_insert_to_db(test_video_id, 200, thumbnail_path1);
1284
1285         media_info_get_bookmark_count_from_db(test_video_id, g_filter_g, &bookmark_count);
1286
1287         content_debug("bookmark_count : [%d]", bookmark_count);
1288
1289         ret = media_info_foreach_bookmark_from_db(test_video_id, g_filter_g, bookmarks_cb, NULL);
1290 #endif
1291
1292         /* Tag */
1293         ret = media_info_get_tag_count_from_db(test_audio_id, g_filter_g, &bookmark_count);
1294         if (ret != MEDIA_CONTENT_ERROR_NONE)
1295                 content_error("media_info_get_tag_count_from_db failed: %d", ret);
1296         else
1297                 content_debug("tag_count : [%d]", bookmark_count);
1298
1299         ret = media_info_foreach_tag_from_db(test_audio_id, g_filter_g, tag_list_cb, NULL);
1300         if (ret != MEDIA_CONTENT_ERROR_NONE)
1301                 content_error("media_info_foreach_tag_from_db failed: %d", ret);
1302
1303         test_filter_destroy();
1304
1305         return ret;
1306 }
1307
1308 int test_folder_operation(void)
1309 {
1310         int ret = MEDIA_CONTENT_ERROR_NONE;
1311         filter_h filter = NULL;
1312         media_folder_h folder = NULL;
1313         char *folder_id = NULL;
1314         int count = 0;
1315
1316         content_debug("\n============Folder Test============\n\n");
1317
1318         test_filter_create();
1319
1320         ret = media_filter_create(&filter);
1321         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1322                 content_error("[ERROR] media_folder_filter_create is failed");
1323                 return ret;
1324         }
1325
1326         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*/
1327         media_filter_set_offset(filter, 0, 5);
1328         media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE);
1329         media_filter_set_storage(filter, "cfbf3d2c-71c5-4611-bccc-7cbac890146e");
1330
1331         ret = media_folder_get_folder_count_from_db(filter, &count);
1332         content_debug("Folder count : [%d]", count);
1333
1334         ret = media_folder_foreach_folder_from_db(filter, folder_list_cb, &folder);
1335
1336         filter_h m_filter = NULL;
1337
1338         ret = media_filter_create(&m_filter);
1339         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1340                 test_filter_destroy();
1341                 media_filter_destroy(filter);
1342                 content_error("[ERROR] media_info_filter_create is failed");
1343                 return ret;
1344         }
1345
1346         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*/
1347         media_filter_set_offset(m_filter, 0, 5);
1348         media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE);
1349
1350         ret = media_folder_foreach_media_from_db(folder_id, m_filter, media_item_cb, NULL);
1351         if (ret != MEDIA_CONTENT_ERROR_NONE)
1352                 content_error("[ERROR] media_folder_foreach_media_from_db is failed, error code : %d", ret);
1353
1354         media_filter_destroy(filter);
1355         media_filter_destroy(m_filter);
1356
1357         test_filter_destroy();
1358
1359         /* fix prevent: Resource Leak */
1360         SAFE_FREE(folder_id);
1361
1362         return ret;
1363 }
1364
1365 int test_playlist_operation(void)
1366 {
1367         int ret = MEDIA_CONTENT_ERROR_NONE;
1368         media_playlist_h playlist_1 = NULL;
1369         media_playlist_h playlist_2 = NULL;
1370         media_playlist_h playlist_3 = NULL;
1371         media_playlist_h playlist_4 = NULL;
1372         int playlist_id_1 = 0;
1373         int playlist_id_2 = 0;
1374         int playlist_id_3 = 0;
1375         const char *playlist_name_1 = "myPlaylist_1";
1376         const char *playlist_name_2 = "myPlaylist_2";
1377         const char *playlist_name_3 = "myPlaylist_3";
1378         int playlist_count = 0;
1379         int media_count = 0;
1380         int order_1 = 0;
1381         int order_2 = 0;
1382         int order_3 = 0;
1383         int order_4 = 0;
1384         int order_5 = 0;
1385         filter_h filter = NULL;
1386         filter_h m_filter = NULL;
1387
1388         content_debug("\n============Playlist Test============\n\n");
1389
1390         /* Filter for playlist */
1391
1392         const char *condition = "(MEDIA_TYPE=1 or MEDIA_TYPE=3)";       /*0-image, 1-video, 2-sound, 3-music, 4-other*/
1393
1394         ret = media_filter_create(&filter);
1395         ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_NOCASE);
1396         ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_NAME, MEDIA_CONTENT_COLLATE_NOCASE);
1397
1398         /* Create Playlist */
1399         media_playlist_insert_to_db(playlist_name_1, &playlist_1);
1400         media_playlist_insert_to_db(playlist_name_2, &playlist_2);
1401         media_playlist_insert_to_db(playlist_name_3, &playlist_3);
1402
1403         if (playlist_1 != NULL) {
1404                 /* Add media to Playlist */
1405                 media_playlist_add_media(playlist_1, test_audio_id);
1406                 media_playlist_add_media(playlist_1, test_audio_id);
1407                 media_playlist_add_media(playlist_1, test_video_id);
1408
1409                 #if 0
1410                 char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg"));
1411                 media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
1412                 #endif
1413
1414                 media_playlist_update_to_db(playlist_1);
1415         }
1416
1417         if (playlist_2 != NULL) {
1418                 media_playlist_add_media(playlist_2, test_audio_id);
1419                 media_playlist_add_media(playlist_2, test_audio_id);
1420                 media_playlist_update_to_db(playlist_2);
1421         }
1422
1423         /* Get Playlist Count*/
1424         ret = media_playlist_get_playlist_count_from_db(filter, &playlist_count);
1425         if (ret == 0)
1426                 content_debug("playlist_count [%d]", playlist_count);
1427
1428         /* Get Playlist*/
1429         GList *playlist_id_list = NULL;
1430         media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, &playlist_id_list);
1431         /* 64bit build issue */
1432 #if 0
1433         /* Get Playlist id*/
1434         playlist_id_1 = (int)g_list_nth_data(playlist_id_list, 0);
1435         playlist_id_2 = (int)g_list_nth_data(playlist_id_list, 1);
1436         playlist_id_3 = (int)g_list_nth_data(playlist_id_list, 2);
1437 #endif
1438         content_debug("playlist_id_1 [%d]", playlist_id_1);
1439         content_debug("playlist_id_2 [%d]", playlist_id_2);
1440         content_debug("playlist_id_3 [%d]", playlist_id_3);
1441
1442         /* Export and import playlist */
1443         media_playlist_export_to_file(playlist_3, tzplatform_mkpath(TZ_USER_MUSIC, "playlist.m3u"));
1444         media_playlist_import_from_file(tzplatform_mkpath(TZ_USER_MUSIC, "playlist.m3u"), "playlist_4", &playlist_4);
1445
1446         /* Filter for media*/
1447         ret = media_filter_create(&m_filter);
1448
1449         ret = media_filter_set_condition(m_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1450
1451         ret = media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_MEMBER_ORDER, MEDIA_CONTENT_COLLATE_DEFAULT);
1452
1453         /* Get media count */
1454         media_playlist_get_media_count_from_db(playlist_id_1, m_filter, &media_count);
1455         content_debug("playlist_1_media_count [%d]", media_count);
1456
1457         media_playlist_get_media_count_from_db(playlist_id_2, m_filter, &media_count);
1458         content_debug("playlist_2_media_count [%d]", media_count);
1459
1460         media_playlist_get_media_count_from_db(playlist_id_3, m_filter, &media_count);
1461         content_debug("playlist_3_media_count [%d]", media_count);
1462
1463         /* Get media of playlist */
1464         GList *playlist_member_id_list = NULL;
1465         GList *playlist_member_id_list_1 = NULL;
1466
1467         media_playlist_foreach_media_from_db(playlist_id_1, m_filter, playlist_item_cb, &playlist_member_id_list);
1468         media_playlist_foreach_media_from_db(playlist_id_2, m_filter, playlist_item_cb, &playlist_member_id_list_1);
1469
1470         int playlist_member_id_1_1 = 0;
1471         int playlist_member_id_1_2 = 0;
1472         int playlist_member_id_1_3 = 0;
1473         int playlist_member_id_2_1 = 0;
1474         int playlist_member_id_2_2 = 0;
1475         /* 64bit build issue */
1476 #if 0
1477         playlist_member_id_1_1 = (int)g_list_nth_data(playlist_member_id_list, 0);
1478         playlist_member_id_1_2 = (int)g_list_nth_data(playlist_member_id_list, 1);
1479         playlist_member_id_1_3 = (int)g_list_nth_data(playlist_member_id_list, 2);
1480         playlist_member_id_2_1 = (int)g_list_nth_data(playlist_member_id_list_1, 0);
1481         playlist_member_id_2_2 = (int)g_list_nth_data(playlist_member_id_list_1, 1);
1482 #endif
1483         content_debug("playlist_member_id_1_1 [%d]", playlist_member_id_1_1);
1484         content_debug("playlist_member_id_1_2 [%d]", playlist_member_id_1_2);
1485         content_debug("playlist_member_id_1_3 [%d]", playlist_member_id_1_3);
1486         content_debug("playlist_member_id_2_1 [%d]", playlist_member_id_2_1);
1487         content_debug("playlist_member_id_2_2 [%d]", playlist_member_id_2_2);
1488
1489         media_playlist_get_play_order(playlist_1, playlist_member_id_1_1, &order_1);
1490         media_playlist_get_play_order(playlist_1, playlist_member_id_1_2, &order_2);
1491         media_playlist_get_play_order(playlist_1, playlist_member_id_1_3, &order_3);
1492         media_playlist_get_play_order(playlist_2, playlist_member_id_2_1, &order_4);
1493         media_playlist_get_play_order(playlist_2, playlist_member_id_2_2, &order_5);
1494         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);
1495
1496         /* Update Playlist */
1497         media_playlist_remove_media(playlist_2, playlist_member_id_2_1);
1498         media_playlist_add_media(playlist_2, test_video_id);
1499         media_playlist_set_name(playlist_2, "test_playlist");
1500         media_playlist_set_play_order(playlist_2, playlist_member_id_2_2, order_5+100);
1501         media_playlist_update_to_db(playlist_2);
1502
1503         /* Get Updated Playlist*/
1504         media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, NULL);
1505
1506         /* deletes the playlist */
1507 #if 0
1508         media_playlist_delete_from_db(playlist_id_1);
1509         media_playlist_delete_from_db(playlist_id_2);
1510 #endif
1511
1512         if (playlist_1 != NULL)
1513                 media_playlist_destroy(playlist_1);
1514         if (playlist_2 != NULL)
1515                 media_playlist_destroy(playlist_2);
1516         if (playlist_3 != NULL)
1517                 media_playlist_destroy(playlist_3);
1518         if (playlist_4 != NULL)
1519                 media_playlist_destroy(playlist_4);
1520
1521         g_list_free(playlist_id_list);
1522         g_list_free(playlist_member_id_list);
1523         g_list_free(playlist_member_id_list_1);
1524
1525         if (filter != NULL)
1526                 ret = media_filter_destroy(filter);
1527         if (m_filter != NULL)
1528                 ret = media_filter_destroy(m_filter);
1529
1530         return ret;
1531 }
1532
1533 int test_playlist_operation_v2(void)
1534 {
1535         int ret = MEDIA_CONTENT_ERROR_NONE;
1536         media_playlist_h playlist_1 = NULL;
1537         const char *playlist_name_1 = "myPlaylist_1";
1538         const char *playlist_thumb_path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg");
1539         int playlist_id = 0;
1540
1541         content_debug("\n============Playlist Test V2============\n\n");
1542
1543         ret = media_playlist_create(&playlist_1);
1544         if (ret != MEDIA_CONTENT_ERROR_NONE)
1545                 content_error("error media_playlist_create : [%d]", ret);
1546
1547         ret = media_playlist_set_name(playlist_1, playlist_name_1);
1548         if (ret != MEDIA_CONTENT_ERROR_NONE)
1549                 content_error("error media_playlist_set_name : [%d]", ret);
1550
1551         ret = media_playlist_set_thumbnail_path(playlist_1, playlist_thumb_path);
1552         if (ret != MEDIA_CONTENT_ERROR_NONE)
1553                 content_error("error media_playlist_set_thumbnail_path : [%d]", ret);
1554
1555         ret = media_playlist_insert_to_db_v2(playlist_1);
1556         if (ret != MEDIA_CONTENT_ERROR_NONE)
1557                 content_error("error media_playlist_insert_to_db_v2 : [%d]", ret);
1558
1559         ret = media_playlist_set_name(playlist_1, "myPlaylist_3");
1560         if (ret != MEDIA_CONTENT_ERROR_NONE)
1561                 content_error("error media_playlist_set_name : [%d]", ret);
1562
1563         ret = media_playlist_get_playlist_id(playlist_1, &playlist_id);
1564         if (ret != MEDIA_CONTENT_ERROR_NONE)
1565                 content_error("error media_playlist_get_playlist_id : [%d]", ret);
1566
1567         ret = media_playlist_update_to_db_v2(playlist_id, playlist_1);
1568         if (ret != MEDIA_CONTENT_ERROR_NONE)
1569                 content_error("error media_playlist_update_to_db_v2 : [%d]", ret);
1570
1571         ret = media_playlist_destroy(playlist_1);
1572         if (ret != MEDIA_CONTENT_ERROR_NONE)
1573                 content_error("error media_playlist_destroy : [%d]", ret);
1574
1575         return ret;
1576 }
1577
1578 int test_tag_operation(void)
1579 {
1580         int ret = MEDIA_CONTENT_ERROR_NONE;
1581         media_tag_h tag_1;
1582         media_tag_h tag_2;
1583         media_tag_h tag_3;
1584         int tag_id_1 = 0;
1585         int tag_id_2 = 0;
1586         int tag_id_3 = 0;
1587         const char *tag_name_1 = "myTag_1";
1588         const char *tag_name_2 = "myTag_2";
1589         const char *tag_name_3 = "myTag_3";
1590         int tag_count = 0;
1591         int media_count = 0;
1592         filter_h filter;
1593
1594         content_debug("\n============Tag Test============\n\n");
1595
1596         const char *g_condition = "TAG_NAME like \"%%my%%\"";
1597
1598         ret = media_filter_create(&filter);
1599
1600         ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1601
1602         ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, TAG_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
1603
1604         /* Create Tag */
1605         ret = media_tag_insert_to_db(tag_name_1, &tag_1);
1606         if (ret != MEDIA_CONTENT_ERROR_NONE)
1607                 content_error("error media_tag_insert_to_db : [%d]", ret);
1608         ret = media_tag_insert_to_db(tag_name_2, &tag_2);
1609         if (ret != MEDIA_CONTENT_ERROR_NONE)
1610                 content_error("error media_tag_insert_to_db : [%d]", ret);
1611         ret = media_tag_insert_to_db(tag_name_3, &tag_3);
1612         if (ret != MEDIA_CONTENT_ERROR_NONE)
1613                 content_error("error media_tag_insert_to_db : [%d]", ret);
1614
1615         /* Add media to Tag */
1616         ret = media_tag_add_media(tag_1, test_audio_id);
1617         if (ret != MEDIA_CONTENT_ERROR_NONE)
1618                 content_error("error media_tag_add_media : [%d]", ret);
1619         ret = media_tag_add_media(tag_1, test_video_id);
1620         if (ret != MEDIA_CONTENT_ERROR_NONE)
1621                 content_error("error media_tag_add_media : [%d]", ret);
1622         ret = media_tag_update_to_db(tag_1);
1623         if (ret != MEDIA_CONTENT_ERROR_NONE)
1624                 content_error("error media_tag_update_to_db : [%d]", ret);
1625
1626         ret = media_tag_add_media(tag_2, test_audio_id);
1627         if (ret != MEDIA_CONTENT_ERROR_NONE)
1628                 content_error("error media_tag_add_media : [%d]", ret);
1629         ret = media_tag_update_to_db(tag_2);
1630         if (ret != MEDIA_CONTENT_ERROR_NONE)
1631                 content_error("error media_tag_update_to_db : [%d]", ret);
1632
1633         /* Get Tag Count*/
1634         ret = media_tag_get_tag_count_from_db(filter, &tag_count);
1635         if (ret != MEDIA_CONTENT_ERROR_NONE)
1636                 content_error("error media_tag_get_tag_count_from_db : [%d]", ret);
1637         else
1638                 content_debug("tag_count [%d]", tag_count);
1639
1640         /* Get Tag*/
1641         ret = media_tag_foreach_tag_from_db(filter, tag_list_cb, NULL);
1642         if (ret != MEDIA_CONTENT_ERROR_NONE)
1643                 content_error("error media_tag_foreach_tag_from_db : [%d]", ret);
1644
1645         /* Get Tag id*/
1646         ret = media_tag_get_tag_id(tag_1, &tag_id_1);
1647         if (ret != MEDIA_CONTENT_ERROR_NONE)
1648                 content_error("error media_tag_get_tag_id : [%d]", ret);
1649         else
1650                 content_debug("tag_id_1 [%d]", tag_id_1);
1651
1652         ret = media_tag_get_tag_id(tag_2, &tag_id_2);
1653         if (ret != MEDIA_CONTENT_ERROR_NONE)
1654                 content_error("error media_tag_get_tag_id : [%d]", ret);
1655         else
1656                 content_debug("tag_id_2 [%d]", tag_id_2);
1657
1658         ret = media_tag_get_tag_id(tag_3, &tag_id_3);
1659         if (ret != MEDIA_CONTENT_ERROR_NONE)
1660                 content_error("error media_tag_get_tag_id : [%d]", ret);
1661         else
1662                 content_debug("tag_id_3 [%d]", tag_id_3);
1663
1664         /* Get media count */
1665         ret = media_tag_get_media_count_from_db(tag_id_1, NULL, &media_count);
1666         if (ret != MEDIA_CONTENT_ERROR_NONE)
1667                 content_error("error media_tag_get_media_count_from_db : [%d]", ret);
1668         else
1669                 content_debug("tag_1_media_count [%d]", media_count);
1670
1671         ret = media_tag_get_media_count_from_db(tag_id_2, NULL, &media_count);
1672         if (ret != MEDIA_CONTENT_ERROR_NONE)
1673                 content_error("error media_tag_get_media_count_from_db : [%d]", ret);
1674         else
1675                 content_debug("tag_2_media_count [%d]", media_count);
1676
1677         /* Get media of Tag */
1678         ret = media_tag_foreach_media_from_db(tag_id_1, NULL, media_item_cb, NULL);
1679         if (ret != MEDIA_CONTENT_ERROR_NONE)
1680                 content_error("error media_tag_foreach_media_from_db : [%d]", ret);
1681
1682         ret = media_tag_foreach_media_from_db(tag_id_2, NULL, media_item_cb, NULL);
1683         if (ret != MEDIA_CONTENT_ERROR_NONE)
1684                 content_error("error media_tag_foreach_media_from_db : [%d]", ret);
1685
1686         /* Update Tag */
1687         ret = media_tag_add_media(tag_2, test_video_id);
1688         if (ret != MEDIA_CONTENT_ERROR_NONE)
1689                 content_error("error media_tag_add_media : [%d]", ret);
1690         ret = media_tag_set_name(tag_2, "test_tag");
1691         if (ret != MEDIA_CONTENT_ERROR_NONE)
1692                 content_error("error media_tag_set_name : [%d]", ret);
1693         ret = media_tag_update_to_db(tag_2);
1694         if (ret != MEDIA_CONTENT_ERROR_NONE)
1695                 content_error("error media_tag_update_to_db : [%d]", ret);
1696
1697         /* Get Updated Tag*/
1698         ret = media_tag_foreach_tag_from_db(filter, tag_list_cb, NULL);
1699         if (ret != MEDIA_CONTENT_ERROR_NONE)
1700                 content_error("error media_tag_foreach_tag_from_db : [%d]", ret);
1701
1702         /* deletes the tag */
1703         ret = media_tag_delete_from_db(tag_id_1);
1704         if (ret != MEDIA_CONTENT_ERROR_NONE)
1705                 content_error("error media_tag_delete_from_db : [%d]", ret);
1706         ret = media_tag_delete_from_db(tag_id_2);
1707         if (ret != MEDIA_CONTENT_ERROR_NONE)
1708                 content_error("error media_tag_delete_from_db : [%d]", ret);
1709
1710         ret = media_tag_destroy(tag_1);
1711         if (ret != MEDIA_CONTENT_ERROR_NONE)
1712                 content_error("error media_tag_destroy : [%d]", ret);
1713         ret = media_tag_destroy(tag_2);
1714         if (ret != MEDIA_CONTENT_ERROR_NONE)
1715                 content_error("error media_tag_destroy : [%d]", ret);
1716         ret = media_tag_destroy(tag_3);
1717         if (ret != MEDIA_CONTENT_ERROR_NONE)
1718                 content_error("error media_tag_destroy : [%d]", ret);
1719         ret = media_filter_destroy(filter);
1720         if (ret != MEDIA_CONTENT_ERROR_NONE)
1721                 content_error("error media_filter_destroy : [%d]", ret);
1722
1723         return ret;
1724 }
1725
1726 int test_tag_operation_v2(void)
1727 {
1728         int ret = MEDIA_CONTENT_ERROR_NONE;
1729         media_tag_h tag_1;
1730         const char *tag_name_1 = "myTag_1";
1731         int tag_id = -1;
1732
1733         content_debug("\n============Tag Test V2============\n\n");
1734
1735         /* Create Tag */
1736         ret = media_tag_create(&tag_1);
1737         if (ret != MEDIA_CONTENT_ERROR_NONE)
1738                 content_error("error media_tag_create : [%d]", ret);
1739
1740         ret = media_tag_set_name(tag_1, tag_name_1);
1741         if (ret != MEDIA_CONTENT_ERROR_NONE)
1742                 content_error("error media_tag_set_name : [%d]", ret);
1743
1744         /* Add media to Tag */
1745         ret = media_tag_add_media(tag_1, test_audio_id);
1746         if (ret != MEDIA_CONTENT_ERROR_NONE)
1747                 content_error("error media_tag_add_media : [%d]", ret);
1748
1749         ret = media_tag_add_media(tag_1, test_video_id);
1750         if (ret != MEDIA_CONTENT_ERROR_NONE)
1751                 content_error("error media_tag_add_media : [%d]", ret);
1752
1753         ret = media_tag_insert_to_db_v2(tag_1);
1754         if (ret != MEDIA_CONTENT_ERROR_NONE)
1755                 content_error("error media_tag_insert_to_db_v2 : [%d]", ret);
1756
1757 #if 1
1758         ret = media_tag_get_tag_id(tag_1, &tag_id);
1759         if (ret != MEDIA_CONTENT_ERROR_NONE)
1760                 content_error("error media_tag_get_tag_id : [%d]", ret);
1761
1762         ret = media_tag_remove_media(tag_1, test_video_id);
1763         if (ret != MEDIA_CONTENT_ERROR_NONE)
1764                 content_error("error media_tag_add_media : [%d]", ret);
1765
1766         ret = media_tag_update_to_db_v2(tag_id, tag_1);
1767         if (ret != MEDIA_CONTENT_ERROR_NONE)
1768                 content_error("error media_tag_update_to_db_v2 : [%d]", ret);
1769 #endif
1770
1771         ret = media_tag_destroy(tag_1);
1772         if (ret != MEDIA_CONTENT_ERROR_NONE)
1773                 content_error("error media_tag_destroy : [%d]", ret);
1774
1775         return ret;
1776 }
1777
1778 int test_bookmark_operation(void)
1779 {
1780         /* bookmark is only supported for video information. */
1781         int ret = MEDIA_CONTENT_ERROR_NONE;
1782         int bookmark_count = 0;
1783         filter_h filter;
1784         GList *all_item_list = NULL;
1785         int idx = 0;
1786
1787         content_debug("\n============Bookmark Test============\n\n");
1788
1789         const char *g_condition = "BOOKMARK_MARKED_TIME > 300";
1790
1791         ret = media_filter_create(&filter);
1792         if (ret != MEDIA_CONTENT_ERROR_NONE)
1793                 content_error("error media_filter_create : [%d]", ret);
1794
1795         ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1796         if (ret != MEDIA_CONTENT_ERROR_NONE)
1797                 content_error("error media_filter_set_condition : [%d]", ret);
1798
1799         ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, BOOKMARK_MARKED_TIME, MEDIA_CONTENT_COLLATE_DEFAULT);
1800         if (ret != MEDIA_CONTENT_ERROR_NONE)
1801                 content_error("error media_filter_set_order : [%d]", ret);
1802
1803         /* insert bookmark to video */
1804         const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1805         ret = media_bookmark_insert_to_db(test_video_id, 400, thumbnail_path1);
1806         if (ret != MEDIA_CONTENT_ERROR_NONE)
1807                 content_error("error media_bookmark_insert_to_db : [%d]", ret);
1808
1809         ret = media_bookmark_insert_to_db(test_video_id, 600, thumbnail_path1);
1810         if (ret != MEDIA_CONTENT_ERROR_NONE)
1811                 content_error("error media_bookmark_insert_to_db : [%d]", ret);
1812
1813         ret = media_bookmark_get_bookmark_count_from_db(filter, &bookmark_count);
1814         if (ret != MEDIA_CONTENT_ERROR_NONE)
1815                 content_error("error media_bookmark_get_bookmark_count_from_db : [%d]", ret);
1816         else
1817                 content_debug("bookmark_count = [%d]", bookmark_count);
1818
1819         ret = media_info_foreach_bookmark_from_db(test_video_id, NULL, bookmarks_cb, &all_item_list);
1820         if (ret != MEDIA_CONTENT_ERROR_NONE)
1821                 content_error("error media_info_foreach_bookmark_from_db : [%d]", ret);
1822
1823         for (idx = 0; idx < g_list_length(all_item_list); idx++) {
1824                 media_bookmark_h bookmark_handle;
1825                 bookmark_handle = (media_bookmark_h)g_list_nth_data(all_item_list, idx);
1826
1827                 ret = media_bookmark_set_name(bookmark_handle, "test 1");
1828                 if (ret != MEDIA_CONTENT_ERROR_NONE)
1829                         content_error("error media_bookmark_set_name : [%d]", ret);
1830
1831                 ret = media_bookmark_update_to_db(bookmark_handle);
1832                 if (ret != MEDIA_CONTENT_ERROR_NONE)
1833                         content_error("error media_bookmark_update_to_db : [%d]", ret);
1834         }
1835
1836         ret = media_info_foreach_bookmark_from_db(test_video_id, NULL, bookmarks_cb, NULL);
1837         if (ret != MEDIA_CONTENT_ERROR_NONE)
1838                 content_error("error media_info_foreach_bookmark_from_db : [%d]", ret);
1839
1840         ret = media_filter_destroy(filter);
1841         if (ret != MEDIA_CONTENT_ERROR_NONE)
1842                 content_error("error media_filter_destroy : [%d]", ret);
1843
1844         return ret;
1845 }
1846
1847 int test_bookmark_operation_v2(void)
1848 {
1849         content_debug("\n============Bookmark Test V2============\n\n");
1850
1851         int ret = MEDIA_CONTENT_ERROR_NONE;
1852         media_bookmark_h bookmark = NULL;
1853         const char *thumbnail_path1 = tzplatform_mkpath(TZ_USER_VIDEOS, "teat11.jpg");
1854
1855         ret = media_bookmark_create(test_video_id, 400, &bookmark);
1856         if (ret != MEDIA_CONTENT_ERROR_NONE)
1857                 content_error("error media_bookmark_create : [%d]", ret);
1858
1859         ret = media_bookmark_set_name(bookmark, "test bookmark");
1860         if (ret != MEDIA_CONTENT_ERROR_NONE)
1861                 content_error("error media_bookmark_set_name : [%d]", ret);
1862
1863         ret = media_bookmark_set_thumbnail_path(bookmark, thumbnail_path1);
1864         if (ret != MEDIA_CONTENT_ERROR_NONE)
1865                 content_error("error media_bookmark_set_thumbnail_path : [%d]", ret);
1866
1867         ret = media_bookmark_insert_to_db_v2(bookmark);
1868         if (ret != MEDIA_CONTENT_ERROR_NONE)
1869                 content_error("error media_bookmark_insert_to_db_v2 : [%d]", ret);
1870
1871         ret = media_bookmark_set_name(bookmark, "test bookmark 2");
1872         if (ret != MEDIA_CONTENT_ERROR_NONE)
1873                 content_error("error media_bookmark_set_name : [%d]", ret);
1874
1875         ret = media_bookmark_update_to_db(bookmark);
1876         if (ret != MEDIA_CONTENT_ERROR_NONE)
1877                 content_error("error media_bookmark_update_to_db : [%d]", ret);
1878
1879         ret = media_bookmark_destroy(bookmark);
1880         if (ret != MEDIA_CONTENT_ERROR_NONE)
1881                 content_error("error media_bookmark_destroy : [%d]", ret);
1882
1883         return ret;
1884 }
1885
1886 int test_album_list(void)
1887 {
1888         content_debug("\n============Album Test============\n\n");
1889
1890         int ret = MEDIA_CONTENT_ERROR_NONE;
1891         int album_count = 0;
1892         filter_h filter;
1893
1894         /*Set Filter*/
1895         const char *condition = "MEDIA_TYPE=3"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/
1896
1897         ret = media_filter_create(&filter);
1898         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1899                 content_error("Fail to create filter");
1900                 return ret;
1901         }
1902         ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
1903         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1904                 media_filter_destroy(filter);
1905                 content_error("Fail to set condition");
1906                 return ret;
1907         }
1908         ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ALBUM, MEDIA_CONTENT_COLLATE_NOCASE);
1909         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1910                 media_filter_destroy(filter);
1911                 content_error("Fail to set order");
1912                 return ret;
1913         }
1914
1915         ret = media_album_get_album_count_from_db(filter, &album_count);
1916         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1917                 media_filter_destroy(filter);
1918                 return ret;
1919         } else {
1920                 content_debug("album_count [%d]", album_count);
1921         }
1922
1923         ret = media_album_foreach_album_from_db(filter, album_list_cb, NULL);
1924         if (ret != MEDIA_CONTENT_ERROR_NONE)
1925                 content_error("error media_album_foreach_album_from_db : [%d]", ret);
1926
1927         ret = media_filter_destroy(filter);
1928         if (ret != MEDIA_CONTENT_ERROR_NONE)
1929                 content_error("error media_filter_destroy : [%d]", ret);
1930
1931         return ret;
1932 }
1933
1934 int test_group_operation(void)
1935 {
1936         content_debug("\n============Group Test============\n\n");
1937
1938         int ret = MEDIA_CONTENT_ERROR_NONE;
1939         int group_count = 0;
1940         int idx = 0;
1941
1942         ret = test_filter_create();
1943         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1944                 content_error("[error(0x%08x)", ret);
1945                 return ret;
1946         }
1947
1948         for (idx = 0; idx < MEDIA_CONTENT_GROUP_MAX; idx++) {
1949                 ret = media_group_get_group_count_from_db(g_filter, idx, &group_count);
1950                 if (ret != MEDIA_CONTENT_ERROR_NONE) {
1951                         test_filter_destroy();
1952                         content_error("media_group_get_group_count_from_db fail. ret=[%d] idx=[%d]", ret, idx);
1953                         return ret;
1954                 } else {
1955                         content_debug("[%2d]group_count [%d]", idx, group_count);
1956                 }
1957
1958                 ret = media_group_foreach_group_from_db(g_filter, idx, group_list_cb, &idx);
1959                 if (ret != MEDIA_CONTENT_ERROR_NONE)
1960                         content_error("media_group_foreach_group_from_db failed: %d", ret);
1961         }
1962         ret = test_filter_destroy();
1963
1964         return ret;
1965 }
1966
1967 int test_update_operation()
1968 {
1969         int ret = MEDIA_CONTENT_ERROR_NONE;
1970         unsigned int i = 0;
1971         media_info_h media_handle = NULL;
1972         GList *all_item_list = NULL;
1973
1974         /* Get all item list */
1975         ret = media_info_foreach_media_from_db(NULL, gallery_media_item_cb, &all_item_list);
1976         if (ret != MEDIA_CONTENT_ERROR_NONE) {
1977                 content_error("media_info_foreach_media_from_db failed: %d", ret);
1978                 return -1;
1979         } else {
1980                 content_debug("media_info_foreach_media_from_db success");
1981
1982                 for (i = 0; i < g_list_length(all_item_list); i++) {
1983                         media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
1984                         get_media_meta(media_handle);
1985                 }
1986         }
1987
1988         return MEDIA_CONTENT_ERROR_NONE;
1989 }
1990
1991 int test_insert(void)
1992 {
1993         int ret = MEDIA_CONTENT_ERROR_NONE;
1994         const char *path = tzplatform_mkpath(TZ_USER_IMAGES, "Default.jpg");
1995 #if 0
1996         const char *path = tzplatform_mkpath(TZ_USER_DOCUMENTS, "other.txt"));
1997         char *path = NULL;
1998 #endif
1999         media_info_h media_item = NULL;
2000         content_debug("\n============DB Insert Test============\n\n");
2001
2002         ret = media_info_insert_to_db(path, &media_item);
2003
2004         if ((ret == MEDIA_CONTENT_ERROR_NONE) && (media_item != NULL)) {
2005                 content_debug("Insertion is success");
2006         } else {
2007                 content_error("Insertion is failed");
2008                 ret = media_info_destroy(media_item);
2009                 return ret;
2010         }
2011
2012         char *media_id = NULL;
2013
2014         ret = media_info_get_media_id(media_item, &media_id);
2015         if (ret != MEDIA_CONTENT_ERROR_NONE)
2016                 content_error("media_info_get_media_id failed: %d", ret);
2017         else
2018                 content_debug("Media ID: %s", media_id);
2019
2020         SAFE_FREE(media_id);
2021
2022         ret = media_info_update_to_db(media_item);
2023         if (ret == MEDIA_CONTENT_ERROR_NONE)
2024                 content_debug("media_info_update_to_db is success");
2025         else
2026                 content_error("media_info_update_to_db is failed");
2027
2028         ret = media_info_destroy(media_item);
2029         if (ret != MEDIA_CONTENT_ERROR_NONE)
2030                 content_error("media_info_destroy failed: %d", ret);
2031
2032         return ret;
2033 }
2034
2035 int test_move(void)
2036 {
2037         int ret = MEDIA_CONTENT_ERROR_NONE;
2038         const char *move_media_id = "60aea677-4742-408e-b5f7-f2628062d06d";
2039         const char *dst_path = tzplatform_mkpath(TZ_USER_IMAGES, "XX/Default1.jpg");
2040         media_info_h move_media = NULL;
2041
2042         ret = media_info_get_media_from_db(move_media_id, &move_media);
2043         if (ret == MEDIA_CONTENT_ERROR_NONE)
2044                 content_debug("media_info_get_media_from_db success");
2045         else
2046                 content_error("media_info_get_media_from_db failed: %d", ret);
2047
2048         content_debug("\n============DB Move Test============\n\n");
2049
2050         if (move_media) {
2051                 ret = media_info_move_to_db(move_media, dst_path);
2052
2053                 if (ret == MEDIA_CONTENT_ERROR_NONE)
2054                         content_debug("Move is success");
2055                 else
2056                         content_error("Move is failed");
2057
2058                 ret = media_info_destroy(move_media);
2059         } else {
2060                 content_debug("There is no item : %s", move_media_id);
2061         }
2062
2063         return ret;
2064 }
2065
2066 void thumbnail_completed_cb(media_content_error_e error, const char *path, void *user_data)
2067 {
2068         char *thumbnail_path = NULL;
2069         int ret = MEDIA_CONTENT_ERROR_NONE;
2070         g_cnt++;
2071
2072         content_debug("=================[%d][%d]", g_media_cnt, g_cnt);
2073         content_debug("error_code [%d]", error);
2074         content_debug("thumbnail_path [%s]", path);
2075         if (user_data != NULL) {
2076                 media_info_h media = (media_info_h)user_data;
2077                 ret = media_info_get_thumbnail_path(media, &thumbnail_path);
2078                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2079                         content_error("media_info_get_thumbnail_path failed: %d", ret);
2080                 else
2081                         content_debug("thumbnail_path get from media[%s]", thumbnail_path);
2082                 SAFE_FREE(thumbnail_path);
2083                 ret = media_info_destroy(media);
2084                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2085                         content_error("media_info_destroy failed: %d", ret);
2086         }
2087
2088         if (g_cnt == g_media_cnt)
2089                 g_main_loop_quit(g_loop);
2090
2091         return;
2092 }
2093
2094 bool thumbnail_create_cb(media_info_h media, void *user_data)
2095 {
2096         char *media_id = NULL;
2097         media_info_h dst = NULL;
2098         int ret = MEDIA_CONTENT_ERROR_NONE;
2099
2100         if (media == NULL) {
2101                 content_debug("NO Item");
2102                 return true;
2103         }
2104
2105         ret = media_info_get_media_id(media, &media_id);
2106         if (ret != MEDIA_CONTENT_ERROR_NONE)
2107                 content_error("media_info_get_media_id failed: %d", ret);
2108         else
2109                 content_debug("media_id : [%s]", media_id);
2110
2111         ret = media_info_clone(&dst, media);
2112         if (ret != MEDIA_CONTENT_ERROR_NONE)
2113                 content_error("media_info_clone failed: %d", ret);
2114         else {
2115                 ret = media_info_create_thumbnail(dst, thumbnail_completed_cb, dst);
2116                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2117                         content_error("media_info_create_thumbnail failed: %d", ret);
2118         }
2119
2120         /* fix prevent: Resource leak */
2121         SAFE_FREE(media_id);
2122
2123         return true;
2124 }
2125
2126 bool thumbnail_cancel_cb(media_info_h media, void *user_data)
2127 {
2128         int ret = MEDIA_CONTENT_ERROR_NONE;
2129
2130         char *media_id = NULL;
2131         media_info_h dst = NULL;
2132
2133         g_cnt++;
2134
2135         if (media == NULL) {
2136                 content_debug("NO Item");
2137                 return true;
2138         }
2139
2140         ret = media_info_get_media_id(media, &media_id);
2141         if (ret != MEDIA_CONTENT_ERROR_NONE)
2142                 content_error("media_info_get_media_id failed: %d", ret);
2143         else
2144                 content_debug("media_id : [%s]", media_id);
2145
2146         ret = media_info_clone(&dst, media);
2147         if (ret != MEDIA_CONTENT_ERROR_NONE)
2148                 content_error("media_info_clone failed: %d", ret);
2149
2150         ret = media_info_cancel_thumbnail(dst);
2151         if (ret != MEDIA_CONTENT_ERROR_NONE)
2152                 content_error("media_info_cancel_thumbnail failed: %d", ret);
2153
2154         ret = media_info_destroy(dst);
2155         if (ret != MEDIA_CONTENT_ERROR_NONE)
2156                         content_error("media_info_destroy failed: %d", ret);
2157
2158         if (g_cnt == g_media_cnt)
2159                 g_main_loop_quit(g_loop);
2160
2161         /* fix prevent: Resource leak */
2162         SAFE_FREE(media_id);
2163
2164         return true;
2165 }
2166
2167 gboolean create_thumbnail_start(gpointer data)
2168 {
2169         int ret = MEDIA_CONTENT_ERROR_NONE;
2170
2171         ret = media_info_foreach_media_from_db(g_filter, thumbnail_create_cb, NULL);
2172
2173         if (ret == MEDIA_CONTENT_ERROR_NONE)
2174                 content_debug("media_info_foreach_media_from_db is success");
2175         else
2176                 content_error("media_info_foreach_media_from_db is failed");
2177
2178         return false;
2179 }
2180
2181 gboolean cancel_thumbnail_start(gpointer data)
2182 {
2183         int ret = MEDIA_CONTENT_ERROR_NONE;
2184
2185         ret = media_info_foreach_media_from_db(g_filter, thumbnail_cancel_cb, NULL);
2186
2187         if (ret == MEDIA_CONTENT_ERROR_NONE)
2188                 content_debug("media_info_foreach_media_from_db is success");
2189         else
2190                 content_error("media_info_foreach_media_from_db is failed");
2191
2192         return false;
2193 }
2194
2195 int test_create_thumbnail(int cancel)
2196 {
2197         int ret = MEDIA_CONTENT_ERROR_NONE;
2198         GSource *source = NULL;
2199         GMainContext *context = NULL;
2200
2201         test_filter_create();
2202
2203         ret = media_info_get_media_count_from_db(g_filter, &g_media_cnt);
2204         if (ret != MEDIA_CONTENT_ERROR_NONE)
2205                 content_error("media_info_get_media_count_from_db failed: %d", ret);
2206         else
2207                 content_debug("media_count : [%d]", g_media_cnt);
2208
2209         g_loop = g_main_loop_new(NULL, FALSE);
2210         context = g_main_loop_get_context(g_loop);
2211         source = g_idle_source_new();
2212         g_source_set_callback(source, create_thumbnail_start, NULL, NULL);
2213         g_source_attach(source, context);
2214
2215         /* Logic to cancel */
2216         if (cancel) {
2217                 GSource *cancel_src = NULL;
2218                 cancel_src = g_idle_source_new();
2219                 g_source_set_callback(cancel_src, cancel_thumbnail_start, NULL, NULL);
2220                 g_source_attach(cancel_src, context);
2221         }
2222
2223         g_main_loop_run(g_loop);
2224         g_main_loop_unref(g_loop);
2225
2226         test_filter_destroy();
2227
2228         return ret;
2229 }
2230
2231 bool face_cb(media_face_h face, void *user_data)
2232 {
2233         get_face_meta(face);
2234
2235         return false;
2236 }
2237
2238 void face_detection_complete_cb(media_content_error_e error, int count, void *user_data)
2239 {
2240         int ret = MEDIA_CONTENT_ERROR_NONE;
2241         g_cnt++;
2242
2243         content_debug("=================[%d][%d]", g_media_cnt, g_cnt);
2244         content_debug("error_code [%d]", error);
2245         content_debug("face_count [%d]", count);
2246         if (count == 0) {
2247                 content_debug("No faces are detected!");
2248         } else if (user_data != NULL) {
2249                 media_info_h media = (media_info_h)user_data;
2250                 char *media_id = NULL;
2251                 ret = media_info_get_media_id(media, &media_id);
2252                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2253                         content_error("media_info_get_media_id failed: %d", ret);
2254                 if (media_id != NULL) {
2255                         ret = media_info_foreach_face_from_db(media_id, NULL, face_cb, NULL);
2256                         SAFE_FREE(media_id);
2257                         if (ret != MEDIA_CONTENT_ERROR_NONE)
2258                                 content_error("media_info_foreach_face_from_db failed: %d", ret);
2259                 }
2260                 ret = media_info_destroy(media);
2261                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2262                         content_error("media_info_destroy failed: %d", ret);
2263         }
2264
2265         if (g_cnt == g_media_cnt)
2266                 g_main_loop_quit(g_loop);
2267
2268         return;
2269 }
2270
2271 bool start_face_detection_cb(media_info_h media, void *user_data)
2272 {
2273         char *media_id = NULL;
2274         media_info_h dst = NULL;
2275         int ret = MEDIA_CONTENT_ERROR_NONE;
2276
2277         if (media == NULL) {
2278                 content_debug("NO Item");
2279                 return true;
2280         }
2281
2282         ret = media_info_get_media_id(media, &media_id);
2283         if (ret != MEDIA_CONTENT_ERROR_NONE)
2284                 content_error("media_info_get_media_id failed: %d", ret);
2285         else
2286                 content_debug("media_id : [%s]", media_id);
2287
2288         ret = media_info_clone(&dst, media);
2289         if (ret != MEDIA_CONTENT_ERROR_NONE)
2290                 content_error("media_info_clone failed: %d", ret);
2291
2292         GList **list = (GList**)user_data;
2293         *list = g_list_append(*list, dst);
2294
2295         /* fix prevent: Resource leak */
2296         SAFE_FREE(media_id);
2297
2298         return true;
2299 }
2300
2301 bool cancel_face_detection_cb(media_info_h media, void *user_data)
2302 {
2303         int ret = MEDIA_CONTENT_ERROR_NONE;
2304
2305         char *media_id = NULL;
2306         media_info_h dst = NULL;
2307
2308         g_cnt++;
2309
2310         if (media == NULL) {
2311                 content_debug("NO Item");
2312                 return true;
2313         }
2314
2315         ret = media_info_get_media_id(media, &media_id);
2316         if (ret != MEDIA_CONTENT_ERROR_NONE)
2317                 content_error("media_info_get_media_id failed: %d", ret);
2318         else
2319                 content_debug("media_id : [%s]", media_id);
2320
2321         ret = media_info_clone(&dst, media);
2322         if (ret != MEDIA_CONTENT_ERROR_NONE)
2323                 content_error("media_info_clone failed: %d", ret);
2324
2325         ret = media_info_cancel_face_detection(dst);
2326         if (ret != MEDIA_CONTENT_ERROR_NONE)
2327                 content_error("media_info_cancel_face_detection failed: %d", ret);
2328
2329         ret = media_info_destroy(dst);
2330         if (ret != MEDIA_CONTENT_ERROR_NONE)
2331                         content_error("media_info_destroy failed: %d", ret);
2332
2333         if (g_cnt == g_media_cnt)
2334                 g_main_loop_quit(g_loop);
2335
2336         /* fix prevent: Resource leak */
2337         SAFE_FREE(media_id);
2338
2339         return true;
2340 }
2341
2342 gboolean face_detection_start(gpointer data)
2343 {
2344         int ret = MEDIA_CONTENT_ERROR_NONE;
2345         GList *all_item_list = NULL;
2346         int idx = 0;
2347
2348         ret = media_info_foreach_media_from_db(g_filter, start_face_detection_cb, &all_item_list);
2349
2350         if (ret == MEDIA_CONTENT_ERROR_NONE)
2351                 content_debug("media_info_foreach_media_from_db is success");
2352         else
2353                 content_error("media_info_foreach_media_from_db is failed");
2354
2355         for (idx = 0; idx < g_list_length(all_item_list); idx++) {
2356                 media_info_h media_handle = NULL;
2357
2358                 media_handle = (media_info_h)g_list_nth_data(all_item_list, idx);
2359
2360                 ret = media_info_start_face_detection(media_handle, face_detection_complete_cb, NULL);
2361                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2362                         content_error("media_info_start_face_detection failed: %d", ret);
2363
2364         }
2365
2366         return false;
2367 }
2368
2369 gboolean face_detection_cancel(gpointer data)
2370 {
2371         int ret = MEDIA_CONTENT_ERROR_NONE;
2372
2373         ret = media_info_foreach_media_from_db(g_filter, cancel_face_detection_cb, NULL);
2374
2375         if (ret == MEDIA_CONTENT_ERROR_NONE)
2376                 content_debug("media_info_foreach_media_from_db is success");
2377         else
2378                 content_error("media_info_foreach_media_from_db is failed");
2379
2380         return false;
2381 }
2382
2383 int test_start_face_detection(int cancel)
2384 {
2385         int ret = MEDIA_CONTENT_ERROR_NONE;
2386         GSource *source = NULL;
2387         GMainContext *context = NULL;
2388
2389         test_filter_create();
2390
2391         ret = media_info_get_media_count_from_db(g_filter, &g_media_cnt);
2392         if (ret != MEDIA_CONTENT_ERROR_NONE)
2393                 content_error("media_info_get_media_count_from_db failed: %d", ret);
2394         else
2395                 content_debug("media_count : [%d]", g_media_cnt);
2396
2397         if (g_media_cnt == 0)
2398                 goto END;
2399
2400         g_loop = g_main_loop_new(NULL, FALSE);
2401         context = g_main_loop_get_context(g_loop);
2402         source = g_idle_source_new();
2403         g_source_set_callback(source, face_detection_start, NULL, NULL);
2404         g_source_attach(source, context);
2405
2406         /* Logic to cancel */
2407         if (cancel) {
2408                 GSource *cancel_src = NULL;
2409                 cancel_src = g_idle_source_new();
2410                 g_source_set_callback(cancel_src, face_detection_cancel, NULL, NULL);
2411                 g_source_attach(cancel_src, context);
2412         }
2413
2414         g_main_loop_run(g_loop);
2415         g_main_loop_unref(g_loop);
2416
2417 END:
2418         test_filter_destroy();
2419
2420         return ret;
2421 }
2422
2423 int test_ebook_text_finder(const char *keyword)
2424 {
2425         int ret = MEDIA_CONTENT_ERROR_NONE;
2426         char **book_path_list = NULL;
2427         unsigned int book_path_len = 0;
2428         unsigned int i = 0;
2429         media_info_h media = NULL;
2430         book_meta_h book = NULL;
2431         char *s_value = NULL;
2432         long long ms_time = 0;
2433         struct timeval start_time;
2434         struct timeval end_time;
2435
2436         gettimeofday(&start_time, NULL);
2437
2438         ret = book_meta_get_path_with_keyword(keyword, &book_path_list, &book_path_len);
2439         if (ret == MEDIA_CONTENT_ERROR_NONE)
2440                 content_debug("book_meta_get_path_with_keyword is success");
2441         else
2442                 content_error("book_meta_get_path_with_keyword is failed");
2443
2444         gettimeofday(&end_time, NULL);
2445
2446         for (i = 0; i < book_path_len; i++) {
2447                 ret = media_info_get_media_from_db_by_path(book_path_list[i], &media);
2448                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2449                         continue;
2450
2451                 content_debug("===============================");
2452                 content_debug("[%d] %s", i, book_path_list[i]);
2453                 content_debug("===============================");
2454                 media_info_get_title(media, &s_value);
2455                 content_debug("Title  : %s", s_value);
2456                 g_free(s_value);
2457                 s_value = NULL;
2458
2459                 ret = media_info_get_book(media, &book);
2460                 if (ret != MEDIA_CONTENT_ERROR_NONE) {
2461                         media_info_destroy(media);
2462                         continue;
2463                 }
2464
2465                 ret = book_meta_get_author(book, &s_value);
2466                 if (ret == MEDIA_CONTENT_ERROR_NONE && s_value) {
2467                         content_debug("Author : %s", s_value);
2468                         g_free(s_value);
2469                         s_value = NULL;
2470                 }
2471
2472                 ret = book_meta_get_date(book, &s_value);
2473                 if (ret == MEDIA_CONTENT_ERROR_NONE && s_value) {
2474                         content_debug("Date   : %s", s_value);
2475                         g_free(s_value);
2476                         s_value = NULL;
2477                 }
2478
2479                 content_debug("===============================");
2480                 ret = book_meta_destroy(book);
2481                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2482                         content_error("book_meta_destroy failed");
2483
2484                 ret = media_info_destroy(media);
2485                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2486                         content_error("media_info_destroy failed");
2487
2488                 g_free(book_path_list[i]);
2489         }
2490
2491         ms_time = (end_time.tv_sec * 1000LL + end_time.tv_usec / 1000) - (start_time.tv_sec * 1000LL + start_time.tv_usec/ 1000);
2492         content_debug("Search Time [%lld]", ms_time);
2493
2494         g_free(book_path_list);
2495
2496         return ret;
2497 }
2498 int test_disconnect_database(void)
2499 {
2500         int ret = MEDIA_CONTENT_ERROR_NONE;
2501         content_debug("\n============DB Disconnection Test============\n\n");
2502
2503         ret = media_content_disconnect();
2504
2505         if (ret == MEDIA_CONTENT_ERROR_NONE)
2506                 content_debug("disconnection is success");
2507         else
2508                 content_error("disconnection is failed");
2509
2510         return ret;
2511 }
2512
2513 int test_request_update_db(void)
2514 {
2515         int ret = MEDIA_CONTENT_ERROR_NONE;
2516         media_info_h media = NULL;
2517         bool favorite = FALSE;
2518
2519         ret = media_info_get_media_from_db("71b19196-5b38-4ab1-ab34-bfe05c369614", &media);
2520         if (ret != MEDIA_CONTENT_ERROR_NONE)
2521                 content_error("media_info_get_media_from_db failed: %d", ret);
2522
2523         ret = media_info_set_favorite(media, TRUE);
2524         if (ret != MEDIA_CONTENT_ERROR_NONE)
2525                 content_error("media_info_set_favorite failed: %d", ret);
2526
2527         ret = media_info_update_to_db(media);
2528         if (ret == MEDIA_CONTENT_ERROR_NONE)
2529                 content_debug("media_info_update_to_db is success");
2530         else
2531                 content_error("media_info_update_to_db is failed");
2532
2533         if (media != NULL)
2534                 media_info_destroy(media);
2535
2536         /*get the updated value*/
2537         ret = media_info_get_media_from_db("71b19196-5b38-4ab1-ab34-bfe05c369614", &media);
2538         if (ret != MEDIA_CONTENT_ERROR_NONE)
2539                 content_error("media_info_get_media_from_db failed: %d", ret);
2540
2541         ret = media_info_get_favorite(media, &favorite);
2542         if (ret != MEDIA_CONTENT_ERROR_NONE)
2543                 content_error("media_info_get_favorite failed: %d", ret);
2544         else
2545                 content_debug("favorite [%d]", favorite);
2546
2547         ret = media_info_destroy(media);
2548
2549         return ret;
2550 }
2551
2552 int g_total_photo_size = 0;
2553 int g_total_video_size = 0;
2554 int g_total_mp3_size = 0;
2555 int g_total_voice_memo_size = 0;
2556
2557 bool dft_cb(media_info_h media, void *user_data)
2558 {
2559         unsigned long long file_size = 0;
2560         media_content_type_e media_type = -1;
2561         char *mime_type = NULL;
2562         int ret = MEDIA_CONTENT_ERROR_NONE;
2563
2564         if (media == NULL)
2565                 return true;
2566
2567         ret = media_info_get_media_type(media, &media_type);
2568         if (ret != MEDIA_CONTENT_ERROR_NONE)
2569                 content_error("media_info_get_media_type failed: %d", ret);
2570         ret = media_info_get_size(media, &file_size);
2571         if (ret != MEDIA_CONTENT_ERROR_NONE)
2572                 content_error("media_info_get_size failed: %d", ret);
2573         ret = media_info_get_mime_type(media, &mime_type);
2574         if (ret != MEDIA_CONTENT_ERROR_NONE)
2575                 content_error("media_info_get_mime_type failed: %d", ret);
2576
2577         if (media_type == MEDIA_CONTENT_TYPE_IMAGE)
2578                 g_total_photo_size += file_size;
2579         else if (media_type == MEDIA_CONTENT_TYPE_VIDEO)
2580                 g_total_video_size += file_size;
2581         else if (media_type == MEDIA_CONTENT_TYPE_SOUND)
2582                 g_total_voice_memo_size += file_size;
2583         else if (media_type == MEDIA_CONTENT_TYPE_MUSIC) {
2584                 if ((mime_type != NULL) && (!strcmp("audio/mpeg", mime_type)))
2585                         g_total_mp3_size += file_size;
2586                 else
2587                         g_total_voice_memo_size += file_size;
2588         } else
2589                 content_debug("invalid media_type");
2590
2591         SAFE_FREE(mime_type);
2592
2593         return true;
2594
2595 }
2596
2597 int DFT_test(void)
2598 {
2599         int ret = MEDIA_CONTENT_ERROR_NONE;
2600         content_debug("\n============DFT_test============\n\n");
2601
2602         filter_h filter = NULL;
2603         int media_cnt = 0;
2604
2605         /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
2606
2607         ret = media_filter_create(&filter);
2608
2609 /*Internal Memory*/
2610         content_debug("[Internal Memory]\n");
2611         /*1. Photo ============================================================*/
2612         ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);
2613
2614         /*Get Photo Count*/
2615         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2616         content_debug("Photo count = [%d]\n", media_cnt);
2617
2618         /*Get Photo Size*/
2619         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2620         content_debug("Photo size = [%d]\n", g_total_photo_size);
2621
2622         /*2. Video ============================================================*/
2623         ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT);
2624
2625         /*Get Video Count*/
2626         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2627         content_debug("Video count = [%d]\n", media_cnt);
2628
2629         /*Get Video Size*/
2630         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2631         content_debug("Video size = [%d]\n", g_total_video_size);
2632
2633         /*3. MP3 ============================================================*/
2634         ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT);
2635
2636         /*Get MP3 Count*/
2637         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2638         content_debug("MP3 count = [%d]\n", media_cnt);
2639
2640         /*Get MP3 Size*/
2641         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2642         content_debug("MP3 size = [%d]\n", g_total_mp3_size);
2643
2644         /*4. Voice Memo ============================================================*/
2645         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);
2646
2647         /*Get Voice Memo Count*/
2648         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2649         content_debug("Voice Memo count = [%d]\n", media_cnt);
2650
2651         /*Get Voice Memo Size*/
2652         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2653         content_debug("Voice Memo size = [%d]\n", g_total_voice_memo_size);
2654
2655         g_total_photo_size = 0;
2656         g_total_video_size = 0;
2657         g_total_mp3_size = 0;
2658         g_total_voice_memo_size = 0;
2659
2660 /*External Memory*/
2661         content_debug("\n[External Memory]\n");
2662         /*1. Photo ============================================================*/
2663         ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);
2664
2665         /*Get Photo Count*/
2666         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2667         content_debug("Photo count = [%d]\n", media_cnt);
2668
2669         /*Get Photo Size*/
2670         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2671         content_debug("Photo size = [%d]\n", g_total_photo_size);
2672
2673         /*2. Video ============================================================*/
2674         ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT);
2675
2676         /*Get Video Count*/
2677         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2678         content_debug("Video count = [%d]\n", media_cnt);
2679
2680         /*Get Video Size*/
2681         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2682         content_debug("Video size = [%d]\n", g_total_video_size);
2683
2684         /*3. MP3 ============================================================*/
2685         ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT);
2686
2687         /*Get MP3 Count*/
2688         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2689         content_debug("MP3 count = [%d]\n", media_cnt);
2690
2691         /*Get MP3 Size*/
2692         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2693         content_debug("MP3 size = [%d]\n", g_total_mp3_size);
2694
2695         /*4. Voice Memo ============================================================*/
2696         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);
2697
2698         /*Get Voice Memo Count*/
2699         ret = media_info_get_media_count_from_db(filter, &media_cnt);
2700         content_debug("Voice Memo count = [%d]\n", media_cnt);
2701
2702         /*Get Voice Memo Size*/
2703         ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
2704         content_debug("Voice Memo size = [%d]\n", g_total_voice_memo_size);
2705         ret = media_filter_destroy(filter);
2706
2707         return ret;
2708 }
2709
2710 void insert_batch_cb(media_content_error_e error, void * user_data)
2711 {
2712         content_debug("media_info_insert_batch_to_db completed!\n");
2713 }
2714
2715 int test_batch_operations()
2716 {
2717         int ret = -1;
2718         int i = 0;
2719         char *file_list[10];
2720
2721         for (i = 0; i < 10; i++) {
2722                 file_list[i] = g_strdup_printf("%s%d.jpg", tzplatform_mkpath(TZ_USER_CONTENT, "test/image"), i+1);
2723                 content_debug("File : %s\n", file_list[i]);
2724         }
2725
2726         ret = media_info_insert_batch_to_db((const char **)file_list, 10, insert_batch_cb, NULL);
2727         if (ret != MEDIA_CONTENT_ERROR_NONE)
2728                 content_error("media_info_insert_batch_to_db failed : %d\n", ret);
2729
2730         for (i = 0; i < 10; i++)
2731                 g_free(file_list[i]);
2732
2733         return ret;
2734 }
2735
2736 void _scan_cb(media_content_error_e err, void *user_data)
2737 {
2738         content_debug("scan callback is called : %d\n", err);
2739         g_main_loop_quit(g_loop);
2740
2741         return;
2742 }
2743
2744 int test_scan_file()
2745 {
2746         int ret = -1;
2747
2748         const char *file_path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
2749         ret = media_content_scan_file(file_path);
2750         if (ret != MEDIA_CONTENT_ERROR_NONE) {
2751                 content_error("Fail to media_content_scan_file : %d", ret);
2752                 return ret;
2753         }
2754
2755         return 0;
2756 }
2757
2758 gboolean test_scan_dir_start(gpointer data)
2759 {
2760         int ret = -1;
2761
2762         const char *dir_path = tzplatform_getenv(TZ_USER_CONTENT);
2763
2764         ret = media_content_scan_folder(dir_path, TRUE, _scan_cb, NULL);
2765
2766         if (ret != MEDIA_CONTENT_ERROR_NONE) {
2767                 content_error("Fail to test_scan_dir_start : %d", ret);
2768                 return ret;
2769         }
2770
2771         return 0;
2772 }
2773
2774 gboolean cancel_scan_dir_start(gpointer data)
2775 {
2776         int ret = MEDIA_CONTENT_ERROR_NONE;
2777
2778         const char *dir_path = tzplatform_getenv(TZ_USER_IMAGES);
2779
2780         ret = media_content_cancel_scan_folder(dir_path);
2781
2782         if (ret == MEDIA_CONTENT_ERROR_NONE)
2783                 content_debug("media_content_cancel_scan_folder is success");
2784         else
2785                 content_error("media_content_cancel_scan_folder is failed");
2786
2787         return false;
2788 }
2789
2790 int test_scan_dir(int cancel)
2791 {
2792         GSource *source = NULL;
2793         GMainContext *context = NULL;
2794
2795         g_loop = g_main_loop_new(NULL, FALSE);
2796         context = g_main_loop_get_context(g_loop);
2797         source = g_idle_source_new();
2798         g_source_set_callback(source, test_scan_dir_start, NULL, NULL);
2799         g_source_attach(source, context);
2800
2801         if (cancel) {
2802                 GSource *cancel_src = NULL;
2803                 cancel_src = g_idle_source_new();
2804                 g_source_set_callback(cancel_src, cancel_scan_dir_start, NULL, NULL);
2805                 g_source_attach(cancel_src, context);
2806         }
2807
2808         g_main_loop_run(g_loop);
2809         g_main_loop_unref(g_loop);
2810
2811         return 0;
2812 }
2813
2814 void _noti_cb(media_content_error_e error,
2815                                 int pid,
2816                                 media_content_db_update_item_type_e update_item,
2817                                 media_content_db_update_type_e update_type,
2818                                 media_content_type_e media_type,
2819                                 char *uuid,
2820                                 char *path,
2821                                 char *mime_type,
2822                                 void *user_data)
2823 {
2824         if (error == 0)
2825                 content_debug("noti success! : %d\n", error);
2826         else
2827                 content_debug("error occurred! : %d\n", error);
2828
2829         content_debug("Noti from PID(%d)\n", pid);
2830
2831         if (update_item == MEDIA_ITEM_FILE)
2832                 content_debug("Noti item : MEDIA_ITEM_FILE\n");
2833         else if (update_item == MEDIA_ITEM_DIRECTORY)
2834                 content_debug("Noti item : MEDIA_ITEM_DIRECTORY\n");
2835
2836         if (update_type == MEDIA_CONTENT_INSERT)
2837                 content_debug("Noti type : MEDIA_CONTENT_INSERT\n");
2838         else if (update_type == MEDIA_CONTENT_DELETE)
2839                 content_debug("Noti type : MEDIA_CONTENT_DELETE\n");
2840         else if (update_type == MEDIA_CONTENT_UPDATE)
2841                 content_debug("Noti type : MEDIA_CONTENT_UPDATE\n");
2842
2843         content_debug("content type : %d\n", media_type);
2844
2845         if (path)
2846                 content_debug("path : %s\n", path);
2847         else
2848                 content_debug("path not\n");
2849
2850         if (uuid)
2851                 content_debug("uuid : %s\n", uuid);
2852         else
2853                 content_debug("uuid not\n");
2854
2855         if (mime_type)
2856                 content_debug("mime_type : %s\n", mime_type);
2857         else
2858                 content_debug("mime not\n");
2859
2860         if (user_data) content_debug("String : %s\n", (char *)user_data);
2861
2862         return;
2863 }
2864
2865 void _noti_cb_2(media_content_error_e error,
2866                                 int pid,
2867                                 media_content_db_update_item_type_e update_item,
2868                                 media_content_db_update_type_e update_type,
2869                                 media_content_type_e media_type,
2870                                 char *uuid,
2871                                 char *path,
2872                                 char *mime_type,
2873                                 void *user_data)
2874 {
2875         if (error == 0)
2876                 content_debug("noti_2 success! : %d\n", error);
2877         else
2878                 content_debug("error occurred! : %d\n", error);
2879
2880         content_debug("Noti_2 from PID(%d)\n", pid);
2881
2882         g_main_loop_quit(g_loop);
2883         return;
2884 }
2885
2886 static media_content_noti_h noti_h;
2887 static media_content_noti_h noti_h_2;
2888
2889 gboolean _send_noti_operations(gpointer data)
2890 {
2891         int ret = MEDIA_CONTENT_ERROR_NONE;
2892
2893         /* First of all, noti subscription */
2894         char *user_str = strdup("hi");
2895         media_content_add_db_updated_cb(_noti_cb, (void*)user_str, &noti_h);
2896         media_content_add_db_updated_cb(_noti_cb_2, (void*)user_str, &noti_h_2);
2897
2898         /* media_info_insert_to_db */
2899         media_info_h media_item = NULL;
2900         const char *path = tzplatform_mkpath(TZ_USER_CONTENT, "test/image1.jpg");
2901
2902         ret = media_info_insert_to_db(path, &media_item);
2903         if (ret != MEDIA_CONTENT_ERROR_NONE) {
2904                 content_error("media_info_insert_to_db failed : %d", ret);
2905                 media_info_destroy(media_item);
2906                 return FALSE;
2907         }
2908
2909         content_debug("media_info_insert_to_db success");
2910
2911         media_content_remove_db_updated_cb(noti_h);
2912
2913         /* media_info_update_to_db */
2914         ret = media_info_update_to_db(media_item);
2915         if (ret != MEDIA_CONTENT_ERROR_NONE) {
2916                 content_error("media_info_update_to_db failed : %d\n", ret);
2917                 media_info_destroy(media_item);
2918                 return ret;
2919         }
2920
2921         media_info_destroy(media_item);
2922
2923         return FALSE;
2924 }
2925
2926 int test_noti()
2927 {
2928         int ret = MEDIA_CONTENT_ERROR_NONE;
2929         GSource *source = NULL;
2930         GMainContext *context = NULL;
2931
2932         g_loop = g_main_loop_new(NULL, FALSE);
2933         context = g_main_loop_get_context(g_loop);
2934         source = g_idle_source_new();
2935         g_source_set_callback(source, _send_noti_operations, NULL, NULL);
2936         g_source_attach(source, context);
2937
2938         g_main_loop_run(g_loop);
2939         g_main_loop_unref(g_loop);
2940
2941         test_filter_destroy();
2942         media_content_remove_db_updated_cb(noti_h_2);
2943
2944         return ret;
2945 }
2946
2947 bool media_face_test_cb(media_face_h face, void *user_data)
2948 {
2949         get_face_meta(face);
2950
2951         if (user_data != NULL) {
2952                 media_face_h new_face = NULL;
2953                 media_face_clone(&new_face, face);
2954
2955                 GList **list = (GList**)user_data;
2956                 *list = g_list_append(*list, new_face);
2957         }
2958
2959         return true;
2960 }
2961
2962 int test_face(void)
2963 {
2964         int ret = MEDIA_CONTENT_ERROR_NONE;
2965         filter_h filter = NULL;
2966         GList *all_item_list = NULL;
2967         int i = 0;
2968
2969         ret = media_filter_create(&filter);
2970         content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_filter_create");
2971
2972         ret = media_filter_set_condition(filter, "MEDIA_TYPE = 0", MEDIA_CONTENT_COLLATE_DEFAULT);
2973         if (ret != MEDIA_CONTENT_ERROR_NONE) {
2974                 media_filter_destroy(filter);
2975                 content_error("Fail to set condition");
2976                 return ret;
2977         }
2978
2979         ret = media_info_foreach_media_from_db(filter, gallery_media_item_cb, &all_item_list);
2980         if (ret != MEDIA_CONTENT_ERROR_NONE) {
2981                 content_error("media_info_foreach_media_from_db failed: %d", ret);
2982                 media_filter_destroy(filter);
2983                 return ret;
2984         }
2985
2986         for (i = 0; i < g_list_length(all_item_list); i++) {
2987                 media_info_h media_handle = NULL;
2988                 char *media_id = NULL;
2989                 int face_count = 0;
2990
2991                 media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
2992
2993                 ret = media_info_get_media_id(media_handle, &media_id);
2994                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2995                         content_error("media_info_get_media_id failed: %d", ret);
2996
2997                 ret = media_info_get_face_count_from_db(media_id, filter, &face_count);
2998                 if (ret != MEDIA_CONTENT_ERROR_NONE)
2999                         content_error("media_info_get_face_count_from_db failed: %d", ret);
3000
3001                 content_error("media_id [%s] face_count [%d]", media_id, face_count);
3002
3003                 ret = media_info_foreach_face_from_db(media_id, filter, media_face_test_cb, NULL);
3004                 if (ret != MEDIA_CONTENT_ERROR_NONE)
3005                         content_error("media_info_foreach_face_from_db failed: %d", ret);
3006
3007                 media_info_destroy(media_handle);
3008         }
3009
3010         media_filter_destroy(filter);
3011
3012         return ret;
3013 }
3014
3015 int test_face_add_del(void)
3016 {
3017         int ret = MEDIA_CONTENT_ERROR_NONE;
3018         char *media_id = "ecca7366-e085-41d8-a12b-cbdfc2b9c5fc";
3019
3020         /* Insert Test */
3021         media_face_h face = NULL;
3022
3023         char *face_tag = "test_face_tag";
3024
3025         ret = media_face_create(media_id, &face);
3026         content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_face_create");
3027
3028         ret = media_face_set_face_rect(face, 10, 12, 50, 100);
3029         if (ret != MEDIA_CONTENT_ERROR_NONE)
3030                 content_error("media_face_set_face_rect failed: %d", ret);
3031
3032         ret = media_face_set_orientation(face, 5);
3033         if (ret != MEDIA_CONTENT_ERROR_NONE)
3034                 content_error("media_face_set_orientation failed: %d", ret);
3035
3036         ret = media_face_set_tag(face, face_tag);
3037         if (ret != MEDIA_CONTENT_ERROR_NONE)
3038                 content_error("media_face_set_tag failed: %d", ret);
3039
3040         ret = media_face_insert_to_db(face);
3041         if (ret != MEDIA_CONTENT_ERROR_NONE)
3042                 content_error("media_face_insert_to_db failed: %d", ret);
3043
3044         ret = media_face_destroy(face);
3045         if (ret != MEDIA_CONTENT_ERROR_NONE)
3046                 content_error("media_face_destroy failed: %d", ret);
3047
3048         /* Update Test */
3049         GList *all_item_list = NULL;
3050         filter_h filter = NULL;
3051         ret = media_filter_create(&filter);
3052         content_retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, ret, "fail media_filter_create");
3053
3054         ret = media_filter_set_condition(filter, "MEDIA_FACE_TAG IS NOT NULL", MEDIA_CONTENT_COLLATE_DEFAULT);
3055         if (ret != MEDIA_CONTENT_ERROR_NONE) {
3056                 media_filter_destroy(filter);
3057                 content_error("Fail to set condition");
3058                 return ret;
3059         }
3060
3061         ret = media_info_foreach_face_from_db(media_id, filter, media_face_test_cb, &all_item_list);
3062
3063         if (g_list_length(all_item_list) > 0) {
3064                 media_face_h face_handle = NULL;
3065                 face_handle = (media_face_h)g_list_nth_data(all_item_list, 0);
3066
3067                 ret = media_face_set_face_rect(face_handle, 20, 22, 70, 70);
3068                 if (ret != MEDIA_CONTENT_ERROR_NONE)
3069                         content_error("media_face_set_face_rect failed: %d", ret);
3070                 ret = media_face_set_orientation(face_handle, 3);
3071                 if (ret != MEDIA_CONTENT_ERROR_NONE)
3072                         content_error("media_face_set_orientation failed: %d", ret);
3073                 ret = media_face_set_tag(face_handle, NULL);
3074                 if (ret != MEDIA_CONTENT_ERROR_NONE)
3075                         content_error("media_face_set_tag failed: %d", ret);
3076                 ret = media_face_update_to_db(face_handle);
3077                 if (ret != MEDIA_CONTENT_ERROR_NONE)
3078                         content_error("media_face_update_to_db failed: %d", ret);
3079
3080                 media_face_destroy(face_handle);
3081         }
3082
3083         media_filter_destroy(filter);
3084
3085         /* Delete Test */
3086         char *face_id = "5e58a3a8-f0b2-4c29-b799-b49a70dc2313";
3087
3088         /* Delete Test*/
3089         ret = media_face_delete_from_db(face_id);
3090
3091         return ret;
3092 }
3093
3094 #ifdef _USE_TVPD_MODE
3095 filter_h g_tv_filter = NULL;
3096
3097 int test_tv_filter_create(void)
3098 {
3099         content_debug("\n============Filter Create============\n\n");
3100
3101         int ret = MEDIA_CONTENT_ERROR_NONE;
3102
3103         ret = media_filter_create(&g_tv_filter);
3104
3105         ret = media_filter_set_storage(g_tv_filter, "0a22a163-e634-4a2e-ba14-0469a969eea0");
3106
3107         ret = media_filter_set_order(g_tv_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_DEFAULT);
3108
3109         return ret;
3110 }
3111
3112 int test_tv_filter_destroy(void)
3113 {
3114         content_debug("\n============Filter Destroy============\n\n");
3115
3116         int ret = MEDIA_CONTENT_ERROR_NONE;
3117
3118         ret = media_filter_destroy(g_tv_filter);
3119
3120         return ret;
3121 }
3122
3123 bool pvr_item_cb(media_pvr_h pvr, void *user_data)
3124 {
3125         int ret = MEDIA_CONTENT_ERROR_NONE;
3126         char *c_value = NULL;
3127         int i_value = 0;
3128         bool b_value = false;
3129         unsigned long long l_value = 0;
3130
3131         if (pvr == NULL) {
3132                 content_debug("NO Item");
3133                 return true;
3134         }
3135
3136         ret = media_pvr_get_media_id(pvr, &c_value);
3137         if (ret != MEDIA_CONTENT_ERROR_NONE)
3138                 content_error("Fail to media_pvr_get_media_id");
3139         content_debug("media_id [%s]", c_value);
3140         SAFE_FREE(c_value);
3141
3142         ret = media_pvr_get_channel_name(pvr, &c_value);
3143         if (ret != MEDIA_CONTENT_ERROR_NONE)
3144                 content_error("Fail to media_pvr_get_channel_name");
3145         content_debug("channel_name [%s]", c_value);
3146         SAFE_FREE(c_value);
3147
3148         ret = media_pvr_get_program_title(pvr, &c_value);
3149         if (ret != MEDIA_CONTENT_ERROR_NONE)
3150                 content_error("Fail to media_pvr_get_program_title");
3151         content_debug("program_title [%s]", c_value);
3152         SAFE_FREE(c_value);
3153
3154         ret = media_pvr_get_program_crid(pvr, &c_value);
3155         if (ret != MEDIA_CONTENT_ERROR_NONE)
3156                 content_error("Fail to media_pvr_get_program_crid");
3157         content_debug("program_crid [%s]", c_value);
3158         SAFE_FREE(c_value);
3159
3160         ret = media_pvr_get_guidance(pvr, &c_value);
3161         if (ret != MEDIA_CONTENT_ERROR_NONE)
3162                 content_error("Fail to media_pvr_get_guidance");
3163         content_debug("guidance [%s]", c_value);
3164         SAFE_FREE(c_value);
3165
3166         ret = media_pvr_get_synopsis(pvr, &c_value);
3167         if (ret != MEDIA_CONTENT_ERROR_NONE)
3168                 content_error("Fail to media_pvr_get_synopsis");
3169         content_debug("synopsis [%s]", c_value);
3170         SAFE_FREE(c_value);
3171
3172         ret = media_pvr_get_genre(pvr, &c_value);
3173         if (ret != MEDIA_CONTENT_ERROR_NONE)
3174                 content_error("Fail to media_pvr_get_synopsis");
3175         content_debug("genre [%s]", c_value);
3176         SAFE_FREE(c_value);
3177
3178         ret = media_pvr_get_language(pvr, &c_value);
3179         if (ret != MEDIA_CONTENT_ERROR_NONE)
3180                 content_error("Fail to media_pvr_get_language");
3181         content_debug("language [%s]", c_value);
3182         SAFE_FREE(c_value);
3183
3184         ret = media_pvr_get_path(pvr, &c_value);
3185         if (ret != MEDIA_CONTENT_ERROR_NONE)
3186                 content_error("Fail to media_pvr_get_path");
3187         content_debug("path [%s]", c_value);
3188         SAFE_FREE(c_value);
3189
3190         ret = media_pvr_get_storage_id(pvr, &c_value);
3191         if (ret != MEDIA_CONTENT_ERROR_NONE)
3192                 content_error("Fail to media_pvr_get_storage_id");
3193         content_debug("storage_id [%s]", c_value);
3194         SAFE_FREE(c_value);
3195
3196         ret = media_pvr_get_size(pvr, &l_value);
3197         if (ret != MEDIA_CONTENT_ERROR_NONE)
3198                 content_error("Fail to media_pvr_get_size");
3199         content_debug("size [%lld]", l_value);
3200
3201         ret = media_pvr_get_timezone(pvr, &i_value);
3202         if (ret != MEDIA_CONTENT_ERROR_NONE)
3203                 content_error("Fail to media_pvr_get_timezone");
3204         content_debug("timezone [%d]", i_value);
3205
3206         ret = media_pvr_get_ptc(pvr, &i_value);
3207         if (ret != MEDIA_CONTENT_ERROR_NONE)
3208                 content_error("Fail to media_pvr_get_ptc");
3209         content_debug("ptc [%d]", i_value);
3210
3211         ret = media_pvr_get_major(pvr, &i_value);
3212         if (ret != MEDIA_CONTENT_ERROR_NONE)
3213                 content_error("Fail to media_pvr_get_major");
3214         content_debug("[%d]", i_value);
3215
3216         ret = media_pvr_get_minor(pvr, &i_value);
3217         if (ret != MEDIA_CONTENT_ERROR_NONE)
3218                 content_error("Fail to media_pvr_get_minor");
3219         content_debug("minor [%d]", i_value);
3220
3221         ret = media_pvr_get_channel_type(pvr, &i_value);
3222         if (ret != MEDIA_CONTENT_ERROR_NONE)
3223                 content_error("Fail to media_pvr_get_channel_type");
3224         content_debug("channel_type [%d]", i_value);
3225
3226         ret = media_pvr_get_program_num(pvr, &i_value);
3227         if (ret != MEDIA_CONTENT_ERROR_NONE)
3228                 content_error("Fail to media_pvr_get_program_num");
3229         content_debug("program_num [%d]", i_value);
3230
3231         unsigned int ui_value = 0;
3232         ret = media_pvr_get_service_profile(pvr, &ui_value);
3233         if (ret != MEDIA_CONTENT_ERROR_NONE)
3234                 content_error("Fail to media_pvr_get_service_profile");
3235         content_debug("service_profile [%u]", ui_value);
3236
3237         ret = media_pvr_get_duration(pvr, &i_value);
3238         if (ret != MEDIA_CONTENT_ERROR_NONE)
3239                 content_error("Fail to media_pvr_get_duration");
3240         content_debug("duration [%d]", i_value);
3241
3242         ret = media_pvr_get_embargo_time(pvr, &i_value);
3243         if (ret != MEDIA_CONTENT_ERROR_NONE)
3244                 content_error("Fail to media_pvr_get_embargo_time");
3245         content_debug("embargo_time [%d]", i_value);
3246
3247         ret = media_pvr_get_expiry_time(pvr, &i_value);
3248         if (ret != MEDIA_CONTENT_ERROR_NONE)
3249                 content_error("Fail to media_pvr_get_expiry_time");
3250         content_debug("expiry_time [%d]", i_value);
3251
3252         ret = media_pvr_get_parental_rating(pvr, &i_value);
3253         if (ret != MEDIA_CONTENT_ERROR_NONE)
3254                 content_error("Fail to media_pvr_get_parental_rating");
3255         content_debug("parental_rating [%d]", i_value);
3256
3257         ret = media_pvr_get_start_time(pvr, &i_value);
3258         if (ret != MEDIA_CONTENT_ERROR_NONE)
3259                 content_error("Fail to media_pvr_get_start_time");
3260         content_debug("start_time [%d]", i_value);
3261
3262         ret = media_pvr_get_program_start_time(pvr, &i_value);
3263         if (ret != MEDIA_CONTENT_ERROR_NONE)
3264                 content_error("Fail to media_pvr_get_program_start_time");
3265         content_debug("program_start_time [%d]", i_value);
3266
3267         ret = media_pvr_get_program_end_time(pvr, &i_value);
3268         if (ret != MEDIA_CONTENT_ERROR_NONE)
3269                 content_error("Fail to media_pvr_get_program_end_time");
3270         content_debug("program_end_time [%d]", i_value);
3271
3272         ret = media_pvr_get_program_date(pvr, &i_value);
3273         if (ret != MEDIA_CONTENT_ERROR_NONE)
3274                 content_error("Fail to media_pvr_get_program_date");
3275         content_debug("program_date [%d]", i_value);
3276
3277         ret = media_pvr_get_timer_record(pvr, &b_value);
3278         if (ret != MEDIA_CONTENT_ERROR_NONE)
3279                 content_error("Fail to media_pvr_get_timer_record");
3280         content_debug("timer_record [%d]", b_value);
3281
3282         ret = media_pvr_get_series_record(pvr, &b_value);
3283         if (ret != MEDIA_CONTENT_ERROR_NONE)
3284                 content_error("Fail to media_pvr_get_series_record");
3285         content_debug("series_record [%d]", b_value);
3286
3287         ret = media_pvr_get_hd(pvr, &i_value);
3288         if (ret != MEDIA_CONTENT_ERROR_NONE)
3289                 content_error("Fail to media_pvr_get_hd");
3290         content_debug("hd [%d]", i_value);
3291
3292         ret = media_pvr_get_subtitle(pvr, &b_value);
3293         if (ret != MEDIA_CONTENT_ERROR_NONE)
3294                 content_error("Fail to media_pvr_get_subtitle");
3295         content_debug("subtitle [%d]", b_value);
3296
3297         ret = media_pvr_get_ttx(pvr, &b_value);
3298         if (ret != MEDIA_CONTENT_ERROR_NONE)
3299                 content_error("Fail to media_pvr_get_ttx");
3300         content_debug("ttx [%d]", b_value);
3301
3302         ret = media_pvr_get_ad(pvr, &b_value);
3303         if (ret != MEDIA_CONTENT_ERROR_NONE)
3304                 content_error("Fail to media_pvr_get_ad");
3305         content_debug("ad [%d]", b_value);
3306
3307         ret = media_pvr_get_hard_of_hearing_radio(pvr, &b_value);
3308         if (ret != MEDIA_CONTENT_ERROR_NONE)
3309                 content_error("Fail to media_pvr_get_hard_of_hearing_radio");
3310         content_debug("hard_of_hearing_radio [%d]", b_value);
3311
3312         ret = media_pvr_get_data_service(pvr, &b_value);
3313         if (ret != MEDIA_CONTENT_ERROR_NONE)
3314                 content_error("Fail to media_pvr_get_data_service");
3315         content_debug("data_service [%d]", b_value);
3316
3317         ret = media_pvr_get_content_lock(pvr, &b_value);
3318         if (ret != MEDIA_CONTENT_ERROR_NONE)
3319                 content_error("Fail to media_pvr_get_content_lock");
3320         content_debug("content_lock [%d]", b_value);
3321
3322         ret = media_pvr_get_content_watch(pvr, &b_value);
3323         if (ret != MEDIA_CONTENT_ERROR_NONE)
3324                 content_error("Fail to media_pvr_get_content_watch");
3325         content_debug("content_watch [%d]", b_value);
3326
3327         ret = media_pvr_get_has_audio_only(pvr, &b_value);
3328         if (ret != MEDIA_CONTENT_ERROR_NONE)
3329                 content_error("Fail to media_pvr_get_has_audio_only");
3330         content_debug("has_audio_only [%d]", b_value);
3331
3332         ret = media_pvr_get_is_local_record(pvr, &b_value);
3333         if (ret != MEDIA_CONTENT_ERROR_NONE)
3334                 content_error("Fail to media_pvr_get_is_local_record");
3335         content_debug("is_local_record [%d]", b_value);
3336
3337         ret = media_pvr_get_resolution(pvr, (media_pvr_resolution_e*)&i_value);
3338         if (ret != MEDIA_CONTENT_ERROR_NONE)
3339                 content_error("Fail to media_pvr_get_resolution");
3340         content_debug("resolution [%d]", i_value);
3341
3342         ret = media_pvr_get_aspectratio(pvr, (media_pvr_aspectratio_e*)&i_value);
3343         if (ret != MEDIA_CONTENT_ERROR_NONE)
3344                 content_error("Fail to media_pvr_get_aspectratio");
3345         content_debug("aspectratio [%d]", i_value);
3346
3347         ret = media_pvr_get_highlight(pvr, &b_value);
3348         if (ret != MEDIA_CONTENT_ERROR_NONE)
3349                 content_error("Fail to media_pvr_get_highlight");
3350         content_debug("highlight [%d]", b_value);
3351
3352
3353         return TRUE;
3354 }
3355
3356 int test_pvr()
3357 {
3358         int ret = MEDIA_CONTENT_ERROR_NONE;
3359         int media_count = 0;
3360
3361         content_debug("\n============PVR Test============\n\n");
3362
3363         test_tv_filter_create();
3364
3365         ret = media_pvr_get_media_count_from_db(g_tv_filter, &media_count);
3366         if (ret != MEDIA_CONTENT_ERROR_NONE)
3367                 content_error("media_pvr_get_media_count_from_db failed: %d", ret);
3368         else
3369                 content_debug("media_count : [%d]", media_count);
3370
3371         ret = media_pvr_foreach_media_from_db(g_tv_filter, pvr_item_cb, NULL);
3372         if (ret != MEDIA_CONTENT_ERROR_NONE)
3373                 content_error("media_pvr_foreach_media_from_db is failed");
3374
3375         test_tv_filter_destroy();
3376
3377         return ret;
3378 }
3379
3380 int test_pvr_update_db(void)
3381 {
3382         int ret = MEDIA_CONTENT_ERROR_NONE;
3383         media_pvr_h pvr = NULL;
3384
3385         ret = media_pvr_get_pvr_from_db("ff9b5a9a-a7b4-47f4-8255-84e007e25f13", &pvr);
3386         if (ret != MEDIA_CONTENT_ERROR_NONE)
3387                 content_error("media_pvr_get_pvr_from_db failed: %d", ret);
3388
3389         ret = media_pvr_set_content_lock(pvr, TRUE);
3390         if (ret != MEDIA_CONTENT_ERROR_NONE)
3391                 content_error("Fail to media_pvr_set_content_lock");
3392
3393         ret = media_pvr_set_content_watch(pvr, TRUE);
3394         if (ret != MEDIA_CONTENT_ERROR_NONE)
3395                 content_error("Fail to media_pvr_set_content_watch");
3396
3397         ret = media_pvr_set_program_title(pvr, "TEST TITLE");
3398         if (ret != MEDIA_CONTENT_ERROR_NONE)
3399                 content_error("Fail to media_pvr_set_program_title");
3400
3401         ret = media_pvr_set_highlight(pvr, TRUE);
3402         if (ret != MEDIA_CONTENT_ERROR_NONE)
3403                 content_error("Fail to media_pvr_set_highlight");
3404
3405         ret = media_pvr_update_to_db(pvr);
3406         if (ret != MEDIA_CONTENT_ERROR_NONE)
3407                 content_error("Fail to media_pvr_update_to_db");
3408
3409         if (pvr != NULL)
3410                 media_pvr_destroy(pvr);
3411
3412         return ret;
3413 }
3414 #endif
3415
3416 int main(int argc, char *argv[])
3417 {
3418         int ret = MEDIA_CONTENT_ERROR_NONE;
3419
3420         content_debug("--- content manager test start ---\n\n");
3421
3422         ret = test_connect_database();
3423         if (ret != MEDIA_CONTENT_ERROR_NONE)
3424                 return MEDIA_CONTENT_ERROR_NONE;
3425 #ifdef _USE_TVPD_MODE
3426         test_pvr();
3427
3428         test_pvr_update_db();
3429
3430         test_pvr();
3431 #endif
3432
3433 #if 0
3434         if (argc == 2) {
3435                 ret = test_ebook_text_finder(argv[1]);
3436                 if (ret != MEDIA_CONTENT_ERROR_NONE)
3437                         return ret;
3438         }
3439
3440         ret = test_start_face_detection(FALSE);
3441         if (ret != MEDIA_CONTENT_ERROR_NONE)
3442                 return ret;
3443
3444         ret = test_move();
3445         if (ret != MEDIA_CONTENT_ERROR_NONE)
3446                 return ret;
3447
3448         ret = test_gallery_scenario();
3449         if (ret != MEDIA_CONTENT_ERROR_NONE)
3450                 return ret;
3451
3452         ret = test_get_all_music_files();
3453         if (ret != MEDIA_CONTENT_ERROR_NONE)
3454                 return ret;
3455
3456         ret = test_media_info_operation();
3457         if (ret != MEDIA_CONTENT_ERROR_NONE)
3458                 return ret;
3459
3460         ret = test_folder_operation();
3461         if (ret != MEDIA_CONTENT_ERROR_NONE)
3462                 return ret;
3463
3464         ret = test_playlist_operation();
3465         if (ret != MEDIA_CONTENT_ERROR_NONE)
3466                 return ret;
3467
3468         ret = test_tag_operation();
3469         if (ret != MEDIA_CONTENT_ERROR_NONE)
3470                 return ret;
3471
3472         ret = test_bookmark_operation();
3473         if (ret != MEDIA_CONTENT_ERROR_NONE)
3474                 return ret;
3475
3476         ret = test_album_list();
3477         if (ret != MEDIA_CONTENT_ERROR_NONE)
3478                 return ret;
3479
3480         ret = test_group_operation();
3481         if (ret != MEDIA_CONTENT_ERROR_NONE)
3482                 return ret;
3483
3484         ret = test_update_operation();
3485         if (ret != MEDIA_CONTENT_ERROR_NONE)
3486                 return ret;
3487
3488         ret = test_insert();
3489         if (ret != MEDIA_CONTENT_ERROR_NONE)
3490                 return ret;
3491
3492         ret = test_move();
3493         if (ret != MEDIA_CONTENT_ERROR_NONE)
3494                 return ret;
3495
3496         ret = test_create_thumbnail(TRUE);
3497         if (ret != MEDIA_CONTENT_ERROR_NONE)
3498                 return ret;
3499
3500         ret = test_extrace_face(TRUE);
3501         if (ret != MEDIA_CONTENT_ERROR_NONE)
3502                 return ret;
3503
3504         ret = test_request_update_db();
3505         if (ret != MEDIA_CONTENT_ERROR_NONE)
3506                 return ret;
3507
3508         ret = DFT_test();
3509         if (ret != MEDIA_CONTENT_ERROR_NONE)
3510                 return ret;
3511
3512         ret = test_batch_operations();
3513         if (ret != MEDIA_CONTENT_ERROR_NONE)
3514                 return MEDIA_CONTENT_ERROR_NONE;
3515
3516         ret = test_scan_file();
3517         if (ret != MEDIA_CONTENT_ERROR_NONE)
3518                 return MEDIA_CONTENT_ERROR_NONE;
3519
3520         ret = test_scan_dir(true);
3521         if (ret != MEDIA_CONTENT_ERROR_NONE)
3522                 return MEDIA_CONTENT_ERROR_NONE;
3523
3524         ret = test_noti();
3525         if (ret != MEDIA_CONTENT_ERROR_NONE)
3526                 return MEDIA_CONTENT_ERROR_NONE;
3527
3528         ret = test_face();
3529         if (ret != MEDIA_CONTENT_ERROR_NONE)
3530                 return MEDIA_CONTENT_ERROR_NONE;
3531
3532         ret = test_face_add_del();
3533         if (ret != MEDIA_CONTENT_ERROR_NONE)
3534                 return MEDIA_CONTENT_ERROR_NONE;
3535
3536         ret = test_playlist_operation_v2();
3537         if (ret != MEDIA_CONTENT_ERROR_NONE)
3538                 return MEDIA_CONTENT_ERROR_NONE;
3539
3540         ret = test_bookmark_operation_v2();
3541         if (ret != MEDIA_CONTENT_ERROR_NONE)
3542                 return MEDIA_CONTENT_ERROR_NONE;
3543
3544         ret = test_tag_operation_v2();
3545         if (ret != MEDIA_CONTENT_ERROR_NONE)
3546                 return MEDIA_CONTENT_ERROR_NONE;
3547 #endif
3548
3549         ret = test_disconnect_database();
3550         if (ret != MEDIA_CONTENT_ERROR_NONE)
3551                 return ret;
3552
3553         content_debug("--- content manager test end ---\n");
3554
3555         return ret;
3556 }