[gtksourceview] Added unit test case checking bug 634510.



commit fe5c83f56b5f3fb2ca95d4f030cc20319a7d84b5
Author: Krzesimir Nowak <qdlacz gmail com>
Date:   Fri Nov 12 23:00:12 2010 +0100

    Added unit test case checking bug 634510.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=634510

 tests/Makefile.am   |    7 +++++++
 tests/test-buffer.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4e4e1c2..b409a23 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -41,6 +41,13 @@ test_printcompositor_LDADD = 		\
 	$(DEP_LIBS)			\
 	$(TESTS_LIBS)
 
+UNIT_TEST_PROGS += test-buffer
+test_buffer_SOURCES = test-buffer.c
+test_buffer_LDADD = 		\
+	$(top_builddir)/gtksourceview/libgtksourceview-3.0.la \
+	$(DEP_LIBS)			\
+	$(TESTS_LIBS)
+
 python_tests =			\
 	test-completion.py	\
 	test-widget.py
diff --git a/tests/test-buffer.c b/tests/test-buffer.c
new file mode 100644
index 0000000..a45c665
--- /dev/null
+++ b/tests/test-buffer.c
@@ -0,0 +1,47 @@
+#include "config.h"
+#include <string.h>
+#include <stdlib.h>
+
+#include <gtk/gtk.h>
+#include <gtksourceview/gtksourcebuffer.h>
+#include <gtksourceview/gtksourceview.h>
+
+static void
+test_get_buffer (void)
+{
+	GtkWidget* view;
+	GtkSourceBuffer* buffer;
+
+	view = gtk_source_view_new ();
+
+	buffer = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
+
+	g_assert (buffer != NULL);
+	g_assert (GTK_IS_SOURCE_BUFFER (buffer));
+
+	if (g_object_is_floating (view))
+	{
+		g_object_ref_sink (view);
+	}
+
+	/* Here we check if notify_buffer recreates the buffer while view is being
+	 * destroyed, which causes assertion failure in GtkTextView's finalize ()
+	 * function.
+	 * Please see: https://bugzilla.gnome.org/show_bug.cgi?id=634510 */
+	if (g_test_trap_fork (0, 0))
+	{
+		g_object_unref (view);
+		exit (EXIT_SUCCESS);
+	}
+	g_test_trap_assert_passed ();
+}
+
+int
+main (int argc, char** argv)
+{
+	gtk_test_init (&argc, &argv);
+
+	g_test_add_func ("/Buffer/bug-634510", test_get_buffer);
+
+	return g_test_run();
+}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]