diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2009-04-21 16:30:34 +0200 |
---|---|---|
committer | Wim Taymans <wim@metal.(none)> | 2009-05-12 00:07:06 +0200 |
commit | 2aaf72d259701c4437b7c24e4903084b93bdb79b (patch) | |
tree | e10946ddd54e9671c9c08617910b3207ab42c512 | |
parent | b59045aab9fb9fe042670085ecc2b426717770a2 (diff) |
tests: add a unit-test for the stream-status
Add a unit test for the STREAM_STATUS messages.
-rw-r--r-- | tests/check/gst/gstmessage.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/check/gst/gstmessage.c b/tests/check/gst/gstmessage.c index 39bae402de..dc9a571435 100644 --- a/tests/check/gst/gstmessage.c +++ b/tests/check/gst/gstmessage.c @@ -186,6 +186,60 @@ GST_START_TEST (test_parsing) void gst_message_parse_warning (GstMessage *message, GError **gerror, gchar **debug); */ + /* GST_MESSAGE_STREAM_STATUS */ + { + GstStreamStatusType type; + GstTask *task, *task2; + GValue value = { 0 }; + const GValue *val; + + message = + gst_message_new_stream_status (NULL, GST_STREAM_STATUS_TYPE_ENTER, + NULL); + fail_if (message == NULL); + fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STREAM_STATUS); + fail_unless (GST_MESSAGE_SRC (message) == NULL); + + /* set some wrong values to check if the parse method overwrites them + * with the good values */ + type = GST_STREAM_STATUS_TYPE_START; + gst_message_parse_stream_status (message, &type, NULL); + fail_unless (type == GST_STREAM_STATUS_TYPE_ENTER); + + /* create a task with some dummy function, we're not actually going to run + * the task here */ + task = gst_task_create ((GstTaskFunction) gst_object_unref, NULL); + + ASSERT_OBJECT_REFCOUNT (task, "task", 1); + + /* set the task */ + g_value_init (&value, GST_TYPE_TASK); + g_value_set_object (&value, task); + + ASSERT_OBJECT_REFCOUNT (task, "task", 2); + + gst_message_set_stream_status_object (message, &value); + ASSERT_OBJECT_REFCOUNT (task, "task", 3); + g_value_unset (&value); + ASSERT_OBJECT_REFCOUNT (task, "task", 2); + gst_object_unref (task); + ASSERT_OBJECT_REFCOUNT (task, "task", 1); + + /* get the object back, no refcount is changed */ + val = gst_message_get_stream_status_object (message); + ASSERT_OBJECT_REFCOUNT (task, "task", 1); + + task2 = g_value_get_object (val); + + fail_unless (GST_IS_TASK (task2)); + fail_unless (task2 == task); + + ASSERT_OBJECT_REFCOUNT (task, "task", 1); + ASSERT_OBJECT_REFCOUNT (task2, "task", 1); + + gst_message_unref (message); + } + /* GST_MESSAGE_REQUEST_STATE */ { GstState state; |