From ecf64a2f000ee9666a263afe23075d36bf2efe9a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 14 Jun 2010 13:54:12 -0500 Subject: Adding in a test for the pixbuf property --- tests/test-gtk-objects.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'tests/test-gtk-objects.c') diff --git a/tests/test-gtk-objects.c b/tests/test-gtk-objects.c index 561f91e..c9f9c4c 100644 --- a/tests/test-gtk-objects.c +++ b/tests/test-gtk-objects.c @@ -22,6 +22,8 @@ with this program. If not, see . #include #include +#define TEST_IMAGE SRCDIR "/" "test-gtk-objects.jpg" + /* Building the basic menu item, make sure we didn't break any core GObject stuff */ static void @@ -45,11 +47,49 @@ test_object_menuitem (void) return; } +/* Setting and getting a pixbuf */ +static void +test_object_prop_pixbuf (void) +{ + const gchar * prop_name = "image-test"; + + /* Build a menu item */ + DbusmenuMenuitem * item = dbusmenu_menuitem_new(); + + /* Test to make sure it's a happy object */ + g_assert(item != NULL); + g_assert(G_IS_OBJECT(item)); + g_assert(DBUSMENU_IS_MENUITEM(item)); + + /* Load our image */ + GdkPixbuf * pixbuf = gdk_pixbuf_new_from_file(TEST_IMAGE, NULL); + g_assert(pixbuf != NULL); + + /* Set the property */ + gboolean success = dbusmenu_menuitem_property_set_image(item, prop_name, pixbuf); + g_assert(success); + g_object_unref(pixbuf); + + /* Check to see if it's set */ + const GValue * val = dbusmenu_menuitem_property_get_value(item, prop_name); + g_assert(val != NULL); + + /* Get the pixbuf back! */ + GdkPixbuf * newpixbuf = dbusmenu_menuitem_property_get_image(item, prop_name); + g_assert(newpixbuf != NULL); + g_object_unref(newpixbuf); + + g_object_unref(item); + + return; +} + /* Build the test suite */ static void test_gtk_objects_suite (void) { g_test_add_func ("/dbusmenu/gtk/objects/menuitem/base", test_object_menuitem); + g_test_add_func ("/dbusmenu/gtk/objects/menuitem/prop_pixbuf", test_object_prop_pixbuf); return; } -- cgit v1.2.3