validate-scenario: fix g-i warning in annotation
[platform/upstream/gstreamer.git] / tests / static-plugins / test-gst-full-features.c
1 #include <gst/gst.h>
2
3
4 void
5 assert_feature_names (gchar * names, GType feature_type, gboolean spook)
6 {
7   GstPluginFeature *feature = NULL;
8   gchar **split = NULL;
9   int i;
10
11   if (names)
12     split = g_strsplit (names, ",", 0);
13   if (split) {
14     for (i = 0; split[i]; i++) {
15       feature = gst_registry_find_feature (gst_registry_get (),
16           split[i], feature_type);
17       if (spook)
18         g_assert_null (feature);
19       else
20         g_assert_nonnull (feature);
21       if (feature)
22         gst_object_unref (feature);
23     }
24     g_strfreev (split);
25   }
26 }
27
28 int
29 main (int argc, char *argv[])
30 {
31   GOptionContext *ctx;
32   GError *err = NULL;
33   gchar *elements, *typefinds, *deviceproviders, *dynamictypes;
34   gchar *spook_elements, *spook_typefinds, *spook_deviceproviders,
35       *spook_dynamictypes;
36
37   elements = typefinds = deviceproviders = dynamictypes = NULL;
38   spook_elements = spook_typefinds = spook_deviceproviders =
39       spook_dynamictypes = NULL;
40
41   GOptionEntry options[] = {
42     {"elements", 'e', 0, G_OPTION_ARG_STRING, &elements,
43           "Element(s) which should be available. Specify multiple ones using ',' as separator",
44         NULL},
45     {"spook-elements", 'E', 0, G_OPTION_ARG_STRING, &spook_elements,
46           "Element(s) which should NOT be available. Specify multiple ones using ',' as separator",
47         NULL},
48     {"typefinds", 't', 0, G_OPTION_ARG_STRING, &typefinds,
49           "Typefind(s) which should be available. Specify multiple ones using ',' as separator",
50         NULL},
51     {"spook-typefinds", 'T', 0, G_OPTION_ARG_STRING, &spook_typefinds,
52           "Typefind(s) which should NOT be available. Specify multiple ones using ',' as separator",
53         NULL},
54     {"deviceproviders", 'd', 0, G_OPTION_ARG_STRING, &deviceproviders,
55           "Deviceprovider(s) which should be available. Specify multiple ones using ',' as separator",
56         NULL},
57     {"spook-deviceproviders", 'D', 0, G_OPTION_ARG_STRING,
58           &spook_deviceproviders,
59           "Deviceprovider(s) which should NOT be available. Specify multiple ones using ',' as separator",
60         NULL},
61     {"dynamictypes", 'l', 0, G_OPTION_ARG_STRING, &dynamictypes,
62           "Dynamictype(s) which should be available. Specify multiple ones using ',' as separator",
63         NULL},
64     {"spook-dynamictypes", 'L', 0, G_OPTION_ARG_STRING, &spook_dynamictypes,
65           "Dynamictype(s) which should NOT be available. Specify multiple ones using ',' as separator",
66         NULL},
67     {NULL}
68   };
69   ctx = g_option_context_new ("elements ...");
70   g_option_context_add_main_entries (ctx, options, NULL);
71   g_option_context_add_group (ctx, gst_init_get_option_group ());
72   if (!g_option_context_parse (ctx, &argc, &argv, &err)) {
73     g_print ("Error initializing: %s\n", GST_STR_NULL (err->message));
74     g_clear_error (&err);
75     g_option_context_free (ctx);
76     return 1;
77   }
78   g_option_context_free (ctx);
79
80   gst_init (&argc, &argv);
81
82   /* Test that elements are instanciable. */
83   assert_feature_names (elements, GST_TYPE_ELEMENT_FACTORY, FALSE);
84   /* Test that elements are NOT instanciable. */
85   assert_feature_names (spook_elements, GST_TYPE_ELEMENT_FACTORY, TRUE);
86
87   /* Test that typefinds are instanciable. */
88   assert_feature_names (typefinds, GST_TYPE_TYPE_FIND_FACTORY, FALSE);
89   /* Test that typefinds are NOT instanciable. */
90   assert_feature_names (spook_typefinds, GST_TYPE_TYPE_FIND_FACTORY, TRUE);
91
92   /* Test that device providers are instanciable. */
93   assert_feature_names (deviceproviders, GST_TYPE_DEVICE_PROVIDER_FACTORY,
94       FALSE);
95   /* Test that device providers are NOT instanciable. */
96   assert_feature_names (spook_deviceproviders, GST_TYPE_DEVICE_PROVIDER_FACTORY,
97       TRUE);
98
99   /* Test that dynamic types are instanciable. */
100   assert_feature_names (dynamictypes, GST_TYPE_DYNAMIC_TYPE_FACTORY, FALSE);
101   /* Test that dynamic types are NOT instanciable. */
102   assert_feature_names (spook_dynamictypes, GST_TYPE_DYNAMIC_TYPE_FACTORY,
103       TRUE);
104
105   gst_deinit ();
106
107   return 0;
108 }