1 /* GStreamer unit test for the gdkpixbufoverlay element
2 * Copyright (C) 2015 Tim-Philipp Müller <tim centricular com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifdef HAVE_CONFIG_H
21 # include "config.h"
22 #endif
23
24 #include <gst/check/gstcheck.h>
25
GST_START_TEST(test_simple_overlay)26 GST_START_TEST (test_simple_overlay)
27 {
28 GstElement *pipeline, *src, *overlay, *sink;
29 GstMessage *msg;
30 GstBus *bus;
31
32 src = gst_element_factory_make ("videotestsrc", NULL);
33 fail_unless (src != NULL);
34 g_object_set (src, "num-buffers", 3, NULL);
35
36 overlay = gst_element_factory_make ("gdkpixbufoverlay", NULL);
37 fail_unless (overlay != NULL);
38
39 #define IMAGE_PATH GST_TEST_FILES_PATH G_DIR_SEPARATOR_S "image.jpg"
40 g_object_set (overlay, "location", IMAGE_PATH, NULL);
41
42 sink = gst_element_factory_make ("fakesink", NULL);
43 fail_unless (sink != NULL);
44
45 pipeline = gst_pipeline_new (NULL);
46 gst_bin_add_many (GST_BIN (pipeline), src, overlay, sink, NULL);
47 gst_element_link_many (src, overlay, sink, NULL);
48
49 /* start prerolling */
50 fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_PLAYING),
51 GST_STATE_CHANGE_ASYNC);
52
53 bus = gst_element_get_bus (pipeline);
54
55 /* wait for EOS */
56 msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_EOS);
57 gst_message_unref (msg);
58
59 fail_unless_equals_int (gst_element_set_state (pipeline, GST_STATE_NULL),
60 GST_STATE_CHANGE_SUCCESS);
61
62 gst_object_unref (bus);
63 gst_object_unref (pipeline);
64 }
65
66 GST_END_TEST;
67
68 static Suite *
gdkpixbufoverlay_suite(void)69 gdkpixbufoverlay_suite (void)
70 {
71 Suite *s = suite_create ("gdkpixbufoverlay");
72 TCase *tc_chain = tcase_create ("general");
73
74 suite_add_tcase (s, tc_chain);
75 tcase_add_test (tc_chain, test_simple_overlay);
76
77 return s;
78 }
79
80 GST_CHECK_MAIN (gdkpixbufoverlay);
81