2 * Copyright (C) <2012> Intel Corporation
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.
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.
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., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
20 #include <gst/check/gstcheck.h>
21 #include <gst/policy/gstpolicy.h>
25 test_pads (GstElement * policy)
30 sinkpad1 = gst_element_get_request_pad (policy, "sink_%d");
32 assert_equals_int (policy->numpads, 2);
33 assert_equals_int (policy->numsinkpads, 1);
34 assert_equals_int (policy->numsrcpads, 1);
36 sinkpad2 = gst_element_get_request_pad (policy, "sink_%d");
38 assert_equals_int (policy->numpads, 4);
39 assert_equals_int (policy->numsinkpads, 2);
40 assert_equals_int (policy->numsrcpads, 2);
42 gst_element_release_request_pad (policy, sinkpad2);
43 g_object_unref (sinkpad2);
44 assert_equals_int (policy->numpads, 2);
45 assert_equals_int (policy->numsinkpads, 1);
46 assert_equals_int (policy->numsrcpads, 1);
48 gst_element_release_request_pad (policy, sinkpad1);
49 g_object_unref (sinkpad1);
50 assert_equals_int (policy->numpads, 0);
51 assert_equals_int (policy->numsinkpads, 0);
52 assert_equals_int (policy->numsrcpads, 0);
55 GST_START_TEST (test_autopolicy)
61 policy = gst_check_setup_element ("autopolicy");
66 gst_child_proxy_set (GST_OBJECT (policy), "actual-policy::role", role1,
68 gst_child_proxy_get (GST_OBJECT (policy), "actual-policy::role", &role2,
70 assert_equals_string (role1, role2);
73 gst_check_teardown_element (policy);
79 GST_START_TEST (test_defaultpolicy)
85 policy = gst_check_setup_element ("defaultpolicy");
90 g_object_set (policy, "role", role1, NULL);
91 g_object_get (policy, "role", &role2, NULL);
92 assert_equals_string (role1, role2);
95 gst_check_teardown_element (policy);
103 Suite *s = suite_create ("policy");
104 TCase *tc_chain = tcase_create ("general");
106 suite_add_tcase (s, tc_chain);
107 tcase_add_test (tc_chain, test_defaultpolicy);
108 tcase_add_test (tc_chain, test_autopolicy);
113 GST_CHECK_MAIN (policy);