diff --git a/tests/check/libs/test_transform.c b/tests/check/libs/test_transform.c index 0f72743199..5706f8897e 100644 --- a/tests/check/libs/test_transform.c +++ b/tests/check/libs/test_transform.c @@ -28,18 +28,7 @@ GST_STATIC_PAD_TEMPLATE ("sink", typedef struct _GstTestTrans GstTestTrans; typedef struct _GstTestTransClass GstTestTransClass; -#define GST_TYPE_TEST_TRANS \ - (gst_test_trans_get_type()) -#define GST_TEST_TRANS(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TEST_TRANS,GstTestTrans)) -#define GST_TEST_TRANS_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TEST_TRANS,GstTestTransClass)) -#define GST_TEST_TRANS_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_TEST_TRANS, GstTestTransClass)) -#define GST_IS_TEST_TRANS(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TEST_TRANS)) -#define GST_IS_TEST_TRANS_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TEST_TRANS)) +#define GST_TEST_TRANS(obj) ((GstTestTrans *)(obj)) struct _GstTestTrans { @@ -53,10 +42,6 @@ struct _GstTestTransClass GstBaseTransformClass parent_class; }; -GType gst_test_trans_get_type (void); - -G_DEFINE_TYPE (GstTestTrans, gst_test_trans, GST_TYPE_BASE_TRANSFORM); - static GstFlowReturn (*klass_transform) (GstBaseTransform * trans, GstBuffer * inbuf, GstBuffer * outbuf) = NULL; static GstFlowReturn (*klass_transform_ip) (GstBaseTransform * trans, @@ -92,6 +77,8 @@ gst_test_trans_class_init (GstTestTransClass * klass) gst_element_class_add_static_pad_template (element_class, sink_template); gst_element_class_add_static_pad_template (element_class, src_template); + GST_INFO ("setting up %s", g_type_name (((GTypeClass *) klass)->g_type)); + trans_class->passthrough_on_same_caps = klass_passthrough_on_same_caps; if (klass_transform_ip != NULL) trans_class->transform_ip = klass_transform_ip; @@ -156,9 +143,24 @@ gst_test_trans_new (void) TestTransData *res; GstPad *tmp; GstPadTemplate *templ; + GType type; + + /* we register a new sub-class for every test-run, so the class init + * function is called for every test run and can be set up properly + * even with CK_FORK=no */ + { + static gint counter = 0; + gchar name[100]; + + g_snprintf (name, sizeof (name), "GstTestTrans%d", ++counter); + + type = g_type_register_static_simple (GST_TYPE_BASE_TRANSFORM, name, + sizeof (GstTestTransClass), (GClassInitFunc) gst_test_trans_class_init, + sizeof (GstTestTrans), (GInstanceInitFunc) gst_test_trans_init, 0); + } res = g_new0 (TestTransData, 1); - res->trans = g_object_new (GST_TYPE_TEST_TRANS, NULL); + res->trans = g_object_new (type, NULL); templ = gst_static_pad_template_get (sink_template); templ->direction = GST_PAD_SRC; diff --git a/tests/check/libs/transform1.c b/tests/check/libs/transform1.c index f8f32e28c2..45e64774a8 100644 --- a/tests/check/libs/transform1.c +++ b/tests/check/libs/transform1.c @@ -96,6 +96,14 @@ GST_START_TEST (basetransform_chain_pt1) gst_test_trans_push_segment (trans); gst_test_trans_free (trans); + + klass_transform_ip = NULL; + klass_transform = NULL; + klass_transform_caps = NULL; + klass_transform_size = NULL; + klass_set_caps = NULL; + klass_submit_input_buffer = NULL; + klass_generate_output = NULL; } GST_END_TEST; @@ -879,6 +887,25 @@ GST_START_TEST (basetransform_chain_ct3) GST_END_TEST; +static void +transform1_setup (void) +{ + sink_template = &gst_test_trans_sink_template; + src_template = &gst_test_trans_src_template; +} + +static void +transform1_teardown (void) +{ + /* reset global state */ + klass_transform_ip = NULL; + klass_transform = NULL; + klass_transform_caps = NULL; + klass_transform_size = NULL; + klass_set_caps = NULL; + klass_submit_input_buffer = NULL; + klass_generate_output = NULL; +} static Suite * gst_basetransform_suite (void) @@ -887,6 +914,8 @@ gst_basetransform_suite (void) TCase *tc = tcase_create ("general"); suite_add_tcase (s, tc); + tcase_add_checked_fixture (tc, transform1_setup, transform1_teardown); + /* pass through */ tcase_add_test (tc, basetransform_chain_pt1); tcase_add_test (tc, basetransform_chain_pt2); diff --git a/tests/check/libs/transform2.c b/tests/check/libs/transform2.c index e8e746fdd6..bc1f4d01be 100644 --- a/tests/check/libs/transform2.c +++ b/tests/check/libs/transform2.c @@ -49,10 +49,13 @@ static GstFlowReturn collate_submit_input_buffer (GstBaseTransform * trans, gboolean is_discont, GstBuffer * input) { - GstFlowReturn ret = - GST_BASE_TRANSFORM_CLASS - (gst_test_trans_parent_class)->submit_input_buffer (trans, is_discont, - input); + GstBaseTransformClass *tt_parent_class; + GstFlowReturn ret; + + tt_parent_class = + g_type_class_peek_parent (GST_BASE_TRANSFORM_GET_CLASS (trans)); + + ret = tt_parent_class->submit_input_buffer (trans, is_discont, input); if (ret != GST_FLOW_OK) return ret;