root/gtkimageview/tests/test-gtk-signals.c

Revision 730, 1.2 kB (checked in by bjourne, 3 years ago)

more gtk3.0 changes from #41

Line 
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; coding: utf-8 -*-
2  *
3  * This file tests GTK signals like expose_event on GtkImageView.
4  **/
5 #include <src/gtkimageview.h>
6 #include <assert.h>
7 #include "testlib/testlib.h"
8
9 /**
10  * test_expose_event_with_pixbuf:
11  *
12  * The objective of this test is simply to verify that GtkImageView
13  * doesn't crash when it is repainting a pixbuf.
14  **/
15 static void
16 test_expose_event_with_pixbuf ()
17 {
18     printf ("test_expose_event_with_pixbuf\n");
19     GtkWidget *view = gtk_image_view_new ();
20     g_object_ref_sink (view);
21     GdkPixbuf *pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 5, 5);
22
23     fake_realize (view);
24
25     GtkAllocation alloc;
26     gtk_widget_get_allocation (view, &alloc);
27     alloc.width = 100;
28     alloc.height = 100;
29     gtk_widget_set_allocation (view, &alloc);
30    
31     gtk_image_view_set_pixbuf (GTK_IMAGE_VIEW (view), pixbuf, FALSE);
32
33     GdkEventExpose ev = {.area = {0, 0, 999, 999}};
34     GTK_WIDGET_GET_CLASS (view)->expose_event (view, &ev);
35
36     g_object_unref (pixbuf);
37     gtk_widget_destroy (view);
38     g_object_unref (view);
39 }
40
41 int
42 main (int argc, char *argv[])
43 {
44     gtk_init (&argc, &argv);
45     test_expose_event_with_pixbuf ();
46     printf ("1 test passed.\n");
47 }
48
Note: See TracBrowser for help on using the browser.