From 094553712ca5087ccba1df594643c0538e7d1aaa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 13 May 2009 23:14:22 -0500 Subject: First parts of some tests to test the properties. --- tests/Makefile.am | 38 ++++++++++++++- tests/test-glib-properties-client.c | 9 ++++ tests/test-glib-properties-server.c | 9 ++++ tests/test-glib-properties.h | 95 +++++++++++++++++++++++++++++++++++++ 4 files changed, 149 insertions(+), 2 deletions(-) create mode 100644 tests/test-glib-properties-client.c create mode 100644 tests/test-glib-properties-server.c create mode 100644 tests/test-glib-properties.h (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index ca0bd77..1f21141 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,12 +2,14 @@ check: tests DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf -tests: test-glib-layout +tests: test-glib-layout test-glib-properties libexec_PROGRAMS = \ glib-server-nomenu \ test-glib-layout-client \ - test-glib-layout-server + test-glib-layout-server \ + test-glib-properties-client \ + test-glib-properties-server glib_server_nomenu_SOURCES = \ glib-server-nomenu.c @@ -20,10 +22,13 @@ glib_server_nomenu_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ $(DBUSMENUGLIB_LIBS) + + test-glib-layout: test-glib-layout-client test-glib-layout-server $(DBUS_RUNNER) --task ./test-glib-layout-client --task-name Client --task ./test-glib-layout-server --task-name Server --ignore-return test_glib_layout_server_SOURCES = \ + test-glib-layout.h \ test-glib-layout-server.c test_glib_layout_server_CFLAGS = \ @@ -35,6 +40,7 @@ test_glib_layout_server_LDADD = \ $(DBUSMENUGLIB_LIBS) test_glib_layout_client_SOURCES = \ + test-glib-layout.h \ test-glib-layout-client.c test_glib_layout_client_CFLAGS = \ @@ -47,6 +53,34 @@ test_glib_layout_client_LDADD = \ +test-glib-properties: test-glib-properties-client test-glib-properties-server + $(DBUS_RUNNER) --task ./test-glib-properties-client --task-name Client --task ./test-glib-properties-server --task-name Server --ignore-return + +test_glib_properties_server_SOURCES = \ + test-glib-properties.h \ + test-glib-properties-server.c + +test_glib_properties_server_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_glib_properties_server_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + $(DBUSMENUGLIB_LIBS) + +test_glib_properties_client_SOURCES = \ + test-glib-properties.h \ + test-glib-properties-client.c + +test_glib_properties_client_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_glib_properties_client_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + $(DBUSMENUGLIB_LIBS) + + examplesdir = $(docdir)/examples/ diff --git a/tests/test-glib-properties-client.c b/tests/test-glib-properties-client.c new file mode 100644 index 0000000..bcbd170 --- /dev/null +++ b/tests/test-glib-properties-client.c @@ -0,0 +1,9 @@ + +#include "test-glib-properties.h" + +int +main (int argc, char * argv[]) +{ + + return 0; +} diff --git a/tests/test-glib-properties-server.c b/tests/test-glib-properties-server.c new file mode 100644 index 0000000..bcbd170 --- /dev/null +++ b/tests/test-glib-properties-server.c @@ -0,0 +1,9 @@ + +#include "test-glib-properties.h" + +int +main (int argc, char * argv[]) +{ + + return 0; +} diff --git a/tests/test-glib-properties.h b/tests/test-glib-properties.h new file mode 100644 index 0000000..3ab7ee7 --- /dev/null +++ b/tests/test-glib-properties.h @@ -0,0 +1,95 @@ + +#include + +typedef struct _proplayout_t proplayout_t; +struct _proplayout_t { + guint id; + gchar ** properties; + proplayout_t * submenu; +}; + +gchar * props1[] = {"property1", "value1", "property2", "value2", NULL}; +gchar * props2[] = {"property00", "value00", "property01", "value01", "property02", "value02", "property03", "value03", "property04", "value04", + "property05", "value05", "property06", "value06", "property07", "value07", "property08", "value08", "property09", "value09", + "property10", "value10", "property11", "value11", "property12", "value12", "property13", "value13", "property14", "value14", + "property15", "value15", "property16", "value16", "property17", "value17", "property18", "value18", "property19", "value19", + "property20", "value20", "property21", "value21", "property22", "value22", "property23", "value23", "property24", "value24", + "property25", "value25", "property26", "value26", "property27", "value27", "property28", "value28", "property29", "value29", + "property30", "value30", "property31", "value31", "property32", "value32", "property33", "value33", "property34", "value34", + "property35", "value35", "property36", "value36", "property37", "value37", "property38", "value38", "property39", "value39", + "property40", "value40", "property41", "value41", "property42", "value42", "property43", "value43", "property44", "value44", + "property45", "value45", "property46", "value46", "property47", "value47", "property48", "value48", "property49", "value49", + "property50", "value50", "property51", "value51", "property52", "value52", "property53", "value53", "property54", "value54", + "property55", "value55", "property56", "value56", "property57", "value57", "property58", "value58", "property59", "value59", + "property60", "value60", "property61", "value61", "property62", "value62", "property63", "value63", "property64", "value64", + "property65", "value65", "property66", "value66", "property67", "value67", "property68", "value68", "property69", "value69", + "property70", "value70", "property71", "value71", "property72", "value72", "property73", "value73", "property74", "value74", + "property75", "value75", "property76", "value76", "property77", "value77", "property78", "value78", "property79", "value79", + "property80", "value80", "property81", "value81", "property82", "value82", "property83", "value83", "property84", "value84", + "property85", "value85", "property86", "value86", "property87", "value87", "property88", "value88", "property89", "value89", + "property90", "value90", "property91", "value91", "property92", "value92", "property93", "value93", "property94", "value94", + "property95", "value95", "property96", "value96", "property97", "value97", "property98", "value98", "property99", "value99", + NULL}; +gchar * props3[] = {"property name that is really long and will ensure that we can really have long property names, which could be important at some point.", + "And a property name that is really long should have a value that is really long, because well, that's an important part of the yin and yang of software testing.", + NULL}; +gchar * props4[] = {"icon-name", "network-status", "label", "Look at network", "right-column", "10:32", NULL}; + + +proplayout_t submenu_4_1[] = { + {id: 10, properties: props2, submenu: NULL}, + {id: 11, properties: props2, submenu: NULL}, + {id: 12, properties: props2, submenu: NULL}, + {id: 13, properties: props2, submenu: NULL}, + {id: 14, properties: props2, submenu: NULL}, + {id: 15, properties: props2, submenu: NULL}, + {id: 16, properties: props2, submenu: NULL}, + {id: 17, properties: props2, submenu: NULL}, + {id: 18, properties: props2, submenu: NULL}, + {id: 19, properties: props2, submenu: NULL}, + {id: 0, properties: NULL, submenu: NULL} +}; + +proplayout_t submenu_4_2[] = { + {id: 20, properties: props2, submenu: NULL}, + {id: 21, properties: props2, submenu: NULL}, + {id: 22, properties: props2, submenu: NULL}, + {id: 23, properties: props2, submenu: NULL}, + {id: 24, properties: props2, submenu: NULL}, + {id: 25, properties: props2, submenu: NULL}, + {id: 26, properties: props2, submenu: NULL}, + {id: 27, properties: props2, submenu: NULL}, + {id: 28, properties: props2, submenu: NULL}, + {id: 29, properties: props2, submenu: NULL}, + {id: 0, properties: NULL, submenu: NULL} +}; + +proplayout_t submenu_4_3[] = { + {id: 30, properties: props2, submenu: NULL}, + {id: 31, properties: props2, submenu: NULL}, + {id: 32, properties: props2, submenu: NULL}, + {id: 33, properties: props2, submenu: NULL}, + {id: 34, properties: props2, submenu: NULL}, + {id: 35, properties: props2, submenu: NULL}, + {id: 36, properties: props2, submenu: NULL}, + {id: 37, properties: props2, submenu: NULL}, + {id: 38, properties: props2, submenu: NULL}, + {id: 39, properties: props2, submenu: NULL}, + {id: 0, properties: NULL, submenu: NULL} +}; + +proplayout_t submenu_4_0[] = { + {id: 1, properties: props2, submenu: submenu_4_1}, + {id: 2, properties: props2, submenu: submenu_4_2}, + {id: 3, properties: props2, submenu: submenu_4_3}, + {id: 0, properties: NULL, submenu: NULL} +}; + +proplayout_t layouts[] = { + {id: 1, properties: props1, submenu: NULL}, + {id: 10, properties: props2, submenu: NULL}, + {id: 20, properties: props3, submenu: NULL}, + {id: 100, properties: props2, submenu: submenu_4_0}, + {id: 0, properties: NULL, submenu: NULL} +}; + -- cgit v1.2.3 From 8920ae931c8eb9312d9c78ea1970d922a47a6a91 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 14 May 2009 16:13:54 -0500 Subject: Adding some flesh to that script. --- tests/test-glib-properties-server.c | 78 ++++++++++++++++++++++++++++++++++++- 1 file changed, 77 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-glib-properties-server.c b/tests/test-glib-properties-server.c index bcbd170..477f951 100644 --- a/tests/test-glib-properties-server.c +++ b/tests/test-glib-properties-server.c @@ -1,9 +1,85 @@ +#include + +#include +#include +#include + +#include +#include #include "test-glib-properties.h" +static void +set_props (DbusmenuMenuitem * mi, gchar ** props) +{ + if (props == NULL) return; + + guint i; + for (i = 0; props[i] != NULL; i += 2) { + dbusmenu_menuitem_property_set(mi, props[i], props[i+1]); + } + + return; +} + +static DbusmenuMenuitem * +layout2menuitem (proplayout_t * layout) +{ + if (layout == NULL || layout->id == 0) return NULL; + + DbusmenuMenuitem * local = dbusmenu_menuitem_new_with_id(layout->id); + set_props(local, layout->properties); + + if (layout->submenu != NULL) { + guint count; + for (count = 0; layout->submenu[count].id != 0; count++) { + DbusmenuMenuitem * child = layout2menuitem(&layout->submenu[count]); + if (child != NULL) { + dbusmenu_menuitem_child_append(local, child); + } + } + } + + g_debug("Layout to menu return: 0x%X", (unsigned int)local); + return local; +} + +static guint layouton = 0; +static DbusmenuServer * server = NULL; +static GMainLoop * mainloop = NULL; + +static gboolean +timer_func (gpointer data) +{ + if (layouts[layouton].id == 0) { + g_main_loop_quit(mainloop); + return FALSE; + } + g_debug("Updating to Layout %d", layouton); + + dbusmenu_server_set_root(server, layout2menuitem(&layouts[layouton])); + layouton++; + + return TRUE; +} + int -main (int argc, char * argv[]) +main (int argc, char ** argv) { + g_type_init(); + + g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + + server = dbusmenu_server_new("/org/test"); + + timer_func(NULL); + g_timeout_add(2500, timer_func, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_debug("Quiting"); return 0; } + -- cgit v1.2.3 From b5312e7a0591a734a463d3eb50ff565605f210bf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 May 2009 14:12:51 -0500 Subject: Adding in a function to get the properties, and make sure to catch soem more warnings and other protections. Also, no more deprecated GTK stuf. --- tests/test-glib-properties-client.c | 134 +++++++++++++++++++++++++++++++++++- 1 file changed, 132 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test-glib-properties-client.c b/tests/test-glib-properties-client.c index bcbd170..244b7c4 100644 --- a/tests/test-glib-properties-client.c +++ b/tests/test-glib-properties-client.c @@ -1,9 +1,139 @@ +/* +A test for libdbusmenu to ensure its quality. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include + +#include +#include #include "test-glib-properties.h" +static guint layouton = 0; +static GMainLoop * mainloop = NULL; +static gboolean passed = TRUE; + +static gboolean +verify_props (DbusmenuMenuitem * mi, gchar ** properties) +{ + + + +} + +static gboolean +verify_root_to_layout(DbusmenuMenuitem * mi, proplayout_t * layout) +{ + g_debug("Verifying ID: %d", layout->id); + + if (layout->id != dbusmenu_menuitem_get_id(mi)) { + g_debug("Failed as ID %d is not equal to %d", layout->id, dbusmenu_menuitem_get_id(mi)); + return FALSE; + } + + if (!veryify_props(mi, layout->properties)) { + return FALSE; + } + + GList * children = dbusmenu_menuitem_get_children(mi); + + if (children == NULL && layout->submenu == NULL) { + return TRUE; + } + if (children == NULL || layout->submenu == NULL) { + if (children == NULL) { + g_debug("Failed as there are no children but we have submenus"); + } else { + g_debug("Failed as we have children but no submenu"); + } + return FALSE; + } + + guint i = 0; + for (i = 0; children != NULL && layout->submenu[i].id != 0; children = g_list_next(children), i++) { + if (!verify_root_to_layout(DBUSMENU_MENUITEM(children->data), &layout->submenu[i])) { + return FALSE; + } + } + + if (children == NULL && layout->submenu[i].id == 0) { + return TRUE; + } + + if (children != NULL) { + g_debug("Failed as there are still children but no submenus. (ID: %d)", layout->id); + } else { + g_debug("Failed as there are still submenus but no children. (ID: %d)", layout->id); + } + return FALSE; +} + +static void +layout_updated (DbusmenuClient * client, gpointer data) +{ + g_debug("Layout Updated"); + + DbusmenuMenuitem * menuroot = dbusmenu_client_get_root(client); + proplayout_t * layout = &layouts[layouton]; + + if (!verify_root_to_layout(menuroot, layout)) { + g_debug("Failed layout: %d", layouton); + passed = FALSE; + } + + layouton++; + + return; +} + +static gboolean +timer_func (gpointer data) +{ + g_debug("Death timer. Oops. Got to: %d", layouton); + passed = FALSE; + g_main_loop_quit(mainloop); + return FALSE; +} + int -main (int argc, char * argv[]) +main (int argc, char ** argv) { + g_type_init(); + + g_usleep(500000); + + DbusmenuClient * client = dbusmenu_client_new(":1.0", "/org/test"); + g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED, G_CALLBACK(layout_updated), NULL); + + g_timeout_add_seconds(10, timer_func, client); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_object_unref(G_OBJECT(client)); - return 0; + if (passed) { + g_debug("Quiting"); + return 0; + } else { + g_debug("Quiting as we're a failure"); + return 0; + } } -- cgit v1.2.3 From cc8b4e70486af063785d0dd6ea42c382a2d84aa4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 May 2009 15:19:12 -0500 Subject: Oops, that didn't compile. --- tests/test-glib-properties-client.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/test-glib-properties-client.c b/tests/test-glib-properties-client.c index 244b7c4..7fe9b8f 100644 --- a/tests/test-glib-properties-client.c +++ b/tests/test-glib-properties-client.c @@ -33,9 +33,11 @@ static gboolean passed = TRUE; static gboolean verify_props (DbusmenuMenuitem * mi, gchar ** properties) { + if (properties == NULL) { + return TRUE; + } - - + return TRUE; } static gboolean @@ -48,7 +50,7 @@ verify_root_to_layout(DbusmenuMenuitem * mi, proplayout_t * layout) return FALSE; } - if (!veryify_props(mi, layout->properties)) { + if (!verify_props(mi, layout->properties)) { return FALSE; } -- cgit v1.2.3 From fe514517e8f6dffab8820ef3d40458f8f08e72fa Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Fri, 15 May 2009 15:23:34 -0500 Subject: Adding a property for testing. --- tests/glib-server-nomenu.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/glib-server-nomenu.c b/tests/glib-server-nomenu.c index e5ea159..fb2c61e 100644 --- a/tests/glib-server-nomenu.c +++ b/tests/glib-server-nomenu.c @@ -31,6 +31,7 @@ main (int argc, char ** argv) DbusmenuServer * server = dbusmenu_server_new("/org/test"); DbusmenuMenuitem * menuitem = dbusmenu_menuitem_new(); + dbusmenu_menuitem_property_set(menuitem, "test", "test"); dbusmenu_server_set_root(server, menuitem); g_main_loop_run(g_main_loop_new(NULL, FALSE)); -- cgit v1.2.3 From 9f3095425e166de4b82c0066057749edafe3980e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 19 May 2009 04:15:57 +0200 Subject: Cleaning up pass and fail message to make them more readable --- tests/test-glib-properties-client.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/test-glib-properties-client.c b/tests/test-glib-properties-client.c index 7fe9b8f..11cd70d 100644 --- a/tests/test-glib-properties-client.c +++ b/tests/test-glib-properties-client.c @@ -46,24 +46,26 @@ verify_root_to_layout(DbusmenuMenuitem * mi, proplayout_t * layout) g_debug("Verifying ID: %d", layout->id); if (layout->id != dbusmenu_menuitem_get_id(mi)) { - g_debug("Failed as ID %d is not equal to %d", layout->id, dbusmenu_menuitem_get_id(mi)); + g_debug("\tFailed as ID %d is not equal to %d", layout->id, dbusmenu_menuitem_get_id(mi)); return FALSE; } if (!verify_props(mi, layout->properties)) { + g_debug("\tFailed as unable to verify properties."); return FALSE; } GList * children = dbusmenu_menuitem_get_children(mi); if (children == NULL && layout->submenu == NULL) { + g_debug("\tPassed: %d", layout->id); return TRUE; } if (children == NULL || layout->submenu == NULL) { if (children == NULL) { - g_debug("Failed as there are no children but we have submenus"); + g_debug("\tFailed as there are no children but we have submenus"); } else { - g_debug("Failed as we have children but no submenu"); + g_debug("\tFailed as we have children but no submenu"); } return FALSE; } @@ -76,13 +78,14 @@ verify_root_to_layout(DbusmenuMenuitem * mi, proplayout_t * layout) } if (children == NULL && layout->submenu[i].id == 0) { + g_debug("\tPassed: %d", layout->id); return TRUE; } if (children != NULL) { - g_debug("Failed as there are still children but no submenus. (ID: %d)", layout->id); + g_debug("\tFailed as there are still children but no submenus. (ID: %d)", layout->id); } else { - g_debug("Failed as there are still submenus but no children. (ID: %d)", layout->id); + g_debug("\tFailed as there are still submenus but no children. (ID: %d)", layout->id); } return FALSE; } -- cgit v1.2.3 From 17a0a712d5187101216ed937955c6871a000d8b0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 19 May 2009 04:24:27 +0200 Subject: Handling death better. Now we extend our life the more successful we are. Plus if we get through all the layouts we quit right then. --- tests/test-glib-properties-client.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/test-glib-properties-client.c b/tests/test-glib-properties-client.c index 11cd70d..d840217 100644 --- a/tests/test-glib-properties-client.c +++ b/tests/test-glib-properties-client.c @@ -29,6 +29,7 @@ with this program. If not, see . static guint layouton = 0; static GMainLoop * mainloop = NULL; static gboolean passed = TRUE; +static guint death_timer = 0; static gboolean verify_props (DbusmenuMenuitem * mi, gchar ** properties) @@ -90,6 +91,15 @@ verify_root_to_layout(DbusmenuMenuitem * mi, proplayout_t * layout) return FALSE; } +static gboolean +timer_func (gpointer data) +{ + g_debug("Death timer. Oops. Got to: %d", layouton); + passed = FALSE; + g_main_loop_quit(mainloop); + return FALSE; +} + static void layout_updated (DbusmenuClient * client, gpointer data) { @@ -99,35 +109,35 @@ layout_updated (DbusmenuClient * client, gpointer data) proplayout_t * layout = &layouts[layouton]; if (!verify_root_to_layout(menuroot, layout)) { - g_debug("Failed layout: %d", layouton); + g_debug("FAILED LAYOUT: %d", layouton); passed = FALSE; + } else { + /* Extend our death */ + g_source_remove(death_timer); + death_timer = g_timeout_add_seconds(10, timer_func, client); } layouton++; + + if (layouts[layouton].id == 0) { + g_main_loop_quit(mainloop); + } return; } -static gboolean -timer_func (gpointer data) -{ - g_debug("Death timer. Oops. Got to: %d", layouton); - passed = FALSE; - g_main_loop_quit(mainloop); - return FALSE; -} - int main (int argc, char ** argv) { g_type_init(); + /* Make sure the server starts up and all that */ g_usleep(500000); DbusmenuClient * client = dbusmenu_client_new(":1.0", "/org/test"); g_signal_connect(G_OBJECT(client), DBUSMENU_CLIENT_SIGNAL_LAYOUT_UPDATED, G_CALLBACK(layout_updated), NULL); - g_timeout_add_seconds(10, timer_func, client); + death_timer = g_timeout_add_seconds(10, timer_func, client); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From 85ff79a58f531a5173565bbe1b97b5a9c7e4148e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 19 May 2009 04:34:59 +0200 Subject: Starting to verify the properties --- tests/test-glib-properties-client.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') diff --git a/tests/test-glib-properties-client.c b/tests/test-glib-properties-client.c index d840217..145e4fd 100644 --- a/tests/test-glib-properties-client.c +++ b/tests/test-glib-properties-client.c @@ -38,6 +38,19 @@ verify_props (DbusmenuMenuitem * mi, gchar ** properties) return TRUE; } + /* Verify they're all there and correct */ + guint i; + for (i = 0; properties[i] != NULL; i += 2) { + const gchar * value = dbusmenu_menuitem_property_get(mi, properties[i]); + if (g_strcmp0(value, properties[i + 1])) { + g_debug("\tFailed as property '%s' should be '%s' and is '%s'", properties[i], properties[i+1], value); + return FALSE; + } + } + + /* Verify that we don't have any extras */ + // GList * props = dbusmenu_menuitem_properties_list(mi); + return TRUE; } -- cgit v1.2.3 From 0386af8ac00626ace16cd3c882a1bc261a4cc256 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 19 May 2009 04:42:50 +0200 Subject: Making it so that the verifcation hapens slightly after the update, as it takes a couple of milliseconds for the properties to trasfer over DBus. --- tests/test-glib-properties-client.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/test-glib-properties-client.c b/tests/test-glib-properties-client.c index 145e4fd..4439788 100644 --- a/tests/test-glib-properties-client.c +++ b/tests/test-glib-properties-client.c @@ -113,12 +113,20 @@ timer_func (gpointer data) return FALSE; } +static gboolean layout_verify_timer (gpointer data); + static void layout_updated (DbusmenuClient * client, gpointer data) { g_debug("Layout Updated"); + g_timeout_add (250, layout_verify_timer, client); + return; +} - DbusmenuMenuitem * menuroot = dbusmenu_client_get_root(client); +static gboolean +layout_verify_timer (gpointer data) +{ + DbusmenuMenuitem * menuroot = dbusmenu_client_get_root(DBUSMENU_CLIENT(data)); proplayout_t * layout = &layouts[layouton]; if (!verify_root_to_layout(menuroot, layout)) { @@ -127,7 +135,7 @@ layout_updated (DbusmenuClient * client, gpointer data) } else { /* Extend our death */ g_source_remove(death_timer); - death_timer = g_timeout_add_seconds(10, timer_func, client); + death_timer = g_timeout_add_seconds(10, timer_func, data); } layouton++; @@ -136,7 +144,7 @@ layout_updated (DbusmenuClient * client, gpointer data) g_main_loop_quit(mainloop); } - return; + return FALSE; } int -- cgit v1.2.3 From c77c0f5b854bb2b924b98a09f598db66de0ab5e4 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 00:06:22 +0200 Subject: Building up the gtk tests. Oops, should have committed these a while ago. --- tests/Makefile.am | 39 ++++++++- tests/test-gtk-label-client.c | 180 ++++++++++++++++++++++++++++++++++++++++++ tests/test-gtk-label-server.c | 85 ++++++++++++++++++++ tests/test-gtk-label.h | 95 ++++++++++++++++++++++ 4 files changed, 397 insertions(+), 2 deletions(-) create mode 100644 tests/test-gtk-label-client.c create mode 100644 tests/test-gtk-label-server.c create mode 100644 tests/test-gtk-label.h (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 1f21141..70750ac 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,14 +2,16 @@ check: tests DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf -tests: test-glib-layout test-glib-properties +tests: test-glib-layout test-glib-properties test-gtk-label libexec_PROGRAMS = \ glib-server-nomenu \ test-glib-layout-client \ test-glib-layout-server \ test-glib-properties-client \ - test-glib-properties-server + test-glib-properties-server \ + test-gtk-label-client \ + test-gtk-label-server glib_server_nomenu_SOURCES = \ glib-server-nomenu.c @@ -82,6 +84,39 @@ test_glib_properties_client_LDADD = \ +test-gtk-label: test-gtk-label-client test-gtk-label-server + $(DBUS_RUNNER) --task ./test-gtk-label-client --task-name Client --task ./test-gtk-label-server --task-name Server --ignore-return + +test_gtk_label_server_SOURCES = \ + test-gtk-label.h \ + test-gtk-label-server.c + +test_gtk_label_server_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGTK_CFLAGS) \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_gtk_label_server_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + ../libdbusmenu-gtk/libdbusmenu-gtk.la \ + $(DBUSMENUGTK_LIBS) + +test_gtk_label_client_SOURCES = \ + test-gtk-label.h \ + test-gtk-label-client.c + +test_gtk_label_client_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGTK_CFLAGS) \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_gtk_label_client_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + ../libdbusmenu-gtk/libdbusmenu-gtk.la \ + $(DBUSMENUGTK_LIBS) + + + examplesdir = $(docdir)/examples/ examples_DATA = \ diff --git a/tests/test-gtk-label-client.c b/tests/test-gtk-label-client.c new file mode 100644 index 0000000..028a526 --- /dev/null +++ b/tests/test-gtk-label-client.c @@ -0,0 +1,180 @@ +/* +A test for libdbusmenu to ensure its quality. + +Copyright 2009 Canonical Ltd. + +Authors: + Ted Gould + +This program is free software: you can redistribute it and/or modify it +under the terms of the GNU General Public License version 3, as published +by the Free Software Foundation. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranties of +MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR +PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along +with this program. If not, see . +*/ + +#include +#include + +static guint layouton = 0; +static GMainLoop * mainloop = NULL; +static gboolean passed = TRUE; +static guint death_timer = 0; + +#if 0 +static gboolean +verify_props (DbusmenuMenuitem * mi, gchar ** properties) +{ + if (properties == NULL) { + return TRUE; + } + + /* Verify they're all there and correct */ + guint i; + for (i = 0; properties[i] != NULL; i += 2) { + const gchar * value = dbusmenu_menuitem_property_get(mi, properties[i]); + if (g_strcmp0(value, properties[i + 1])) { + g_debug("\tFailed as property '%s' should be '%s' and is '%s'", properties[i], properties[i+1], value); + return FALSE; + } + } + + /* Verify that we don't have any extras */ + // GList * props = dbusmenu_menuitem_properties_list(mi); + + return TRUE; +} + +static gboolean +verify_root_to_layout(DbusmenuMenuitem * mi, proplayout_t * layout) +{ + g_debug("Verifying ID: %d", layout->id); + + if (layout->id != dbusmenu_menuitem_get_id(mi)) { + g_debug("\tFailed as ID %d is not equal to %d", layout->id, dbusmenu_menuitem_get_id(mi)); + return FALSE; + } + + if (!verify_props(mi, layout->properties)) { + g_debug("\tFailed as unable to verify properties."); + return FALSE; + } + + GList * children = dbusmenu_menuitem_get_children(mi); + + if (children == NULL && layout->submenu == NULL) { + g_debug("\tPassed: %d", layout->id); + return TRUE; + } + if (children == NULL || layout->submenu == NULL) { + if (children == NULL) { + g_debug("\tFailed as there are no children but we have submenus"); + } else { + g_debug("\tFailed as we have children but no submenu"); + } + return FALSE; + } + + guint i = 0; + for (i = 0; children != NULL && layout->submenu[i].id != 0; children = g_list_next(children), i++) { + if (!verify_root_to_layout(DBUSMENU_MENUITEM(children->data), &layout->submenu[i])) { + return FALSE; + } + } + + if (children == NULL && layout->submenu[i].id == 0) { + g_debug("\tPassed: %d", layout->id); + return TRUE; + } + + if (children != NULL) { + g_debug("\tFailed as there are still children but no submenus. (ID: %d)", layout->id); + } else { + g_debug("\tFailed as there are still submenus but no children. (ID: %d)", layout->id); + } + return FALSE; +} +#endif + +static gboolean +timer_func (gpointer data) +{ + g_debug("Death timer. Oops. Got to: %d", layouton); + passed = FALSE; + g_main_loop_quit(mainloop); + return FALSE; +} + +#if 0 +static gboolean layout_verify_timer (gpointer data); + +static void +layout_updated (DbusmenuClient * client, gpointer data) +{ + g_debug("Layout Updated"); + g_timeout_add (250, layout_verify_timer, client); + return; +} + +static gboolean +layout_verify_timer (gpointer data) +{ + DbusmenuMenuitem * menuroot = dbusmenu_client_get_root(DBUSMENU_CLIENT(data)); + proplayout_t * layout = &layouts[layouton]; + + if (!verify_root_to_layout(menuroot, layout)) { + g_debug("FAILED LAYOUT: %d", layouton); + passed = FALSE; + } else { + /* Extend our death */ + g_source_remove(death_timer); + death_timer = g_timeout_add_seconds(10, timer_func, data); + } + + layouton++; + + if (layouts[layouton].id == 0) { + g_main_loop_quit(mainloop); + } + + return FALSE; +} +#endif + +int +main (int argc, char ** argv) +{ + gtk_init(&argc, &argv); + + /* Make sure the server starts up and all that */ + g_usleep(500000); + + GtkWidget * window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + GtkWidget * menubar = gtk_menu_bar_new(); + GtkWidget * menuitem = gtk_menu_item_new_with_label("Test"); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(dbusmenu_gtkmenu_new (":1.0", "/org/test"))); + gtk_widget_show(menuitem); + gtk_menu_bar_append(menubar, menuitem); + gtk_widget_show(menubar); + gtk_container_add(GTK_CONTAINER(window), menubar); + gtk_widget_show(window); + + death_timer = g_timeout_add_seconds(10, timer_func, window); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + if (passed) { + g_debug("Quiting"); + return 0; + } else { + g_debug("Quiting as we're a failure"); + return 0; + } +} diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c new file mode 100644 index 0000000..477f951 --- /dev/null +++ b/tests/test-gtk-label-server.c @@ -0,0 +1,85 @@ +#include + +#include +#include +#include + +#include +#include + +#include "test-glib-properties.h" + +static void +set_props (DbusmenuMenuitem * mi, gchar ** props) +{ + if (props == NULL) return; + + guint i; + for (i = 0; props[i] != NULL; i += 2) { + dbusmenu_menuitem_property_set(mi, props[i], props[i+1]); + } + + return; +} + +static DbusmenuMenuitem * +layout2menuitem (proplayout_t * layout) +{ + if (layout == NULL || layout->id == 0) return NULL; + + DbusmenuMenuitem * local = dbusmenu_menuitem_new_with_id(layout->id); + set_props(local, layout->properties); + + if (layout->submenu != NULL) { + guint count; + for (count = 0; layout->submenu[count].id != 0; count++) { + DbusmenuMenuitem * child = layout2menuitem(&layout->submenu[count]); + if (child != NULL) { + dbusmenu_menuitem_child_append(local, child); + } + } + } + + g_debug("Layout to menu return: 0x%X", (unsigned int)local); + return local; +} + +static guint layouton = 0; +static DbusmenuServer * server = NULL; +static GMainLoop * mainloop = NULL; + +static gboolean +timer_func (gpointer data) +{ + if (layouts[layouton].id == 0) { + g_main_loop_quit(mainloop); + return FALSE; + } + g_debug("Updating to Layout %d", layouton); + + dbusmenu_server_set_root(server, layout2menuitem(&layouts[layouton])); + layouton++; + + return TRUE; +} + +int +main (int argc, char ** argv) +{ + g_type_init(); + + g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + + server = dbusmenu_server_new("/org/test"); + + timer_func(NULL); + g_timeout_add(2500, timer_func, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + g_debug("Quiting"); + + return 0; +} + diff --git a/tests/test-gtk-label.h b/tests/test-gtk-label.h new file mode 100644 index 0000000..3ab7ee7 --- /dev/null +++ b/tests/test-gtk-label.h @@ -0,0 +1,95 @@ + +#include + +typedef struct _proplayout_t proplayout_t; +struct _proplayout_t { + guint id; + gchar ** properties; + proplayout_t * submenu; +}; + +gchar * props1[] = {"property1", "value1", "property2", "value2", NULL}; +gchar * props2[] = {"property00", "value00", "property01", "value01", "property02", "value02", "property03", "value03", "property04", "value04", + "property05", "value05", "property06", "value06", "property07", "value07", "property08", "value08", "property09", "value09", + "property10", "value10", "property11", "value11", "property12", "value12", "property13", "value13", "property14", "value14", + "property15", "value15", "property16", "value16", "property17", "value17", "property18", "value18", "property19", "value19", + "property20", "value20", "property21", "value21", "property22", "value22", "property23", "value23", "property24", "value24", + "property25", "value25", "property26", "value26", "property27", "value27", "property28", "value28", "property29", "value29", + "property30", "value30", "property31", "value31", "property32", "value32", "property33", "value33", "property34", "value34", + "property35", "value35", "property36", "value36", "property37", "value37", "property38", "value38", "property39", "value39", + "property40", "value40", "property41", "value41", "property42", "value42", "property43", "value43", "property44", "value44", + "property45", "value45", "property46", "value46", "property47", "value47", "property48", "value48", "property49", "value49", + "property50", "value50", "property51", "value51", "property52", "value52", "property53", "value53", "property54", "value54", + "property55", "value55", "property56", "value56", "property57", "value57", "property58", "value58", "property59", "value59", + "property60", "value60", "property61", "value61", "property62", "value62", "property63", "value63", "property64", "value64", + "property65", "value65", "property66", "value66", "property67", "value67", "property68", "value68", "property69", "value69", + "property70", "value70", "property71", "value71", "property72", "value72", "property73", "value73", "property74", "value74", + "property75", "value75", "property76", "value76", "property77", "value77", "property78", "value78", "property79", "value79", + "property80", "value80", "property81", "value81", "property82", "value82", "property83", "value83", "property84", "value84", + "property85", "value85", "property86", "value86", "property87", "value87", "property88", "value88", "property89", "value89", + "property90", "value90", "property91", "value91", "property92", "value92", "property93", "value93", "property94", "value94", + "property95", "value95", "property96", "value96", "property97", "value97", "property98", "value98", "property99", "value99", + NULL}; +gchar * props3[] = {"property name that is really long and will ensure that we can really have long property names, which could be important at some point.", + "And a property name that is really long should have a value that is really long, because well, that's an important part of the yin and yang of software testing.", + NULL}; +gchar * props4[] = {"icon-name", "network-status", "label", "Look at network", "right-column", "10:32", NULL}; + + +proplayout_t submenu_4_1[] = { + {id: 10, properties: props2, submenu: NULL}, + {id: 11, properties: props2, submenu: NULL}, + {id: 12, properties: props2, submenu: NULL}, + {id: 13, properties: props2, submenu: NULL}, + {id: 14, properties: props2, submenu: NULL}, + {id: 15, properties: props2, submenu: NULL}, + {id: 16, properties: props2, submenu: NULL}, + {id: 17, properties: props2, submenu: NULL}, + {id: 18, properties: props2, submenu: NULL}, + {id: 19, properties: props2, submenu: NULL}, + {id: 0, properties: NULL, submenu: NULL} +}; + +proplayout_t submenu_4_2[] = { + {id: 20, properties: props2, submenu: NULL}, + {id: 21, properties: props2, submenu: NULL}, + {id: 22, properties: props2, submenu: NULL}, + {id: 23, properties: props2, submenu: NULL}, + {id: 24, properties: props2, submenu: NULL}, + {id: 25, properties: props2, submenu: NULL}, + {id: 26, properties: props2, submenu: NULL}, + {id: 27, properties: props2, submenu: NULL}, + {id: 28, properties: props2, submenu: NULL}, + {id: 29, properties: props2, submenu: NULL}, + {id: 0, properties: NULL, submenu: NULL} +}; + +proplayout_t submenu_4_3[] = { + {id: 30, properties: props2, submenu: NULL}, + {id: 31, properties: props2, submenu: NULL}, + {id: 32, properties: props2, submenu: NULL}, + {id: 33, properties: props2, submenu: NULL}, + {id: 34, properties: props2, submenu: NULL}, + {id: 35, properties: props2, submenu: NULL}, + {id: 36, properties: props2, submenu: NULL}, + {id: 37, properties: props2, submenu: NULL}, + {id: 38, properties: props2, submenu: NULL}, + {id: 39, properties: props2, submenu: NULL}, + {id: 0, properties: NULL, submenu: NULL} +}; + +proplayout_t submenu_4_0[] = { + {id: 1, properties: props2, submenu: submenu_4_1}, + {id: 2, properties: props2, submenu: submenu_4_2}, + {id: 3, properties: props2, submenu: submenu_4_3}, + {id: 0, properties: NULL, submenu: NULL} +}; + +proplayout_t layouts[] = { + {id: 1, properties: props1, submenu: NULL}, + {id: 10, properties: props2, submenu: NULL}, + {id: 20, properties: props3, submenu: NULL}, + {id: 100, properties: props2, submenu: submenu_4_0}, + {id: 0, properties: NULL, submenu: NULL} +}; + -- cgit v1.2.3 From 8d10e66c11d3708a72e9c5f6ba79632e6fcc1b8f Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 00:09:10 +0200 Subject: Properties that make a little more sense. --- tests/test-gtk-label.h | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'tests') diff --git a/tests/test-gtk-label.h b/tests/test-gtk-label.h index 3ab7ee7..ca98700 100644 --- a/tests/test-gtk-label.h +++ b/tests/test-gtk-label.h @@ -8,29 +8,8 @@ struct _proplayout_t { proplayout_t * submenu; }; -gchar * props1[] = {"property1", "value1", "property2", "value2", NULL}; -gchar * props2[] = {"property00", "value00", "property01", "value01", "property02", "value02", "property03", "value03", "property04", "value04", - "property05", "value05", "property06", "value06", "property07", "value07", "property08", "value08", "property09", "value09", - "property10", "value10", "property11", "value11", "property12", "value12", "property13", "value13", "property14", "value14", - "property15", "value15", "property16", "value16", "property17", "value17", "property18", "value18", "property19", "value19", - "property20", "value20", "property21", "value21", "property22", "value22", "property23", "value23", "property24", "value24", - "property25", "value25", "property26", "value26", "property27", "value27", "property28", "value28", "property29", "value29", - "property30", "value30", "property31", "value31", "property32", "value32", "property33", "value33", "property34", "value34", - "property35", "value35", "property36", "value36", "property37", "value37", "property38", "value38", "property39", "value39", - "property40", "value40", "property41", "value41", "property42", "value42", "property43", "value43", "property44", "value44", - "property45", "value45", "property46", "value46", "property47", "value47", "property48", "value48", "property49", "value49", - "property50", "value50", "property51", "value51", "property52", "value52", "property53", "value53", "property54", "value54", - "property55", "value55", "property56", "value56", "property57", "value57", "property58", "value58", "property59", "value59", - "property60", "value60", "property61", "value61", "property62", "value62", "property63", "value63", "property64", "value64", - "property65", "value65", "property66", "value66", "property67", "value67", "property68", "value68", "property69", "value69", - "property70", "value70", "property71", "value71", "property72", "value72", "property73", "value73", "property74", "value74", - "property75", "value75", "property76", "value76", "property77", "value77", "property78", "value78", "property79", "value79", - "property80", "value80", "property81", "value81", "property82", "value82", "property83", "value83", "property84", "value84", - "property85", "value85", "property86", "value86", "property87", "value87", "property88", "value88", "property89", "value89", - "property90", "value90", "property91", "value91", "property92", "value92", "property93", "value93", "property94", "value94", - "property95", "value95", "property96", "value96", "property97", "value97", "property98", "value98", "property99", "value99", - NULL}; -gchar * props3[] = {"property name that is really long and will ensure that we can really have long property names, which could be important at some point.", +gchar * props1[] = {"label", "value1", NULL}; +gchar * props3[] = {"label", "And a property name that is really long should have a value that is really long, because well, that's an important part of the yin and yang of software testing.", NULL}; gchar * props4[] = {"icon-name", "network-status", "label", "Look at network", "right-column", "10:32", NULL}; -- cgit v1.2.3 From 342660113458cdcd2c19421733701aba335774eb Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 00:35:41 +0200 Subject: Requesting a name on the bus --- tests/test-gtk-label-server.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests') diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c index 477f951..0e395d4 100644 --- a/tests/test-gtk-label-server.c +++ b/tests/test-gtk-label-server.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -68,8 +69,23 @@ main (int argc, char ** argv) { g_type_init(); + DBusGConnection * connection = dbus_g_bus_get(DBUS_BUS_SESSION, NULL); g_debug("DBus ID: %s", dbus_connection_get_server_id(dbus_g_connection_get_connection(dbus_g_bus_get(DBUS_BUS_SESSION, NULL)))); + DBusGProxy * bus_proxy = dbus_g_proxy_new_for_name(connection, DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS); + GError * error = NULL; + guint nameret = 0; + + if (!org_freedesktop_DBus_request_name(bus_proxy, "glib.label.test", 0, &nameret, &error)) { + g_error("Unable to call to request name"); + return 1; + } + + if (nameret != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER) { + g_error("Unable to get name"); + return 1; + } + server = dbusmenu_server_new("/org/test"); timer_func(NULL); -- cgit v1.2.3 From b26bb869e0bc037533c62ae77907b5368fdee9a3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 00:39:09 +0200 Subject: Using the new name --- tests/test-gtk-label-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-gtk-label-client.c b/tests/test-gtk-label-client.c index 028a526..44a847f 100644 --- a/tests/test-gtk-label-client.c +++ b/tests/test-gtk-label-client.c @@ -158,7 +158,7 @@ main (int argc, char ** argv) GtkWidget * window = gtk_window_new(GTK_WINDOW_TOPLEVEL); GtkWidget * menubar = gtk_menu_bar_new(); GtkWidget * menuitem = gtk_menu_item_new_with_label("Test"); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(dbusmenu_gtkmenu_new (":1.0", "/org/test"))); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), GTK_WIDGET(dbusmenu_gtkmenu_new ("glib.label.test", "/org/test"))); gtk_widget_show(menuitem); gtk_menu_bar_append(menubar, menuitem); gtk_widget_show(menubar); -- cgit v1.2.3 From c6e13ca433f0e8538a60a80cee3ce1a359b88bd6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 14:17:44 +0200 Subject: Switching to the right header and updating the properties more. --- tests/test-gtk-label-server.c | 2 +- tests/test-gtk-label.h | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c index 0e395d4..426daa2 100644 --- a/tests/test-gtk-label-server.c +++ b/tests/test-gtk-label-server.c @@ -8,7 +8,7 @@ #include #include -#include "test-glib-properties.h" +#include "test-gtk-label.h" static void set_props (DbusmenuMenuitem * mi, gchar ** props) diff --git a/tests/test-gtk-label.h b/tests/test-gtk-label.h index ca98700..e63ac44 100644 --- a/tests/test-gtk-label.h +++ b/tests/test-gtk-label.h @@ -9,6 +9,7 @@ struct _proplayout_t { }; gchar * props1[] = {"label", "value1", NULL}; +gchar * props2[] = {"label", "value1", NULL}; gchar * props3[] = {"label", "And a property name that is really long should have a value that is really long, because well, that's an important part of the yin and yang of software testing.", NULL}; @@ -65,9 +66,9 @@ proplayout_t submenu_4_0[] = { }; proplayout_t layouts[] = { - {id: 1, properties: props1, submenu: NULL}, - {id: 10, properties: props2, submenu: NULL}, - {id: 20, properties: props3, submenu: NULL}, + {id: 1, properties: props1, submenu: submenu_4_3}, + {id: 10, properties: props2, submenu: submenu_4_2}, + {id: 20, properties: props3, submenu: submenu_4_1}, {id: 100, properties: props2, submenu: submenu_4_0}, {id: 0, properties: NULL, submenu: NULL} }; -- cgit v1.2.3 From 7967d870eee94c0ce26cf820a6f6e556ee9cea48 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 22:56:31 +0200 Subject: Unref'ing the menuitem after being created. --- tests/test-glib-properties-server.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test-glib-properties-server.c b/tests/test-glib-properties-server.c index 477f951..c9d2880 100644 --- a/tests/test-glib-properties-server.c +++ b/tests/test-glib-properties-server.c @@ -40,7 +40,7 @@ layout2menuitem (proplayout_t * layout) } } - g_debug("Layout to menu return: 0x%X", (unsigned int)local); + /* g_debug("Layout to menu return: 0x%X", (unsigned int)local); */ return local; } @@ -57,7 +57,9 @@ timer_func (gpointer data) } g_debug("Updating to Layout %d", layouton); - dbusmenu_server_set_root(server, layout2menuitem(&layouts[layouton])); + DbusmenuMenuitem * mi = layout2menuitem(&layouts[layouton]); + dbusmenu_server_set_root(server, mi); + g_object_unref(G_OBJECT(mi)); layouton++; return TRUE; -- cgit v1.2.3 From 2d5dc7c1f0be1da109fd6a19a2f6f4db70bc2f1a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 25 May 2009 23:11:00 +0200 Subject: Removing the server as we go away --- tests/test-glib-properties-server.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/test-glib-properties-server.c b/tests/test-glib-properties-server.c index c9d2880..a51ac0c 100644 --- a/tests/test-glib-properties-server.c +++ b/tests/test-glib-properties-server.c @@ -80,6 +80,7 @@ main (int argc, char ** argv) mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); + g_object_unref(G_OBJECT(server)); g_debug("Quiting"); return 0; -- cgit v1.2.3 From cd053ef1cae0ffb2ccd38afcc5ea7c719daf3334 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Wed, 27 May 2009 10:11:12 +0200 Subject: Pointer casts make the 64-bit builds unhappy. --- tests/test-glib-layout-server.c | 2 +- tests/test-gtk-label-server.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test-glib-layout-server.c b/tests/test-glib-layout-server.c index e69c6b2..cc9b8e7 100644 --- a/tests/test-glib-layout-server.c +++ b/tests/test-glib-layout-server.c @@ -48,7 +48,7 @@ layout2menuitem (layout_t * layout) } } - g_debug("Layout to menu return: 0x%X", (unsigned int)local); + /* g_debug("Layout to menu return: 0x%X", (unsigned int)local); */ return local; } diff --git a/tests/test-gtk-label-server.c b/tests/test-gtk-label-server.c index 426daa2..4e2fe0a 100644 --- a/tests/test-gtk-label-server.c +++ b/tests/test-gtk-label-server.c @@ -41,7 +41,7 @@ layout2menuitem (proplayout_t * layout) } } - g_debug("Layout to menu return: 0x%X", (unsigned int)local); + /* g_debug("Layout to menu return: 0x%X", (unsigned int)local); */ return local; } -- cgit v1.2.3