tests: include config.h and don't include unix headers
[platform/upstream/gstreamer.git] / tests / check / gst / gst.c
1 /* GStreamer
2  * Copyright (C) <2005> Thomas Vander Stichele <thomas at apestaart dot org>
3  *
4  * gst.c: Unit test for gst.c
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the
18  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24
25 #include <gst/check/gstcheck.h>
26 #include <gst/gstversion.h>
27
28 GST_START_TEST (test_init)
29 {
30   /* don't segfault with NULL, NULL */
31   gst_init (NULL, NULL);
32   /* allow calling twice. well, actually, thrice. */
33   gst_init (NULL, NULL);
34 }
35
36 GST_END_TEST;
37
38 GST_START_TEST (test_deinit)
39 {
40   gst_init (NULL, NULL);
41
42   gst_deinit ();
43 }
44
45 GST_END_TEST;
46
47 GST_START_TEST (test_deinit_sysclock)
48 {
49   GstClock *clock;
50
51   gst_init (NULL, NULL);
52
53   clock = gst_system_clock_obtain ();
54   gst_object_unref (clock);
55
56   gst_deinit ();
57 }
58
59 GST_END_TEST;
60
61 /* tests if we can create an element from a compiled-in plugin */
62 GST_START_TEST (test_new_pipeline)
63 {
64   GstElement *pipeline;
65
66   pipeline = gst_pipeline_new ("pipeline");
67   gst_object_unref (pipeline);
68 }
69
70 GST_END_TEST;
71
72 /* tests if we can load an element from a plugin */
73 GST_START_TEST (test_new_fakesrc)
74 {
75   GstElement *element;
76
77   element = gst_element_factory_make ("fakesrc", NULL);
78   gst_object_unref (element);
79 }
80
81 GST_END_TEST;
82
83 GST_START_TEST (test_version)
84 {
85   guint major, minor, micro, nano;
86   gchar *version;
87
88   gst_version (&major, &minor, &micro, &nano);
89   assert_equals_int (major, GST_VERSION_MAJOR);
90
91   version = gst_version_string ();
92   fail_if (version == NULL);
93   g_free (version);
94 }
95
96 GST_END_TEST;
97
98 static Suite *
99 gst_suite (void)
100 {
101   Suite *s = suite_create ("Gst");
102   TCase *tc_chain = tcase_create ("gst tests");
103
104   suite_add_tcase (s, tc_chain);
105   tcase_add_test (tc_chain, test_init);
106   tcase_add_test (tc_chain, test_new_pipeline);
107   tcase_add_test (tc_chain, test_new_fakesrc);
108   tcase_add_test (tc_chain, test_version);
109   /* run these last so the others don't fail if CK_FORK=no is being used */
110   tcase_add_test (tc_chain, test_deinit_sysclock);
111   tcase_add_test (tc_chain, test_deinit);
112
113   return s;
114 }
115
116 GST_CHECK_MAIN (gst);