aboutsummaryrefslogtreecommitdiff
path: root/tests/test-gtk-objects.c
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-06-14 13:54:12 -0500
committerTed Gould <ted@gould.cx>2010-06-14 13:54:12 -0500
commitecf64a2f000ee9666a263afe23075d36bf2efe9a (patch)
tree9e0cc10cc689133edff1c20bec95e687d6a5fbbc /tests/test-gtk-objects.c
parentc78d1b4b827e13ee4e498516e14a56571e8a8b5f (diff)
downloadlibdbusmenu-ecf64a2f000ee9666a263afe23075d36bf2efe9a.tar.gz
libdbusmenu-ecf64a2f000ee9666a263afe23075d36bf2efe9a.tar.bz2
libdbusmenu-ecf64a2f000ee9666a263afe23075d36bf2efe9a.zip
Adding in a test for the pixbuf property
Diffstat (limited to 'tests/test-gtk-objects.c')
-rw-r--r--tests/test-gtk-objects.c40
1 files changed, 40 insertions, 0 deletions
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;
}