[farsight2/master] Added a test for fs_element_added_notifier_set_properties_from_file

Louis-Francis Ratté-Boulianne louis-francis.ratte-boulianne at collabora.co.uk
Tue Jul 14 09:51:02 PDT 2009


---
 tests/check/utils/binadded.c       |   67 ++++++++++++++++++++++++++++++++++++
 tests/check/utils/gstelements.conf |    2 +
 2 files changed, 69 insertions(+), 0 deletions(-)
 create mode 100644 tests/check/utils/gstelements.conf

diff --git a/tests/check/utils/binadded.c b/tests/check/utils/binadded.c
index 35f8640..bdde413 100644
--- a/tests/check/utils/binadded.c
+++ b/tests/check/utils/binadded.c
@@ -26,6 +26,8 @@
 #include <gst/check/gstcheck.h>
 #include <gst/farsight/fs-element-added-notifier.h>
 
+#include "testutils.h"
+
 gboolean called = FALSE;
 gpointer last_added = NULL;
 gpointer last_bin = NULL;
@@ -244,6 +246,70 @@ GST_START_TEST (test_bin_keyfile)
 }
 GST_END_TEST;
 
+GST_START_TEST (test_bin_file)
+{
+  GstElement *pipeline = NULL;
+  GstElement *identity = NULL;
+  FsElementAddedNotifier *notifier = NULL;
+  gboolean sync;
+  GError *error = NULL;
+  gchar *filename = NULL;
+
+  pipeline = gst_pipeline_new (NULL);
+
+  identity = gst_element_factory_make ("identity", NULL);
+  gst_object_ref (identity);
+
+  g_object_get (identity, "sync", &sync, NULL);
+  fail_unless (sync == FALSE, "sync prop on identity does not start at FALSE");
+
+  notifier = fs_element_added_notifier_new ();
+
+  fail_if (fs_element_added_notifier_set_properties_from_file (notifier, "invalid-filename", &error));
+  fail_if (error == NULL);
+  fail_unless (error->domain == G_FILE_ERROR);
+  g_clear_error (&error);
+
+  filename = get_fullpath ("utils/gstelements.conf");
+  fs_element_added_notifier_set_properties_from_file (notifier, filename, &error);
+
+  fs_element_added_notifier_add (notifier, GST_BIN (pipeline));
+
+  fail_unless (gst_bin_add (GST_BIN (pipeline), identity),
+      "Could not add identity to pipeline");
+
+  g_object_get (identity, "sync", &sync, NULL);
+  fail_unless (sync == TRUE, "sync prop on identity is not changed to TRUE");
+
+
+  fail_unless (gst_bin_remove (GST_BIN (pipeline), identity),
+      "Could not remove identity from pipeline");
+
+  g_object_set (identity, "sync", FALSE, NULL);
+
+  g_object_get (identity, "sync", &sync, NULL);
+  fail_unless (sync == FALSE, "sync prop on identity not reset to FALSE");
+
+  fail_unless (
+      fs_element_added_notifier_remove (notifier, GST_BIN (pipeline)),
+      "Could not remove notification");
+
+  fail_unless (gst_bin_add (GST_BIN (pipeline), identity),
+      "Could not add identity to bin");
+
+  g_object_get (identity, "sync", &sync, NULL);
+  fail_if (sync == TRUE, "sync prop on identity changed to TRUE");
+
+  fs_element_added_notifier_add (notifier, GST_BIN (pipeline));
+
+  g_object_get (identity, "sync", &sync, NULL);
+  fail_unless (sync == TRUE, "sync prop on identity is not changed to TRUE");
+
+  gst_object_unref (identity);
+  gst_object_unref (pipeline);
+}
+GST_END_TEST;
+
 GST_START_TEST (test_bin_errors)
 {
   FsElementAddedNotifier *notifier = NULL;
@@ -276,6 +342,7 @@ binadded_suite (void)
   tcase_add_test (tc_chain, test_bin_added_simple);
   tcase_add_test (tc_chain, test_bin_added_recursive);
   tcase_add_test (tc_chain, test_bin_keyfile);
+  tcase_add_test (tc_chain, test_bin_file);
   tcase_add_test (tc_chain, test_bin_errors);
 
   return s;
diff --git a/tests/check/utils/gstelements.conf b/tests/check/utils/gstelements.conf
new file mode 100644
index 0000000..35e4542
--- /dev/null
+++ b/tests/check/utils/gstelements.conf
@@ -0,0 +1,2 @@
+[identity]
+sync=true
-- 
1.5.6.5




More information about the farsight-commits mailing list