diff options
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/test-gtk-objects.c | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 6482d09..b21c346 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -217,6 +217,7 @@ test_gtk_objects_CFLAGS = \ -I $(srcdir)/.. \ $(DBUSMENUGLIB_CFLAGS) \ $(DBUSMENUGTK_CFLAGS) \ + -DSRCDIR="\"$(srcdir)\"" \ -Wall -Werror test_gtk_objects_LDADD = \ 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 <http://www.gnu.org/licenses/>. #include <libdbusmenu-glib/menuitem.h> #include <libdbusmenu-gtk/menuitem.h> +#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; } |