summaryrefslogtreecommitdiff
path: root/tests/check/generic/plugin-test.c
blob: e784b2d12f617461c454beb8bbaf797c20256772 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* GStreamer
 * Copyright (C) 2009 Jan Schmidt <thaytan@noraisin.net>
 *
 * Test that the FFmpeg plugin is loadable, and not broken in some stupid
 * way.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */


#include <gst/check/gstcheck.h>
#include <stdlib.h>

GST_START_TEST (test_ffmpeg_plugin)
{
  GstPlugin *plugin = gst_plugin_load_by_name ("ffmpeg");

  fail_if (plugin == NULL, "Could not load FFmpeg plugin");

  gst_object_unref (plugin);

}

GST_END_TEST;

GST_START_TEST (test_ffmpeg_update_reg)
{
  GstElement *encoder, *muxer, *decoder;

  /* Ask for elements the first time */
  encoder = gst_element_factory_make ("ffenc_mpeg2video", "sink");
  GST_DEBUG ("Creating element ffenc_mpeg2video %p", encoder);
  fail_unless (encoder != NULL);

  decoder = gst_element_factory_make ("ffdec_mpeg2video", "sink");
  GST_DEBUG ("Creating element ffdec_mpeg2video %p", decoder);
  fail_unless (decoder != NULL);

  muxer = gst_element_factory_make ("ffmux_dvd", "sink");
  GST_DEBUG ("Creating element ffmux_dvd %p", muxer);
  fail_unless (muxer != NULL);

  gst_object_unref (encoder);
  gst_object_unref (decoder);
  gst_object_unref (muxer);

  GST_DEBUG ("calls gst_update_registry");
  gst_update_registry ();

  /* Ask for elements the second time */

  encoder = gst_element_factory_make ("ffenc_mpeg2video", "sink");
  GST_DEBUG ("Creating element ffenc_mpeg2video %p", encoder);
  fail_unless (encoder != NULL);

  decoder = gst_element_factory_make ("ffdec_mpeg2video", "sink");
  GST_DEBUG ("Creating element ffdec_mpeg2video %p", decoder);
  fail_unless (decoder != NULL);

  muxer = gst_element_factory_make ("ffmux_dvd", "sink");
  GST_DEBUG ("Creating element ffmux_dvd %p", muxer);
  fail_unless (muxer != NULL);

  gst_object_unref (encoder);
  gst_object_unref (decoder);
  gst_object_unref (muxer);
}

GST_END_TEST;

static Suite *
plugin_test_suite (void)
{
  Suite *s = suite_create ("Plugin");
  TCase *tc_chain = tcase_create ("existence");

  suite_add_tcase (s, tc_chain);

  tcase_add_test (tc_chain, test_ffmpeg_plugin);
  tcase_add_test (tc_chain, test_ffmpeg_update_reg);

  return s;
}

int
main (int argc, char **argv)
{
  SRunner *sr;
  Suite *s;
  int nf;

  gst_check_init (&argc, &argv);

  s = plugin_test_suite ();
  sr = srunner_create (s);

  srunner_run_all (sr, CK_NORMAL);
  nf = srunner_ntests_failed (sr);
  srunner_free (sr);

  return nf;
}