1 /* GStreamer unit tests for playsink
2 * Copyright (C) 2015 Matthew Waters <matthew@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
26
GST_START_TEST(test_initial_statistics)27 GST_START_TEST (test_initial_statistics)
28 {
29 GstElement *urisrc;
30 GstStructure *stats = NULL;
31 guint min_bytes, max_bytes, avg_bytes;
32 guint64 min_time, max_time, avg_time;
33
34 urisrc = gst_element_factory_make ("urisourcebin", NULL);
35 fail_unless (urisrc != NULL);
36
37 g_object_get (urisrc, "statistics", &stats, NULL);
38
39 fail_unless (stats != NULL);
40 fail_unless (g_strcmp0 (gst_structure_get_name (stats),
41 "application/x-urisourcebin-stats") == 0);
42 fail_unless_equals_int (6, gst_structure_n_fields (stats));
43
44 fail_unless_equals_int (TRUE, gst_structure_get_uint (stats,
45 "minimum-byte-level", &min_bytes));
46 fail_unless_equals_int (0, min_bytes);
47 fail_unless_equals_int (TRUE, gst_structure_get_uint (stats,
48 "maximum-byte-level", &max_bytes));
49 fail_unless_equals_int (0, max_bytes);
50 fail_unless_equals_int (TRUE, gst_structure_get_uint (stats,
51 "average-byte-level", &avg_bytes));
52 fail_unless_equals_int (0, avg_bytes);
53
54 fail_unless_equals_int (TRUE, gst_structure_get_uint64 (stats,
55 "minimum-time-level", &min_time));
56 fail_unless_equals_int (0, min_time);
57 fail_unless_equals_int (TRUE, gst_structure_get_uint64 (stats,
58 "maximum-time-level", &max_time));
59 fail_unless_equals_int (0, max_time);
60 fail_unless_equals_int (TRUE, gst_structure_get_uint64 (stats,
61 "average-time-level", &avg_time));
62 fail_unless_equals_int (0, avg_time);
63
64 gst_structure_free (stats);
65 gst_object_unref (urisrc);
66 }
67
68 GST_END_TEST;
69
GST_START_TEST(test_get_set_watermark)70 GST_START_TEST (test_get_set_watermark)
71 {
72 GstElement *urisrc;
73 gdouble watermark;
74
75 urisrc = gst_element_factory_make ("urisourcebin", NULL);
76 fail_unless (urisrc != NULL);
77
78 g_object_set (urisrc, "low-watermark", 0.2, "high-watermark", 0.8, NULL);
79 g_object_get (urisrc, "low-watermark", &watermark, NULL);
80 fail_unless_equals_float (watermark, 0.2);
81 g_object_get (urisrc, "high-watermark", &watermark, NULL);
82 fail_unless_equals_float (watermark, 0.8);
83
84 gst_object_unref (urisrc);
85 }
86
87 GST_END_TEST;
88
89 static Suite *
urisourcebin_suite(void)90 urisourcebin_suite (void)
91 {
92 Suite *s = suite_create ("urisourcebin");
93 TCase *tc_chain = tcase_create ("general");
94
95 suite_add_tcase (s, tc_chain);
96
97 tcase_add_test (tc_chain, test_initial_statistics);
98 tcase_add_test (tc_chain, test_get_set_watermark);
99
100 return s;
101 }
102
103 GST_CHECK_MAIN (urisourcebin);
104