File: test-buffer.c

package info (click to toggle)
gtksourceview3 3.4.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 14,000 kB
  • sloc: ansic: 32,034; sh: 11,667; python: 548; makefile: 508; xml: 359
file content (47 lines) | stat: -rw-r--r-- 1,005 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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_SOURCE_IS_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();
}