tests/filesrc: Set location in wrong state
authorSebastian Rasmussen <sebras@hotmail.com>
Sun, 29 Sep 2013 15:35:11 +0000 (17:35 +0200)
committerOlivier CrĂȘte <olivier.crete@collabora.com>
Sun, 13 Oct 2013 16:18:57 +0000 (12:18 -0400)
Also remove incorrect comment about code possibly not being reachable
that is now exercised by the filesrc unit test.

https://bugzilla.gnome.org/show_bug.cgi?id=709831

plugins/elements/gstfilesrc.c
tests/check/elements/filesrc.c

index b68c279..fbfccc7 100644 (file)
@@ -241,7 +241,7 @@ gst_file_src_set_location (GstFileSrc * src, const gchar * location)
   g_free (src->filename);
   g_free (src->uri);
 
-  /* clear the filename if we get a NULL (is that possible?) */
+  /* clear the filename if we get a NULL */
   if (location == NULL) {
     src->filename = NULL;
     src->uri = NULL;
index 4e760f8..5487f7c 100644 (file)
@@ -342,12 +342,17 @@ GST_START_TEST (test_uri_interface)
   GstElement *src;
   gchar *location;
   GstBus *bus;
+  GstPad *pad;
 
   src = setup_filesrc ();
   bus = gst_bus_new ();
 
   gst_element_set_bus (src, bus);
 
+  g_object_set (G_OBJECT (src), "location", NULL, NULL);
+  g_object_get (G_OBJECT (src), "location", &location, NULL);
+  fail_unless (location == NULL);
+
   g_object_set (G_OBJECT (src), "location", "/i/do/not/exist", NULL);
   g_object_get (G_OBJECT (src), "location", &location, NULL);
   fail_unless_equals_string (location, "/i/do/not/exist");
@@ -390,6 +395,25 @@ GST_START_TEST (test_uri_interface)
   fail_if (gst_uri_handler_set_uri (GST_URI_HANDLER (src),
           "file://hostname/foo/foo", NULL));
 
+  g_object_set (G_OBJECT (src), "location", TESTFILE, NULL);
+
+  pad = gst_element_get_static_pad (src, "src");
+  fail_unless (pad != NULL);
+  fail_unless (gst_pad_activate_mode (pad, GST_PAD_MODE_PULL, TRUE));
+  gst_object_unref (pad);
+
+  fail_unless (gst_element_set_state (src,
+          GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
+      "could not set to playing");
+
+  ASSERT_WARNING (g_object_set (G_OBJECT (src), "location", "/wrong", NULL));
+  g_object_get (G_OBJECT (src), "location", &location, NULL);
+  fail_unless_equals_string (location, TESTFILE);
+  g_free (location);
+
+  fail_unless (gst_element_set_state (src,
+          GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null");
+
   /* cleanup */
   gst_element_set_bus (src, NULL);
   gst_object_unref (GST_OBJECT (bus));