tests: add test for extended message types and gst_bus_timed_pop_filtered
authorTim-Philipp Müller <tim@centricular.com>
Sun, 16 Mar 2014 14:08:45 +0000 (14:08 +0000)
committerTim-Philipp Müller <tim@centricular.com>
Sun, 16 Mar 2014 14:38:07 +0000 (14:38 +0000)
tests/check/gst/gstbus.c

index 870a700425e782f2b0cbaa9d90e4ce9701450dcc..6168d24e97f6d5feedc643e90d3d2c8307bc68f2 100644 (file)
@@ -390,6 +390,31 @@ GST_START_TEST (test_timed_pop)
 
 GST_END_TEST;
 
+static GType foo_device_get_type (void);
+
+typedef struct
+{
+  GstDevice device;
+} FooDevice;
+typedef struct
+{
+  GstDeviceClass device_klass;
+} FooDeviceClass;
+
+G_DEFINE_TYPE (FooDevice, foo_device, GST_TYPE_DEVICE);
+
+static void
+foo_device_class_init (FooDeviceClass * klass)
+{
+  /* nothing to do here */
+}
+
+static void
+foo_device_init (FooDevice * device)
+{
+  /* nothing to do here */
+}
+
 /* test that you get the messages with pop_filtered */
 GST_START_TEST (test_timed_pop_filtered)
 {
@@ -433,6 +458,23 @@ GST_START_TEST (test_timed_pop_filtered)
   msg = gst_bus_timed_pop_filtered (test_bus, 0, GST_MESSAGE_ERROR);
   fail_unless (msg == NULL);
 
+  send_5app_1el_1err_2app_messages (0);
+  {
+    GstDevice *device;
+
+    device = g_object_new (foo_device_get_type (), NULL);
+    msg = gst_message_new_device_added (NULL, device);
+    gst_object_unref (device);
+
+    GST_LOG ("posting device message");
+    gst_bus_post (test_bus, msg);
+  }
+  send_5app_1el_1err_2app_messages (0);
+  msg = gst_bus_timed_pop_filtered (test_bus, 0, GST_MESSAGE_EXTENDED);
+  fail_unless (msg != NULL);
+  fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_DEVICE_ADDED);
+  gst_message_unref (msg);
+
   gst_object_unref (test_bus);
 }