[gssdp] tests: Add regression test for bgo#673150
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gssdp] tests: Add regression test for bgo#673150
- Date: Thu, 3 May 2012 08:42:49 +0000 (UTC)
commit d3041f261a066e87d838fb14f17a6ee43b025e00
Author: Jens Georg <mail jensge org>
Date: Fri Mar 30 13:12:45 2012 +0200
tests: Add regression test for bgo#673150
configure.ac | 1 +
tests/Makefile.am | 2 +
tests/gtest/Makefile.am | 18 +++++++
tests/gtest/test-regression.c | 113 +++++++++++++++++++++++++++++++++++++++++
4 files changed, 134 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 4de526a..1c48a0a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -93,6 +93,7 @@ Makefile
libgssdp/Makefile
tools/Makefile
tests/Makefile
+tests/gtest/Makefile
doc/Makefile
doc/version.xml
gssdp-1.0.pc
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9f47337..5c0809f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,3 +1,5 @@
+SUBDIRS = gtest
+
AM_CFLAGS = $(LIBGSSDP_CFLAGS) -I$(top_srcdir)
noinst_PROGRAMS = test-browser test-publish
diff --git a/tests/gtest/Makefile.am b/tests/gtest/Makefile.am
new file mode 100644
index 0000000..a9498a4
--- /dev/null
+++ b/tests/gtest/Makefile.am
@@ -0,0 +1,18 @@
+TESTS_ENVIRONMENT = G_SLICE=debug-blocks \
+ LD_LIBRARY_PATH=$(top_builddir)/libgssdp/.libs
+
+TESTS=$(check_PROGRAMS)
+
+check_PROGRAMS = test-regression
+
+test_regression_SOURCES = test-regression.c
+
+LDADD = \
+ $(top_builddir)/libgssdp/libgssdp-1.0.la \
+ $(LIBGSSDP_LIBS)
+
+AM_CFLAGS = \
+ $(LIBGSSDP_CFLAGS) \
+ -I $(top_srcdir) \
+ -DDATA_PATH="\"$(srcdir)\""
+
diff --git a/tests/gtest/test-regression.c b/tests/gtest/test-regression.c
new file mode 100644
index 0000000..ec1b967
--- /dev/null
+++ b/tests/gtest/test-regression.c
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2012 Openismus GmbH
+ *
+ * Author: Jens Georg <jensg openismus com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#define UUID_1 "uuid:81909e94-ebf4-469e-ac68-81f2f189de1b"
+#define USN "urn:org-gupnp:device:RegressionTest673150:2"
+#define USN_1 "urn:org-gupnp:device:RegressionTest673150:1"
+
+#include <libgssdp/gssdp-resource-browser.h>
+#include <libgssdp/gssdp-resource-group.h>
+
+static void
+on_test_bgo673150_resource_unavailable (GSSDPResourceBrowser *src,
+ const char *usn)
+{
+ g_assert_not_reached ();
+}
+
+static gboolean
+on_test_bgo673150_delay_timeout (gpointer user_data)
+{
+ GSSDPResourceBrowser *browser = GSSDP_RESOURCE_BROWSER (user_data);
+
+ gssdp_resource_browser_set_active (browser, TRUE);
+ g_assert (gssdp_resource_browser_get_active (browser));
+
+ return FALSE;
+}
+
+static void
+test_bgo673150 (void)
+{
+ GSSDPClient *dest, *src;
+ GSSDPResourceBrowser *browser;
+ GSSDPResourceGroup *group;
+ GError *error = NULL;
+ GMainLoop *loop;
+ gulong signal_id;
+
+ dest = gssdp_client_new (NULL, "lo", &error);
+ g_assert (dest != NULL);
+ g_assert (error == NULL);
+
+ src = gssdp_client_new (NULL, "lo", &error);
+ g_assert (src != NULL);
+ g_assert (error == NULL);
+
+ group = gssdp_resource_group_new (src);
+ gssdp_resource_group_add_resource_simple (group,
+ USN,
+ UUID_1"::"USN,
+ "http://127.0.0.1:3456");
+ gssdp_resource_group_set_max_age (group, 10);
+
+ browser = gssdp_resource_browser_new (dest, USN_1);
+
+ signal_id = g_signal_connect (browser,
+ "resource-unavailable",
+ G_CALLBACK (on_test_bgo673150_resource_unavailable),
+ NULL);
+
+ /* Delay resource browser until ressource group sent its initial
+ * announcement */
+ g_timeout_add_seconds (5, on_test_bgo673150_delay_timeout, browser);
+
+ gssdp_resource_group_set_available (group, TRUE);
+
+ g_assert (gssdp_resource_group_get_available (group));
+
+ loop = g_main_loop_new (NULL, FALSE);
+ g_timeout_add_seconds (30, (GSourceFunc) g_main_loop_quit, loop);
+ g_main_loop_run (loop);
+
+ /* prevent the _unref from triggering the assertion */
+ g_signal_handler_disconnect (browser, signal_id);
+ g_object_unref (group);
+ g_object_unref (browser);
+ g_object_unref (src);
+ g_object_unref (dest);
+ g_main_loop_unref (loop);
+}
+
+int main (int argc, char *argv[])
+{
+ g_type_init ();
+ g_test_init (&argc, &argv, NULL);
+
+ if (g_test_slow ()) {
+ g_test_add_func ("/bugs/gnome/673150",
+ test_bgo673150);
+ }
+
+ g_test_run ();
+
+ return 0;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]