Git init
[framework/multimedia/gst-plugins-base0.10.git] / tests / check / libs / profile.c
1 /* GStreamer unit test for gstprofile
2  *
3  * Copyright (C) <2009> Edward Hervey <edward.hervey@collabora.co.uk>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 /* #include <fcntl.h> */
26 #include <unistd.h>
27 #include <glib.h>
28 #include <glib/gstdio.h>
29 #include <gst/check/gstcheck.h>
30
31 #include <gst/pbutils/encoding-profile.h>
32 #include <gst/pbutils/encoding-target.h>
33
34 #define CHECK_PROFILE(profile, name, description, format, preset, presence, restriction) \
35   {                                                                     \
36   fail_if(profile == NULL);                                             \
37   fail_unless_equals_string (gst_encoding_profile_get_name (profile), name); \
38   fail_unless_equals_string (gst_encoding_profile_get_description (profile), description); \
39   fail_unless (gst_caps_is_equal (gst_encoding_profile_get_format (profile), format)); \
40   fail_unless_equals_string (gst_encoding_profile_get_preset (profile), preset); \
41   fail_unless_equals_int (gst_encoding_profile_get_presence (profile), presence); \
42   fail_unless (gst_caps_is_equal (gst_encoding_profile_get_restriction (profile), restriction)); \
43   }
44
45 GST_START_TEST (test_profile_creation)
46 {
47   GstEncodingProfile *encprof;
48   GstEncodingAudioProfile *audioprof;
49   GstEncodingVideoProfile *videoprof;
50   GstCaps *ogg, *vorbis, *theora;
51   GstCaps *test1, *test2;
52
53   ogg = gst_caps_new_simple ("application/ogg", NULL);
54   vorbis = gst_caps_new_simple ("audio/x-vorbis", NULL);
55   theora = gst_caps_new_simple ("video/x-theora", NULL);
56
57   encprof = (GstEncodingProfile *) gst_encoding_container_profile_new ((gchar *)
58       "ogg-theora-vorbis", "dumb-profile", ogg, (gchar *) "dumb-preset");
59   CHECK_PROFILE (encprof, "ogg-theora-vorbis", "dumb-profile", ogg,
60       "dumb-preset", 0, NULL);
61
62   audioprof = gst_encoding_audio_profile_new (vorbis, (gchar *) "HQ", NULL, 0);
63   CHECK_PROFILE ((GstEncodingProfile *) audioprof, NULL, NULL, vorbis, "HQ", 0,
64       NULL);
65
66   videoprof = gst_encoding_video_profile_new (theora, (gchar *) "HQ", NULL, 0);
67   CHECK_PROFILE ((GstEncodingProfile *) videoprof, NULL, NULL, theora, "HQ",
68       0, NULL);
69
70   fail_unless (gst_encoding_container_profile_add_profile (
71           (GstEncodingContainerProfile *) encprof,
72           (GstEncodingProfile *) audioprof));
73   fail_unless (gst_encoding_container_profile_add_profile (
74           (GstEncodingContainerProfile *) encprof,
75           (GstEncodingProfile *) videoprof));
76
77   /* Test caps */
78   test1 = gst_caps_from_string ("video/x-theora; audio/x-vorbis");
79   test2 = gst_encoding_profile_get_input_caps (encprof);
80   fail_unless (gst_caps_is_equal (test1, test2));
81   gst_caps_unref (test1);
82   gst_caps_unref (test2);
83
84   gst_encoding_profile_unref (encprof);
85   gst_caps_unref (ogg);
86   gst_caps_unref (theora);
87   gst_caps_unref (vorbis);
88 }
89
90 GST_END_TEST;
91
92
93 GST_START_TEST (test_profile_input_caps)
94 {
95   GstEncodingProfile *sprof;
96   GstCaps *vorbis;
97   GstCaps *out, *restriction, *test1;
98
99   vorbis = gst_caps_new_simple ("audio/x-vorbis", NULL);
100
101   /* Simple case, no restriction */
102   sprof = (GstEncodingProfile *)
103       gst_encoding_audio_profile_new (vorbis, NULL, NULL, 0);
104   fail_if (sprof == NULL);
105
106   out = gst_encoding_profile_get_input_caps (sprof);
107   fail_if (out == NULL);
108   fail_unless (gst_caps_is_equal (out, vorbis));
109   gst_caps_unref (out);
110   gst_encoding_profile_unref (sprof);
111
112   /* One simple restriction */
113   restriction = gst_caps_from_string ("audio/x-raw-int,channels=2,rate=44100");
114   test1 = gst_caps_from_string ("audio/x-vorbis,channels=2,rate=44100");
115   fail_if (restriction == NULL);
116
117   sprof = (GstEncodingProfile *)
118       gst_encoding_audio_profile_new (vorbis, NULL, restriction, 0);
119   fail_if (sprof == NULL);
120
121   out = gst_encoding_profile_get_input_caps (sprof);
122   fail_if (out == NULL);
123   GST_DEBUG ("got caps %" GST_PTR_FORMAT, out);
124   fail_unless (gst_caps_is_equal (out, test1));
125   gst_caps_unref (out);
126   gst_caps_unref (restriction);
127   gst_caps_unref (test1);
128   gst_encoding_profile_unref (sprof);
129
130   gst_caps_unref (vorbis);
131 }
132
133 GST_END_TEST;
134
135
136 GST_START_TEST (test_target_naming)
137 {
138   GstEncodingTarget *target;
139
140   /* NULL values */
141   ASSERT_CRITICAL (target = gst_encoding_target_new (NULL, NULL, NULL, NULL));
142   fail_if (target != NULL);
143   ASSERT_CRITICAL (target =
144       gst_encoding_target_new ("donkey", NULL, NULL, NULL));
145   fail_if (target != NULL);
146   ASSERT_CRITICAL (target =
147       gst_encoding_target_new (NULL, "donkey", NULL, NULL));
148   fail_if (target != NULL);
149   ASSERT_CRITICAL (target =
150       gst_encoding_target_new (NULL, NULL, "donkey", NULL));
151   fail_if (target != NULL);
152
153   /* Name and Category validation */
154
155   /* empty non-NULL strings */
156   fail_if (gst_encoding_target_new ("", "valid", "description", NULL) != NULL);
157   fail_if (gst_encoding_target_new ("valid", "", "description", NULL) != NULL);
158
159   /* don't start with a lower case ASCII character */
160   fail_if (gst_encoding_target_new ("A", "valid", "description", NULL) != NULL);
161   fail_if (gst_encoding_target_new ("3", "valid", "description", NULL) != NULL);
162   fail_if (gst_encoding_target_new ("-", "valid", "description", NULL) != NULL);
163   fail_if (gst_encoding_target_new ("!", "valid", "description", NULL) != NULL);
164   fail_if (gst_encoding_target_new (" ", "valid", "description", NULL) != NULL);
165   fail_if (gst_encoding_target_new ("valid", "A", "description", NULL) != NULL);
166   fail_if (gst_encoding_target_new ("valid", "3", "description", NULL) != NULL);
167   fail_if (gst_encoding_target_new ("valid", "-", "description", NULL) != NULL);
168   fail_if (gst_encoding_target_new ("valid", "!", "description", NULL) != NULL);
169   fail_if (gst_encoding_target_new ("valid", " ", "description", NULL) != NULL);
170
171   /* Starting with anything else is valid */
172   target = gst_encoding_target_new ("a", "valid", "description", NULL);
173   fail_if (target == NULL);
174   gst_encoding_target_unref (target);
175   target = gst_encoding_target_new ("z", "valid", "description", NULL);
176   fail_if (target == NULL);
177   gst_encoding_target_unref (target);
178   target = gst_encoding_target_new ("valid", "a", "description", NULL);
179   fail_if (target == NULL);
180   gst_encoding_target_unref (target);
181   target = gst_encoding_target_new ("valid", "z", "description", NULL);
182   fail_if (target == NULL);
183   gst_encoding_target_unref (target);
184
185   /* only inner valid characters are lower-case ASCII letters *OR* digits *OR* hyphens */
186   fail_if (gst_encoding_target_new ("aA", "valid", "description",
187           NULL) != NULL);
188   fail_if (gst_encoding_target_new ("a!", "valid", "description",
189           NULL) != NULL);
190   fail_if (gst_encoding_target_new ("space donkeys", "valid", "description",
191           NULL) != NULL);
192   fail_if (gst_encoding_target_new ("howaboutùnicode", "valid", "description",
193           NULL) != NULL);
194   fail_if (gst_encoding_target_new ("valid", "aA", "description",
195           NULL) != NULL);
196   fail_if (gst_encoding_target_new ("valid", "a!", "description",
197           NULL) != NULL);
198
199   target =
200       gst_encoding_target_new ("donkey-4-ever", "valid", "description", NULL);
201   fail_if (target == NULL);
202   gst_encoding_target_unref (target);
203   target =
204       gst_encoding_target_new ("valid", "donkey-4-ever", "description", NULL);
205   fail_if (target == NULL);
206   gst_encoding_target_unref (target);
207
208 }
209
210 GST_END_TEST;
211
212 static GstEncodingTarget *
213 create_saveload_target (const gchar * targetname)
214 {
215   GstEncodingTarget *target;
216   GstEncodingProfile *profile, *sprof;
217   GstCaps *caps, *caps2;
218
219   GST_DEBUG ("Creating target");
220
221   target = gst_encoding_target_new (targetname, "herding",
222       "Plenty of pony glitter profiles", NULL);
223   caps = gst_caps_from_string ("animal/x-pony");
224   profile =
225       (GstEncodingProfile *) gst_encoding_container_profile_new ("pony",
226       "I don't want a description !", caps, NULL);
227   gst_caps_unref (caps);
228   gst_encoding_target_add_profile (target, profile);
229
230   caps = gst_caps_from_string ("audio/x-pony-song,pretty=True");
231   caps2 = gst_caps_from_string ("audio/x-raw-int,channels=1,rate=44100");
232   sprof =
233       (GstEncodingProfile *) gst_encoding_audio_profile_new (caps, NULL, caps2,
234       1);
235   gst_encoding_container_profile_add_profile ((GstEncodingContainerProfile *)
236       profile, sprof);
237   gst_caps_unref (caps);
238   gst_caps_unref (caps2);
239
240   caps = gst_caps_from_string ("video/x-glitter,sparkling=True");
241   caps2 =
242       gst_caps_from_string
243       ("video/x-raw-yuv,width=640,height=480,framerate=15/1");
244   sprof = (GstEncodingProfile *)
245       gst_encoding_video_profile_new (caps, "seriously glittery", caps2, 0);
246   gst_encoding_video_profile_set_variableframerate ((GstEncodingVideoProfile *)
247       sprof, TRUE);
248   gst_encoding_container_profile_add_profile ((GstEncodingContainerProfile *)
249       profile, sprof);
250   gst_caps_unref (caps);
251   gst_caps_unref (caps2);
252
253   return target;
254 }
255
256 GST_START_TEST (test_target_profile)
257 {
258   GstEncodingTarget *target;
259   GstEncodingProfile *prof;
260
261   target = create_saveload_target ("myponytarget");
262
263   /* NULL isn't a valid profile name */
264   ASSERT_CRITICAL (gst_encoding_target_get_profile (target, NULL));
265
266   /* try finding a profile that doesn't exist */
267   fail_if (gst_encoding_target_get_profile (target,
268           "no-really-does-not-exist"));
269
270   /* try finding a profile that exists */
271   prof = gst_encoding_target_get_profile (target, "pony");
272   fail_if (prof == NULL);
273
274   gst_encoding_profile_unref (prof);
275   gst_encoding_target_unref (target);
276 }
277
278 GST_END_TEST;
279
280 GST_START_TEST (test_saving_profile)
281 {
282   GstEncodingTarget *orig, *loaded = NULL;
283   GstEncodingProfile *proforig, *profloaded;
284   gchar *profile_file_name;
285
286   /* Create and store a target */
287   orig = create_saveload_target ("myponytarget2");
288   GST_DEBUG ("Saving target 'myponytarget2'");
289   fail_unless (gst_encoding_target_save (orig, NULL));
290
291   /* Check we can load it */
292   profile_file_name = g_build_filename (g_get_home_dir (), ".gstreamer-0.10",
293       "encoding-profiles", "herding", "myponytarget2.gep", NULL);
294   GST_DEBUG ("Loading target from '%s'", profile_file_name);
295   loaded = gst_encoding_target_load_from_file (profile_file_name, NULL);
296   fail_unless (loaded != NULL);
297   g_free (profile_file_name);
298
299   GST_DEBUG ("Checking targets are equal");
300   /* Check targets are identical */
301   /* 1. at the target level */
302   fail_unless_equals_string (gst_encoding_target_get_name (orig),
303       gst_encoding_target_get_name (loaded));
304   fail_unless_equals_string (gst_encoding_target_get_category (orig),
305       gst_encoding_target_get_category (loaded));
306   fail_unless_equals_string (gst_encoding_target_get_description (orig),
307       gst_encoding_target_get_description (loaded));
308   fail_unless_equals_int (g_list_length ((GList *)
309           gst_encoding_target_get_profiles (loaded)), 1);
310
311   /* 2. at the profile level */
312   profloaded =
313       (GstEncodingProfile *) gst_encoding_target_get_profiles (loaded)->data;
314   proforig =
315       (GstEncodingProfile *) gst_encoding_target_get_profiles (orig)->data;
316
317   fail_unless_equals_int (G_TYPE_FROM_INSTANCE (profloaded),
318       G_TYPE_FROM_INSTANCE (proforig));
319   GST_DEBUG ("Comparing loaded:%p to original:%p", profloaded, proforig);
320   fail_unless (gst_encoding_profile_is_equal (profloaded, proforig));
321
322   gst_encoding_target_unref (orig);
323   gst_encoding_target_unref (loaded);
324 }
325
326 GST_END_TEST;
327
328 static void
329 test_individual_target (GstEncodingTarget * target)
330 {
331   GstEncodingProfile *prof;
332   GstCaps *tmpcaps, *tmpcaps2;
333   GstEncodingProfile *sprof1, *sprof2;
334
335   GST_DEBUG ("Checking the target properties");
336   /* Check the target  */
337   fail_unless_equals_string (gst_encoding_target_get_name (target),
338       "myponytarget");
339   fail_unless_equals_string (gst_encoding_target_get_category (target),
340       "herding");
341   fail_unless_equals_string (gst_encoding_target_get_description (target),
342       "Plenty of pony glitter profiles");
343
344   GST_DEBUG ("Checking the number of profiles the target contains");
345   fail_unless_equals_int (g_list_length ((GList *)
346           gst_encoding_target_get_profiles (target)), 1);
347
348
349   GST_DEBUG ("Checking the container profile");
350   /* Check the profile */
351   prof = (GstEncodingProfile *) gst_encoding_target_get_profiles (target)->data;
352   tmpcaps = gst_caps_from_string ("animal/x-pony");
353   CHECK_PROFILE (prof, "pony", "I don't want a description !", tmpcaps, NULL, 0,
354       0);
355   gst_caps_unref (tmpcaps);
356
357   GST_DEBUG ("Checking the container profile has 2 stream profiles");
358   /* Check the stream profiles */
359   fail_unless_equals_int (g_list_length ((GList *)
360           gst_encoding_container_profile_get_profiles (
361               (GstEncodingContainerProfile *) prof)), 2);
362
363   GST_DEBUG ("Checking the container profile has the audio/x-pony-song stream");
364   tmpcaps = gst_caps_from_string ("audio/x-pony-song,pretty=True");
365   tmpcaps2 = gst_caps_from_string ("audio/x-raw-int,channels=1,rate=44100");
366   sprof1 =
367       (GstEncodingProfile *) gst_encoding_audio_profile_new (tmpcaps, NULL,
368       tmpcaps2, 1);
369   fail_unless (gst_encoding_container_profile_contains_profile (
370           (GstEncodingContainerProfile *) prof, sprof1));
371   gst_encoding_profile_unref (sprof1);
372   gst_caps_unref (tmpcaps);
373   gst_caps_unref (tmpcaps2);
374
375   GST_DEBUG ("Checking the container profile has the video//x-glitter stream");
376   tmpcaps = gst_caps_from_string ("video/x-glitter,sparkling=True");
377   tmpcaps2 =
378       gst_caps_from_string
379       ("video/x-raw-yuv,width=640,height=480,framerate=15/1");
380   sprof2 = (GstEncodingProfile *)
381       gst_encoding_video_profile_new (tmpcaps, "seriously glittery", tmpcaps2,
382       0);
383   gst_encoding_video_profile_set_variableframerate ((GstEncodingVideoProfile *)
384       sprof2, TRUE);
385   fail_unless (gst_encoding_container_profile_contains_profile (
386           (GstEncodingContainerProfile *) prof, sprof2));
387   gst_encoding_profile_unref (sprof2);
388   gst_caps_unref (tmpcaps);
389   gst_caps_unref (tmpcaps2);
390 }
391
392 GST_START_TEST (test_loading_profile)
393 {
394   GstEncodingTarget *target;
395   gchar *profile_file_name;
396   GstEncodingProfile *profile;
397   GstCaps *tmpcaps;
398   GValue strvalue = { 0, };
399   GValue miniobjectvalue = { 0, };
400
401   /* Test loading using short method and all arguments */
402   target = gst_encoding_target_load ("myponytarget", "herding", NULL);
403   fail_unless (target != NULL);
404   test_individual_target (target);
405   gst_encoding_target_unref (target);
406
407   /* Test loading using short method and no category */
408   target = gst_encoding_target_load ("myponytarget", NULL, NULL);
409   fail_unless (target != NULL);
410   test_individual_target (target);
411   gst_encoding_target_unref (target);
412
413   /* Test loading using fully specified path */
414   profile_file_name = g_build_filename (g_get_home_dir (), ".gstreamer-0.10",
415       "encoding-profiles", "herding", "myponytarget.gep", NULL);
416
417   GST_DEBUG ("Loading target from '%s'", profile_file_name);
418   target = gst_encoding_target_load_from_file (profile_file_name, NULL);
419   g_free (profile_file_name);
420   fail_unless (target != NULL);
421   test_individual_target (target);
422   gst_encoding_target_unref (target);
423
424   /* Test getting the profiles directly
425    * First without category */
426   profile = gst_encoding_profile_find ("myponytarget", "pony", NULL);
427   fail_unless (profile != NULL);
428   tmpcaps = gst_caps_from_string ("animal/x-pony");
429   CHECK_PROFILE (profile, "pony", "I don't want a description !", tmpcaps, NULL,
430       0, 0);
431   gst_caps_unref (tmpcaps);
432   gst_encoding_profile_unref (profile);
433
434   /* Then with a specific category */
435   profile = gst_encoding_profile_find ("myponytarget", "pony", "herding");
436   fail_unless (profile != NULL);
437   tmpcaps = gst_caps_from_string ("animal/x-pony");
438   CHECK_PROFILE (profile, "pony", "I don't want a description !", tmpcaps, NULL,
439       0, 0);
440   gst_caps_unref (tmpcaps);
441   gst_encoding_profile_unref (profile);
442
443   /* For my next trick, I will need the assistance of a GValue */
444   g_value_init (&strvalue, G_TYPE_STRING);
445   g_value_init (&miniobjectvalue, GST_TYPE_ENCODING_PROFILE);
446   g_value_set_static_string (&strvalue, "myponytarget/pony");
447   fail_unless (g_value_transform (&strvalue, &miniobjectvalue));
448   profile = (GstEncodingProfile *) gst_value_dup_mini_object (&miniobjectvalue);
449   fail_if (profile == NULL);
450   g_value_unset (&strvalue);
451   g_value_unset (&miniobjectvalue);
452   tmpcaps = gst_caps_from_string ("animal/x-pony");
453   CHECK_PROFILE (profile, "pony", "I don't want a description !", tmpcaps, NULL,
454       0, 0);
455   gst_caps_unref (tmpcaps);
456   gst_encoding_profile_unref (profile);
457
458   /* Let's go crazy for error detection */
459   fail_if (gst_encoding_profile_find ("myponytarget", "whales", NULL));
460   fail_if (gst_encoding_profile_find ("myponytarget", "whales", "herding"));
461   fail_if (gst_encoding_profile_find ("myponytarget", "", NULL));
462   fail_if (gst_encoding_profile_find ("", "pony", NULL));
463 }
464
465 GST_END_TEST;
466
467 GST_START_TEST (test_target_list)
468 {
469   GList *categories;
470   GList *targets;
471   GList *tmp;
472
473   /* Make sure we get our test category in the available categories */
474   categories = gst_encoding_list_available_categories ();
475   fail_if (categories == NULL);
476   fail_if (g_list_find_custom (categories, "herding",
477           (GCompareFunc) g_strcmp0) == NULL);
478   g_list_foreach (categories, (GFunc) g_free, NULL);
479   g_list_free (categories);
480
481   /* Try getting all available targets with a specified category */
482   targets = gst_encoding_list_all_targets ("herding");
483   fail_if (targets == NULL);
484   for (tmp = targets; tmp; tmp = tmp->next) {
485     GstEncodingTarget *target = (GstEncodingTarget *) tmp->data;
486     if (!g_strcmp0 (gst_encoding_target_get_name (target), "myponytarget"))
487       break;
488   }
489   /* If tmp is NULL, it means we iterated the whole list without finding
490    * our target */
491   fail_if (tmp == NULL);
492   g_list_foreach (targets, (GFunc) gst_mini_object_unref, NULL);
493   g_list_free (targets);
494
495   /* Try getting all available targets without a specified category */
496   targets = gst_encoding_list_all_targets (NULL);
497   fail_if (targets == NULL);
498   for (tmp = targets; tmp; tmp = tmp->next) {
499     GstEncodingTarget *target = (GstEncodingTarget *) tmp->data;
500     if (!g_strcmp0 (gst_encoding_target_get_name (target), "myponytarget"))
501       break;
502   }
503   /* If tmp is NULL, it means we iterated the whole list without finding
504    * our target */
505   fail_if (tmp == NULL);
506   g_list_foreach (targets, (GFunc) gst_mini_object_unref, NULL);
507   g_list_free (targets);
508 }
509
510 GST_END_TEST;
511
512
513 static const gchar *profile_string = "\
514 [GStreamer Encoding Target]\n\
515 name=myponytarget\n\
516 category=herding\n\
517 description=Plenty of pony glitter profiles\n\
518 \n\
519 [profile-pony1]\n\
520 name=pony\n\
521 type=container\n\
522 description=I don't want a description !\n\
523 format=animal/x-pony\n\
524 \n\
525 [streamprofile-pony11]\n\
526 parent=pony\n\
527 type=audio\n\
528 format=audio/x-pony-song,pretty=True\n\
529 restriction=audio/x-raw-int,channels=1,rate=44100\n\
530 presence=1\n\
531 \n\
532 [streamprofile-pony12]\n\
533 parent=pony\n\
534 type=video\n\
535 preset=seriously glittery\n\
536 format=video/x-glitter,sparkling=True\n\
537 restriction=video/x-raw-yuv,width=640,height=480,framerate=15/1\n\
538 presence=0\n\
539 variableframerate=true\n\
540 ";
541
542 static void
543 remove_profile_file (void)
544 {
545   gchar *profile_file_name;
546
547   profile_file_name = g_build_filename (g_get_home_dir (), ".gstreamer-0.10",
548       "encoding-profiles", "herding", "myponytarget.gep", NULL);
549   g_unlink (profile_file_name);
550   g_free (profile_file_name);
551   profile_file_name = g_build_filename (g_get_home_dir (), ".gstreamer-0.10",
552       "encoding-profiles", "herding", "myponytarget2.gep", NULL);
553   g_unlink (profile_file_name);
554   g_free (profile_file_name);
555 }
556
557 static void
558 create_profile_file (void)
559 {
560   gchar *profile_file_name;
561   gchar *profile_dir;
562   GError *error = NULL;
563
564   profile_dir =
565       g_build_filename (g_get_home_dir (), ".gstreamer-0.10",
566       "encoding-profiles", "herding", NULL);
567   profile_file_name =
568       g_build_filename (g_get_home_dir (), ".gstreamer-0.10",
569       "encoding-profiles", "herding", "myponytarget.gep", NULL);
570   g_mkdir_with_parents (profile_dir, S_IRUSR | S_IWUSR | S_IXUSR);
571   if (!g_file_set_contents (profile_file_name, profile_string,
572           strlen (profile_string), &error))
573     GST_WARNING ("Couldn't write contents to file : %s", error->message);
574   g_free (profile_dir);
575   g_free (profile_file_name);
576 }
577
578 static void
579 test_setup (void)
580 {
581   create_profile_file ();
582 }
583
584 static void
585 test_teardown (void)
586 {
587   remove_profile_file ();
588 }
589
590
591 static Suite *
592 profile_suite (void)
593 {
594   Suite *s = suite_create ("profile support library");
595   TCase *tc_chain = tcase_create ("general");
596   gboolean can_write;
597   gchar *gst_dir;
598
599   /* cehck if we can create profiles */
600   gst_dir = g_build_filename (g_get_home_dir (), ".gstreamer-0.10", NULL);
601   can_write = (g_access (gst_dir, R_OK | W_OK | X_OK) == 0);
602   g_free (gst_dir);
603
604   suite_add_tcase (s, tc_chain);
605
606   tcase_add_test (tc_chain, test_profile_creation);
607   tcase_add_test (tc_chain, test_profile_input_caps);
608   tcase_add_test (tc_chain, test_target_naming);
609   tcase_add_test (tc_chain, test_target_profile);
610   if (can_write) {
611     tcase_add_test (tc_chain, test_loading_profile);
612     tcase_add_test (tc_chain, test_saving_profile);
613     tcase_add_test (tc_chain, test_target_list);
614   }
615
616   tcase_add_unchecked_fixture (tc_chain, test_setup, test_teardown);
617
618   return s;
619 }
620
621 GST_CHECK_MAIN (profile);