[farsight2/master] Add test for fs_codec_list_from_keyfile

Olivier Crête olivier.crete at collabora.co.uk
Tue Dec 23 15:26:02 PST 2008


---
 tests/check/Makefile.am     |    6 ++-
 tests/check/base/fscodec.c  |   69 +++++++++++++++++++++++++++++++++++++++++++
 tests/check/base/test1.conf |   34 +++++++++++++++++++++
 3 files changed, 107 insertions(+), 2 deletions(-)
 create mode 100644 tests/check/base/test1.conf

diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am
index d45a195..17220d8 100644
--- a/tests/check/Makefile.am
+++ b/tests/check/Makefile.am
@@ -12,7 +12,8 @@ TESTS_ENVIRONMENT = \
 	GST_PLUGIN_PATH=$(top_builddir)/gst:${GST_PLUGIN_PATH}	\
 	FS_PLUGIN_PATH=$(top_builddir)/transmitters/rawudp/.libs:$(top_builddir)/transmitters/multicast/.libs \
 	LD_LIBRARY_PATH=$(top_builddir)/gst-libs/gst/farsight/.libs:${LD_LIBRARY_PATH} \
-	UPNP_XML_PATH=$(srcdir)/upnp
+	UPNP_XML_PATH=$(srcdir)/upnp \
+	SRCDIR=$(srcdir)
 
 
 # ths core dumps of some machines have PIDs appended
@@ -30,7 +31,8 @@ SUPPRESSIONS = $(top_srcdir)/common/gst.supp
 
 EXTRA_DIST = \
 	upnp/InternetGatewayDevice.xml \
-	upnp/WANIPConnection.xml
+	upnp/WANIPConnection.xml \
+	base/tests1.conf
 
 #######
 # From here.. Its a list of our tests and their sub stuff
diff --git a/tests/check/base/fscodec.c b/tests/check/base/fscodec.c
index aa27236..2271739 100644
--- a/tests/check/base/fscodec.c
+++ b/tests/check/base/fscodec.c
@@ -198,6 +198,74 @@ GST_START_TEST (test_fscodec_null)
 }
 GST_END_TEST;
 
+static gchar *
+get_fullpath (const gchar *filename)
+{
+  if (g_getenv ("SRCDIR"))
+    return g_strdup_printf ("%s/%s", g_getenv ("SRCDIR"), filename);
+  else
+    return g_strdup (filename);
+}
+
+GST_START_TEST (test_fscodec_keyfile)
+{
+  GList *codecs = NULL;
+  GError *error = NULL;
+  gchar *filename = NULL;
+  GList *comparison = NULL;
+  FsCodec *codec = NULL;
+
+  fail_if (fs_codec_list_from_keyfile ("invalid-filename", &error));
+  fail_if (error == NULL);
+  fail_unless (error->domain == G_FILE_ERROR);
+  g_clear_error (&error);
+
+  filename = get_fullpath ("base/test1.conf");
+  codecs = fs_codec_list_from_keyfile (filename, &error);
+  g_free (filename);
+  fail_unless (error == NULL);
+  fail_if (codecs == NULL);
+
+#if 0
+  {
+    GList *item;
+    for(item = codecs; item ; item= item->next)
+    {
+      g_debug ("%s", fs_codec_to_string (item->data));
+    }
+  }
+#endif
+
+  codec = fs_codec_new (122, "TEST1", FS_MEDIA_TYPE_AUDIO, 8001);
+  codec->channels = 5;
+  fs_codec_add_optional_parameter (codec, "test3", "test4");
+  comparison = g_list_append (comparison, codec);
+
+  codec = fs_codec_new (123, "TEST2", FS_MEDIA_TYPE_VIDEO, 8002);
+  codec->channels = 6;
+  fs_codec_add_optional_parameter (codec, "test5", "test6");
+  comparison = g_list_append (comparison, codec);
+
+  codec = fs_codec_new (FS_CODEC_ID_ANY, "TEST3", FS_MEDIA_TYPE_AUDIO, 0);
+  comparison = g_list_append (comparison, codec);
+
+  codec = fs_codec_new (FS_CODEC_ID_DISABLE, "TEST4", FS_MEDIA_TYPE_AUDIO, 0);
+  comparison = g_list_append (comparison, codec);
+
+  codec = fs_codec_new (FS_CODEC_ID_ANY, "TEST5", FS_MEDIA_TYPE_AUDIO, 0);
+  comparison = g_list_append (comparison, codec);
+
+  codec = fs_codec_new (124, "TEST5", FS_MEDIA_TYPE_AUDIO, 0);
+  comparison = g_list_append (comparison, codec);
+
+  fail_unless (fs_codec_list_are_equal (codecs, comparison));
+
+  fs_codec_list_destroy (comparison);
+  fs_codec_list_destroy (codecs);
+
+}
+GST_END_TEST;
+
 static Suite *
 fscodec_suite (void)
 {
@@ -211,6 +279,7 @@ fscodec_suite (void)
   tcase_add_test (tc_chain, test_fscodec_are_equal_opt_params);
   tcase_add_test (tc_chain, test_fscodec_copy);
   tcase_add_test (tc_chain, test_fscodec_null);
+  tcase_add_test (tc_chain, test_fscodec_keyfile);
 
   return s;
 }
diff --git a/tests/check/base/test1.conf b/tests/check/base/test1.conf
new file mode 100644
index 0000000..43b2421
--- /dev/null
+++ b/tests/check/base/test1.conf
@@ -0,0 +1,34 @@
+[audio/TEST1]
+id=122
+clock-rate=8001
+channels=5
+test3=test4
+
+[video/TEST2]
+id=123
+clock-rate=8002
+channels=6
+test5=test6
+
+[audio/TEST3]
+
+[audio/TEST4]
+id=-1
+
+[audio/TEST5]
+id=asdas
+clock-rate=das
+channels=asd
+channels=1asd
+channels=1asd2
+
+[audio/TEST5:1]
+id=124
+
+[asdas]
+adsas=11
+clock-rate=dsa
+
+[daasd/asdsa]
+asdasd=11
+channels=1das
-- 
1.5.6.5




More information about the farsight-commits mailing list