From 8fa3697487b63874cc60446c6674f77b62ee7414 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Thu, 16 Apr 2009 16:03:57 -0500 Subject: Adding in tests dictory, a test, and making it compile --- tests/Makefile.am | 24 ++++++++++++++++++++++++ tests/glib-server-nomenu.c | 18 ++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 tests/Makefile.am create mode 100644 tests/glib-server-nomenu.c (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am new file mode 100644 index 0000000..3c58cf0 --- /dev/null +++ b/tests/Makefile.am @@ -0,0 +1,24 @@ + +libexec_PROGRAMS = \ + glib-server-nomenu + +glib_server_nomenu_SOURCES = \ + glib-server-nomenu.c + +glib_server_nomenu_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +glib_server_nomenu_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + $(DBUSMENUGLIB_LIBS) + + + + +examplesdir = $(docdir)/examples/ + +examples_DATA = \ + $(glib_server_nomenu_SOURCES) + +EXTRA_DIST = $(examples_DATA) diff --git a/tests/glib-server-nomenu.c b/tests/glib-server-nomenu.c new file mode 100644 index 0000000..36aac3e --- /dev/null +++ b/tests/glib-server-nomenu.c @@ -0,0 +1,18 @@ +#include + +#include +#include + +int +main (int argc, char ** argv) +{ + g_type_init(); + + DbusmenuServer * server = dbusmenu_server_new("/org/test"); + DbusmenuMenuitem * menuitem = dbusmenu_menuitem_new(); + dbusmenu_server_set_root(server, menuitem); + + g_main_loop_run(g_main_loop_new(NULL, FALSE)); + + return 0; +} -- cgit v1.2.3 From fee7a8e7b7e8a9c1d6d549de1137a85c4a7421db Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 28 Apr 2009 15:34:47 -0500 Subject: Starting to build a layout test. We're compiling again. --- tests/Makefile.am | 14 +++++++++- tests/test-glib-layout-client.c | 0 tests/test-glib-layout-server.c | 61 +++++++++++++++++++++++++++++++++++++++++ tests/test-glib-layout.h | 58 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 132 insertions(+), 1 deletion(-) create mode 100644 tests/test-glib-layout-client.c create mode 100644 tests/test-glib-layout-server.c create mode 100644 tests/test-glib-layout.h (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 3c58cf0..f00a7e7 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,7 @@ libexec_PROGRAMS = \ - glib-server-nomenu + glib-server-nomenu \ + test-glib-layout-server glib_server_nomenu_SOURCES = \ glib-server-nomenu.c @@ -13,6 +14,17 @@ glib_server_nomenu_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ $(DBUSMENUGLIB_LIBS) +test_glib_layout_server_SOURCES = \ + test-glib-layout-server.c + +test_glib_layout_server_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_glib_layout_server_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + $(DBUSMENUGLIB_LIBS) + diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c new file mode 100644 index 0000000..e69de29 diff --git a/tests/test-glib-layout-server.c b/tests/test-glib-layout-server.c new file mode 100644 index 0000000..6ec9b0c --- /dev/null +++ b/tests/test-glib-layout-server.c @@ -0,0 +1,61 @@ + +#include + +#include +#include + +#include "test-glib-layout.h" + + +static DbusmenuMenuitem * +layout2menuitem (layout_t * layout) +{ + if (layout == NULL || layout->id == 0) return NULL; + + DbusmenuMenuitem * local = dbusmenu_menuitem_new_with_id(layout->id); + + 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); + } + } + } + + 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; + } + + dbusmenu_server_set_root(server, layout2menuitem(&layouts[layouton++])); + + return TRUE; +} + +int +main (int argc, char ** argv) +{ + g_type_init(); + + server = dbusmenu_server_new("/org/test"); + + timer_func(NULL); + g_timeout_add(100, timer_func, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return 0; +} diff --git a/tests/test-glib-layout.h b/tests/test-glib-layout.h new file mode 100644 index 0000000..d315e90 --- /dev/null +++ b/tests/test-glib-layout.h @@ -0,0 +1,58 @@ + +typedef struct _layout_t layout_t; +struct _layout_t { + guint id; + layout_t * submenu; +}; + +layout_t submenu_2[] = { + {id: 2, submenu: NULL}, + {id: 3, submenu: NULL}, + {id: 0, submenu: NULL} +}; +layout_t submenu_3_1[] = { + {id: 3, submenu: NULL}, + {id: 4, submenu: NULL}, + {id: 5, submenu: NULL}, + {id: 0, submenu: NULL} +}; +layout_t submenu_3_2[] = { + {id: 7, submenu: NULL}, + {id: 8, submenu: NULL}, + {id: 9, submenu: NULL}, + {id: 0, submenu: NULL} +}; +layout_t submenu_3[] = { + {id: 2, submenu: submenu_3_1}, + {id: 6, submenu: submenu_3_2}, + {id: 0, submenu: NULL} +}; +layout_t submenu_4_1[] = { + {id: 6, submenu: NULL}, + {id: 0, submenu: NULL} +}; +layout_t submenu_4_2[] = { + {id: 5, submenu: submenu_4_1}, + {id: 0, submenu: NULL} +}; +layout_t submenu_4_3[] = { + {id: 4, submenu: submenu_4_2}, + {id: 0, submenu: NULL} +}; +layout_t submenu_4_4[] = { + {id: 3, submenu: submenu_4_3}, + {id: 0, submenu: NULL} +}; +layout_t submenu_4_5[] = { + {id: 2, submenu: submenu_4_4}, + {id: 0, submenu: NULL} +}; + +layout_t layouts[] = { + {id: 5, submenu: NULL}, + {id: 1, submenu: submenu_2}, + {id: 1, submenu: submenu_3}, + {id: 1, submenu: submenu_4_5}, + {id: 0, submenu: NULL} +}; + -- cgit v1.2.3 From f7c32c45fc4c9dff6822b10698c7b4d740c92ca0 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 28 Apr 2009 15:39:58 -0500 Subject: Messages and slowing down a touch --- tests/test-glib-layout-server.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test-glib-layout-server.c b/tests/test-glib-layout-server.c index 6ec9b0c..d6f9f3d 100644 --- a/tests/test-glib-layout-server.c +++ b/tests/test-glib-layout-server.c @@ -38,8 +38,10 @@ timer_func (gpointer data) g_main_loop_quit(mainloop); return FALSE; } + g_debug("Updating to Layout %d", layouton); - dbusmenu_server_set_root(server, layout2menuitem(&layouts[layouton++])); + dbusmenu_server_set_root(server, layout2menuitem(&layouts[layouton])); + layouton++; return TRUE; } @@ -52,10 +54,12 @@ main (int argc, char ** argv) server = dbusmenu_server_new("/org/test"); timer_func(NULL); - g_timeout_add(100, timer_func, NULL); + g_timeout_add(250, 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 a10757b066e0291cde11136c2b33b5b6ebcccad5 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 28 Apr 2009 15:52:40 -0500 Subject: Adding a little flesh to the client --- tests/Makefile.am | 12 ++++++++++++ tests/test-glib-layout-client.c | 42 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index f00a7e7..a80f1d1 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,7 @@ libexec_PROGRAMS = \ glib-server-nomenu \ + test-glib-layout-client \ test-glib-layout-server glib_server_nomenu_SOURCES = \ @@ -25,6 +26,17 @@ test_glib_layout_server_LDADD = \ ../libdbusmenu-glib/libdbusmenu-glib.la \ $(DBUSMENUGLIB_LIBS) +test_glib_layout_client_SOURCES = \ + test-glib-layout-client.c + +test_glib_layout_client_CFLAGS = \ + -I $(srcdir)/.. \ + $(DBUSMENUGLIB_CFLAGS) -Wall -Werror + +test_glib_layout_client_LDADD = \ + ../libdbusmenu-glib/libdbusmenu-glib.la \ + $(DBUSMENUGLIB_LIBS) + diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index e69de29..814f019 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -0,0 +1,42 @@ +#include + +#include +#include + +#include "test-glib-layout.h" + +static guint layouton = 0; +static GMainLoop * mainloop = NULL; +static gboolean passed = TRUE; + +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(); + + DbusmenuClient * client = dbusmenu_client_new(":1", "/org/test"); + dbusmenu_client_get_root(client); + + timer_func(NULL); + g_timeout_add_seconds(2, timer_func, NULL); + + 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; + } +} -- cgit v1.2.3 From 640720591a52701b852564fba3e0df3bd3c56e40 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 28 Apr 2009 15:53:57 -0500 Subject: Oops can't call the kill function first --- tests/test-glib-layout-client.c | 1 - 1 file changed, 1 deletion(-) (limited to 'tests') diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index 814f019..b2687e3 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -26,7 +26,6 @@ main (int argc, char ** argv) DbusmenuClient * client = dbusmenu_client_new(":1", "/org/test"); dbusmenu_client_get_root(client); - timer_func(NULL); g_timeout_add_seconds(2, timer_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); -- cgit v1.2.3 From 3701dfcaab6465a1aff34f1030cba8d559e271d3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 28 Apr 2009 16:11:02 -0500 Subject: Fixing address --- tests/test-glib-layout-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index b2687e3..2a1f583 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -23,7 +23,7 @@ main (int argc, char ** argv) { g_type_init(); - DbusmenuClient * client = dbusmenu_client_new(":1", "/org/test"); + DbusmenuClient * client = dbusmenu_client_new(":1.1", "/org/test"); dbusmenu_client_get_root(client); g_timeout_add_seconds(2, timer_func, NULL); -- cgit v1.2.3 From f1a04e66561c54fc3120239e2ee5a0240ab50656 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 28 Apr 2009 16:41:39 -0500 Subject: This doesn't crash, not a good sign for using DBus --- tests/test-glib-layout-client.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index 2a1f583..e6fc1ba 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -24,13 +24,14 @@ main (int argc, char ** argv) g_type_init(); DbusmenuClient * client = dbusmenu_client_new(":1.1", "/org/test"); - dbusmenu_client_get_root(client); - g_timeout_add_seconds(2, timer_func, NULL); + g_timeout_add_seconds(2, timer_func, client); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); + g_object_unref(G_OBJECT(client)); + if (passed) { g_debug("Quiting"); return 0; -- cgit v1.2.3 From 22e6abdd0a1bea1ee257da6eeb767228aeff212c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 4 May 2009 14:07:16 +0100 Subject: Some timers to get things lined up correctly and other little cleanups to stop breaking this. --- tests/test-glib-layout-client.c | 4 +++- tests/test-glib-layout-server.c | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index e6fc1ba..bc8eb2c 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -23,7 +23,9 @@ main (int argc, char ** argv) { g_type_init(); - DbusmenuClient * client = dbusmenu_client_new(":1.1", "/org/test"); + g_usleep(10000); + + DbusmenuClient * client = dbusmenu_client_new(":1.0", "/org/test"); g_timeout_add_seconds(2, timer_func, client); diff --git a/tests/test-glib-layout-server.c b/tests/test-glib-layout-server.c index d6f9f3d..8539a2b 100644 --- a/tests/test-glib-layout-server.c +++ b/tests/test-glib-layout-server.c @@ -1,6 +1,10 @@ #include +#include +#include +#include + #include #include @@ -51,10 +55,12 @@ 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(250, timer_func, NULL); + g_timeout_add(2500, timer_func, NULL); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From eec69c6d029f32cff471508598a3404542a2b1b7 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 4 May 2009 14:08:06 +0100 Subject: A small script to run the test easily --- tests/test.sh | 4 ++++ 1 file changed, 4 insertions(+) create mode 100755 tests/test.sh (limited to 'tests') diff --git a/tests/test.sh b/tests/test.sh new file mode 100755 index 0000000..ea31515 --- /dev/null +++ b/tests/test.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +echo dbus-test-runner -d /usr/share/dbus-test-runner/session.conf --task ./test-glib-layout-client --task ./test-glib-layout-server +dbus-test-runner -d /usr/share/dbus-test-runner/session.conf --task ./test-glib-layout-client --task ./test-glib-layout-server -- cgit v1.2.3 From dcca29ed8812682d7fb0bbbd224c4c5eff16c9a6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 4 May 2009 14:39:05 +0100 Subject: More time --- tests/test-glib-layout-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index bc8eb2c..7f3f52f 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -23,7 +23,7 @@ main (int argc, char ** argv) { g_type_init(); - g_usleep(10000); + g_usleep(500000); DbusmenuClient * client = dbusmenu_client_new(":1.0", "/org/test"); -- cgit v1.2.3 From 125df5401f1977f01b189b9ba598f898202d2727 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 5 May 2009 17:29:53 +0100 Subject: Debugging message. --- tests/test-glib-layout-server.c | 1 + 1 file changed, 1 insertion(+) (limited to 'tests') diff --git a/tests/test-glib-layout-server.c b/tests/test-glib-layout-server.c index 8539a2b..2e71e84 100644 --- a/tests/test-glib-layout-server.c +++ b/tests/test-glib-layout-server.c @@ -28,6 +28,7 @@ layout2menuitem (layout_t * layout) } } + g_debug("Layout to menu return: 0x%X", (unsigned int)local); return local; } -- cgit v1.2.3 From 59a21ee084758c2ba4774a86767f8c593ff94f72 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 5 May 2009 18:25:20 +0100 Subject: Extending time a little bit --- tests/test-glib-layout-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index 7f3f52f..850b17c 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -27,7 +27,7 @@ main (int argc, char ** argv) DbusmenuClient * client = dbusmenu_client_new(":1.0", "/org/test"); - g_timeout_add_seconds(2, timer_func, client); + g_timeout_add_seconds(6, timer_func, client); mainloop = g_main_loop_new(NULL, FALSE); g_main_loop_run(mainloop); -- cgit v1.2.3 From e91e2504652a59870ac5e439fcdf0b452fd87d70 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 5 May 2009 18:58:23 +0100 Subject: Loving the signal handling --- tests/test-glib-layout-client.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'tests') diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index 850b17c..0a8aa13 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -9,6 +9,12 @@ static guint layouton = 0; static GMainLoop * mainloop = NULL; static gboolean passed = TRUE; +static void +layout_updated (DbusmenuClient * client, gpointer data) +{ + g_debug("Layout Updated"); +} + static gboolean timer_func (gpointer data) { @@ -26,6 +32,7 @@ main (int argc, char ** argv) 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(6, timer_func, client); -- cgit v1.2.3 From 17c8844b6418c3fe7c63b946dc184b819b7f469c Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 5 May 2009 19:53:59 +0100 Subject: Doing some layout parsing for fun and profit. --- tests/test-glib-layout-client.c | 44 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index 0a8aa13..8f9b7eb 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -9,10 +9,52 @@ static guint layouton = 0; static GMainLoop * mainloop = NULL; static gboolean passed = TRUE; +static gboolean +verify_root_to_layout(DbusmenuMenuitem * mi, layout_t * layout) +{ + if (layout->id != dbusmenu_menuitem_get_id(mi)) { + return FALSE; + } + + GList * children = dbusmenu_menuitem_get_children(mi); + + if (children == NULL && layout->submenu == NULL) { + return TRUE; + } + if (children == NULL || layout->submenu == NULL) { + return FALSE; + } + + guint i = 0; + for (i = 0; children != NULL && layout[i].id != 0; children = g_list_next(children), i++) { + if (!verify_root_to_layout(DBUSMENU_MENUITEM(children->data), &layout[i])) { + return FALSE; + } + } + + if (children != NULL || layout[i].id != 0) { + return FALSE; + } + + return TRUE; +} + static void layout_updated (DbusmenuClient * client, gpointer data) { g_debug("Layout Updated"); + + DbusmenuMenuitem * menuroot = dbusmenu_client_get_root(client); + layout_t * layout = &layouts[layouton]; + + if (!verify_root_to_layout(menuroot, layout)) { + g_debug("Failed layout: %d", layouton); + passed = FALSE; + } + + layouton++; + + return; } static gboolean @@ -34,7 +76,7 @@ main (int argc, char ** argv) 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(6, timer_func, client); + 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 8b68de6ce69edd4bdef028f6941a9286ec14e191 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 5 May 2009 23:03:55 +0100 Subject: A ton more debugging messages to know where it failed --- tests/test-glib-layout-client.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index 8f9b7eb..3620bb7 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -13,6 +13,7 @@ static gboolean verify_root_to_layout(DbusmenuMenuitem * mi, layout_t * layout) { 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; } @@ -22,6 +23,11 @@ verify_root_to_layout(DbusmenuMenuitem * mi, layout_t * layout) 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; } @@ -32,11 +38,16 @@ verify_root_to_layout(DbusmenuMenuitem * mi, layout_t * layout) } } - if (children != NULL || layout[i].id != 0) { - return FALSE; + if (children == NULL && layout[i].id == 0) { + return TRUE; } - return TRUE; + if (children != NULL) { + g_debug("Failed as there are still children but no submenus"); + } else { + g_debug("Failed as there are still submenus but no children"); + } + return FALSE; } static void -- cgit v1.2.3 From f2cd48dd391855a6f4304038459effd5c6463884 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sat, 9 May 2009 14:42:08 -0500 Subject: Debug message --- tests/test-glib-layout-client.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tests') diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index 3620bb7..6086c7f 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -12,6 +12,8 @@ static gboolean passed = TRUE; static gboolean verify_root_to_layout(DbusmenuMenuitem * mi, layout_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; -- cgit v1.2.3 From 3c7a5751473ef1c92de1aff135dd055bda05257e Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 10 May 2009 22:15:37 -0500 Subject: Fixing going into the recursive submenus --- tests/test-glib-layout-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index 6086c7f..2099cd5 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -35,7 +35,7 @@ verify_root_to_layout(DbusmenuMenuitem * mi, layout_t * layout) guint i = 0; for (i = 0; children != NULL && layout[i].id != 0; children = g_list_next(children), i++) { - if (!verify_root_to_layout(DBUSMENU_MENUITEM(children->data), &layout[i])) { + if (!verify_root_to_layout(DBUSMENU_MENUITEM(children->data), &layout->submenu[i])) { return FALSE; } } -- cgit v1.2.3 From 65e3edf11624283530ba8de1e7c68244b04f9ea6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Sun, 10 May 2009 22:26:25 -0500 Subject: Looking at submenus instead of the current array as we should have been originally. Oops. --- tests/test-glib-layout-client.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index 2099cd5..6c012a5 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -34,20 +34,20 @@ verify_root_to_layout(DbusmenuMenuitem * mi, layout_t * layout) } guint i = 0; - for (i = 0; children != NULL && layout[i].id != 0; children = g_list_next(children), i++) { + 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[i].id == 0) { + if (children == NULL && layout->submenu[i].id == 0) { return TRUE; } if (children != NULL) { - g_debug("Failed as there are still children but no submenus"); + 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"); + g_debug("Failed as there are still submenus but no children. (ID: %d)", layout->id); } return FALSE; } -- cgit v1.2.3 From ccd39004abc4c5ade0103a6cf17144443745f2cf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 11 May 2009 13:29:10 -0500 Subject: Moving the glib layout test into the make file --- tests/Makefile.am | 8 ++++++++ tests/test.sh | 4 ---- 2 files changed, 8 insertions(+), 4 deletions(-) delete mode 100755 tests/test.sh (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index a80f1d1..4f52706 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,3 +1,8 @@ +check: tests + +DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.conf + +tests: test-glib-layout libexec_PROGRAMS = \ glib-server-nomenu \ @@ -15,6 +20,9 @@ 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 ./test-glib-layout-server + test_glib_layout_server_SOURCES = \ test-glib-layout-server.c diff --git a/tests/test.sh b/tests/test.sh deleted file mode 100755 index ea31515..0000000 --- a/tests/test.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -echo dbus-test-runner -d /usr/share/dbus-test-runner/session.conf --task ./test-glib-layout-client --task ./test-glib-layout-server -dbus-test-runner -d /usr/share/dbus-test-runner/session.conf --task ./test-glib-layout-client --task ./test-glib-layout-server -- cgit v1.2.3 From afa84740cda0f8d24288a783c57283b75bb32bcf Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 11 May 2009 14:06:08 -0500 Subject: Making nice friendly names. --- tests/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/Makefile.am b/tests/Makefile.am index 4f52706..ca0bd77 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -21,7 +21,7 @@ glib_server_nomenu_LDADD = \ $(DBUSMENUGLIB_LIBS) test-glib-layout: test-glib-layout-client test-glib-layout-server - $(DBUS_RUNNER) --task ./test-glib-layout-client --task ./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-server.c -- cgit v1.2.3 From bbeb7864cc36c0c50a94361ae6edfe3c83bb56c3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Tue, 12 May 2009 08:38:58 -0500 Subject: Put the GPL v3 on these tests --- tests/glib-server-nomenu.c | 21 +++++++++++++++++++++ tests/test-glib-layout-client.c | 21 +++++++++++++++++++++ tests/test-glib-layout-server.c | 20 ++++++++++++++++++++ tests/test-glib-layout.h | 20 ++++++++++++++++++++ 4 files changed, 82 insertions(+) (limited to 'tests') diff --git a/tests/glib-server-nomenu.c b/tests/glib-server-nomenu.c index 36aac3e..e5ea159 100644 --- a/tests/glib-server-nomenu.c +++ b/tests/glib-server-nomenu.c @@ -1,3 +1,24 @@ +/* +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 diff --git a/tests/test-glib-layout-client.c b/tests/test-glib-layout-client.c index 6c012a5..7a53443 100644 --- a/tests/test-glib-layout-client.c +++ b/tests/test-glib-layout-client.c @@ -1,3 +1,24 @@ +/* +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 diff --git a/tests/test-glib-layout-server.c b/tests/test-glib-layout-server.c index 2e71e84..e69c6b2 100644 --- a/tests/test-glib-layout-server.c +++ b/tests/test-glib-layout-server.c @@ -1,3 +1,23 @@ +/* +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 diff --git a/tests/test-glib-layout.h b/tests/test-glib-layout.h index d315e90..a13125d 100644 --- a/tests/test-glib-layout.h +++ b/tests/test-glib-layout.h @@ -1,3 +1,23 @@ +/* +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 . +*/ typedef struct _layout_t layout_t; struct _layout_t { -- cgit v1.2.3